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

Commit a0f63c6e authored by Alan Viverette's avatar Alan Viverette Committed by Android (Google) Code Review
Browse files

Merge "Fixed mutate() for RippleDrawable, ASLD, AVD, fix applyTheme in VD" into lmp-dev

parents 1b409bcf 5004032e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -492,7 +492,7 @@ public class AnimatedStateListDrawable extends StateListDrawable {

    @Override
    public Drawable mutate() {
        if (!mMutated) {
        if (!mMutated && super.mutate() == this) {
            final AnimatedStateListState newState = new AnimatedStateListState(mState, this, null);
            setConstantState(newState);
            mMutated = true;
+1 −1
Original line number Diff line number Diff line
@@ -151,7 +151,7 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable {
    @Override
    public Drawable mutate() {
        if (!mMutated && super.mutate() == this) {
            mAnimatedVectorState = new AnimatedVectorDrawableState(mAnimatedVectorState);
            mAnimatedVectorState.mVectorDrawable.mutate();
            mMutated = true;
        }
        return this;
+23 −6
Original line number Diff line number Diff line
@@ -114,7 +114,8 @@ public class RippleDrawable extends LayerDrawable {
    /** Current dirty bounds, union of current and previous drawing bounds. */
    private final Rect mDirtyBounds = new Rect();

    private final RippleState mState;
    /** Mirrors mLayerState with some extra information. */
    private RippleState mState;

    /** The masking layer, e.g. the layer with id R.id.mask. */
    private Drawable mMask;
@@ -885,18 +886,34 @@ public class RippleDrawable extends LayerDrawable {
        return mState;
    }

    @Override
    public Drawable mutate() {
        super.mutate();

        // LayerDrawable creates a new state using createConstantState, so
        // this should always be a safe cast.
        mState = (RippleState) mLayerState;
        return this;
    }

    @Override
    RippleState createConstantState(LayerState state, Resources res) {
        return new RippleState(state, this, res);
    }

    static class RippleState extends LayerState {
        int[] mTouchThemeAttrs;
        ColorStateList mColor = ColorStateList.valueOf(Color.MAGENTA);
        int mMaxRadius = RADIUS_AUTO;

        public RippleState(RippleState orig, RippleDrawable owner, Resources res) {
        public RippleState(LayerState orig, RippleDrawable owner, Resources res) {
            super(orig, owner, res);

            if (orig != null) {
                mTouchThemeAttrs = orig.mTouchThemeAttrs;
                mColor = orig.mColor;
                mMaxRadius = orig.mMaxRadius;
            if (orig != null && orig instanceof RippleState) {
                final RippleState origs = (RippleState) orig;
                mTouchThemeAttrs = origs.mTouchThemeAttrs;
                mColor = origs.mColor;
                mMaxRadius = origs.mMaxRadius;
            }
        }

+22 −9
Original line number Diff line number Diff line
@@ -507,9 +507,10 @@ public class VectorDrawable extends Drawable {
                pathRenderer.getAlpha());
        pathRenderer.setAlpha(alphaInFloat);

        pathRenderer.mRootName = a.getString(R.styleable.VectorDrawable_name);
        if (pathRenderer.mRootName != null) {
            pathRenderer.mVGTargetsMap.put(pathRenderer.mRootName, pathRenderer);
        final String name = a.getString(R.styleable.VectorDrawable_name);
        if (name != null) {
            pathRenderer.mRootName = name;
            pathRenderer.mVGTargetsMap.put(name, pathRenderer);
        }
    }

@@ -1313,9 +1314,15 @@ public class VectorDrawable extends Drawable {
            // Account for any configuration changes.
            mChangingConfigurations |= a.getChangingConfigurations();

            mPathName = a.getString(R.styleable.VectorDrawableClipPath_name);
            mNodes = PathParser.createNodesFromPathData(a.getString(
                    R.styleable.VectorDrawableClipPath_pathData));
            final String pathName = a.getString(R.styleable.VectorDrawableClipPath_name);
            if (pathName != null) {
                mPathName = pathName;
            }

            final String pathData = a.getString(R.styleable.VectorDrawableClipPath_pathData);
            if (pathData != null) {
                mNodes = PathParser.createNodesFromPathData(pathData);
            }
        }

        @Override
@@ -1415,9 +1422,15 @@ public class VectorDrawable extends Drawable {
            // Extract the theme attributes, if any.
            mThemeAttrs = a.extractThemeAttrs();

            mPathName = a.getString(R.styleable.VectorDrawablePath_name);
            mNodes = PathParser.createNodesFromPathData(a.getString(
                    R.styleable.VectorDrawablePath_pathData));
            final String pathName = a.getString(R.styleable.VectorDrawablePath_name);
            if (pathName != null) {
                mPathName = pathName;
            }

            final String pathData = a.getString(R.styleable.VectorDrawablePath_pathData);
            if (pathData != null) {
                mNodes = PathParser.createNodesFromPathData(pathData);
            }

            mFillColor = a.getColor(R.styleable.VectorDrawablePath_fillColor,
                    mFillColor);