diff options
author | 2011-04-29 10:01:23 -0700 | |
---|---|---|
committer | 2011-04-29 10:01:23 -0700 | |
commit | eb8171bcff9bd980dbdfc99b2d843a5bcc0ae3e5 (patch) | |
tree | 6e46b759892329ae5da014d7efc919cd8e7607be | |
parent | 76616b138eb68a77a838a93fdf2f0322e982f706 (diff) | |
parent | 40209532bff0f83cbbdf408bb3f6e8142e7b02cd (diff) |
Merge "Adjust mBiggerTouchSlopSquare to the suitable value"
-rw-r--r-- | api/current.xml | 11 | ||||
-rwxr-xr-x[-rw-r--r--] | core/java/android/view/GestureDetector.java | 11 | ||||
-rwxr-xr-x[-rw-r--r--] | core/java/android/view/ViewConfiguration.java | 17 |
3 files changed, 34 insertions, 5 deletions
diff --git a/api/current.xml b/api/current.xml index c43075bd5a41..f5245092ba73 100644 --- a/api/current.xml +++ b/api/current.xml @@ -192791,6 +192791,17 @@ visibility="public" > </method> +<method name="getScaledLargeTouchSlop" + return="int" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> <method name="getScaledMaximumDrawingCacheSize" return="int" abstract="false" diff --git a/core/java/android/view/GestureDetector.java b/core/java/android/view/GestureDetector.java index c1e1049ace5b..79b3d421b966 100644..100755 --- a/core/java/android/view/GestureDetector.java +++ b/core/java/android/view/GestureDetector.java @@ -193,10 +193,8 @@ public class GestureDetector { } } - // TODO: ViewConfiguration - private int mBiggerTouchSlopSquare = 20 * 20; - private int mTouchSlopSquare; + private int mLargeTouchSlopSquare; private int mDoubleTapSlopSquare; private int mMinimumFlingVelocity; private int mMaximumFlingVelocity; @@ -384,10 +382,11 @@ public class GestureDetector { mIgnoreMultitouch = ignoreMultitouch; // Fallback to support pre-donuts releases - int touchSlop, doubleTapSlop; + int touchSlop, largeTouchSlop, doubleTapSlop; if (context == null) { //noinspection deprecation touchSlop = ViewConfiguration.getTouchSlop(); + largeTouchSlop = touchSlop + 2; doubleTapSlop = ViewConfiguration.getDoubleTapSlop(); //noinspection deprecation mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity(); @@ -395,11 +394,13 @@ public class GestureDetector { } else { final ViewConfiguration configuration = ViewConfiguration.get(context); touchSlop = configuration.getScaledTouchSlop(); + largeTouchSlop = configuration.getScaledLargeTouchSlop(); doubleTapSlop = configuration.getScaledDoubleTapSlop(); mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity(); } mTouchSlopSquare = touchSlop * touchSlop; + mLargeTouchSlopSquare = largeTouchSlop * largeTouchSlop; mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop; } @@ -534,7 +535,7 @@ public class GestureDetector { mHandler.removeMessages(SHOW_PRESS); mHandler.removeMessages(LONG_PRESS); } - if (distance > mBiggerTouchSlopSquare) { + if (distance > mLargeTouchSlopSquare) { mAlwaysInBiggerTapRegion = false; } } else if ((Math.abs(scrollX) >= 1) || (Math.abs(scrollY) >= 1)) { diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java index 924c9d48f5d4..5397449f806b 100644..100755 --- a/core/java/android/view/ViewConfiguration.java +++ b/core/java/android/view/ViewConfiguration.java @@ -102,6 +102,12 @@ public class ViewConfiguration { private static final int TOUCH_SLOP = 16; /** + * Distance a touch can wander before we think the user is the first touch + * in a sequence of double tap + */ + private static final int LARGE_TOUCH_SLOP = 18; + + /** * Distance a touch can wander before we think the user is attempting a paged scroll * (in dips) */ @@ -156,6 +162,7 @@ public class ViewConfiguration { private final int mMaximumFlingVelocity; private final int mScrollbarSize; private final int mTouchSlop; + private final int mLargeTouchSlop; private final int mPagingTouchSlop; private final int mDoubleTapSlop; private final int mWindowTouchSlop; @@ -177,6 +184,7 @@ public class ViewConfiguration { mMaximumFlingVelocity = MAXIMUM_FLING_VELOCITY; mScrollbarSize = SCROLL_BAR_SIZE; mTouchSlop = TOUCH_SLOP; + mLargeTouchSlop = LARGE_TOUCH_SLOP; mPagingTouchSlop = PAGING_TOUCH_SLOP; mDoubleTapSlop = DOUBLE_TAP_SLOP; mWindowTouchSlop = WINDOW_TOUCH_SLOP; @@ -206,6 +214,7 @@ public class ViewConfiguration { mMaximumFlingVelocity = (int) (density * MAXIMUM_FLING_VELOCITY + 0.5f); mScrollbarSize = (int) (density * SCROLL_BAR_SIZE + 0.5f); mTouchSlop = (int) (density * TOUCH_SLOP + 0.5f); + mLargeTouchSlop = (int) (density * LARGE_TOUCH_SLOP + 0.5f); mPagingTouchSlop = (int) (density * PAGING_TOUCH_SLOP + 0.5f); mDoubleTapSlop = (int) (density * DOUBLE_TAP_SLOP + 0.5f); mWindowTouchSlop = (int) (density * WINDOW_TOUCH_SLOP + 0.5f); @@ -367,6 +376,14 @@ public class ViewConfiguration { } /** + * @return Distance a touch can wander before we think the user is the first touch + * in a sequence of double tap + */ + public int getScaledLargeTouchSlop() { + return mLargeTouchSlop; + } + + /** * @return Distance a touch can wander before we think the user is scrolling a full page * in dips */ |