.. | .. |
---|
27 | 27 | import android.graphics.Matrix; |
---|
28 | 28 | import android.graphics.drawable.Drawable; |
---|
29 | 29 | import android.os.AsyncTask; |
---|
| 30 | +import android.os.SystemProperties; |
---|
30 | 31 | import android.util.AttributeSet; |
---|
31 | 32 | import android.view.View; |
---|
32 | 33 | import android.widget.ImageButton; |
---|
.. | .. |
---|
74 | 75 | private int mAnimDirection; |
---|
75 | 76 | private Matrix mMatrix = new Matrix(); |
---|
76 | 77 | private ValueAnimator mAnimator; |
---|
| 78 | + |
---|
| 79 | + private static final String ANDROID_UVC_PROPERTY = "ro.camera.uvcfacing"; |
---|
77 | 80 | |
---|
78 | 81 | public MultiToggleImageButton(Context context) { |
---|
79 | 82 | super(context); |
---|
.. | .. |
---|
242 | 245 | |
---|
243 | 246 | private void nextState() { |
---|
244 | 247 | int state = mState + 1; |
---|
| 248 | + if(getId() == R.id.camera_toggle_button){ |
---|
| 249 | + /* |
---|
| 250 | + *If ro.camera.uvcfacing is set, then skip the original facing state. |
---|
| 251 | + */ |
---|
| 252 | + String uvcProperty = SystemProperties.get(ANDROID_UVC_PROPERTY, ""); |
---|
| 253 | + if(uvcProperty.equals("")){ |
---|
| 254 | + if(state == Integer.parseInt(getResources() |
---|
| 255 | + .getString(R.string.pref_camera_id_entry_external_value))){ |
---|
| 256 | + state = state + 1; |
---|
| 257 | + } |
---|
| 258 | + } |
---|
| 259 | + else if (uvcProperty.equals("back")) { |
---|
| 260 | + if(state == Integer.parseInt(getResources() |
---|
| 261 | + .getString(R.string.pref_camera_id_entry_back_value))){ |
---|
| 262 | + state = state + 1; |
---|
| 263 | + } |
---|
| 264 | + } |
---|
| 265 | + else if (uvcProperty.equals("front")) { |
---|
| 266 | + if(state == Integer.parseInt(getResources() |
---|
| 267 | + .getString(R.string.pref_camera_id_entry_front_value))){ |
---|
| 268 | + state = state + 1; |
---|
| 269 | + } |
---|
| 270 | + } |
---|
| 271 | + else if (uvcProperty.equals("external")) { |
---|
| 272 | + int externalValue = Integer.parseInt(getResources(). |
---|
| 273 | + getString(R.string.pref_camera_id_entry_external_value)); |
---|
| 274 | + if(state != externalValue){ |
---|
| 275 | + state = externalValue; |
---|
| 276 | + } |
---|
| 277 | + } |
---|
| 278 | + } |
---|
245 | 279 | if (state >= mImageIds.length) { |
---|
246 | 280 | state = 0; |
---|
247 | 281 | } |
---|