Fix bug in EdgeEffect with glow

Fixes: 182499389

With the glow edge effect, using the drag gesture to reduce
the edge glow could cause the glow to flip and repeat. This
was caused by the update() modifying the determined distance
during the pull when it wasn't animating.

We also force the alpha to be 0 if the pull distance is 0.

Test: manual testing
Change-Id: Iacc1df0fcb92e3380523187badf7ea62d7d19d2f
This commit is contained in:
George Mount
2021-03-16 20:26:50 +00:00
parent e3e90bd0c4
commit a479a3268f

View File

@@ -354,13 +354,14 @@ public class EdgeEffect {
mDistance = Math.max(0f, mPullDistance);
mVelocity = 0;
final float absdd = Math.abs(deltaDistance);
mGlowAlpha = mGlowAlphaStart = Math.min(MAX_ALPHA,
mGlowAlpha + (absdd * PULL_DISTANCE_ALPHA_GLOW_FACTOR));
if (mPullDistance == 0) {
mGlowScaleY = mGlowScaleYStart = 0;
mGlowAlpha = mGlowAlphaStart = 0;
} else {
final float absdd = Math.abs(deltaDistance);
mGlowAlpha = mGlowAlphaStart = Math.min(MAX_ALPHA,
mGlowAlpha + (absdd * PULL_DISTANCE_ALPHA_GLOW_FACTOR));
final float scale = (float) (Math.max(0, 1 - 1 /
Math.sqrt(Math.abs(mPullDistance) * mBounds.height()) - 0.3d) / 0.7d);
@@ -698,7 +699,9 @@ public class EdgeEffect {
mGlowAlpha = mGlowAlphaStart + (mGlowAlphaFinish - mGlowAlphaStart) * interp;
mGlowScaleY = mGlowScaleYStart + (mGlowScaleYFinish - mGlowScaleYStart) * interp;
mDistance = calculateDistanceFromGlowValues(mGlowScaleY, mGlowAlpha);
if (mState != STATE_PULL) {
mDistance = calculateDistanceFromGlowValues(mGlowScaleY, mGlowAlpha);
}
mDisplacement = (mDisplacement + mTargetDisplacement) / 2;
if (t >= 1.f - EPSILON) {