Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a505866a authored by Jay Aliomer's avatar Jay Aliomer Committed by Automerger Merge Worker
Browse files

Merge "Reset patterned animations when solid ripple is reset" into sc-dev am:...

Merge "Reset patterned animations when solid ripple is reset" into sc-dev am: 70c0c935 am: 6f44007d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15413252

Change-Id: I46c735c527598dc34e6b7746f15d1d295c76d16e
parents 0b606fb0 6f44007d
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ public final class RippleAnimationSession {
    private long mStartTime;
    private boolean mForceSoftware;
    private Animator mLoopAnimation;
    private Animator mCurrentAnimation;

    RippleAnimationSession(@NonNull AnimationProperties<Float, Paint> properties,
            boolean forceSoftware) {
@@ -74,6 +75,12 @@ public final class RippleAnimationSession {
        return this;
    }

    void end() {
        if (mCurrentAnimation != null) {
            mCurrentAnimation.end();
        }
    }

    @NonNull RippleAnimationSession exit(Canvas canvas) {
        if (isHwAccelerated(canvas)) exitHardware((RecordingCanvas) canvas);
        else exitSoftware();
@@ -114,10 +121,12 @@ public final class RippleAnimationSession {
                if (mLoopAnimation != null) mLoopAnimation.cancel();
                Consumer<RippleAnimationSession> onEnd = mOnSessionEnd;
                if (onEnd != null) onEnd.accept(RippleAnimationSession.this);
                if (mCurrentAnimation == expand) mCurrentAnimation = null;
            }
        });
        expand.setInterpolator(LINEAR_INTERPOLATOR);
        expand.start();
        mCurrentAnimation = expand;
    }

    private long computeDelay() {
@@ -147,6 +156,7 @@ public final class RippleAnimationSession {
                if (mLoopAnimation != null) mLoopAnimation.cancel();
                Consumer<RippleAnimationSession> onEnd = mOnSessionEnd;
                if (onEnd != null) onEnd.accept(RippleAnimationSession.this);
                if (mCurrentAnimation == exit) mCurrentAnimation = null;
            }
        });
        exit.setTarget(canvas);
@@ -155,6 +165,7 @@ public final class RippleAnimationSession {
        long delay = computeDelay();
        exit.setStartDelay(delay);
        exit.start();
        mCurrentAnimation = exit;
    }

    private void enterHardware(RecordingCanvas canvas) {
@@ -167,6 +178,7 @@ public final class RippleAnimationSession {
                mStartTime + MAX_NOISE_PHASE);
        loop.setTarget(canvas);
        startAnimation(expand, loop);
        mCurrentAnimation = expand;
    }

    private void startAnimation(Animator expand, Animator loop) {
@@ -200,6 +212,7 @@ public final class RippleAnimationSession {
            mProperties.getShader().setNoisePhase((float) loop.getAnimatedValue());
        });
        startAnimation(expand, loop);
        mCurrentAnimation = expand;
    }

    void setRadius(float radius) {
+10 −2
Original line number Diff line number Diff line
@@ -278,6 +278,15 @@ public class RippleDrawable extends LayerDrawable {
        }

        cancelExitingRipples();
        endPatternedAnimations();
    }

    private void endPatternedAnimations() {
        for (int i = 0; i < mRunningAnimations.size(); i++) {
            RippleAnimationSession session = mRunningAnimations.get(i);
            session.end();
        }
        mRunningAnimations.clear();
    }

    private void cancelExitingRipples() {
@@ -291,7 +300,6 @@ public class RippleDrawable extends LayerDrawable {
            Arrays.fill(ripples, 0, count, null);
        }
        mExitingRipplesCount = 0;
        mExitingAnimation = true;
        // Always draw an additional "clean" frame after canceling animations.
        invalidateSelf(false);
    }
@@ -714,7 +722,7 @@ public class RippleDrawable extends LayerDrawable {
        }

        cancelExitingRipples();
        exitPatternedAnimation();
        endPatternedAnimations();
    }

    @Override