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

Commit 9ec7b3d3 authored by Android (Google) Code Review's avatar Android (Google) Code Review Committed by The Android Open Source Project
Browse files

am c70b6444: Merge change 1463 into donut

Merge commit 'c70b6444'

* commit 'c70b6444':
  Fixes #1846038. DrawableContainer was wrongly returning its opacity by ignoring the visibility of the currently selected layer. This change simply reports a TRANSPARENT opacity if there is no currently selected layer of if the selected layer is not visible. Otherwise it reports the opacity computed by the state class.
parents 7378637d c70b6444
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4556,6 +4556,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback {
     *
     * @hide Pending API council approval
     */
    @ViewDebug.ExportedProperty
    public boolean isOpaque() {
        return mBGDrawable != null && mBGDrawable.getOpacity() == PixelFormat.OPAQUE;
    }
+1 −1
Original line number Diff line number Diff line
@@ -823,7 +823,7 @@ public class RelativeLayout extends ViewGroup {
            @ViewDebug.IntToString(from = RIGHT_OF,            to = "rightOf")
        }, mapping = {
            @ViewDebug.IntToString(from = TRUE, to = "true"),
            @ViewDebug.IntToString(from = 0,    to = "NO_ID")
            @ViewDebug.IntToString(from = 0,    to = "FALSE/NO_ID")
        })
        private int[] mRules = new int[VERB_COUNT];

+28 −38
Original line number Diff line number Diff line
@@ -181,7 +181,8 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {

    @Override
    public int getOpacity() {
        return mDrawableContainerState.getOpacity();
        return mCurrDrawable == null || !mCurrDrawable.isVisible() ? PixelFormat.TRANSPARENT :
                mDrawableContainerState.getOpacity();
    }

    public boolean selectDrawable(int idx)
@@ -336,13 +337,11 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
            return pos;
        }

        public final int getChildCount()
        {
        public final int getChildCount() {
            return mNumChildren;
        }

        public final Drawable[] getChildren()
        {
        public final Drawable[] getChildren() {
            return mDrawables;
        }

@@ -350,13 +349,11 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
          * all frames in the set (false), or to use the padding value of the frame 
          * being shown (true). Default value is false. 
          */
        public final void setVariablePadding(boolean variable)
        {
        public final void setVariablePadding(boolean variable) {
            mVariablePadding = variable;
        }

        public final Rect getConstantPadding()
        {
        public final Rect getConstantPadding() {
            if (mVariablePadding) {
                return null;
            }
@@ -364,11 +361,12 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
                return mConstantPadding;
            }

            Rect r = new Rect(0, 0, 0, 0);
            Rect t = new Rect();
            final Rect r = new Rect(0, 0, 0, 0);
            final Rect t = new Rect();
            final int N = getChildCount();
            final Drawable[] drawables = mDrawables;
            for (int i = 0; i < N; i++) {
                if (mDrawables[i].getPadding(t)) {
                if (drawables[i].getPadding(t)) {
                    if (t.left > r.left) r.left = t.left;
                    if (t.top > r.top) r.top = t.top;
                    if (t.right > r.right) r.right = t.right;
@@ -378,18 +376,15 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
            return (mConstantPadding=r);
        }

        public final void setConstantSize(boolean constant)
        {
        public final void setConstantSize(boolean constant) {
            mConstantSize = constant;
        }

        public final boolean isConstantSize()
        {
        public final boolean isConstantSize() {
            return mConstantSize;
        }

        public final int getConstantWidth()
        {
        public final int getConstantWidth() {
            if (!mComputedConstantSize) {
                computeConstantSize();
            }
@@ -397,8 +392,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
            return mConstantWidth;
        }

        public final int getConstantHeight()
        {
        public final int getConstantHeight() {
            if (!mComputedConstantSize) {
                computeConstantSize();
            }
@@ -406,8 +400,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
            return mConstantHeight;
        }

        public final int getConstantMinimumWidth()
        {
        public final int getConstantMinimumWidth() {
            if (!mComputedConstantSize) {
                computeConstantSize();
            }
@@ -415,8 +408,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
            return mConstantMinimumWidth;
        }

        public final int getConstantMinimumHeight()
        {
        public final int getConstantMinimumHeight() {
            if (!mComputedConstantSize) {
                computeConstantSize();
            }
@@ -424,15 +416,15 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
            return mConstantMinimumHeight;
        }

        private void computeConstantSize()
        {
        private void computeConstantSize() {
            mComputedConstantSize = true;

            final int N = getChildCount();
            final Drawable[] drawables = mDrawables;
            mConstantWidth = mConstantHeight = 0;
            mConstantMinimumWidth = mConstantMinimumHeight = 0;
            for (int i = 0; i < N; i++) {
                Drawable dr = mDrawables[i];
                Drawable dr = drawables[i];
                int s = dr.getIntrinsicWidth();
                if (s > mConstantWidth) mConstantWidth = s;
                s = dr.getIntrinsicHeight();
@@ -444,17 +436,16 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
            }
        }

        public final int getOpacity()
        {
        public final int getOpacity() {
            if (mHaveOpacity) {
                return mOpacity;
            }

            final int N = getChildCount();
            int op = N > 0
                ? mDrawables[0].getOpacity() : PixelFormat.TRANSPARENT;
            final Drawable[] drawables = mDrawables;
            int op = N > 0 ? drawables[0].getOpacity() : PixelFormat.TRANSPARENT;
            for (int i = 1; i < N; i++) {
                op = Drawable.resolveOpacity(op, mDrawables[i].getOpacity());
                op = Drawable.resolveOpacity(op, drawables[i].getOpacity());
            }
            mOpacity = op;
            mHaveOpacity = true;
@@ -480,8 +471,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
            return stateful;
        }

        public void growArray(int oldSize, int newSize)
        {
        public void growArray(int oldSize, int newSize) {
            Drawable[] newDrawables = new Drawable[newSize];
            System.arraycopy(mDrawables, 0, newDrawables, 0, oldSize);
            mDrawables = newDrawables;