Merge "Fix selection highlight for tablets" into gb-ub-photos-bryce
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);
+        }
+    }
 }
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index d13d261..e5ddbf5 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -433,6 +433,9 @@
     }
 
     public void showRepresentation(FilterRepresentation representation) {
+        if (representation == null) {
+            return;
+        }
         useFilterRepresentation(representation);
 
         // show representation
@@ -817,7 +820,8 @@
         loadXML();
         loadMainPanel();
 
-        if (!mShowingTinyPlanet) {
+        // mLoadBitmapTask==null implies you have looked at the intent
+        if (!mShowingTinyPlanet && (mLoadBitmapTask == null)) {
             mCategoryFiltersAdapter.removeTinyPlanet();
         }
         final View loading = findViewById(R.id.loading);
diff --git a/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java b/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java
index 0a65cd9..4dfaa7f 100644
--- a/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java
+++ b/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java
@@ -34,7 +34,7 @@
 public class CategoryAdapter extends ArrayAdapter<Action> {
 
     private static final String LOGTAG = "CategoryAdapter";
-    private int mItemHeight = 200;
+    private int mItemHeight;
     private View mContainer;
     private int mItemWidth = ListView.LayoutParams.MATCH_PARENT;
     private boolean mUseFilterIconButton = false;
@@ -43,6 +43,7 @@
 
     public CategoryAdapter(Context context, int textViewResourceId) {
         super(context, textViewResourceId);
+        mItemHeight = (int) (context.getResources().getDisplayMetrics().density * 100);
     }
 
     public CategoryAdapter(Context context) {
diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java
index 5c8ac1c..7afa203 100644
--- a/src/com/android/gallery3d/ui/PhotoView.java
+++ b/src/com/android/gallery3d/ui/PhotoView.java
@@ -1423,6 +1423,11 @@
 
     @Override
     protected void render(GLCanvas canvas) {
+        if (mFirst) {
+            // Make sure the fields are properly initialized before checking
+            // whether isCamera()
+            mPictures.get(0).reload();
+        }
         // Check if the camera preview occupies the full screen.
         boolean full = !mFilmMode && mPictures.get(0).isCamera()
                 && mPositionController.isCenter()