diff options
author | Winson Chung <winsonc@google.com> | 2013-04-01 18:21:28 -0700 |
---|---|---|
committer | Arne Coucheron <arco68@gmail.com> | 2013-08-12 16:55:05 +0200 |
commit | fa2a20fd163f345974478eabdc0bf48a69492aaf (patch) | |
tree | 9083da6c18330baec95c14773dd89a5cbeaf030b /src | |
parent | 110df2a70eebad30bcbe04d34e85ebd7f02e3a6d (diff) | |
download | android_packages_apps_Trebuchet-fa2a20fd163f345974478eabdc0bf48a69492aaf.tar.gz android_packages_apps_Trebuchet-fa2a20fd163f345974478eabdc0bf48a69492aaf.tar.bz2 android_packages_apps_Trebuchet-fa2a20fd163f345974478eabdc0bf48a69492aaf.zip |
Fixing issue where drag view is jumping when you scroll from hovering over an edge. (Bug 8522679)
Change-Id: Ie523e718bd1b558db9608aa66f6c353e4b8e1a14
Diffstat (limited to 'src')
-rw-r--r-- | src/com/cyanogenmod/trebuchet/DragController.java | 35 | ||||
-rw-r--r-- | src/com/cyanogenmod/trebuchet/Workspace.java | 2 |
2 files changed, 22 insertions, 15 deletions
diff --git a/src/com/cyanogenmod/trebuchet/DragController.java b/src/com/cyanogenmod/trebuchet/DragController.java index 68b11416a..91adb403a 100644 --- a/src/com/cyanogenmod/trebuchet/DragController.java +++ b/src/com/cyanogenmod/trebuchet/DragController.java @@ -484,6 +484,23 @@ public class DragController { DropTarget dropTarget = findDropTarget(x, y, coordinates); mDragObject.x = coordinates[0]; mDragObject.y = coordinates[1]; + checkTouchMove(dropTarget); + + // Check if we are hovering over the scroll areas + mDistanceSinceScroll += + Math.sqrt(Math.pow(mLastTouch[0] - x, 2) + Math.pow(mLastTouch[1] - y, 2)); + mLastTouch[0] = x; + mLastTouch[1] = y; + checkScrollState(x, y); + } + + public void forceTouchMove() { + int[] dummyCoordinates = mCoordinatesTemp; + DropTarget dropTarget = findDropTarget(mLastTouch[0], mLastTouch[1], dummyCoordinates); + checkTouchMove(dropTarget); + } + + private void checkTouchMove(DropTarget dropTarget) { if (dropTarget != null) { DropTarget delegate = dropTarget.getDropTargetDelegate(mDragObject); if (delegate != null) { @@ -503,14 +520,10 @@ public class DragController { } } mLastDropTarget = dropTarget; + } - // After a scroll, the touch point will still be in the scroll region. - // Rather than scrolling immediately, require a bit of twiddling to scroll again + private void checkScrollState(int x, int y) { final int slop = ViewConfiguration.get(mLauncher).getScaledWindowTouchSlop(); - mDistanceSinceScroll += - Math.sqrt(Math.pow(mLastTouch[0] - x, 2) + Math.pow(mLastTouch[1] - y, 2)); - mLastTouch[0] = x; - mLastTouch[1] = y; final int delay = mDistanceSinceScroll < slop ? RESCROLL_DELAY : SCROLL_DELAY; if (x < mScrollZone) { @@ -536,12 +549,6 @@ public class DragController { } } - public void forceMoveEvent() { - if (mDragging) { - handleMoveEvent(mDragObject.x, mDragObject.y); - } - } - /** * Call this from a drag source view. */ @@ -792,8 +799,8 @@ public class DragController { mLauncher.getDragLayer().onExitScrollArea(); if (isDragging()) { - // Force an update so that we can requeue the scroller if necessary - forceMoveEvent(); + // Check the scroll again so that we can requeue the scroller if necessary + checkScrollState(mLastTouch[0], mLastTouch[1]); } } } diff --git a/src/com/cyanogenmod/trebuchet/Workspace.java b/src/com/cyanogenmod/trebuchet/Workspace.java index c0408ae27..f964d3d67 100644 --- a/src/com/cyanogenmod/trebuchet/Workspace.java +++ b/src/com/cyanogenmod/trebuchet/Workspace.java @@ -937,7 +937,7 @@ public class Workspace extends PagedView if (isSmall()) { // If we are in springloaded mode, then force an event to check if the current touch // is under a new page (to scroll to) - mDragController.forceMoveEvent(); + mDragController.forceTouchMove(); } } else { // If we are not mid-dragging, hide the page outlines |