summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mindy Pereira <mindyp@google.com> 2010-10-08 11:44:23 -0700
committer Mindy Pereira <mindyp@google.com> 2010-10-08 11:45:57 -0700
commit612d570a6fc1e5a0e2e56250f597d1e96d698273 (patch)
tree3ca5f207a63f63fd866a7167161909556bfbf077
parentaecab79b4ec4727a59a5532c7db2683c617e8c21 (diff)
DO NOT MERGE Adjust amount pull effects the glow and edge decay.
Edge decay is now based on the remaining height of the glow so that as the glow reduces, the edge will reduce and not disappear entirely before the glow is gone. Change-Id: I03376ee3807e21ce6ac74c0cfad713b7fd5e4520
-rw-r--r--core/java/android/widget/EdgeGlow.java30
1 files changed, 21 insertions, 9 deletions
diff --git a/core/java/android/widget/EdgeGlow.java b/core/java/android/widget/EdgeGlow.java
index 1f7daabd426a..7a990adf6ba4 100644
--- a/core/java/android/widget/EdgeGlow.java
+++ b/core/java/android/widget/EdgeGlow.java
@@ -91,6 +91,7 @@ public class EdgeGlow {
// How much dragging should effect the height of the glow image.
// Number determined by user testing.
private static final int PULL_DISTANCE_GLOW_FACTOR = 5;
+ private static final float PULL_DISTANCE_ALPHA_GLOW_FACTOR = 0.8f;
private static final int VELOCITY_EDGE_FACTOR = 8;
private static final int VELOCITY_GLOW_FACTOR = 16;
@@ -144,8 +145,10 @@ public class EdgeGlow {
mEdgeScaleY = mEdgeScaleYStart = Math.max(
HELD_EDGE_SCALE_Y, Math.min(distance * PULL_DISTANCE_EDGE_FACTOR, 1.f));
- mGlowAlpha = mGlowAlphaStart = Math.max(
- 0.5f, Math.min(mGlowAlpha + Math.abs(deltaDistance), MAX_ALPHA));
+ mGlowAlpha = mGlowAlphaStart = Math.min(
+ mGlowAlpha +
+ (Math.abs(deltaDistance) * PULL_DISTANCE_ALPHA_GLOW_FACTOR),
+ MAX_ALPHA);
float glowChange = Math.abs(deltaDistance);
if (deltaDistance > 0 && mPullDistance < 0) {
@@ -202,8 +205,8 @@ public class EdgeGlow {
// The edge should always be at least partially visible, regardless
// of velocity.
- mEdgeAlphaStart = 0.5f;
- mEdgeScaleYStart = 0.2f;
+ mEdgeAlphaStart = 0.f;
+ mEdgeScaleY = mEdgeScaleYStart = 0.f;
// The glow depends more on the velocity, and therefore starts out
// nearly invisible.
mGlowAlphaStart = 0.5f;
@@ -213,7 +216,8 @@ public class EdgeGlow {
// reflect the strength of the user's scrolling.
mEdgeAlphaFinish = Math.max(0, Math.min(velocity * VELOCITY_EDGE_FACTOR, 1));
// Edge should never get larger than the size of its asset.
- mEdgeScaleYFinish = 1.f;
+ mEdgeScaleYFinish = Math.max(
+ HELD_EDGE_SCALE_Y, Math.min(velocity * VELOCITY_EDGE_FACTOR, 1.f));
// Growth for the size of the glow should be quadratic to properly
// respond
@@ -281,10 +285,11 @@ public class EdgeGlow {
mGlowAlphaStart = mGlowAlpha;
mGlowScaleYStart = mGlowScaleY;
+ // After absorb, the glow and edge should fade to nothing.
mEdgeAlphaFinish = 0.f;
- mEdgeScaleYFinish = mEdgeScaleY;
+ mEdgeScaleYFinish = 0.f;
mGlowAlphaFinish = 0.f;
- mGlowScaleYFinish = mGlowScaleY;
+ mGlowScaleYFinish = 0.f;
break;
case STATE_PULL:
mState = STATE_PULL_DECAY;
@@ -296,14 +301,21 @@ public class EdgeGlow {
mGlowAlphaStart = mGlowAlpha;
mGlowScaleYStart = mGlowScaleY;
- // After a pull, the glow should fade to nothing.
+ // After pull, the glow and edge should fade to nothing.
mEdgeAlphaFinish = 0.f;
mEdgeScaleYFinish = 0.f;
mGlowAlphaFinish = 0.f;
mGlowScaleYFinish = 0.f;
break;
case STATE_PULL_DECAY:
- // Do nothing; wait for release
+ // When receding, we want edge to decrease more slowly
+ // than the glow.
+ float factor = mGlowScaleYFinish != 0 ? 1
+ / (mGlowScaleYFinish * mGlowScaleYFinish)
+ : Float.MAX_VALUE;
+ mEdgeScaleY = mEdgeScaleYStart +
+ (mEdgeScaleYFinish - mEdgeScaleYStart) *
+ interp * factor;
break;
case STATE_RECEDE:
mState = STATE_IDLE;