summaryrefslogtreecommitdiff
path: root/core/java/android/view/ViewConfiguration.java
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2010-08-25 14:37:03 -0700
committerAdam Powell <adamp@google.com>2010-08-30 19:14:07 -0700
commit0a77ce277c6ed2aa25bbea5f8cd5687c0720cb68 (patch)
treeebc9590d88ae375498aac04a168c49984138749a /core/java/android/view/ViewConfiguration.java
parent4c72ad75cfb413f54cb59d413a232e77c7260ef2 (diff)
New edge effects for scrolling widgets (overscroll)
TODO: Currently disabled for WebView. Assets used for the glow effect need to be themable/styleable. Overscroll effect should take place even when the user did not grab the widget within actual content. Change-Id: I68277d14d37dc5bcdb9254eaddf6e4998b3f2bf4
Diffstat (limited to 'core/java/android/view/ViewConfiguration.java')
-rw-r--r--core/java/android/view/ViewConfiguration.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java
index acdfc2829da9..aa9fe76374c2 100644
--- a/core/java/android/view/ViewConfiguration.java
+++ b/core/java/android/view/ViewConfiguration.java
@@ -140,6 +140,16 @@ public class ViewConfiguration {
*/
private static float SCROLL_FRICTION = 0.015f;
+ /**
+ * Max distance to overscroll for edge effects
+ */
+ private static final int OVERSCROLL_DISTANCE = 4;
+
+ /**
+ * Max distance to overfling for edge effects
+ */
+ private static final int OVERFLING_DISTANCE = 8;
+
private final int mEdgeSlop;
private final int mFadingEdgeLength;
private final int mMinimumFlingVelocity;
@@ -150,6 +160,8 @@ public class ViewConfiguration {
private final int mDoubleTapSlop;
private final int mWindowTouchSlop;
private final int mMaximumDrawingCacheSize;
+ private final int mOverscrollDistance;
+ private final int mOverflingDistance;
private static final SparseArray<ViewConfiguration> sConfigurations =
new SparseArray<ViewConfiguration>(2);
@@ -170,6 +182,8 @@ public class ViewConfiguration {
mWindowTouchSlop = WINDOW_TOUCH_SLOP;
//noinspection deprecation
mMaximumDrawingCacheSize = MAXIMUM_DRAWING_CACHE_SIZE;
+ mOverscrollDistance = OVERSCROLL_DISTANCE;
+ mOverflingDistance = OVERFLING_DISTANCE;
}
/**
@@ -198,6 +212,9 @@ public class ViewConfiguration {
// Size of the screen in bytes, in ARGB_8888 format
mMaximumDrawingCacheSize = 4 * metrics.widthPixels * metrics.heightPixels;
+
+ mOverscrollDistance = (int) (density * OVERSCROLL_DISTANCE + 0.5f);
+ mOverflingDistance = (int) (density * OVERFLING_DISTANCE + 0.5f);
}
/**
@@ -455,6 +472,20 @@ public class ViewConfiguration {
}
/**
+ * @return The maximum distance a View should overscroll by when showing edge effects.
+ */
+ public int getScaledOverscrollDistance() {
+ return mOverscrollDistance;
+ }
+
+ /**
+ * @return The maximum distance a View should overfling by when showing edge effects.
+ */
+ public int getScaledOverflingDistance() {
+ return mOverflingDistance;
+ }
+
+ /**
* The amount of time that the zoom controls should be
* displayed on the screen expressed in milliseconds.
*