Fix 3457875: Mini workspace should zoom on tap, not touch down

Change-Id: I2e9bb6267048f2b2fb97070029f3a0ad2a28cc32
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 195b671..9cea69b 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2245,6 +2245,10 @@
     }
 
     public boolean onLongClick(View v) {
+        if (mState != State.WORKSPACE) {
+            return false;
+        }
+
         switch (v.getId()) {
             case R.id.previous_screen:
                 if (mState != State.ALL_APPS) {
@@ -2277,7 +2281,6 @@
             v = (View) v.getParent().getParent();
         }
 
-
         resetAddInfo();
         CellLayout.CellInfo longClickCellInfo = (CellLayout.CellInfo) v.getTag();
         // This happens when long clicking an item with the dpad/trackball
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 3e5a967..e108f38 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -76,7 +76,8 @@
  * interact with. A workspace is meant to be used with a fixed width only.
  */
 public class Workspace extends SmoothPagedView
-        implements DropTarget, DragSource, DragScroller, View.OnTouchListener {
+        implements DropTarget, DragSource, DragScroller, View.OnTouchListener,
+        View.OnClickListener {
     @SuppressWarnings({"UnusedDeclaration"})
     private static final String TAG = "Launcher.Workspace";
 
@@ -343,6 +344,8 @@
             throw new IllegalArgumentException("A Workspace can only have CellLayout children.");
         }
         ((CellLayout) child).setOnInterceptTouchListener(this);
+        child.setOnClickListener(this);
+        child.setClickable(true);
         super.addView(child, index, params);
     }
 
@@ -352,6 +355,8 @@
             throw new IllegalArgumentException("A Workspace can only have CellLayout children.");
         }
         ((CellLayout) child).setOnInterceptTouchListener(this);
+        child.setOnClickListener(this);
+        child.setClickable(true);
         super.addView(child);
     }
 
@@ -361,6 +366,8 @@
             throw new IllegalArgumentException("A Workspace can only have CellLayout children.");
         }
         ((CellLayout) child).setOnInterceptTouchListener(this);
+        child.setOnClickListener(this);
+        child.setClickable(true);
         super.addView(child, index);
     }
 
@@ -370,6 +377,8 @@
             throw new IllegalArgumentException("A Workspace can only have CellLayout children.");
         }
         ((CellLayout) child).setOnInterceptTouchListener(this);
+        child.setOnClickListener(this);
+        child.setClickable(true);
         super.addView(child, width, height);
     }
 
@@ -379,6 +388,8 @@
             throw new IllegalArgumentException("A Workspace can only have CellLayout children.");
         }
         ((CellLayout) child).setOnInterceptTouchListener(this);
+        child.setOnClickListener(this);
+        child.setClickable(true);
         super.addView(child, params);
     }
 
@@ -521,16 +532,25 @@
         return hitsPage(current + 1, x, y);
     }
 
+    /**
+     * Called directly from a CellLayout (not by the framework), after we've been added as a
+     * listener via setOnInterceptTouchEventListener(). This allows us to tell the CellLayout
+     * that it should intercept touch events, which is not something that is normally supported.
+     */
+    @Override
     public boolean onTouch(View v, MotionEvent event) {
-        // this is an intercepted event being forwarded from a cell layout
-        if (mIsSmall || mIsInUnshrinkAnimation) {
-            // Only allow clicks on a CellLayout if it is visible
-            if (mShrinkState != ShrinkState.BOTTOM_HIDDEN) {
-                mLauncher.onWorkspaceClick((CellLayout) v);
-            }
-            return true;
+        return (mIsSmall || mIsInUnshrinkAnimation);
+    }
+
+    /**
+     * Handle a click event on a CellLayout.
+     */
+    @Override
+    public void onClick(View cellLayout) {
+        // Only allow clicks on a CellLayout if it is shrunken and visible.
+        if ((mIsSmall || mIsInUnshrinkAnimation) && mShrinkState != ShrinkState.BOTTOM_HIDDEN) {
+            mLauncher.onWorkspaceClick((CellLayout) cellLayout);
         }
-        return false;
     }
 
     protected void onWindowVisibilityChanged (int visibility) {
@@ -554,8 +574,7 @@
         }
 
         if (mIsSmall || mIsInUnshrinkAnimation) {
-            if (mLauncher.isAllAppsVisible() &&
-                    mShrinkState == ShrinkState.BOTTOM_HIDDEN) {
+            if (mLauncher.isAllAppsVisible() && mShrinkState == ShrinkState.BOTTOM_HIDDEN) {
                 // Intercept this event so we can show the workspace in full view
                 // when it is clicked on and it is small
                 AllAppsPagedView allApps = (AllAppsPagedView)