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

Commit 727cae19 authored by Alan Viverette's avatar Alan Viverette
Browse files

Mutate and apply theme if needed before caching themed drawables

This ensures that drawables are completely separated from their cached
constant states before applying a theme. After this, we can remove the
implicit (and incomplete) mutation in the clone constructors.

Also implements missing mutate() method on ClipDrawable.

BUG: 17646144
Change-Id: If0d66b0a85724d76e0a4f506758c7ba3c0aa3410
parent 84659edd
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -2323,7 +2323,14 @@ public class Resources {

        final Drawable dr;
        if (cs != null) {
            dr = cs.newDrawable(this, theme);
            final Drawable clonedDr = cs.newDrawable(this);
            if (theme != null) {
                dr = clonedDr.mutate();
                dr.applyTheme(theme);
                dr.clearMutated();
            } else {
                dr = clonedDr;
            }
        } else if (isColorDrawable) {
            dr = new ColorDrawable(value.data);
        } else {
+9 −0
Original line number Diff line number Diff line
@@ -331,6 +331,15 @@ public class AnimatedRotateDrawable extends Drawable implements Drawable.Callbac
        return this;
    }

    /**
     * @hide
     */
    public void clearMutated() {
        super.clearMutated();
        mState.mDrawable.clearMutated();
        mMutated = false;
    }

    final static class AnimatedRotateState extends Drawable.ConstantState {
        Drawable mDrawable;

+8 −0
Original line number Diff line number Diff line
@@ -507,6 +507,14 @@ public class AnimatedStateListDrawable extends StateListDrawable {
        return this;
    }

    /**
     * @hide
     */
    public void clearMutated() {
        super.clearMutated();
        mMutated = false;
    }

    static class AnimatedStateListState extends StateListState {
        private static final int REVERSE_SHIFT = 32;
        private static final int REVERSE_MASK = 0x1;
+9 −0
Original line number Diff line number Diff line
@@ -157,6 +157,15 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable {
        return this;
    }

    /**
     * @hide
     */
    public void clearMutated() {
        super.clearMutated();
        mAnimatedVectorState.mVectorDrawable.clearMutated();
        mMutated = false;
    }

    @Override
    public ConstantState getConstantState() {
        mAnimatedVectorState.mChangingConfigurations = getChangingConfigurations();
+8 −0
Original line number Diff line number Diff line
@@ -347,6 +347,14 @@ public class AnimationDrawable extends DrawableContainer implements Runnable, An
        return this;
    }

    /**
     * @hide
     */
    public void clearMutated() {
        super.clearMutated();
        mMutated = false;
    }

    private final static class AnimationState extends DrawableContainerState {
        private int[] mDurations;
        private boolean mOneShot;
Loading