OSDN Git Service

disable shutter button as soon as possible
authorSpike Sprague <spikuru@google.com>
Mon, 13 Oct 2014 21:49:06 +0000 (14:49 -0700)
committerSpike Sprague <spikuru@google.com>
Tue, 14 Oct 2014 16:30:13 +0000 (09:30 -0700)
to avoid double shutter presses

bug: 17939465
Change-Id: Iac19b8fa78774b525fbaf0d4742d97764d401b78

src/com/android/camera/PhotoModule.java

index 8c1c88c..3839a68 100644 (file)
@@ -456,6 +456,7 @@ public class PhotoModule
         }
         mAppController.getCameraAppUI().transitionToCapture();
         mAppController.getCameraAppUI().showModeOptions();
+        mAppController.setShutterEnabled(true);
     }
 
     @Override
@@ -1267,9 +1268,11 @@ public class PhotoModule
         // If we are already in the middle of taking a snapshot or the image
         // save request is full then ignore.
         if (mCameraDevice == null || mCameraState == SNAPSHOT_IN_PROGRESS
-                || mCameraState == SWITCHING_CAMERA || !mAppController.isShutterEnabled()) {
+                || mCameraState == SWITCHING_CAMERA) {
             return false;
         }
+        setCameraState(SNAPSHOT_IN_PROGRESS);
+
         mCaptureStartTime = System.currentTimeMillis();
 
         mPostViewPictureCallbackTime = 0;
@@ -1293,9 +1296,6 @@ public class PhotoModule
         mJpegRotation = info.getJpegOrientation(orientation);
         mCameraDevice.setJpegOrientation(mJpegRotation);
 
-        // We don't want user to press the button again while taking a
-        // multi-second HDR photo.
-        mAppController.setShutterEnabled(false);
         mCameraDevice.takePicture(mHandler,
                 new ShutterCallback(!animateBefore),
                 mRawPictureCallback, mPostViewPictureCallback,
@@ -1304,7 +1304,6 @@ public class PhotoModule
         mNamedImages.nameNewImage(mCaptureStartTime);
 
         mFaceDetectionStarted = false;
-        setCameraState(SNAPSHOT_IN_PROGRESS);
         return true;
     }
 
@@ -1498,7 +1497,8 @@ public class PhotoModule
     @Override
     public void onShutterButtonClick() {
         if (mPaused || (mCameraState == SWITCHING_CAMERA)
-                || (mCameraState == PREVIEW_STOPPED)) {
+                || (mCameraState == PREVIEW_STOPPED)
+                || !mAppController.isShutterEnabled()) {
             mVolumeButtonClickedFlag = false;
             return;
         }
@@ -1513,6 +1513,8 @@ public class PhotoModule
         Log.d(TAG, "onShutterButtonClick: mCameraState=" + mCameraState +
                 " mVolumeButtonClickedFlag=" + mVolumeButtonClickedFlag);
 
+        mAppController.setShutterEnabled(false);
+
         int countDownDuration = mActivity.getSettingsManager()
             .getInteger(SettingsManager.SCOPE_GLOBAL, Keys.KEY_COUNTDOWN_DURATION);
         mTimerDuration = countDownDuration;