Skip to content

Commit 720efc4

Browse files
adampAndroid (Google) Code Review
authored andcommitted
Merge "Lower touch slop in ViewConfiguration." into ics-mr1
2 parents 6b8b5a0 + 7d39f85 commit 720efc4

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

core/java/android/view/ViewConfiguration.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,29 @@ public class ViewConfiguration {
139139
private static final int EDGE_SLOP = 12;
140140

141141
/**
142-
* Distance a touch can wander before we think the user is scrolling in pixels
142+
* Distance a touch can wander before we think the user is scrolling in dips.
143+
* Note that this value defined here is only used as a fallback by legacy/misbehaving
144+
* applications that do not provide a Context for determining density/configuration-dependent
145+
* values.
146+
*
147+
* To alter this value, see the configuration resource config_viewConfigurationTouchSlop
148+
* in frameworks/base/core/res/res/values/config.xml or the appropriate device resource overlay.
149+
* It may be appropriate to tweak this on a device-specific basis in an overlay based on
150+
* the characteristics of the touch panel and firmware.
143151
*/
144-
private static final int TOUCH_SLOP = 16;
152+
private static final int TOUCH_SLOP = 4;
145153

146154
/**
147155
* Distance a touch can wander before we think the user is attempting a paged scroll
148156
* (in dips)
157+
*
158+
* Note that this value defined here is only used as a fallback by legacy/misbehaving
159+
* applications that do not provide a Context for determining density/configuration-dependent
160+
* values.
161+
*
162+
* See the note above on {@link #TOUCH_SLOP} regarding the dimen resource
163+
* config_viewConfigurationTouchSlop. ViewConfiguration will report a paging touch slop of
164+
* config_viewConfigurationTouchSlop * 2 when provided with a Context.
149165
*/
150166
private static final int PAGING_TOUCH_SLOP = TOUCH_SLOP * 2;
151167

@@ -277,8 +293,6 @@ private ViewConfiguration(Context context) {
277293
mMinimumFlingVelocity = (int) (density * MINIMUM_FLING_VELOCITY + 0.5f);
278294
mMaximumFlingVelocity = (int) (density * MAXIMUM_FLING_VELOCITY + 0.5f);
279295
mScrollbarSize = (int) (density * SCROLL_BAR_SIZE + 0.5f);
280-
mTouchSlop = (int) (sizeAndDensity * TOUCH_SLOP + 0.5f);
281-
mPagingTouchSlop = (int) (sizeAndDensity * PAGING_TOUCH_SLOP + 0.5f);
282296
mDoubleTapSlop = (int) (sizeAndDensity * DOUBLE_TAP_SLOP + 0.5f);
283297
mScaledTouchExplorationTapSlop = (int) (density * TOUCH_EXPLORATION_TAP_SLOP + 0.5f);
284298
mWindowTouchSlop = (int) (sizeAndDensity * WINDOW_TOUCH_SLOP + 0.5f);
@@ -301,6 +315,9 @@ private ViewConfiguration(Context context) {
301315

302316
mFadingMarqueeEnabled = res.getBoolean(
303317
com.android.internal.R.bool.config_ui_enableFadingMarquee);
318+
mTouchSlop = res.getDimensionPixelSize(
319+
com.android.internal.R.dimen.config_viewConfigurationTouchSlop);
320+
mPagingTouchSlop = mTouchSlop * 2;
304321
}
305322

306323
/**

core/res/res/values/config.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,4 +741,8 @@
741741
<string name="config_wimaxServiceClassname"></string>
742742
<!-- Name of the wimax state tracker clas -->
743743
<string name="config_wimaxStateTrackerClassname"></string>
744+
745+
<!-- Base "touch slop" value used by ViewConfiguration as a
746+
movement threshold where scrolling should begin. -->
747+
<dimen name="config_viewConfigurationTouchSlop">4dp</dimen>
744748
</resources>

0 commit comments

Comments
 (0)