diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 893e91d25f..16dad1be91 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -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); } diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java index d9d0487889..a17e2d6047 100644 --- a/src/com/android/launcher2/CellLayout.java +++ b/src/com/android/launcher2/CellLayout.java @@ -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; + } } diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index d228feffc4..d2d734cf33 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -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) { diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index a45d2b8f88..9856f7e16b 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -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);