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

Commit 83aa3222 authored by Winson Chung's avatar Winson Chung Committed by Automerger Merge Worker
Browse files

Merge "Ensure that animated key button drawable has callbacks" into rvc-dev...

Merge "Ensure that animated key button drawable has callbacks" into rvc-dev am: acf07500 am: 9542a56d am: 7bae7f27 am: 77cb9eaa

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

Change-Id: I164cafcf9533ca6c514bd9b8abcb38506201bc8a
parents 38ddedd7 77cb9eaa
Loading
Loading
Loading
Loading
+17 −0
Original line number Original line Diff line number Diff line
@@ -80,6 +80,22 @@ public class KeyButtonDrawable extends Drawable {
    private final Paint mShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
    private final Paint mShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
    private final ShadowDrawableState mState;
    private final ShadowDrawableState mState;
    private AnimatedVectorDrawable mAnimatedDrawable;
    private AnimatedVectorDrawable mAnimatedDrawable;
    private final Callback mAnimatedDrawableCallback = new Callback() {
        @Override
        public void invalidateDrawable(@NonNull Drawable who) {
            invalidateSelf();
        }

        @Override
        public void scheduleDrawable(@NonNull Drawable who, @NonNull Runnable what, long when) {
            scheduleSelf(what, when);
        }

        @Override
        public void unscheduleDrawable(@NonNull Drawable who, @NonNull Runnable what) {
            unscheduleSelf(what);
        }
    };


    public KeyButtonDrawable(Drawable d, @ColorInt int lightColor, @ColorInt int darkColor,
    public KeyButtonDrawable(Drawable d, @ColorInt int lightColor, @ColorInt int darkColor,
            boolean horizontalFlip, Color ovalBackgroundColor) {
            boolean horizontalFlip, Color ovalBackgroundColor) {
@@ -97,6 +113,7 @@ public class KeyButtonDrawable extends Drawable {
        }
        }
        if (canAnimate()) {
        if (canAnimate()) {
            mAnimatedDrawable = (AnimatedVectorDrawable) mState.mChildState.newDrawable().mutate();
            mAnimatedDrawable = (AnimatedVectorDrawable) mState.mChildState.newDrawable().mutate();
            mAnimatedDrawable.setCallback(mAnimatedDrawableCallback);
            setDrawableBounds(mAnimatedDrawable);
            setDrawableBounds(mAnimatedDrawable);
        }
        }
    }
    }