OSDN Git Service

Fix regression: taps were not sent to wallpaper
authorMichael Jurka <mikejurka@google.com>
Tue, 9 Aug 2011 22:00:48 +0000 (15:00 -0700)
committerMichael Jurka <mikejurka@google.com>
Tue, 9 Aug 2011 23:07:40 +0000 (16:07 -0700)
Change-Id: I2114cf8161c7a3b0fa6849f15e5a8e4bd45dbabb

src/com/android/launcher2/AppsCustomizePagedView.java
src/com/android/launcher2/CellLayout.java
src/com/android/launcher2/PagedView.java
src/com/android/launcher2/Workspace.java

index 893e91d..16dad1b 100644 (file)
@@ -245,9 +245,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
     }
 
     @Override
-    protected void onWallpaperTap(MotionEvent ev) {
-        int action = ev.getAction();
-        if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) {
+    protected void onUnhandledTap(MotionEvent ev) {
+        if (LauncherApplication.isScreenLarge()) {
             // Dismiss AppsCustomize if we tap
             mLauncher.showWorkspace(true);
         }
index d9d0487..a17e2d6 100644 (file)
@@ -81,6 +81,7 @@ public class CellLayout extends ViewGroup {
     int[] mTempLocation = new int[2];
 
     boolean[][] mOccupied;
+    private boolean mLastDownOnOccupiedCell = false;
 
     private OnTouchListener mInterceptTouchListener;
 
@@ -752,6 +753,8 @@ public class CellLayout extends ViewGroup {
             }
         }
 
+        mLastDownOnOccupiedCell = found;
+
         if (!found) {
             final int cellXY[] = mTmpXY;
             pointToCellExact(x, y, cellXY);
@@ -1877,4 +1880,8 @@ out:            for (int i = x; i < x + spanX - 1 && x < xCount; i++) {
                     + ", x=" + cellX + ", y=" + cellY + "]";
         }
     }
+
+    public boolean lastDownOnOccupiedCell() {
+        return mLastDownOnOccupiedCell;
+    }
 }
index d228fef..d2d734c 100644 (file)
@@ -1138,7 +1138,7 @@ public abstract class PagedView extends ViewGroup {
                     snapToDestination();
                 }
             } else {
-                onWallpaperTap(ev);
+                onUnhandledTap(ev);
             }
             mTouchState = TOUCH_STATE_REST;
             mActivePointerId = INVALID_POINTER;
@@ -1222,12 +1222,9 @@ public abstract class PagedView extends ViewGroup {
                 mVelocityTracker.clear();
             }
         }
-        if (mTouchState == TOUCH_STATE_REST) {
-            onWallpaperTap(ev);
-        }
     }
 
-    protected void onWallpaperTap(MotionEvent ev) {}
+    protected void onUnhandledTap(MotionEvent ev) {}
 
     @Override
     public void requestChildFocus(View child, View focused) {
index a45d2b8..9856f7e 100644 (file)
@@ -598,11 +598,20 @@ public class Workspace extends SmoothPagedView
 
     @Override
     public boolean onInterceptTouchEvent(MotionEvent ev) {
-        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
+        switch (ev.getAction() & MotionEvent.ACTION_MASK) {
+        case MotionEvent.ACTION_DOWN:
             mXDown = ev.getX();
             mYDown = ev.getY();
+            break;
+        case MotionEvent.ACTION_POINTER_UP:
+        case MotionEvent.ACTION_UP:
+            if (mTouchState == TOUCH_STATE_REST) {
+                final CellLayout currentPage = (CellLayout) getChildAt(mCurrentPage);
+                if (!currentPage.lastDownOnOccupiedCell()) {
+                    onWallpaperTap(ev);
+                }
+            }
         }
-
         return super.onInterceptTouchEvent(ev);
     }
 
@@ -1291,7 +1300,6 @@ public class Workspace extends SmoothPagedView
         }
     }
 
-    @Override
     protected void onWallpaperTap(MotionEvent ev) {
         final int[] position = mTempCell;
         getLocationOnScreen(position);