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

Commit 95930e13 authored by Romain Guy's avatar Romain Guy
Browse files

Apply all Canvas transformations to ColorDrawable.

Change-Id: I29252c58224b236d0770ec005da9842990ef2c06
parent 94e46130
Loading
Loading
Loading
Loading
+1 −12
Original line number Diff line number Diff line
@@ -185,7 +185,6 @@ public class ExpandableListView extends ListView {
    
    /** Drawable to be used as a divider when it is adjacent to any children */
    private Drawable mChildDivider;
    private boolean mClipChildDivider;

    // Bounds of the indicator to be drawn
    private final Rect mIndicatorRect = new Rect();
@@ -379,7 +378,6 @@ public class ExpandableListView extends ListView {
     */
    public void setChildDivider(Drawable childDivider) {
        mChildDivider = childDivider;
        mClipChildDivider = childDivider != null && childDivider instanceof ColorDrawable;
    }

    @Override
@@ -396,17 +394,8 @@ public class ExpandableListView extends ListView {
                    pos.groupMetadata.lastChildFlPos != pos.groupMetadata.flPos)) {
                // These are the cases where we draw the child divider
                final Drawable divider = mChildDivider;
                final boolean clip = mClipChildDivider;
                if (!clip) {
                divider.setBounds(bounds);
                } else {
                    canvas.save();
                    canvas.clipRect(bounds);
                }
                divider.draw(canvas);
                if (clip) {
                    canvas.restore();
                }
                pos.recycle();
                return;
            }
+1 −15
Original line number Diff line number Diff line
@@ -107,7 +107,6 @@ public class ListView extends AbsListView {
    
    private boolean mIsCacheColorOpaque;
    private boolean mDividerIsOpaque;
    private boolean mClipDivider;

    private boolean mHeaderDividersEnabled;
    private boolean mFooterDividersEnabled;
@@ -3057,20 +3056,9 @@ public class ListView extends AbsListView {
    void drawDivider(Canvas canvas, Rect bounds, int childIndex) {
        // This widget draws the same divider for all children
        final Drawable divider = mDivider;
        final boolean clipDivider = mClipDivider;

        if (!clipDivider) {
        divider.setBounds(bounds);
        } else {
            canvas.save();
            canvas.clipRect(bounds);
        }

        divider.draw(canvas);

        if (clipDivider) {
            canvas.restore();
        }
    }

    /**
@@ -3091,10 +3079,8 @@ public class ListView extends AbsListView {
    public void setDivider(Drawable divider) {
        if (divider != null) {
            mDividerHeight = divider.getIntrinsicHeight();
            mClipDivider = divider instanceof ColorDrawable;
        } else {
            mDividerHeight = 0;
            mClipDivider = false;
        }
        mDivider = divider;
        mDividerIsOpaque = divider == null || divider.getOpacity() == PixelFormat.OPAQUE;
+7 −5
Original line number Diff line number Diff line
@@ -26,10 +26,8 @@ import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;

/**
 * A specialized Drawable that fills the Canvas with a specified color,
 * with respect to the clip region. Note that a ColorDrawable ignores the ColorFilter.
 * It also ignores the Bounds, meaning it will draw everywhere in the current clip,
 * even if setBounds(...) was called with a smaller area.
 * A specialized Drawable that fills the Canvas with a specified color.
 * Note that a ColorDrawable ignores the ColorFilter.
 *
 * <p>It can be defined in an XML file with the <code>&lt;color></code> element.</p>
 *
@@ -37,6 +35,7 @@ import java.io.IOException;
 */
public class ColorDrawable extends Drawable {
    private ColorState mState;
    private final Paint mPaint = new Paint();

    /**
     * Creates a new black ColorDrawable.
@@ -66,7 +65,10 @@ public class ColorDrawable extends Drawable {

    @Override
    public void draw(Canvas canvas) {
        canvas.drawColor(mState.mUseColor);
        if ((mState.mUseColor >>> 24) != 0) {
            mPaint.setColor(mState.mUseColor);
            canvas.drawRect(getBounds(), mPaint);
        }
    }

    /**