Skip to content

Commit e49e8cc

Browse files
adampAndroid (Google) Code Review
authored andcommitted
Merge "resolved conflicts for merge of 6a82871 to master"
2 parents 07ee341 + e4b8ff8 commit e49e8cc

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

core/java/android/view/ViewConfiguration.java

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,17 @@ 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 dips
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 the first touch can wander before we stop considering this event a double tap
@@ -152,6 +160,14 @@ public class ViewConfiguration {
152160
/**
153161
* Distance a touch can wander before we think the user is attempting a paged scroll
154162
* (in dips)
163+
*
164+
* Note that this value defined here is only used as a fallback by legacy/misbehaving
165+
* applications that do not provide a Context for determining density/configuration-dependent
166+
* values.
167+
*
168+
* See the note above on {@link #TOUCH_SLOP} regarding the dimen resource
169+
* config_viewConfigurationTouchSlop. ViewConfiguration will report a paging touch slop of
170+
* config_viewConfigurationTouchSlop * 2 when provided with a Context.
155171
*/
156172
private static final int PAGING_TOUCH_SLOP = TOUCH_SLOP * 2;
157173

@@ -285,9 +301,6 @@ private ViewConfiguration(Context context) {
285301
mMinimumFlingVelocity = (int) (density * MINIMUM_FLING_VELOCITY + 0.5f);
286302
mMaximumFlingVelocity = (int) (density * MAXIMUM_FLING_VELOCITY + 0.5f);
287303
mScrollbarSize = (int) (density * SCROLL_BAR_SIZE + 0.5f);
288-
mTouchSlop = (int) (sizeAndDensity * TOUCH_SLOP + 0.5f);
289-
mDoubleTapTouchSlop = (int) (sizeAndDensity * DOUBLE_TAP_TOUCH_SLOP + 0.5f);
290-
mPagingTouchSlop = (int) (sizeAndDensity * PAGING_TOUCH_SLOP + 0.5f);
291304
mDoubleTapSlop = (int) (sizeAndDensity * DOUBLE_TAP_SLOP + 0.5f);
292305
mScaledTouchExplorationTapSlop = (int) (density * TOUCH_EXPLORATION_TAP_SLOP + 0.5f);
293306
mWindowTouchSlop = (int) (sizeAndDensity * WINDOW_TOUCH_SLOP + 0.5f);
@@ -310,6 +323,11 @@ private ViewConfiguration(Context context) {
310323

311324
mFadingMarqueeEnabled = res.getBoolean(
312325
com.android.internal.R.bool.config_ui_enableFadingMarquee);
326+
mTouchSlop = res.getDimensionPixelSize(
327+
com.android.internal.R.dimen.config_viewConfigurationTouchSlop);
328+
mPagingTouchSlop = mTouchSlop * 2;
329+
330+
mDoubleTapTouchSlop = mTouchSlop;
313331
}
314332

315333
/**

core/res/res/values/config.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,4 +747,9 @@
747747

748748
<!-- Name of screensaver components to look for if none has been chosen by the user -->
749749
<string name="config_defaultDreamComponent">com.google.android.deskclock/com.android.deskclock.Screensaver</string>
750+
751+
<!-- Base "touch slop" value used by ViewConfiguration as a
752+
movement threshold where scrolling should begin. -->
753+
<dimen name="config_viewConfigurationTouchSlop">4dp</dimen>
754+
750755
</resources>

0 commit comments

Comments
 (0)