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

Commit 1e6b8f5a authored by Alan Viverette's avatar Alan Viverette Committed by Android Git Automerger
Browse files

am 6acb521f: Merge "Update local state when creating LayerDrawable from...

am 6acb521f: Merge "Update local state when creating LayerDrawable from constant state" into mnc-dev

* commit '6acb521f':
  Update local state when creating LayerDrawable from constant state
parents a36a1ba5 6acb521f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -575,7 +575,7 @@ public class AnimatedStateListDrawable extends StateListDrawable {
            }
        }

        private void mutate() {
        void mutate() {
            mTransitions = mTransitions.clone();
            mStateIds = mStateIds.clone();
        }
+4 −1
Original line number Diff line number Diff line
@@ -730,7 +730,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
                if (origDf != null) {
                    mDrawableFutures = origDf.clone();
                } else {
                    mDrawableFutures = new SparseArray<ConstantStateFuture>(mNumChildren);
                    mDrawableFutures = new SparseArray<>(mNumChildren);
                }

                // Create futures for drawables with constant states. If a
@@ -823,6 +823,9 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
                    final Drawable prepared = mDrawableFutures.valueAt(keyIndex).get(this);
                    mDrawables[index] = prepared;
                    mDrawableFutures.removeAt(keyIndex);
                    if (mDrawableFutures.size() == 0) {
                        mDrawableFutures = null;
                    }
                    return prepared;
                }
            }
+14 −0
Original line number Diff line number Diff line
@@ -133,6 +133,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
        mLayerState.mChildren = r;

        ensurePadding();
        refreshPadding();
    }

    LayerDrawable() {
@@ -143,6 +144,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
        mLayerState = createConstantState(state, res);
        if (mLayerState.mNum > 0) {
            ensurePadding();
            refreshPadding();
        }
    }

@@ -162,6 +164,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
        inflateLayers(r, parser, attrs, theme);

        ensurePadding();
        refreshPadding();
    }

    /**
@@ -431,6 +434,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
        final ChildDrawable layer = createLayer(dr);
        final int index = addLayer(layer);
        ensurePadding();
        refreshChildPadding(index, layer);
        return index;
    }

@@ -568,6 +572,8 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {

        childDrawable.mDrawable = drawable;
        mLayerState.invalidateCache();

        refreshChildPadding(index, childDrawable);
    }

    /**
@@ -1623,6 +1629,14 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
        mPaddingB = new int[N];
    }

    void refreshPadding() {
        final int N = mLayerState.mNum;
        final ChildDrawable[] array = mLayerState.mChildren;
        for (int i = 0; i < N; i++) {
            refreshChildPadding(i, array[i]);
        }
    }

    @Override
    public ConstantState getConstantState() {
        if (mLayerState.canConstantState()) {
+2 −0
Original line number Diff line number Diff line
@@ -198,6 +198,7 @@ public class RippleDrawable extends LayerDrawable {

        setColor(color);
        ensurePadding();
        refreshPadding();
        updateLocalState();
    }

@@ -1013,6 +1014,7 @@ public class RippleDrawable extends LayerDrawable {

        if (mState.mNum > 0) {
            ensurePadding();
            refreshPadding();
        }

        if (res != null) {
+7 −18
Original line number Diff line number Diff line
@@ -59,22 +59,10 @@ import android.util.StateSet;
 * @attr ref android.R.styleable#DrawableStates_state_pressed
 */
public class StateListDrawable extends DrawableContainer {
    private static final String TAG = StateListDrawable.class.getSimpleName();
    private static final String TAG = "StateListDrawable";

    private static final boolean DEBUG = false;

    /**
     * To be proper, we should have a getter for dither (and alpha, etc.)
     * so that proxy classes like this can save/restore their delegates'
     * values, but we don't have getters. Since we do have setters
     * (e.g. setDither), which this proxy forwards on, we have to have some
     * default/initial setting.
     *
     * The initial setting for dither is now true, since it almost always seems
     * to improve the quality at negligible cost.
     */
    private static final boolean DEFAULT_DITHER = true;

    private StateListState mStateListState;
    private boolean mMutated;

@@ -104,16 +92,16 @@ public class StateListDrawable extends DrawableContainer {

    @Override
    protected boolean onStateChange(int[] stateSet) {
        final boolean changed = super.onStateChange(stateSet);

        int idx = mStateListState.indexOfStateSet(stateSet);
        if (DEBUG) android.util.Log.i(TAG, "onStateChange " + this + " states "
                + Arrays.toString(stateSet) + " found " + idx);
        if (idx < 0) {
            idx = mStateListState.indexOfStateSet(StateSet.WILD_CARD);
        }
        if (selectDrawable(idx)) {
            return true;
        }
        return super.onStateChange(stateSet);

        return selectDrawable(idx) || changed;
    }

    @Override
@@ -326,13 +314,14 @@ public class StateListDrawable extends DrawableContainer {
            }
        }

        private void mutate() {
        void mutate() {
            mThemeAttrs = mThemeAttrs != null ? mThemeAttrs.clone() : null;

            final int[][] stateSets = new int[mStateSets.length][];
            for (int i = mStateSets.length - 1; i >= 0; i--) {
                stateSets[i] = mStateSets[i] != null ? mStateSets[i].clone() : null;
            }
            mStateSets = stateSets;
        }

        int addStateSet(int[] stateSet, Drawable drawable) {