diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/camera/Camera.java | 12 | ||||
-rw-r--r-- | src/com/android/camera/ui/IndicatorControlWheel.java | 2 | ||||
-rw-r--r-- | src/com/android/camera/ui/RotateImageView.java | 2 | ||||
-rw-r--r-- | src/com/android/camera/ui/TwoStateImageView.java (renamed from src/com/android/camera/ui/ColorFilterImageView.java) | 15 |
4 files changed, 19 insertions, 12 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index 9c7bbfe..1fad8a8 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -143,6 +143,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener, private GestureDetector mPopupGestureDetector; private boolean mOpenCameraFail = false; private boolean mCameraDisabled = false; + private boolean mFaceDetectionStarted = false; private View mPreviewPanel; // The container of PreviewFrameLayout. private PreviewFrameLayout mPreviewFrameLayout; @@ -520,7 +521,9 @@ public class Camera extends ActivityBase implements FocusManager.Listener, @Override public void startFaceDetection() { + if (mFaceDetectionStarted || mCameraState != IDLE) return; if (mParameters.getMaxNumDetectedFaces() > 0) { + mFaceDetectionStarted = true; mFaceView = (FaceView) findViewById(R.id.face_view); mFaceView.clear(); mFaceView.setVisibility(View.VISIBLE); @@ -535,7 +538,9 @@ public class Camera extends ActivityBase implements FocusManager.Listener, @Override public void stopFaceDetection() { + if (!mFaceDetectionStarted) return; if (mParameters.getMaxNumDetectedFaces() > 0) { + mFaceDetectionStarted = false; mCameraDevice.setFaceDetectionListener(null); mCameraDevice.stopFaceDetection(); if (mFaceView != null) mFaceView.clear(); @@ -982,6 +987,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener, mCameraDevice.takePicture(mShutterCallback, mRawPictureCallback, mPostViewPictureCallback, new JpegPictureCallback(loc)); + mFaceDetectionStarted = false; setCameraState(SNAPSHOT_IN_PROGRESS); return true; } @@ -1461,7 +1467,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener, initializeCapabilities(); resetExposureCompensation(); startPreview(); - if (mFirstTimeInitialized) startFaceDetection(); + startFaceDetection(); } catch (CameraHardwareException e) { Util.showErrorAndFinish(this, R.string.cannot_connect_camera); return; @@ -1683,7 +1689,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener, // display rotation in onCreate may not be what we want. if (mCameraState == PREVIEW_STOPPED) { startPreview(); - if (mFirstTimeInitialized) startFaceDetection(); + startFaceDetection(); } else { if (Util.getDisplayRotation(this) != mDisplayRotation) { setDisplayOrientation(); @@ -1717,6 +1723,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener, private void closeCamera() { if (mCameraDevice != null) { CameraHolder.instance().release(); + mFaceDetectionStarted = false; mCameraDevice.setZoomChangeListener(null); mCameraDevice.setFaceDetectionListener(null); mCameraDevice.setErrorCallback(null); @@ -1795,6 +1802,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener, Log.v(TAG, "stopPreview"); mCameraDevice.cancelAutoFocus(); // Reset the focus. mCameraDevice.stopPreview(); + mFaceDetectionStarted = false; } setCameraState(PREVIEW_STOPPED); mFocusManager.onPreviewStopped(); diff --git a/src/com/android/camera/ui/IndicatorControlWheel.java b/src/com/android/camera/ui/IndicatorControlWheel.java index 3b8bea4..92f658a 100644 --- a/src/com/android/camera/ui/IndicatorControlWheel.java +++ b/src/com/android/camera/ui/IndicatorControlWheel.java @@ -187,7 +187,7 @@ public class IndicatorControlWheel extends IndicatorControl implements if (rotatable) { view = new RotateImageView(context); } else { - view = new ColorFilterImageView(context); + view = new TwoStateImageView(context); } view.setImageResource(resourceId); view.setOnClickListener(this); diff --git a/src/com/android/camera/ui/RotateImageView.java b/src/com/android/camera/ui/RotateImageView.java index f47a26b..39c4df2 100644 --- a/src/com/android/camera/ui/RotateImageView.java +++ b/src/com/android/camera/ui/RotateImageView.java @@ -32,7 +32,7 @@ import android.widget.ImageView; /** * A @{code ImageView} which can rotate it's content. */ -public class RotateImageView extends ColorFilterImageView implements Rotatable { +public class RotateImageView extends TwoStateImageView implements Rotatable { @SuppressWarnings("unused") private static final String TAG = "RotateImageView"; diff --git a/src/com/android/camera/ui/ColorFilterImageView.java b/src/com/android/camera/ui/TwoStateImageView.java index 56bef82..beb6bf5 100644 --- a/src/com/android/camera/ui/ColorFilterImageView.java +++ b/src/com/android/camera/ui/TwoStateImageView.java @@ -23,18 +23,17 @@ import android.util.AttributeSet; import android.widget.ImageView; /** - * A @{code ImageView} which grey out the icon if disabled. + * A @{code ImageView} which change the opacity of the icon if disabled. */ -public class ColorFilterImageView extends ImageView { - private final int DISABLED_COLOR; +public class TwoStateImageView extends ImageView { + private final float DISABLED_ALPHA = 0.4f; private boolean mFilterEnabled = true; - public ColorFilterImageView(Context context, AttributeSet attrs) { + public TwoStateImageView(Context context, AttributeSet attrs) { super(context, attrs); - DISABLED_COLOR = context.getResources().getColor(R.color.icon_disabled_color); } - public ColorFilterImageView(Context context) { + public TwoStateImageView(Context context) { this(context, null); } @@ -43,9 +42,9 @@ public class ColorFilterImageView extends ImageView { super.setEnabled(enabled); if (mFilterEnabled) { if (enabled) { - clearColorFilter(); + setAlpha(1.0f); } else { - setColorFilter(DISABLED_COLOR); + setAlpha(DISABLED_ALPHA); } } } |