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

Commit 52eba0ad authored by Hyunyoung Song's avatar Hyunyoung Song Committed by Android (Google) Code Review
Browse files

Merge "Fix issue in InsetDrawable where master inset attribute get ignored....

Merge "Fix issue in InsetDrawable where master inset attribute get ignored. Test: builds, and did manual test b/37752336" into oc-dev
parents 6dcae2b9 f9fe6c11
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -2,10 +2,7 @@
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <background android:drawable="@android:color/white" />
    <foreground>
        <inset android:insetLeft="27.7%"
            android:insetTop="27.7%"
            android:insetRight="27.7%"
            android:insetBottom="27.7%">
        <inset android:inset="27.7%">
            <bitmap android:src="@mipmap/sym_def_app_icon"/>
        </inset>
    </foreground>
+11 −8
Original line number Diff line number Diff line
@@ -188,19 +188,19 @@ public class InsetDrawable extends DrawableWrapper {

        // Inset attribute may be overridden by more specific attributes.
        if (a.hasValue(R.styleable.InsetDrawable_inset)) {
            final InsetValue inset = getInset(a, R.styleable.InsetDrawable_inset, 0);
            final InsetValue inset = getInset(a, R.styleable.InsetDrawable_inset, new InsetValue());
            state.mInsetLeft = inset;
            state.mInsetTop = inset;
            state.mInsetRight = inset;
            state.mInsetBottom = inset;
        }
        state.mInsetLeft = getInset(a, R.styleable.InsetDrawable_insetLeft, 0);
        state.mInsetTop = getInset(a, R.styleable.InsetDrawable_insetTop, 0);
        state.mInsetRight = getInset(a, R.styleable.InsetDrawable_insetRight, 0);
        state.mInsetBottom = getInset(a, R.styleable.InsetDrawable_insetBottom, 0);
        state.mInsetLeft = getInset(a, R.styleable.InsetDrawable_insetLeft, state.mInsetLeft);
        state.mInsetTop = getInset(a, R.styleable.InsetDrawable_insetTop, state.mInsetTop);
        state.mInsetRight = getInset(a, R.styleable.InsetDrawable_insetRight, state.mInsetRight);
        state.mInsetBottom = getInset(a, R.styleable.InsetDrawable_insetBottom, state.mInsetBottom);
    }

    private InsetValue getInset(@NonNull TypedArray a, int index, int defaultValue) {
    private InsetValue getInset(@NonNull TypedArray a, int index, InsetValue defaultValue) {
        if (a.hasValue(index)) {
            TypedValue tv = a.peekValue(index);
            if (tv.type == TypedValue.TYPE_FRACTION) {
@@ -210,10 +210,13 @@ public class InsetDrawable extends DrawableWrapper {
                }
                return new InsetValue(f, 0);
            } else {
                return new InsetValue(0f, a.getDimensionPixelOffset(index, defaultValue));
                int dimension = a.getDimensionPixelOffset(index, 0);
                if (dimension != 0) {
                    return new InsetValue(0, dimension);
                }
            }
        return new InsetValue();
        }
        return defaultValue;
    }

    private void getInsets(Rect out) {