Make capture thumbnail tappable in video mode.

  Bug: 9054122

Also make gotoGallery public for LightCycle to use.

Change-Id: I3cd5af26531a756e78c1478de29155dfda709afc
diff --git a/src/com/android/camera/ActivityBase.java b/src/com/android/camera/ActivityBase.java
index c3cde8b..59bd82c 100644
--- a/src/com/android/camera/ActivityBase.java
+++ b/src/com/android/camera/ActivityBase.java
@@ -353,7 +353,7 @@
         }
     }
 
-    protected void gotoGallery() {
+    public void gotoGallery() {
         // Move the next picture with capture animation. "1" means next.
         mAppBridge.switchWithCaptureAnimation(1);
     }
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index f7830a3..2c654fc 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -91,6 +91,7 @@
     private static final int SWITCH_CAMERA = 8;
     private static final int SWITCH_CAMERA_START_ANIMATION = 9;
     private static final int HIDE_SURFACE_VIEW = 10;
+    private static final int CAPTURE_ANIMATION_DONE = 11;
 
     private static final int SCREEN_DELAY = 2 * 60 * 1000;
 
@@ -296,6 +297,11 @@
                     break;
                 }
 
+                case CAPTURE_ANIMATION_DONE: {
+                    mUI.enablePreviewThumb(false);
+                    break;
+                }
+
                 default:
                     Log.v(TAG, "Unhandled message: " + msg.what);
                     break;
@@ -578,6 +584,14 @@
                 // the preview. This will cause the preview flicker since the preview
                 // will not be continuous for a short period of time.
                 ((CameraScreenNail) mActivity.mCameraScreenNail).animateCapture(mDisplayRotation);
+
+                mUI.enablePreviewThumb(true);
+
+                // Make sure to disable the thumbnail preview after the
+                // animation is done to disable the click target.
+                mHandler.removeMessages(CAPTURE_ANIMATION_DONE);
+                mHandler.sendEmptyMessageDelayed(CAPTURE_ANIMATION_DONE,
+                        CaptureAnimManager.getAnimationDuration());
             }
         }
     }
@@ -1457,6 +1471,7 @@
 
     private void startVideoRecording() {
         Log.v(TAG, "startVideoRecording");
+        mUI.enablePreviewThumb(false);
         mActivity.setSwipingEnabled(false);
 
         mActivity.updateStorageSpaceAndHint();
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java
index 0c94572..dc23ec8 100644
--- a/src/com/android/camera/VideoUI.java
+++ b/src/com/android/camera/VideoUI.java
@@ -76,6 +76,7 @@
     private VideoController mController;
     private int mZoomMax;
     private List<Integer> mZoomRatios;
+    private View mPreviewThumb;
 
     public VideoUI(CameraActivity activity, VideoController controller, View parent) {
         mActivity = activity;
@@ -227,6 +228,14 @@
                 mGestures.addTouchReceiver(mReviewPlayButton);
             }
         }
+
+        mPreviewThumb = mActivity.findViewById(R.id.preview_thumb);
+        mPreviewThumb.setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                mActivity.gotoGallery();
+            }
+        });
     }
 
     public void setPrefChangedListener(OnPreferenceChangedListener listener) {
@@ -520,4 +529,16 @@
         }
     }
 
+    /**
+     * Enable or disable the preview thumbnail for click events.
+     */
+    public void enablePreviewThumb(boolean enabled) {
+        if (enabled) {
+            mGestures.addTouchReceiver(mPreviewThumb);
+            mPreviewThumb.setVisibility(View.VISIBLE);
+        } else {
+            mGestures.removeTouchReceiver(mPreviewThumb);
+            mPreviewThumb.setVisibility(View.GONE);
+        }
+    }
 }