Fix regression: taps were not sent to wallpaper
Change-Id: I2114cf8161c7a3b0fa6849f15e5a8e4bd45dbabb
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 893e91d..16dad1b 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -245,9 +245,8 @@
}
@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 d9d0487..a17e2d6 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -81,6 +81,7 @@
int[] mTempLocation = new int[2];
boolean[][] mOccupied;
+ private boolean mLastDownOnOccupiedCell = false;
private OnTouchListener mInterceptTouchListener;
@@ -752,6 +753,8 @@
}
}
+ mLastDownOnOccupiedCell = found;
+
if (!found) {
final int cellXY[] = mTmpXY;
pointToCellExact(x, y, cellXY);
@@ -1877,4 +1880,8 @@
+ ", 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 d228fef..d2d734c 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -1138,7 +1138,7 @@
snapToDestination();
}
} else {
- onWallpaperTap(ev);
+ onUnhandledTap(ev);
}
mTouchState = TOUCH_STATE_REST;
mActivePointerId = INVALID_POINTER;
@@ -1222,12 +1222,9 @@
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 a45d2b8..9856f7e 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -598,11 +598,20 @@
@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 @@
}
}
- @Override
protected void onWallpaperTap(MotionEvent ev) {
final int[] position = mTempCell;
getLocationOnScreen(position);