summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/ui/CameraPicker.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera/ui/CameraPicker.java')
-rw-r--r--src/com/android/camera/ui/CameraPicker.java16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/com/android/camera/ui/CameraPicker.java b/src/com/android/camera/ui/CameraPicker.java
index ac8b8a8..21d3efe 100644
--- a/src/com/android/camera/ui/CameraPicker.java
+++ b/src/com/android/camera/ui/CameraPicker.java
@@ -33,7 +33,6 @@ public class CameraPicker extends RotateImageView implements View.OnClickListene
private OnPreferenceChangedListener mListener;
private ListPreference mPreference;
private CharSequence[] mCameras;
- private int mCameraFacing;
public CameraPicker(Context context) {
super(context);
@@ -55,23 +54,16 @@ public class CameraPicker extends RotateImageView implements View.OnClickListene
mCameras = pref.getEntryValues();
if (mCameras == null) return;
setOnClickListener(this);
- String cameraId = pref.getValue();
setVisibility(View.VISIBLE);
- if (mCameras[CameraInfo.CAMERA_FACING_FRONT].equals(cameraId)) {
- mCameraFacing = CameraInfo.CAMERA_FACING_FRONT;
- } else {
- mCameraFacing = CameraInfo.CAMERA_FACING_BACK;
- }
}
@Override
public void onClick(View v) {
if (mCameras == null) return;
- int newCameraIndex = (mCameraFacing == CameraInfo.CAMERA_FACING_BACK)
- ? CameraInfo.CAMERA_FACING_FRONT
- : CameraInfo.CAMERA_FACING_BACK;
- mCameraFacing = newCameraIndex;
- mPreference.setValue((String) mCameras[mCameraFacing]);
+ int index = mPreference.findIndexOfValue(mPreference.getValue());
+ CharSequence[] values = mPreference.getEntryValues();
+ index = (index + 1) % values.length;
+ mPreference.setValue((String) mCameras[index]);
mListener.onSharedPreferenceChanged();
}
}