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

Commit b63b93de authored by Alan Viverette's avatar Alan Viverette
Browse files

Fix drawable CTS breakages

1. ClipDrawable.getOpacity() now correctly respects the current level
2. DrawableWrapper checks the contained drawable's changing config even
   if it doesn't have a constant state
3. DrawableWrapper gives priority to the last valid child drawable
   rather than the drawable attribute

Bug: 21406104
Change-Id: I442fe90d0a3865bfdc6b2d14a7358178310dde02
parent 517f3ee4
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -149,6 +149,23 @@ public class ClipDrawable extends DrawableWrapper {
        return true;
    }

    @Override
    public int getOpacity() {
        final Drawable dr = getDrawable();
        final int opacity = dr.getOpacity();
        if (opacity == PixelFormat.TRANSPARENT || dr.getLevel() == 0) {
            return PixelFormat.TRANSPARENT;
        }

        final int level = getLevel();
        if (level >= MAX_LEVEL) {
            return dr.getOpacity();
        }

        // Some portion of non-transparent drawable is showing.
        return PixelFormat.TRANSLUCENT;
    }

    @Override
    public void draw(Canvas canvas) {
        final Drawable dr = getDrawable();
+5 −8
Original line number Diff line number Diff line
@@ -180,7 +180,8 @@ public abstract class DrawableWrapper extends Drawable implements Drawable.Callb
    @Override
    public int getChangingConfigurations() {
        return super.getChangingConfigurations()
                | (mState != null ? mState.getChangingConfigurations() : 0);
                | (mState != null ? mState.getChangingConfigurations() : 0)
                | mDrawable.getChangingConfigurations();
    }

    @Override
@@ -366,15 +367,12 @@ public abstract class DrawableWrapper extends Drawable implements Drawable.Callb
    }

    /**
     * Called during inflation to inflate the child element.
     * Called during inflation to inflate the child element. The last valid
     * child element will take precedence over any other child elements or
     * explicit drawable attribute.
     */
    void inflateChildDrawable(Resources r, XmlPullParser parser, AttributeSet attrs,
            Resources.Theme theme) throws XmlPullParserException, IOException {
        // Drawable specified on the root element takes precedence.
        if (getDrawable() != null) {
            return;
        }

        // Seek to the first child element.
        Drawable dr = null;
        int type;
@@ -383,7 +381,6 @@ public abstract class DrawableWrapper extends Drawable implements Drawable.Callb
                && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
            if (type == XmlPullParser.START_TAG) {
                dr = Drawable.createFromXmlInner(r, parser, attrs, theme);
                break;
            }
        }