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

Commit b6181565 authored by Alan Viverette's avatar Alan Viverette Committed by Android (Google) Code Review
Browse files

Merge "Return correct intrinsic dimensions for inset colors"

parents 530dcda9 76165b2a
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -913,16 +913,26 @@ public abstract class Drawable {
    protected void onBoundsChange(Rect bounds) {}

    /**
     * Return the intrinsic width of the underlying drawable object.  Returns
     * -1 if it has no intrinsic width, such as with a solid color.
     * Returns the drawable's intrinsic width.
     * <p>
     * Intrinsic width is the width at which the drawable would like to be laid
     * out, including any inherent padding. If the drawable has no intrinsic
     * width, such as a solid color, this method returns -1.
     *
     * @return the intrinsic width, or -1 if no intrinsic width
     */
    public int getIntrinsicWidth() {
        return -1;
    }

    /**
     * Return the intrinsic height of the underlying drawable object. Returns
     * -1 if it has no intrinsic height, such as with a solid color.
     * Returns the drawable's intrinsic height.
     * <p>
     * Intrinsic height is the height at which the drawable would like to be
     * laid out, including any inherent padding. If the drawable has no
     * intrinsic height, such as a solid color, this method returns -1.
     *
     * @return the intrinsic height, or -1 if no intrinsic height
     */
    public int getIntrinsicHeight() {
        return -1;
+10 −2
Original line number Diff line number Diff line
@@ -222,12 +222,20 @@ public class InsetDrawable extends DrawableWrapper {

    @Override
    public int getIntrinsicWidth() {
        return getDrawable().getIntrinsicWidth() + mState.mInsetLeft + mState.mInsetRight;
        final int childWidth = getDrawable().getIntrinsicWidth();
        if (childWidth < 0) {
            return -1;
        }
        return childWidth + mState.mInsetLeft + mState.mInsetRight;
    }

    @Override
    public int getIntrinsicHeight() {
        return getDrawable().getIntrinsicHeight() + mState.mInsetTop + mState.mInsetBottom;
        final int childHeight = getDrawable().getIntrinsicHeight();
        if (childHeight < 0) {
            return -1;
        }
        return childHeight + mState.mInsetTop + mState.mInsetBottom;
    }

    @Override