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

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

Merge "Move setTint into Drawable, unhide getDirtyBounds on Drawable"

parents 94520c74 e7772d31
Loading
Loading
Loading
Loading
+2 −10
Original line number Diff line number Diff line
@@ -11203,7 +11203,6 @@ package android.graphics.drawable {
    method public final android.graphics.Paint getPaint();
    method public android.graphics.Shader.TileMode getTileModeX();
    method public android.graphics.Shader.TileMode getTileModeY();
    method public android.content.res.ColorStateList getTint();
    method public boolean hasAntiAlias();
    method public boolean hasMipMap();
    method public final boolean isAutoMirrored();
@@ -11218,8 +11217,6 @@ package android.graphics.drawable {
    method public void setTileModeX(android.graphics.Shader.TileMode);
    method public void setTileModeXY(android.graphics.Shader.TileMode, android.graphics.Shader.TileMode);
    method public final void setTileModeY(android.graphics.Shader.TileMode);
    method public void setTint(android.content.res.ColorStateList);
    method public void setTintMode(android.graphics.PorterDuff.Mode);
  }
  public class ClipDrawable extends android.graphics.drawable.Drawable implements android.graphics.drawable.Drawable.Callback {
@@ -11272,6 +11269,7 @@ package android.graphics.drawable {
    method public android.graphics.ColorFilter getColorFilter();
    method public android.graphics.drawable.Drawable.ConstantState getConstantState();
    method public android.graphics.drawable.Drawable getCurrent();
    method public android.graphics.Rect getDirtyBounds();
    method public int getIntrinsicHeight();
    method public int getIntrinsicWidth();
    method public final int getLevel();
@@ -11309,6 +11307,7 @@ package android.graphics.drawable {
    method public void setHotspotBounds(int, int, int, int);
    method public final boolean setLevel(int);
    method public boolean setState(int[]);
    method public void setTint(android.content.res.ColorStateList, android.graphics.PorterDuff.Mode);
    method public boolean setVisible(boolean, boolean);
    method public void unscheduleSelf(java.lang.Runnable);
  }
@@ -11464,14 +11463,11 @@ package android.graphics.drawable {
    method public void draw(android.graphics.Canvas);
    method public int getOpacity();
    method public android.graphics.Paint getPaint();
    method public android.content.res.ColorStateList getTint();
    method public void setAlpha(int);
    method public void setColorFilter(android.graphics.ColorFilter);
    method public void setTargetDensity(android.graphics.Canvas);
    method public void setTargetDensity(android.util.DisplayMetrics);
    method public void setTargetDensity(int);
    method public void setTint(android.content.res.ColorStateList);
    method public void setTintMode(android.graphics.PorterDuff.Mode);
  }
  public class PaintDrawable extends android.graphics.drawable.ShapeDrawable {
@@ -11492,10 +11488,6 @@ package android.graphics.drawable {
  }
  public class RippleDrawable extends android.graphics.drawable.LayerDrawable {
    method public android.graphics.Rect getDirtyBounds();
    method public android.content.res.ColorStateList getTint();
    method public void setTint(android.content.res.ColorStateList);
    method public void setTintMode(android.graphics.PorterDuff.Mode);
  }
  public class RotateDrawable extends android.graphics.drawable.Drawable implements android.graphics.drawable.Drawable.Callback {
+8 −32
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.graphics.ColorFilter;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
@@ -588,46 +589,21 @@ public class BitmapDrawable extends Drawable {
        return mBitmapState.mPaint.getColorFilter();
    }

    /**
     * Specifies a tint for this drawable.
     * <p>
     * Setting a color filter via {@link #setColorFilter(ColorFilter)} overrides
     * tint.
     *
     * @param tint Color state list to use for tinting this drawable, or null to
     *            clear the tint
     */
    public void setTint(ColorStateList tint) {
        if (mBitmapState.mTint != tint) {
    @Override
    public void setTint(ColorStateList tint, PorterDuff.Mode tintMode) {
        mBitmapState.mTint = tint;
        mBitmapState.mTintMode = tintMode;
        computeTintFilter();
        invalidateSelf();
    }
    }

    /**
     * Returns the tint color for this drawable.
     *
     * @return Color state list to use for tinting this drawable, or null if
     *         none set
     * @hide only needed by a hack within ProgressBar
     */
    public ColorStateList getTint() {
        return mBitmapState.mTint;
    }

    /**
     * Specifies the blending mode used to apply tint.
     *
     * @param tintMode A Porter-Duff blending mode
     */
    public void setTintMode(Mode tintMode) {
        if (mBitmapState.mTintMode != tintMode) {
            mBitmapState.mTintMode = tintMode;
            computeTintFilter();
            invalidateSelf();
        }
    }

    /**
     * @hide only needed by a hack within ProgressBar
     */
+14 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.os.Trace;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.content.res.TypedArray;
@@ -226,7 +227,7 @@ public abstract class Drawable {
     * By default, this returns the full drawable bounds. Custom drawables may
     * override this method to perform more precise invalidation.
     *
     * @hide
     * @return The dirty bounds of this drawable
     */
    public Rect getDirtyBounds() {
        return getBounds();
@@ -468,6 +469,18 @@ public abstract class Drawable {
        setColorFilter(new PorterDuffColorFilter(color, mode));
    }

    /**
     * Specifies a tint and blending mode for this drawable.
     * <p>
     * Setting a color filter via {@link #setColorFilter(ColorFilter)} overrides
     * tint.
     *
     * @param tint Color state list to use for tinting this drawable, or null to
     *            clear the tint
     * @param tintMode A Porter-Duff blending mode
     */
    public void setTint(ColorStateList tint, PorterDuff.Mode tintMode) {}

    /**
     * Returns the current color filter, or {@code null} if none set.
     *
+7 −38
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.graphics.Insets;
import android.graphics.NinePatch;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
@@ -327,45 +328,13 @@ public class NinePatchDrawable extends Drawable {
        invalidateSelf();
    }

    /**
     * Specifies a tint for this drawable.
     * <p>
     * Setting a color filter via {@link #setColorFilter(ColorFilter)} overrides
     * tint.
     *
     * @param tint Color state list to use for tinting this drawable, or null to
     *            clear the tint
     */
    public void setTint(ColorStateList tint) {
        if (mNinePatchState.mTint != tint) {
    @Override
    public void setTint(ColorStateList tint, PorterDuff.Mode tintMode) {
        mNinePatchState.mTint = tint;
            computeTintFilter();
            invalidateSelf();
        }
    }

    /**
     * Returns the tint color for this drawable.
     *
     * @return Color state list to use for tinting this drawable, or null if
     *         none set
     */
    public ColorStateList getTint() {
        return mNinePatchState.mTint;
    }

    /**
     * Specifies the blending mode used to apply tint.
     *
     * @param tintMode A Porter-Duff blending mode
     */
    public void setTintMode(Mode tintMode) {
        if (mNinePatchState.mTintMode != tintMode) {
        mNinePatchState.mTintMode = tintMode;
        computeTintFilter();
        invalidateSelf();
    }
    }

    private void computeTintFilter() {
        final NinePatchState state = mNinePatchState;
+29 −36
Original line number Diff line number Diff line
@@ -207,35 +207,9 @@ public class RippleDrawable extends LayerDrawable {
        return true;
    }

    /**
     * Specifies a tint for drawing touch feedback ripples.
     *
     * @param tint Color state list to use for tinting touch feedback ripples,
     *        or null to clear the tint
     */
    public void setTint(ColorStateList tint) {
        if (mState.mTint != tint) {
    @Override
    public void setTint(ColorStateList tint, Mode tintMode) {
        mState.mTint = tint;
            invalidateSelf();
        }
    }

    /**
     * Returns the tint color for touch feedback ripples.
     *
     * @return Color state list to use for tinting touch feedback ripples, or
     *         null if none set
     */
    public ColorStateList getTint() {
        return mState.mTint;
    }

    /**
     * Specifies the blending mode used to draw touch feedback ripples.
     *
     * @param tintMode A Porter-Duff blending mode
     */
    public void setTintMode(Mode tintMode) {
        mState.setTintMode(tintMode);
        invalidateSelf();
    }
@@ -243,11 +217,13 @@ public class RippleDrawable extends LayerDrawable {
    @Override
    public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Theme theme)
            throws XmlPullParserException, IOException {
        final TypedArray a = obtainAttributes(
                r, theme, attrs, R.styleable.RippleDrawable);
        final TypedArray a = obtainAttributes(r, theme, attrs, R.styleable.RippleDrawable);
        updateStateFromTypedArray(a);
        a.recycle();

        // Force padding default to STACK before inflating.
        setPaddingMode(PADDING_MODE_STACK);

        super.inflate(r, parser, attrs, theme);

        setTargetDensity(r.getDisplayMetrics());
@@ -274,6 +250,25 @@ public class RippleDrawable extends LayerDrawable {
        return false;
    }

    /**
     * Specifies how layer padding should affect the bounds of subsequent
     * layers. The default and recommended value for RippleDrawable is
     * {@link #PADDING_MODE_STACK}.
     *
     * @param mode padding mode, one of:
     *            <ul>
     *            <li>{@link #PADDING_MODE_NEST} to nest each layer inside the
     *            padding of the previous layer
     *            <li>{@link #PADDING_MODE_STACK} to stack each layer directly
     *            atop the previous layer
     *            </ul>
     * @see #getPaddingMode()
     */
    @Override
    public void setPaddingMode(int mode) {
        super.setPaddingMode(mode);
    }

    /**
     * Initializes the constant state from the values in the typed array.
     */
@@ -643,8 +638,7 @@ public class RippleDrawable extends LayerDrawable {
        Drawable mMask;
        boolean mPinned = false;

        public RippleState(
                RippleState orig, RippleDrawable owner, Resources res) {
        public RippleState(RippleState orig, RippleDrawable owner, Resources res) {
            super(orig, owner, res);

            if (orig != null) {
@@ -653,7 +647,6 @@ public class RippleDrawable extends LayerDrawable {
                mTintXfermode = orig.mTintXfermode;
                mTintXfermodeInverse = orig.mTintXfermodeInverse;
                mPinned = orig.mPinned;
                mMask = orig.mMask;
            }
        }

@@ -740,6 +733,8 @@ public class RippleDrawable extends LayerDrawable {
        }

        mState = ns;
        mState.mMask = findDrawableByLayerId(R.id.mask);

        mLayerState = ns;

        if (ns.mNum > 0) {
@@ -749,7 +744,5 @@ public class RippleDrawable extends LayerDrawable {
        if (needsTheme) {
            applyTheme(theme);
        }

        setPaddingMode(PADDING_MODE_STACK);
    }
}