diff options
author | Patrick Dubroy <dubroy@google.com> | 2010-10-07 16:47:28 -0700 |
---|---|---|
committer | Patrick Dubroy <dubroy@google.com> | 2010-10-07 16:49:10 -0700 |
commit | a16fd5a6bd5371d40a5679261d416f06f8efa022 (patch) | |
tree | 565210d55182e14df901ea5e191bf38de07ef6ed /src/com/android/launcher2/DragController.java | |
parent | 00397b1d9233409d9d6b233b077ae12d09768ce8 (diff) | |
download | android_packages_apps_Trebuchet-a16fd5a6bd5371d40a5679261d416f06f8efa022.tar.gz android_packages_apps_Trebuchet-a16fd5a6bd5371d40a5679261d416f06f8efa022.tar.bz2 android_packages_apps_Trebuchet-a16fd5a6bd5371d40a5679261d416f06f8efa022.zip |
fix 3049894: Require fiddle or longer timeout for subsequent page flips
After initiating a scroll while dragging an item on the home screen, don't flip
so quickly to the next page. Instead, require a bit of additional movement to
trigger the next scroll.
Diffstat (limited to 'src/com/android/launcher2/DragController.java')
-rw-r--r-- | src/com/android/launcher2/DragController.java | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/com/android/launcher2/DragController.java b/src/com/android/launcher2/DragController.java index 68dfb35fc..3c956f07f 100644 --- a/src/com/android/launcher2/DragController.java +++ b/src/com/android/launcher2/DragController.java @@ -16,8 +16,11 @@ package com.android.launcher2; +import com.android.launcher.R; + import android.content.Context; import android.graphics.Bitmap; +import android.graphics.PointF; import android.graphics.Rect; import android.graphics.RectF; import android.os.Handler; @@ -28,13 +31,12 @@ import android.util.Log; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; +import android.view.ViewConfiguration; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; import java.util.ArrayList; -import com.android.launcher.R; - /** * Class for initiating a drag within a view or across multiple views. */ @@ -124,6 +126,9 @@ public class DragController { private InputMethodManager mInputMethodManager; + private int mLastTouch[] = new int[2]; + private int mDistanceSinceScroll = 0; + /** * Interface to receive notifications when a drag starts or stops */ @@ -486,15 +491,24 @@ public class DragController { if (mDeleteRegion != null) { inDeleteRegion = mDeleteRegion.contains(x, y); } + + // 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 + final int slop = ViewConfiguration.get(mContext).getScaledWindowTouchSlop(); + mDistanceSinceScroll += + Math.sqrt(Math.pow(mLastTouch[0] - x, 2) + Math.pow(mLastTouch[1] - y, 2)); + mLastTouch[0] = x; + mLastTouch[1] = y; + if (!inDeleteRegion && x < mScrollZone) { - if (mScrollState == SCROLL_OUTSIDE_ZONE) { + if (mScrollState == SCROLL_OUTSIDE_ZONE && mDistanceSinceScroll > slop) { mScrollState = SCROLL_WAITING_IN_ZONE; mScrollRunnable.setDirection(SCROLL_LEFT); mHandler.postDelayed(mScrollRunnable, SCROLL_DELAY); mDragScroller.onEnterScrollArea(SCROLL_LEFT); } } else if (!inDeleteRegion && x > mScrollView.getWidth() - mScrollZone) { - if (mScrollState == SCROLL_OUTSIDE_ZONE) { + if (mScrollState == SCROLL_OUTSIDE_ZONE && mDistanceSinceScroll > slop) { mScrollState = SCROLL_WAITING_IN_ZONE; mScrollRunnable.setDirection(SCROLL_RIGHT); mHandler.postDelayed(mScrollRunnable, SCROLL_DELAY); @@ -696,6 +710,8 @@ public class DragController { mDragScroller.scrollRight(); } mScrollState = SCROLL_OUTSIDE_ZONE; + mDistanceSinceScroll = 0; + mDragScroller.onExitScrollArea(); } } |