diff options
author | Adam Cohen <adamcohen@google.com> | 2013-08-14 15:57:58 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2013-08-14 15:57:58 -0700 |
commit | 3d1b2b420684a61cf68baf4bd2a6a5ac9680d16a (patch) | |
tree | ab5d6345812a0eaf60889db4f9b099fcce540f45 | |
parent | 61a9a5c359e3e14cb1beaf43dbdb54e00911fe80 (diff) | |
download | android_packages_apps_Trebuchet-3d1b2b420684a61cf68baf4bd2a6a5ac9680d16a.tar.gz android_packages_apps_Trebuchet-3d1b2b420684a61cf68baf4bd2a6a5ac9680d16a.tar.bz2 android_packages_apps_Trebuchet-3d1b2b420684a61cf68baf4bd2a6a5ac9680d16a.zip |
Passing right swipes through to custom content
-> Right swipes must follow page settle by >= 200 ms.
Change-Id: Ie5a5ae36e63f28736599a8a846570949447f7a03
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 254bf00c8..859afa4d5 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -103,6 +103,10 @@ public class Workspace extends SmoothPagedView boolean mDrawBackground = true; private float mBackgroundAlpha = 0; + private static final long CUSTOM_CONTENT_GESTURE_DELAY = 200; + private long mTouchDownTime = -1; + private long mCustomContentShowTime = -1; + private LayoutTransition mLayoutTransition; private final WallpaperManager mWallpaperManager; private IBinder mWindowToken; @@ -819,6 +823,7 @@ public class Workspace extends SmoothPagedView case MotionEvent.ACTION_DOWN: mXDown = ev.getX(); mYDown = ev.getY(); + mTouchDownTime = System.currentTimeMillis(); break; case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_UP: @@ -859,18 +864,28 @@ public class Workspace extends SmoothPagedView protected void determineScrollingStart(MotionEvent ev) { if (!isFinishedSwitchingState()) return; - float deltaX = Math.abs(ev.getX() - mXDown); - float deltaY = Math.abs(ev.getY() - mYDown); + float deltaX = ev.getX() - mXDown; + float absDeltaX = Math.abs(deltaX); + float absDeltaY = Math.abs(ev.getY() - mYDown); - if (Float.compare(deltaX, 0f) == 0) return; + if (Float.compare(absDeltaX, 0f) == 0) return; - float slope = deltaY / deltaX; + float slope = absDeltaY / absDeltaX; float theta = (float) Math.atan(slope); - if (deltaX > mTouchSlop || deltaY > mTouchSlop) { + if (absDeltaX > mTouchSlop || absDeltaY > mTouchSlop) { cancelCurrentPageLongPress(); } + boolean passRightSwipesToCustomContent = + (mTouchDownTime - mCustomContentShowTime) > CUSTOM_CONTENT_GESTURE_DELAY; + + if (deltaX > 0 && getScreenIdForPageIndex(getCurrentPage()) == CUSTOM_CONTENT_SCREEN_ID + && passRightSwipesToCustomContent) { + // Pass swipes to the right to the custom content page. + return; + } + if (theta > MAX_SWIPE_ANGLE) { // Above MAX_SWIPE_ANGLE, we don't want to ever start scrolling the workspace return; @@ -961,6 +976,7 @@ public class Workspace extends SmoothPagedView mCustomContentShowing = true; if (mCustomContentCallbacks != null) { mCustomContentCallbacks.onShow(); + mCustomContentShowTime = System.currentTimeMillis(); } } else if (hasCustomContent() && getNextPage() != 0 && mCustomContentShowing) { mCustomContentShowing = false; |