volume button cancels ongoing countdown
prevent volume button from doing anything during intent capture review

bug: 15141921
Change-Id: Icf974de09eb59e92bcce4a14aaa4775e21043c13
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index f1fb0d0..4b90ea1 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -1516,7 +1516,11 @@
 
     @Override
     public void onCountDownFinished() {
-        mAppController.getCameraAppUI().transitionToCapture();
+        if (mIsImageCaptureIntent) {
+            mAppController.getCameraAppUI().transitionToIntentReviewLayout();
+        } else {
+            mAppController.getCameraAppUI().transitionToCapture();
+        }
         mAppController.getCameraAppUI().showModeOptions();
         if (mPaused) {
             return;
@@ -1745,7 +1749,8 @@
             case KeyEvent.KEYCODE_VOLUME_UP:
             case KeyEvent.KEYCODE_VOLUME_DOWN:
             case KeyEvent.KEYCODE_FOCUS:
-                if (/* TODO: mActivity.isInCameraApp() && */mFirstTimeInitialized) {
+                if (/* TODO: mActivity.isInCameraApp() && */mFirstTimeInitialized &&
+                    !mActivity.getCameraAppUI().isInIntentReview()) {
                     if (event.getRepeatCount() == 0) {
                         onShutterButtonFocus(true);
                     }
@@ -1776,9 +1781,14 @@
         switch (keyCode) {
             case KeyEvent.KEYCODE_VOLUME_UP:
             case KeyEvent.KEYCODE_VOLUME_DOWN:
-                if (/* mActivity.isInCameraApp() && */mFirstTimeInitialized) {
-                    mVolumeButtonClickedFlag = true;
-                    onShutterButtonClick();
+                if (/* mActivity.isInCameraApp() && */mFirstTimeInitialized &&
+                    !mActivity.getCameraAppUI().isInIntentReview()) {
+                    if (mUI.isCountingDown()) {
+                        cancelCountDown();
+                    } else {
+                        mVolumeButtonClickedFlag = true;
+                        onShutterButtonClick();
+                    }
                     return true;
                 }
                 return false;
diff --git a/src/com/android/camera/app/CameraAppUI.java b/src/com/android/camera/app/CameraAppUI.java
index 3de1db1..8baa2a6 100644
--- a/src/com/android/camera/app/CameraAppUI.java
+++ b/src/com/android/camera/app/CameraAppUI.java
@@ -648,7 +648,7 @@
 
     /**
      * Updates the preview matrix without altering it.
-     * 
+     *
      * @param matrix
      * @param aspectRatio the desired aspect ratio for the preview.
      */
@@ -1701,7 +1701,7 @@
 
     /**
      * This adds letterboxing around the preview, one on each side
-     * 
+     *
      * @param width the width in pixels of each letterboxing cover
      */
     public void addLetterboxing(int width) {
@@ -1788,6 +1788,13 @@
         mBottomBar.transitionToIntentReviewLayout();
     }
 
+    /**
+     * @return whether UI is in intent review mode
+     */
+    public boolean isInIntentReview() {
+        return mBottomBar.isInIntentReview();
+    }
+
     @Override
     public void onSettingChanged(SettingsManager settingsManager, int id) {
         // Update the mode options based on the hardware spec,
diff --git a/src/com/android/camera/ui/BottomBar.java b/src/com/android/camera/ui/BottomBar.java
index 3dcfc5e..18bee4e 100644
--- a/src/com/android/camera/ui/BottomBar.java
+++ b/src/com/android/camera/ui/BottomBar.java
@@ -228,10 +228,18 @@
     public void transitionToIntentReviewLayout() {
         mCaptureLayout.setVisibility(View.INVISIBLE);
         mIntentReviewLayout.setVisibility(View.VISIBLE);
+        mCancelLayout.setVisibility(View.INVISIBLE);
 
         mMode = MODE_INTENT_REVIEW;
     }
 
+    /**
+     * @return whether UI is in intent review mode
+     */
+    public boolean isInIntentReview() {
+        return mMode == MODE_INTENT_REVIEW;
+    }
+
     private void setButtonImageLevels(int level) {
         ((ImageButton) findViewById(R.id.cancel_button)).setImageLevel(level);
         ((ImageButton) findViewById(R.id.done_button)).setImageLevel(level);