From a5b41c88ec6695c1fd5dd0d3c47bfa333cc71d34 Mon Sep 17 00:00:00 2001 From: Ned Burns Date: Thu, 18 Aug 2016 17:32:50 -0400 Subject: [PATCH] DO NOT MERGE Cherry-Pick: Add ViewConfiguration.getScaledScrollFactor() This value is used to convert ACTION_SCROLL axis values into raw pixel distances. CP of ag/1333603 from master to feldspar-dev. New method is @hide and @SystemApi in this version. In master, it's part of the new public API, but feldspar will launch before O. Change-Id: I5ee73ebcd183c43939ae8aa157e88489e05d4760 --- core/java/android/view/ViewConfiguration.java | 21 +++++++++++++++++++++ core/res/res/values/config.xml | 4 ++++ core/res/res/values/symbols.xml | 1 + 3 files changed, 26 insertions(+) diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java index 9a73d0b1bfaa..8b8525f2f1b5 100644 --- a/core/java/android/view/ViewConfiguration.java +++ b/core/java/android/view/ViewConfiguration.java @@ -16,6 +16,7 @@ package android.view; +import android.annotation.SystemApi; import android.app.AppGlobals; import android.content.Context; import android.content.res.Configuration; @@ -219,6 +220,12 @@ public class ViewConfiguration { private static final int OVERFLING_DISTANCE = 6; /** + * Amount to scroll in response to a {@link MotionEvent#ACTION_SCROLL} event, in dips per + * axis value. + */ + private static final int SCROLL_FACTOR = 64; + + /** * Default duration to hide an action mode for. */ private static final long ACTION_MODE_HIDE_DURATION_DEFAULT = 2000; @@ -246,6 +253,7 @@ public class ViewConfiguration { private final int mOverflingDistance; private final boolean mFadingMarqueeEnabled; private final long mGlobalActionsKeyTimeout; + private final int mScrollFactor; private boolean sHasPermanentMenuKey; private boolean sHasPermanentMenuKeySet; @@ -274,6 +282,7 @@ public class ViewConfiguration { mOverflingDistance = OVERFLING_DISTANCE; mFadingMarqueeEnabled = true; mGlobalActionsKeyTimeout = GLOBAL_ACTIONS_KEY_TIMEOUT; + mScrollFactor = SCROLL_FACTOR; } /** @@ -357,6 +366,8 @@ public class ViewConfiguration { com.android.internal.R.dimen.config_viewMaxFlingVelocity); mGlobalActionsKeyTimeout = res.getInteger( com.android.internal.R.integer.config_globalActionsKeyTimeout); + mScrollFactor = res.getDimensionPixelSize( + com.android.internal.R.dimen.config_scrollFactor); } /** @@ -669,6 +680,16 @@ public class ViewConfiguration { } /** + * @return Amount to scroll in response to a {@link MotionEvent#ACTION_SCROLL} event. Multiply + * this by the event's axis value to obtain the number of pixels to be scrolled. + * @hide + * @SystemApi + */ + public int getScaledScrollFactor() { + return mScrollFactor; + } + + /** * The maximum drawing cache size expressed in bytes. * * @return the maximum size of View's drawing cache expressed in bytes diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 231dcdacaeeb..5b2f36aca913 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -1753,6 +1753,10 @@ 500 + + 64dp + 3 diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index db118ed591ea..ecab7d0f39b3 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -416,6 +416,7 @@ + -- 2.11.0