From 0ca911f5f850c71d2c0e6406fdd957572ef95122 Mon Sep 17 00:00:00 2001 From: Michel Comin Escude Date: Tue, 13 Apr 2021 19:34:00 -0700 Subject: [PATCH] Added velocity scalar and updated spring values Updated spring values to the latest ones agreed in design. In addition, added a velocity multiplier that only affects after it absorbs an impact at the scroll boundary. This will help to increase the spring behavior when we fling the content, but keeping it controlled when we pull and release. Bug: 183768138 Test: ran EdgeEffectTest and visual Change-Id: I4ed7b01dd42a9a5adda637917369c349a6ae2f76 --- core/java/android/widget/EdgeEffect.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/java/android/widget/EdgeEffect.java b/core/java/android/widget/EdgeEffect.java index cd91d0266c753..e4d5728889d9b 100644 --- a/core/java/android/widget/EdgeEffect.java +++ b/core/java/android/widget/EdgeEffect.java @@ -117,12 +117,18 @@ public class EdgeEffect { /** * The natural frequency of the stretch spring. */ - private static final double NATURAL_FREQUENCY = 17.55; + private static final double NATURAL_FREQUENCY = 24.657; /** * The damping ratio of the stretch spring. */ - private static final double DAMPING_RATIO = 0.92; + private static final double DAMPING_RATIO = 0.98; + + /** + * The variation of the velocity for the stretch effect when it meets the bound. + * if value is > 1, it will accentuate the absorption of the movement. + */ + private static final float ON_ABSORB_VELOCITY_ADJUSTMENT = 13f; /** @hide */ @IntDef({TYPE_GLOW, TYPE_STRETCH}) @@ -460,7 +466,7 @@ public class EdgeEffect { public void onAbsorb(int velocity) { if (mEdgeEffectType == TYPE_STRETCH) { mState = STATE_RECEDE; - mVelocity = velocity; + mVelocity = velocity * ON_ABSORB_VELOCITY_ADJUSTMENT; mDistance = 0; mStartTime = AnimationUtils.currentAnimationTimeMillis(); } else {