summaryrefslogtreecommitdiff
path: root/core/java/android/view/ViewConfiguration.java
diff options
context:
space:
mode:
authorAaron Whyte <awhyte@google.com>2017-03-22 16:30:58 -0700
committerAaron Whyte <awhyte@google.com>2017-03-29 23:34:56 +0000
commitf830652e978ce3eb85528bca81bbdfff2c09cd4a (patch)
treef1d6bee63aafc71792a62e039dddd7e735af63af /core/java/android/view/ViewConfiguration.java
parent84eecd253224ab5db12aa2640240054a6bda4982 (diff)
Split scroll factor into a 2d float.
Test: Existing unit tests, manual sanity check. BUG=35764483 Change-Id: If6ac121452698747e1f8bc9d4ec0111bb881d4d4 (cherry picked from commit e9956c5c65ecd3aaf7390c10d135749e5adfb344)
Diffstat (limited to 'core/java/android/view/ViewConfiguration.java')
-rw-r--r--core/java/android/view/ViewConfiguration.java45
1 files changed, 37 insertions, 8 deletions
diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java
index f16fcc933b70..574137b30f1e 100644
--- a/core/java/android/view/ViewConfiguration.java
+++ b/core/java/android/view/ViewConfiguration.java
@@ -232,10 +232,16 @@ 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.
+ * Amount to scroll in response to a horizontal {@link MotionEvent#ACTION_SCROLL} event,
+ * in dips per axis value.
*/
- private static final int SCROLL_FACTOR = 64;
+ private static final float HORIZONTAL_SCROLL_FACTOR = 64;
+
+ /**
+ * Amount to scroll in response to a vertical {@link MotionEvent#ACTION_SCROLL} event,
+ * in dips per axis value.
+ */
+ private static final float VERTICAL_SCROLL_FACTOR = 64;
/**
* Default duration to hide an action mode for.
@@ -289,7 +295,8 @@ public class ViewConfiguration {
private final int mOverflingDistance;
private final boolean mFadingMarqueeEnabled;
private final long mGlobalActionsKeyTimeout;
- private final int mScrollFactor;
+ private final float mVerticalScrollFactor;
+ private final float mHorizontalScrollFactor;
private boolean sHasPermanentMenuKey;
private boolean sHasPermanentMenuKeySet;
@@ -319,7 +326,8 @@ public class ViewConfiguration {
mOverflingDistance = OVERFLING_DISTANCE;
mFadingMarqueeEnabled = true;
mGlobalActionsKeyTimeout = GLOBAL_ACTIONS_KEY_TIMEOUT;
- mScrollFactor = SCROLL_FACTOR;
+ mHorizontalScrollFactor = HORIZONTAL_SCROLL_FACTOR;
+ mVerticalScrollFactor = VERTICAL_SCROLL_FACTOR;
}
/**
@@ -406,8 +414,11 @@ 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);
+
+ mHorizontalScrollFactor = res.getDimensionPixelSize(
+ com.android.internal.R.dimen.config_horizontalScrollFactor);
+ mVerticalScrollFactor = res.getDimensionPixelSize(
+ com.android.internal.R.dimen.config_verticalScrollFactor);
}
/**
@@ -730,9 +741,27 @@ 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.
+ *
+ * @removed
*/
public int getScaledScrollFactor() {
- return mScrollFactor;
+ return (int) mVerticalScrollFactor;
+ }
+
+ /**
+ * @return Amount to scroll in response to a horizontal {@link MotionEvent#ACTION_SCROLL} event.
+ * Multiply this by the event's axis value to obtain the number of pixels to be scrolled.
+ */
+ public float getScaledHorizontalScrollFactor() {
+ return mHorizontalScrollFactor;
+ }
+
+ /**
+ * @return Amount to scroll in response to a vertical {@link MotionEvent#ACTION_SCROLL} event.
+ * Multiply this by the event's axis value to obtain the number of pixels to be scrolled.
+ */
+ public float getScaledVerticalScrollFactor() {
+ return mVerticalScrollFactor;
}
/**