diff options
21 files changed, 340 insertions, 235 deletions
diff --git a/api/current.txt b/api/current.txt index c6f7613..7743a59 100644 --- a/api/current.txt +++ b/api/current.txt @@ -11777,7 +11777,9 @@ 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 void setTint(int); + method public void setTintList(android.content.res.ColorStateList); + method public void setTintMode(android.graphics.PorterDuff.Mode); method public boolean setVisible(boolean, boolean); method public void unscheduleSelf(java.lang.Runnable); } @@ -34266,7 +34268,7 @@ package android.view { method public android.view.animation.Animation getAnimation(); method public android.os.IBinder getApplicationWindowToken(); method public android.graphics.drawable.Drawable getBackground(); - method public android.content.res.ColorStateList getBackgroundTint(); + method public android.content.res.ColorStateList getBackgroundTintList(); method public android.graphics.PorterDuff.Mode getBackgroundTintMode(); method public int getBaseline(); method public final int getBottom(); @@ -34547,7 +34549,7 @@ package android.view { method public void setBackgroundColor(int); method public deprecated void setBackgroundDrawable(android.graphics.drawable.Drawable); method public void setBackgroundResource(int); - method public void setBackgroundTint(android.content.res.ColorStateList); + method public void setBackgroundTintList(android.content.res.ColorStateList); method public void setBackgroundTintMode(android.graphics.PorterDuff.Mode); method public final void setBottom(int); method public void setCameraDistance(float); @@ -37602,13 +37604,13 @@ package android.widget { method public boolean getSplitTrack(); method public android.graphics.drawable.Drawable getThumb(); method public int getThumbOffset(); - method public android.content.res.ColorStateList getThumbTint(); + method public android.content.res.ColorStateList getThumbTintList(); method public android.graphics.PorterDuff.Mode getThumbTintMode(); method public void setKeyProgressIncrement(int); method public void setSplitTrack(boolean); method public void setThumb(android.graphics.drawable.Drawable); method public void setThumbOffset(int); - method public void setThumbTint(android.content.res.ColorStateList); + method public void setThumbTintList(android.content.res.ColorStateList); method public void setThumbTintMode(android.graphics.PorterDuff.Mode); } @@ -37995,12 +37997,12 @@ package android.widget { ctor public CheckedTextView(android.content.Context, android.util.AttributeSet, int); ctor public CheckedTextView(android.content.Context, android.util.AttributeSet, int, int); method public android.graphics.drawable.Drawable getCheckMarkDrawable(); - method public android.content.res.ColorStateList getCheckMarkTint(); + method public android.content.res.ColorStateList getCheckMarkTintList(); method public android.graphics.PorterDuff.Mode getCheckMarkTintMode(); method public boolean isChecked(); method public void setCheckMarkDrawable(int); method public void setCheckMarkDrawable(android.graphics.drawable.Drawable); - method public void setCheckMarkTint(android.content.res.ColorStateList); + method public void setCheckMarkTintList(android.content.res.ColorStateList); method public void setCheckMarkTintMode(android.graphics.PorterDuff.Mode); method public void setChecked(boolean); method public void toggle(); @@ -38030,12 +38032,12 @@ package android.widget { ctor public CompoundButton(android.content.Context, android.util.AttributeSet); ctor public CompoundButton(android.content.Context, android.util.AttributeSet, int); ctor public CompoundButton(android.content.Context, android.util.AttributeSet, int, int); - method public android.content.res.ColorStateList getButtonTint(); + method public android.content.res.ColorStateList getButtonTintList(); method public android.graphics.PorterDuff.Mode getButtonTintMode(); method public boolean isChecked(); method public void setButtonDrawable(int); method public void setButtonDrawable(android.graphics.drawable.Drawable); - method public void setButtonTint(android.content.res.ColorStateList); + method public void setButtonTintList(android.content.res.ColorStateList); method public void setButtonTintMode(android.graphics.PorterDuff.Mode); method public void setChecked(boolean); method public void setOnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener); @@ -38299,13 +38301,13 @@ package android.widget { method public deprecated boolean getConsiderGoneChildrenWhenMeasuring(); method public android.graphics.drawable.Drawable getForeground(); method public int getForegroundGravity(); - method public android.content.res.ColorStateList getForegroundTint(); + method public android.content.res.ColorStateList getForegroundTintList(); method public android.graphics.PorterDuff.Mode getForegroundTintMode(); method public boolean getMeasureAllChildren(); method protected void onLayout(boolean, int, int, int, int); method public void setForeground(android.graphics.drawable.Drawable); method public void setForegroundGravity(int); - method public void setForegroundTint(android.content.res.ColorStateList); + method public void setForegroundTintList(android.content.res.ColorStateList); method public void setForegroundTintMode(android.graphics.PorterDuff.Mode); method public void setMeasureAllChildren(boolean); } @@ -38512,11 +38514,11 @@ package android.widget { method public android.graphics.drawable.Drawable getDrawable(); method public int getImageAlpha(); method public android.graphics.Matrix getImageMatrix(); + method public android.content.res.ColorStateList getImageTintList(); + method public android.graphics.PorterDuff.Mode getImageTintMode(); method public int getMaxHeight(); method public int getMaxWidth(); method public android.widget.ImageView.ScaleType getScaleType(); - method public android.content.res.ColorStateList getTint(); - method public android.graphics.PorterDuff.Mode getTintMode(); method public int[] onCreateDrawableState(int); method public void setAdjustViewBounds(boolean); method public deprecated void setAlpha(int); @@ -38534,12 +38536,12 @@ package android.widget { method public void setImageMatrix(android.graphics.Matrix); method public void setImageResource(int); method public void setImageState(int[], boolean); + method public void setImageTintList(android.content.res.ColorStateList); + method public void setImageTintMode(android.graphics.PorterDuff.Mode); method public void setImageURI(android.net.Uri); method public void setMaxHeight(int); method public void setMaxWidth(int); method public void setScaleType(android.widget.ImageView.ScaleType); - method public void setTint(android.content.res.ColorStateList); - method public void setTintMode(android.graphics.PorterDuff.Mode); } public static final class ImageView.ScaleType extends java.lang.Enum { @@ -38914,18 +38916,18 @@ package android.widget { ctor public ProgressBar(android.content.Context, android.util.AttributeSet, int); ctor public ProgressBar(android.content.Context, android.util.AttributeSet, int, int); method public android.graphics.drawable.Drawable getIndeterminateDrawable(); - method public android.content.res.ColorStateList getIndeterminateTint(); + method public android.content.res.ColorStateList getIndeterminateTintList(); method public android.graphics.PorterDuff.Mode getIndeterminateTintMode(); method public android.view.animation.Interpolator getInterpolator(); method public synchronized int getMax(); method public synchronized int getProgress(); - method public android.content.res.ColorStateList getProgressBackgroundTint(); + method public android.content.res.ColorStateList getProgressBackgroundTintList(); method public android.graphics.PorterDuff.Mode getProgressBackgroundTintMode(); method public android.graphics.drawable.Drawable getProgressDrawable(); - method public android.content.res.ColorStateList getProgressTint(); + method public android.content.res.ColorStateList getProgressTintList(); method public android.graphics.PorterDuff.Mode getProgressTintMode(); method public synchronized int getSecondaryProgress(); - method public android.content.res.ColorStateList getSecondaryProgressTint(); + method public android.content.res.ColorStateList getSecondaryProgressTintList(); method public android.graphics.PorterDuff.Mode getSecondaryProgressTintMode(); method public final synchronized void incrementProgressBy(int); method public final synchronized void incrementSecondaryProgressBy(int); @@ -38935,20 +38937,20 @@ package android.widget { method public synchronized void setIndeterminate(boolean); method public void setIndeterminateDrawable(android.graphics.drawable.Drawable); method public void setIndeterminateDrawableTiled(android.graphics.drawable.Drawable); - method public void setIndeterminateTint(android.content.res.ColorStateList); + method public void setIndeterminateTintList(android.content.res.ColorStateList); method public void setIndeterminateTintMode(android.graphics.PorterDuff.Mode); method public void setInterpolator(android.content.Context, int); method public void setInterpolator(android.view.animation.Interpolator); method public synchronized void setMax(int); method public synchronized void setProgress(int); - method public void setProgressBackgroundTint(android.content.res.ColorStateList); + method public void setProgressBackgroundTintList(android.content.res.ColorStateList); method public void setProgressBackgroundTintMode(android.graphics.PorterDuff.Mode); method public void setProgressDrawable(android.graphics.drawable.Drawable); method public void setProgressDrawableTiled(android.graphics.drawable.Drawable); - method public void setProgressTint(android.content.res.ColorStateList); + method public void setProgressTintList(android.content.res.ColorStateList); method public void setProgressTintMode(android.graphics.PorterDuff.Mode); method public synchronized void setSecondaryProgress(int); - method public void setSecondaryProgressTint(android.content.res.ColorStateList); + method public void setSecondaryProgressTintList(android.content.res.ColorStateList); method public void setSecondaryProgressTintMode(android.graphics.PorterDuff.Mode); } diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 9eda8e0..328d67c 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -3176,7 +3176,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, @ViewDebug.ExportedProperty(deepExport = true, prefix = "bg_") private Drawable mBackground; - private ColorStateList mBackgroundTint = null; + private ColorStateList mBackgroundTintList = null; private PorterDuff.Mode mBackgroundTintMode = PorterDuff.Mode.SRC_ATOP; private boolean mHasBackgroundTint = false; @@ -4016,7 +4016,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, break; case R.styleable.View_backgroundTint: // This will get applied later during setBackground(). - mBackgroundTint = a.getColorStateList(R.styleable.View_backgroundTint); + mBackgroundTintList = a.getColorStateList(R.styleable.View_backgroundTint); mHasBackgroundTint = true; break; case R.styleable.View_backgroundTintMode: @@ -15912,16 +15912,16 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * <p> * Subsequent calls to {@link #setBackground(Drawable)} will automatically * mutate the drawable and apply the specified tint and tint mode using - * {@link Drawable#setTint(ColorStateList, PorterDuff.Mode)}. + * {@link Drawable#setTintList(ColorStateList)}. * * @param tint the tint to apply, may be {@code null} to clear tint * * @attr ref android.R.styleable#View_backgroundTint - * @see #getBackgroundTint() - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) + * @see #getBackgroundTintList() + * @see Drawable#setTintList(ColorStateList) */ - public void setBackgroundTint(@Nullable ColorStateList tint) { - mBackgroundTint = tint; + public void setBackgroundTintList(@Nullable ColorStateList tint) { + mBackgroundTintList = tint; mHasBackgroundTint = true; applyBackgroundTint(); @@ -15930,23 +15930,23 @@ public class View implements Drawable.Callback, KeyEvent.Callback, /** * @return the tint applied to the background drawable * @attr ref android.R.styleable#View_backgroundTint - * @see #setBackgroundTint(ColorStateList) + * @see #setBackgroundTintList(ColorStateList) */ @Nullable - public ColorStateList getBackgroundTint() { - return mBackgroundTint; + public ColorStateList getBackgroundTintList() { + return mBackgroundTintList; } /** * Specifies the blending mode used to apply the tint specified by - * {@link #setBackgroundTint(ColorStateList)}} to the background drawable. + * {@link #setBackgroundTintList(ColorStateList)}} to the background drawable. * The default mode is {@link PorterDuff.Mode#SRC_ATOP}. * * @param tintMode the blending mode used to apply the tint, may be * {@code null} to clear tint * @attr ref android.R.styleable#View_backgroundTintMode * @see #getBackgroundTintMode() - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) + * @see Drawable#setTintMode(PorterDuff.Mode) */ public void setBackgroundTintMode(@Nullable PorterDuff.Mode tintMode) { mBackgroundTintMode = tintMode; @@ -15967,7 +15967,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, private void applyBackgroundTint() { if (mBackground != null && mHasBackgroundTint) { mBackground = mBackground.mutate(); - mBackground.setTint(mBackgroundTint, mBackgroundTintMode); + mBackground.setTintList(mBackgroundTintList); + mBackground.setTintMode(mBackgroundTintMode); } } diff --git a/core/java/android/widget/AbsSeekBar.java b/core/java/android/widget/AbsSeekBar.java index 2708525..39cd7e3 100644 --- a/core/java/android/widget/AbsSeekBar.java +++ b/core/java/android/widget/AbsSeekBar.java @@ -41,7 +41,7 @@ public abstract class AbsSeekBar extends ProgressBar { private final Rect mTempRect = new Rect(); private Drawable mThumb; - private ColorStateList mThumbTint = null; + private ColorStateList mThumbTintList = null; private PorterDuff.Mode mThumbTintMode = PorterDuff.Mode.SRC_ATOP; private boolean mHasThumbTint = false; @@ -100,7 +100,7 @@ public abstract class AbsSeekBar extends ProgressBar { R.styleable.SeekBar_thumbTintMode, -1), mThumbTintMode); if (a.hasValue(R.styleable.SeekBar_thumbTint)) { - mThumbTint = a.getColorStateList(R.styleable.SeekBar_thumbTint); + mThumbTintList = a.getColorStateList(R.styleable.SeekBar_thumbTint); mHasThumbTint = true; applyThumbTint(); @@ -193,16 +193,16 @@ public abstract class AbsSeekBar extends ProgressBar { * <p> * Subsequent calls to {@link #setThumb(Drawable)} will automatically * mutate the drawable and apply the specified tint and tint mode using - * {@link Drawable#setTint(ColorStateList, PorterDuff.Mode)}. + * {@link Drawable#setTintList(ColorStateList)}. * * @param tint the tint to apply, may be {@code null} to clear tint * * @attr ref android.R.styleable#SeekBar_thumbTint - * @see #getThumbTint() - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) + * @see #getThumbTintList() + * @see Drawable#setTintList(ColorStateList) */ - public void setThumbTint(@Nullable ColorStateList tint) { - mThumbTint = tint; + public void setThumbTintList(@Nullable ColorStateList tint) { + mThumbTintList = tint; mHasThumbTint = true; applyThumbTint(); @@ -211,16 +211,16 @@ public abstract class AbsSeekBar extends ProgressBar { /** * @return the tint applied to the thumb drawable * @attr ref android.R.styleable#SeekBar_thumbTint - * @see #setThumbTint(ColorStateList) + * @see #setThumbTintList(ColorStateList) */ @Nullable - public ColorStateList getThumbTint() { - return mThumbTint; + public ColorStateList getThumbTintList() { + return mThumbTintList; } /** * Specifies the blending mode used to apply the tint specified by - * {@link #setThumbTint(ColorStateList)}} to the thumb drawable. The + * {@link #setThumbTintList(ColorStateList)}} to the thumb drawable. The * default mode is {@link PorterDuff.Mode#SRC_ATOP}. * * @param tintMode the blending mode used to apply the tint, may be @@ -228,7 +228,7 @@ public abstract class AbsSeekBar extends ProgressBar { * * @attr ref android.R.styleable#SeekBar_thumbTintMode * @see #getThumbTintMode() - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) + * @see Drawable#setTintMode(PorterDuff.Mode) */ public void setThumbTintMode(@Nullable PorterDuff.Mode tintMode) { mThumbTintMode = tintMode; @@ -249,7 +249,8 @@ public abstract class AbsSeekBar extends ProgressBar { private void applyThumbTint() { if (mThumb != null && mHasThumbTint) { mThumb = mThumb.mutate(); - mThumb.setTint(mThumbTint, mThumbTintMode); + mThumb.setTintList(mThumbTintList); + mThumb.setTintMode(mThumbTintMode); } } diff --git a/core/java/android/widget/CheckedTextView.java b/core/java/android/widget/CheckedTextView.java index 791151c..ccd0480 100644 --- a/core/java/android/widget/CheckedTextView.java +++ b/core/java/android/widget/CheckedTextView.java @@ -47,7 +47,7 @@ public class CheckedTextView extends TextView implements Checkable { private int mCheckMarkResource; private Drawable mCheckMarkDrawable; - private ColorStateList mCheckMarkTint = null; + private ColorStateList mCheckMarkTintList = null; private PorterDuff.Mode mCheckMarkTintMode = PorterDuff.Mode.SRC_ATOP; private boolean mHasCheckMarkTint = false; @@ -86,7 +86,7 @@ public class CheckedTextView extends TextView implements Checkable { R.styleable.CompoundButton_buttonTintMode, -1), mCheckMarkTintMode); if (a.hasValue(R.styleable.CompoundButton_buttonTint)) { - mCheckMarkTint = a.getColorStateList(R.styleable.CompoundButton_buttonTint); + mCheckMarkTintList = a.getColorStateList(R.styleable.CompoundButton_buttonTint); mHasCheckMarkTint = true; applyCheckMarkTint(); @@ -189,16 +189,16 @@ public class CheckedTextView extends TextView implements Checkable { * Subsequent calls to {@link #setCheckMarkDrawable(Drawable)} will * automatically mutate the drawable and apply the specified tint and * tint mode using - * {@link Drawable#setTint(ColorStateList, PorterDuff.Mode)}. + * {@link Drawable#setTintList(ColorStateList)}. * * @param tint the tint to apply, may be {@code null} to clear tint * * @attr ref android.R.styleable#CheckedTextView_checkMarkTint - * @see #getCheckMarkTint() - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) + * @see #getCheckMarkTintList() + * @see Drawable#setTintList(ColorStateList) */ - public void setCheckMarkTint(@Nullable ColorStateList tint) { - mCheckMarkTint = tint; + public void setCheckMarkTintList(@Nullable ColorStateList tint) { + mCheckMarkTintList = tint; mHasCheckMarkTint = true; applyCheckMarkTint(); @@ -207,23 +207,23 @@ public class CheckedTextView extends TextView implements Checkable { /** * @return the tint applied to the check mark drawable * @attr ref android.R.styleable#CheckedTextView_checkMarkTint - * @see #setCheckMarkTint(ColorStateList) + * @see #setCheckMarkTintList(ColorStateList) */ @Nullable - public ColorStateList getCheckMarkTint() { - return mCheckMarkTint; + public ColorStateList getCheckMarkTintList() { + return mCheckMarkTintList; } /** * Specifies the blending mode used to apply the tint specified by - * {@link #setCheckMarkTint(ColorStateList)} to the check mark + * {@link #setCheckMarkTintList(ColorStateList)} to the check mark * drawable. The default mode is {@link PorterDuff.Mode#SRC_ATOP}. * * @param tintMode the blending mode used to apply the tint, may be * {@code null} to clear tint * @attr ref android.R.styleable#CheckedTextView_checkMarkTintMode - * @see #setCheckMarkTint(ColorStateList) - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) + * @see #setCheckMarkTintList(ColorStateList) + * @see Drawable#setTintMode(PorterDuff.Mode) */ public void setCheckMarkTintMode(@Nullable PorterDuff.Mode tintMode) { mCheckMarkTintMode = tintMode; @@ -244,7 +244,8 @@ public class CheckedTextView extends TextView implements Checkable { private void applyCheckMarkTint() { if (mCheckMarkDrawable != null && mHasCheckMarkTint) { mCheckMarkDrawable = mCheckMarkDrawable.mutate(); - mCheckMarkDrawable.setTint(mCheckMarkTint, mCheckMarkTintMode); + mCheckMarkDrawable.setTintList(mCheckMarkTintList); + mCheckMarkDrawable.setTintMode(mCheckMarkTintMode); } } diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java index a45777e..c1d8cb3 100644 --- a/core/java/android/widget/CompoundButton.java +++ b/core/java/android/widget/CompoundButton.java @@ -53,7 +53,7 @@ public abstract class CompoundButton extends Button implements Checkable { private boolean mBroadcasting; private Drawable mButtonDrawable; - private ColorStateList mButtonTint = null; + private ColorStateList mButtonTintList = null; private PorterDuff.Mode mButtonTintMode = PorterDuff.Mode.SRC_ATOP; private boolean mHasButtonTint = false; @@ -91,7 +91,7 @@ public abstract class CompoundButton extends Button implements Checkable { R.styleable.CompoundButton_buttonTintMode, -1), mButtonTintMode); if (a.hasValue(R.styleable.CompoundButton_buttonTint)) { - mButtonTint = a.getColorStateList(R.styleable.CompoundButton_buttonTint); + mButtonTintList = a.getColorStateList(R.styleable.CompoundButton_buttonTint); mHasButtonTint = true; applyButtonTint(); @@ -245,16 +245,16 @@ public abstract class CompoundButton extends Button implements Checkable { * Subsequent calls to {@link #setButtonDrawable(Drawable)} will * automatically mutate the drawable and apply the specified tint and tint * mode using - * {@link Drawable#setTint(ColorStateList, PorterDuff.Mode)}. + * {@link Drawable#setTintList(ColorStateList)}. * * @param tint the tint to apply, may be {@code null} to clear tint * * @attr ref android.R.styleable#CompoundButton_buttonTint - * @see #setButtonTint(ColorStateList) - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) + * @see #setButtonTintList(ColorStateList) + * @see Drawable#setTintList(ColorStateList) */ - public void setButtonTint(@Nullable ColorStateList tint) { - mButtonTint = tint; + public void setButtonTintList(@Nullable ColorStateList tint) { + mButtonTintList = tint; mHasButtonTint = true; applyButtonTint(); @@ -263,23 +263,23 @@ public abstract class CompoundButton extends Button implements Checkable { /** * @return the tint applied to the button drawable * @attr ref android.R.styleable#CompoundButton_buttonTint - * @see #setButtonTint(ColorStateList) + * @see #setButtonTintList(ColorStateList) */ @Nullable - public ColorStateList getButtonTint() { - return mButtonTint; + public ColorStateList getButtonTintList() { + return mButtonTintList; } /** * Specifies the blending mode used to apply the tint specified by - * {@link #setButtonTint(ColorStateList)}} to the button drawable. The + * {@link #setButtonTintList(ColorStateList)}} to the button drawable. The * default mode is {@link PorterDuff.Mode#SRC_ATOP}. * * @param tintMode the blending mode used to apply the tint, may be * {@code null} to clear tint * @attr ref android.R.styleable#CompoundButton_buttonTintMode * @see #getButtonTintMode() - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) + * @see Drawable#setTintMode(PorterDuff.Mode) */ public void setButtonTintMode(@Nullable PorterDuff.Mode tintMode) { mButtonTintMode = tintMode; @@ -300,7 +300,8 @@ public abstract class CompoundButton extends Button implements Checkable { private void applyButtonTint() { if (mButtonDrawable != null && mHasButtonTint) { mButtonDrawable = mButtonDrawable.mutate(); - mButtonDrawable.setTint(mButtonTint, mButtonTintMode); + mButtonDrawable.setTintList(mButtonTintList); + mButtonDrawable.setTintMode(mButtonTintMode); } } diff --git a/core/java/android/widget/FrameLayout.java b/core/java/android/widget/FrameLayout.java index 81dfcbb..4fb7e62 100644 --- a/core/java/android/widget/FrameLayout.java +++ b/core/java/android/widget/FrameLayout.java @@ -67,7 +67,7 @@ public class FrameLayout extends ViewGroup { @ViewDebug.ExportedProperty(category = "drawing") private Drawable mForeground; - private ColorStateList mForegroundTint = null; + private ColorStateList mForegroundTintList = null; private PorterDuff.Mode mForegroundTintMode = PorterDuff.Mode.SRC_ATOP; private boolean mHasForegroundTint = false; @@ -131,7 +131,7 @@ public class FrameLayout extends ViewGroup { R.styleable.FrameLayout_foregroundTintMode, -1), mForegroundTintMode); if (a.hasValue(R.styleable.FrameLayout_foregroundTint)) { - mForegroundTint = a.getColorStateList(R.styleable.FrameLayout_foregroundTint); + mForegroundTintList = a.getColorStateList(R.styleable.FrameLayout_foregroundTint); mHasForegroundTint = true; applyForegroundTint(); @@ -301,40 +301,21 @@ public class FrameLayout extends ViewGroup { } /** - * Applies a tint to the foreground drawable. - * <p> - * Subsequent calls to {@link #setForeground(Drawable)} will automatically - * mutate the drawable and apply the specified tint and tint mode using - * {@link Drawable#setTint(ColorStateList, PorterDuff.Mode)}. - * - * @param tint the tint to apply, may be {@code null} to clear tint - * @param tintMode the blending mode used to apply the tint, may be - * {@code null} to clear tint - * - * @attr ref android.R.styleable#FrameLayout_foregroundTint - * @attr ref android.R.styleable#FrameLayout_foregroundTintMode - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) - */ - private void setForegroundTint(@Nullable ColorStateList tint, - @Nullable PorterDuff.Mode tintMode) { - } - - /** * Applies a tint to the foreground drawable. Does not modify the current * tint mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default. * <p> * Subsequent calls to {@link #setForeground(Drawable)} will automatically * mutate the drawable and apply the specified tint and tint mode using - * {@link Drawable#setTint(ColorStateList, PorterDuff.Mode)}. + * {@link Drawable#setTintList(ColorStateList)}. * * @param tint the tint to apply, may be {@code null} to clear tint * * @attr ref android.R.styleable#FrameLayout_foregroundTint - * @see #getForegroundTint() - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) + * @see #getForegroundTintList() + * @see Drawable#setTintList(ColorStateList) */ - public void setForegroundTint(@Nullable ColorStateList tint) { - mForegroundTint = tint; + public void setForegroundTintList(@Nullable ColorStateList tint) { + mForegroundTintList = tint; mHasForegroundTint = true; applyForegroundTint(); @@ -343,23 +324,23 @@ public class FrameLayout extends ViewGroup { /** * @return the tint applied to the foreground drawable * @attr ref android.R.styleable#FrameLayout_foregroundTint - * @see #setForegroundTint(ColorStateList) + * @see #setForegroundTintList(ColorStateList) */ @Nullable - public ColorStateList getForegroundTint() { - return mForegroundTint; + public ColorStateList getForegroundTintList() { + return mForegroundTintList; } /** * Specifies the blending mode used to apply the tint specified by - * {@link #setForegroundTint(ColorStateList)}} to the foreground drawable. + * {@link #setForegroundTintList(ColorStateList)}} to the foreground drawable. * The default mode is {@link PorterDuff.Mode#SRC_ATOP}. * * @param tintMode the blending mode used to apply the tint, may be * {@code null} to clear tint * @attr ref android.R.styleable#FrameLayout_foregroundTintMode * @see #getForegroundTintMode() - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) + * @see Drawable#setTintMode(PorterDuff.Mode) */ public void setForegroundTintMode(@Nullable PorterDuff.Mode tintMode) { mForegroundTintMode = tintMode; @@ -381,7 +362,8 @@ public class FrameLayout extends ViewGroup { private void applyForegroundTint() { if (mForeground != null && mHasForegroundTint) { mForeground = mForeground.mutate(); - mForeground.setTint(mForegroundTint, mForegroundTintMode); + mForeground.setTintList(mForegroundTintList); + mForeground.setTintMode(mForegroundTintMode); } } diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index 0881f3e..6a15078 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -175,7 +175,7 @@ public class ImageView extends View { mDrawableTint = a.getColorStateList(R.styleable.ImageView_tint); mHasDrawableTint = true; - applyDrawableTint(); + applyImageTint(); } final int alpha = a.getInt(com.android.internal.R.styleable.ImageView_drawableAlpha, 255); @@ -454,62 +454,63 @@ public class ImageView extends View { * <p> * Subsequent calls to {@link #setImageDrawable(Drawable)} will automatically * mutate the drawable and apply the specified tint and tint mode using - * {@link Drawable#setTint(ColorStateList, PorterDuff.Mode)}. + * {@link Drawable#setTintList(ColorStateList)}. * * @param tint the tint to apply, may be {@code null} to clear tint * * @attr ref android.R.styleable#ImageView_tint - * @see #getTint() - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) + * @see #getImageTintList() + * @see Drawable#setTintList(ColorStateList) */ - public void setTint(@Nullable ColorStateList tint) { + public void setImageTintList(@Nullable ColorStateList tint) { mDrawableTint = tint; mHasDrawableTint = true; - applyDrawableTint(); + applyImageTint(); } /** * @return the tint applied to the image drawable * @attr ref android.R.styleable#ImageView_tint - * @see #setTint(ColorStateList) + * @see #setImageTintList(ColorStateList) */ @Nullable - public ColorStateList getTint() { + public ColorStateList getImageTintList() { return mDrawableTint; } /** * Specifies the blending mode used to apply the tint specified by - * {@link #setTint(ColorStateList)}} to the image drawable. The default + * {@link #setImageTintList(ColorStateList)}} to the image drawable. The default * mode is {@link PorterDuff.Mode#SRC_ATOP}. * * @param tintMode the blending mode used to apply the tint, may be * {@code null} to clear tint * @attr ref android.R.styleable#ImageView_tintMode - * @see #getTintMode() - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) + * @see #getImageTintMode() + * @see Drawable#setTintMode(PorterDuff.Mode) */ - public void setTintMode(@Nullable PorterDuff.Mode tintMode) { + public void setImageTintMode(@Nullable PorterDuff.Mode tintMode) { mDrawableTintMode = tintMode; - applyDrawableTint(); + applyImageTint(); } /** * @return the blending mode used to apply the tint to the image drawable * @attr ref android.R.styleable#ImageView_tintMode - * @see #setTintMode(PorterDuff.Mode) + * @see #setImageTintMode(PorterDuff.Mode) */ @Nullable - public PorterDuff.Mode getTintMode() { + public PorterDuff.Mode getImageTintMode() { return mDrawableTintMode; } - private void applyDrawableTint() { + private void applyImageTint() { if (mDrawable != null && mHasDrawableTint) { mDrawable = mDrawable.mutate(); - mDrawable.setTint(mDrawableTint, mDrawableTintMode); + mDrawable.setTintList(mDrawableTint); + mDrawable.setTintMode(mDrawableTintMode); } } @@ -801,7 +802,7 @@ public class ImageView extends View { d.setLevel(mLevel); mDrawableWidth = d.getIntrinsicWidth(); mDrawableHeight = d.getIntrinsicHeight(); - applyDrawableTint(); + applyImageTint(); applyColorMod(); configureBounds(); } else { diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java index 4a30809..c0fa6e5 100644 --- a/core/java/android/widget/ProgressBar.java +++ b/core/java/android/widget/ProgressBar.java @@ -216,21 +216,21 @@ public class ProgressBar extends View { private boolean mHasAnimation; private Drawable mIndeterminateDrawable; - private ColorStateList mIndeterminateTint = null; + private ColorStateList mIndeterminateTintList = null; private PorterDuff.Mode mIndeterminateTintMode = PorterDuff.Mode.SRC_ATOP; private boolean mHasIndeterminateTint = false; private Drawable mProgressDrawable; - private ColorStateList mProgressTint = null; + private ColorStateList mProgressTintList = null; private PorterDuff.Mode mProgressTintMode = PorterDuff.Mode.SRC_ATOP; private boolean mHasProgressTint = false; - private ColorStateList mProgressBackgroundTint = null; + private ColorStateList mProgressBackgroundTintList = null; private PorterDuff.Mode mProgressBackgroundTintMode = PorterDuff.Mode.SRC_ATOP; private boolean mHasProgressBackgroundTint = false; - private ColorStateList mSecondaryProgressTint = null; + private ColorStateList mSecondaryProgressTintList = null; private PorterDuff.Mode mSecondaryProgressTintMode = PorterDuff.Mode.SRC_ATOP; private boolean mHasSecondaryProgressTint = false; @@ -332,11 +332,11 @@ public class ProgressBar extends View { R.styleable.ProgressBar_progressBackgroundTintMode, -1), mProgressTintMode); if (a.hasValue(R.styleable.ProgressBar_progressTint)) { - mProgressTint = a.getColorStateList( + mProgressTintList = a.getColorStateList( R.styleable.ProgressBar_progressTint); mHasProgressTint = true; - applyProgressLayerTint(R.id.progress, mProgressTint, + applyProgressLayerTint(R.id.progress, mProgressTintList, mProgressTintMode, true); } @@ -344,11 +344,11 @@ public class ProgressBar extends View { R.styleable.ProgressBar_progressTintMode, -1), mProgressBackgroundTintMode); if (a.hasValue(R.styleable.ProgressBar_progressBackgroundTint)) { - mProgressBackgroundTint = a.getColorStateList( + mProgressBackgroundTintList = a.getColorStateList( R.styleable.ProgressBar_progressBackgroundTint); mHasProgressBackgroundTint = true; - applyProgressLayerTint(R.id.background, mProgressBackgroundTint, + applyProgressLayerTint(R.id.background, mProgressBackgroundTintList, mProgressBackgroundTintMode, false); } @@ -356,11 +356,11 @@ public class ProgressBar extends View { R.styleable.ProgressBar_secondaryProgressTintMode, -1), mSecondaryProgressTintMode); if (a.hasValue(R.styleable.ProgressBar_secondaryProgressTint)) { - mSecondaryProgressTint = a.getColorStateList( + mSecondaryProgressTintList = a.getColorStateList( R.styleable.ProgressBar_secondaryProgressTint); mHasSecondaryProgressTint = true; - applyProgressLayerTint(R.id.secondaryProgress, mSecondaryProgressTint, + applyProgressLayerTint(R.id.secondaryProgress, mSecondaryProgressTintList, mSecondaryProgressTintMode, false); } @@ -368,7 +368,7 @@ public class ProgressBar extends View { R.styleable.ProgressBar_indeterminateTintMode, -1), mIndeterminateTintMode); if (a.hasValue(R.styleable.ProgressBar_indeterminateTint)) { - mIndeterminateTint = a.getColorStateList( + mIndeterminateTintList = a.getColorStateList( R.styleable.ProgressBar_indeterminateTint); mHasIndeterminateTint = true; @@ -430,7 +430,8 @@ public class ProgressBar extends View { shapeDrawable.getPaint().setShader(bitmapShader); // Ensure the tint and filter are propagated in the correct order. - shapeDrawable.setTint(bitmap.getTint(), bitmap.getTintMode()); + shapeDrawable.setTintList(bitmap.getTint()); + shapeDrawable.setTintMode(bitmap.getTintMode()); shapeDrawable.setColorFilter(bitmap.getColorFilter()); return clip ? new ClipDrawable( @@ -582,16 +583,16 @@ public class ProgressBar extends View { * Subsequent calls to {@link #setIndeterminateDrawable(Drawable)} will * automatically mutate the drawable and apply the specified tint and * tint mode using - * {@link Drawable#setTint(ColorStateList, android.graphics.PorterDuff.Mode)}. + * {@link Drawable#setTintList(ColorStateList)}. * * @param tint the tint to apply, may be {@code null} to clear tint * * @attr ref android.R.styleable#ProgressBar_indeterminateTint - * @see #getIndeterminateTint() - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) + * @see #getIndeterminateTintList() + * @see Drawable#setTintList(ColorStateList) */ - public void setIndeterminateTint(@Nullable ColorStateList tint) { - mIndeterminateTint = tint; + public void setIndeterminateTintList(@Nullable ColorStateList tint) { + mIndeterminateTintList = tint; mHasIndeterminateTint = true; applyIndeterminateTint(); @@ -600,23 +601,23 @@ public class ProgressBar extends View { /** * @return the tint applied to the indeterminate drawable * @attr ref android.R.styleable#ProgressBar_indeterminateTint - * @see #setIndeterminateTint(ColorStateList) + * @see #setIndeterminateTintList(ColorStateList) */ @Nullable - public ColorStateList getIndeterminateTint() { - return mIndeterminateTint; + public ColorStateList getIndeterminateTintList() { + return mIndeterminateTintList; } /** * Specifies the blending mode used to apply the tint specified by - * {@link #setIndeterminateTint(ColorStateList)} to the indeterminate + * {@link #setIndeterminateTintList(ColorStateList)} to the indeterminate * drawable. The default mode is {@link PorterDuff.Mode#SRC_ATOP}. * * @param tintMode the blending mode used to apply the tint, may be * {@code null} to clear tint * @attr ref android.R.styleable#ProgressBar_indeterminateTintMode - * @see #setIndeterminateTint(ColorStateList) - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) + * @see #setIndeterminateTintList(ColorStateList) + * @see Drawable#setTintMode(PorterDuff.Mode) */ public void setIndeterminateTintMode(@Nullable PorterDuff.Mode tintMode) { mIndeterminateTintMode = tintMode; @@ -637,7 +638,8 @@ public class ProgressBar extends View { private void applyIndeterminateTint() { if (mIndeterminateDrawable != null && mHasIndeterminateTint) { mIndeterminateDrawable = mIndeterminateDrawable.mutate(); - mIndeterminateDrawable.setTint(mIndeterminateTint, mIndeterminateTintMode); + mIndeterminateDrawable.setTintList(mIndeterminateTintList); + mIndeterminateDrawable.setTintMode(mIndeterminateTintMode); } } @@ -704,16 +706,17 @@ public class ProgressBar extends View { } if (mHasProgressTint) { - applyProgressLayerTint(R.id.progress, mProgressTint, mProgressTintMode, true); + applyProgressLayerTint(R.id.progress, mProgressTintList, + mProgressTintMode, true); } if (mHasProgressBackgroundTint) { - applyProgressLayerTint(R.id.background, mProgressBackgroundTint, + applyProgressLayerTint(R.id.background, mProgressBackgroundTintList, mProgressBackgroundTintMode, false); } if (mHasSecondaryProgressTint) { - applyProgressLayerTint(R.id.secondaryProgress, mSecondaryProgressTint, + applyProgressLayerTint(R.id.secondaryProgress, mSecondaryProgressTintList, mSecondaryProgressTintMode, false); } } @@ -743,16 +746,16 @@ public class ProgressBar extends View { * Subsequent calls to {@link #setProgressDrawable(Drawable)} will * automatically mutate the drawable and apply the specified tint and * tint mode using - * {@link Drawable#setTint(ColorStateList, android.graphics.PorterDuff.Mode)}. + * {@link Drawable#setTintList(ColorStateList)}. * * @param tint the tint to apply, may be {@code null} to clear tint * * @attr ref android.R.styleable#ProgressBar_progressTint - * @see #getProgressTint() - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) + * @see #getProgressTintList() + * @see Drawable#setTintList(ColorStateList) */ - public void setProgressTint(@Nullable ColorStateList tint) { - mProgressTint = tint; + public void setProgressTintList(@Nullable ColorStateList tint) { + mProgressTintList = tint; mHasProgressTint = true; applyProgressLayerTint(R.id.progress, tint, mProgressTintMode, true); @@ -761,28 +764,28 @@ public class ProgressBar extends View { /** * @return the tint applied to the progress drawable * @attr ref android.R.styleable#ProgressBar_progressTint - * @see #setProgressTint(ColorStateList) + * @see #setProgressTintList(ColorStateList) */ @Nullable - public ColorStateList getProgressTint() { - return mProgressTint; + public ColorStateList getProgressTintList() { + return mProgressTintList; } /** * Specifies the blending mode used to apply the tint specified by - * {@link #setProgressTint(ColorStateList)}} to the progress + * {@link #setProgressTintList(ColorStateList)}} to the progress * indicator. The default mode is {@link PorterDuff.Mode#SRC_ATOP}. * * @param tintMode the blending mode used to apply the tint, may be * {@code null} to clear tint * @attr ref android.R.styleable#ProgressBar_progressTintMode * @see #getProgressTintMode() - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) + * @see Drawable#setTintMode(PorterDuff.Mode) */ public void setProgressTintMode(@Nullable PorterDuff.Mode tintMode) { mProgressTintMode = tintMode; - applyProgressLayerTint(R.id.progress, mProgressTint, tintMode, true); + applyProgressLayerTint(R.id.progress, mProgressTintList, tintMode, true); } /** @@ -807,16 +810,16 @@ public class ProgressBar extends View { * Subsequent calls to {@link #setProgressDrawable(Drawable)} where the * drawable contains a progress background will automatically mutate the * drawable and apply the specified tint and tint mode using - * {@link Drawable#setTint(ColorStateList, android.graphics.PorterDuff.Mode)}. + * {@link Drawable#setTintList(ColorStateList)}. * * @param tint the tint to apply, may be {@code null} to clear tint * * @attr ref android.R.styleable#ProgressBar_progressBackgroundTint - * @see #getProgressBackgroundTint() - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) + * @see #getProgressBackgroundTintList() + * @see Drawable#setTintList(ColorStateList) */ - public void setProgressBackgroundTint(@Nullable ColorStateList tint) { - mProgressBackgroundTint = tint; + public void setProgressBackgroundTintList(@Nullable ColorStateList tint) { + mProgressBackgroundTintList = tint; mHasProgressBackgroundTint = true; applyProgressLayerTint(R.id.background, tint, mProgressBackgroundTintMode, false); @@ -825,28 +828,28 @@ public class ProgressBar extends View { /** * @return the tint applied to the progress background * @attr ref android.R.styleable#ProgressBar_progressBackgroundTint - * @see #setProgressBackgroundTint(ColorStateList) + * @see #setProgressBackgroundTintList(ColorStateList) */ @Nullable - public ColorStateList getProgressBackgroundTint() { - return mProgressBackgroundTint; + public ColorStateList getProgressBackgroundTintList() { + return mProgressBackgroundTintList; } /** * Specifies the blending mode used to apply the tint specified by - * {@link #setProgressBackgroundTint(ColorStateList)}} to the progress + * {@link #setProgressBackgroundTintList(ColorStateList)}} to the progress * background. The default mode is {@link PorterDuff.Mode#SRC_ATOP}. * * @param tintMode the blending mode used to apply the tint, may be * {@code null} to clear tint * @attr ref android.R.styleable#ProgressBar_progressBackgroundTintMode - * @see #setProgressBackgroundTint(ColorStateList) - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) + * @see #setProgressBackgroundTintList(ColorStateList) + * @see Drawable#setTintMode(PorterDuff.Mode) */ public void setProgressBackgroundTintMode(@Nullable PorterDuff.Mode tintMode) { mProgressBackgroundTintMode = tintMode; - applyProgressLayerTint(R.id.background, mProgressBackgroundTint, tintMode, false); + applyProgressLayerTint(R.id.background, mProgressBackgroundTintList, tintMode, false); } /** @@ -872,16 +875,16 @@ public class ProgressBar extends View { * Subsequent calls to {@link #setProgressDrawable(Drawable)} where the * drawable contains a secondary progress indicator will automatically * mutate the drawable and apply the specified tint and tint mode using - * {@link Drawable#setTint(ColorStateList, android.graphics.PorterDuff.Mode)}. + * {@link Drawable#setTintList(ColorStateList)}. * * @param tint the tint to apply, may be {@code null} to clear tint * * @attr ref android.R.styleable#ProgressBar_secondaryProgressTint - * @see #getSecondaryProgressTint() - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) + * @see #getSecondaryProgressTintList() + * @see Drawable#setTintList(ColorStateList) */ - public void setSecondaryProgressTint(@Nullable ColorStateList tint) { - mSecondaryProgressTint = tint; + public void setSecondaryProgressTintList(@Nullable ColorStateList tint) { + mSecondaryProgressTintList = tint; mHasSecondaryProgressTint = true; applyProgressLayerTint(R.id.secondaryProgress, tint, mSecondaryProgressTintMode, false); @@ -890,29 +893,29 @@ public class ProgressBar extends View { /** * @return the tint applied to the secondary progress drawable * @attr ref android.R.styleable#ProgressBar_secondaryProgressTint - * @see #setSecondaryProgressTint(ColorStateList) + * @see #setSecondaryProgressTintList(ColorStateList) */ @Nullable - public ColorStateList getSecondaryProgressTint() { - return mSecondaryProgressTint; + public ColorStateList getSecondaryProgressTintList() { + return mSecondaryProgressTintList; } /** * Specifies the blending mode used to apply the tint specified by - * {@link #setSecondaryProgressTint(ColorStateList)}} to the secondary + * {@link #setSecondaryProgressTintList(ColorStateList)}} to the secondary * progress indicator. The default mode is * {@link PorterDuff.Mode#SRC_ATOP}. * * @param tintMode the blending mode used to apply the tint, may be * {@code null} to clear tint * @attr ref android.R.styleable#ProgressBar_secondaryProgressTintMode - * @see #setSecondaryProgressTint(ColorStateList) - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) + * @see #setSecondaryProgressTintList(ColorStateList) + * @see Drawable#setTintMode(PorterDuff.Mode) */ public void setSecondaryProgressTintMode(@Nullable PorterDuff.Mode tintMode) { mSecondaryProgressTintMode = tintMode; - applyProgressLayerTint(R.id.secondaryProgress, mSecondaryProgressTint, tintMode, false); + applyProgressLayerTint(R.id.secondaryProgress, mSecondaryProgressTintList, tintMode, false); } /** @@ -942,7 +945,8 @@ public class ProgressBar extends View { } if (layer != null) { - layer.setTint(tint, tintMode); + layer.setTintList(tint); + layer.setTintMode(tintMode); } } } @@ -1066,7 +1070,9 @@ public class ProgressBar extends View { layer = d; } - layer.mutate().setTint(tint, tintMode); + layer.mutate(); + layer.setTintList(tint); + layer.setTintMode(tintMode); } private float getScale(float progress) { diff --git a/graphics/java/android/graphics/drawable/AnimatedRotateDrawable.java b/graphics/java/android/graphics/drawable/AnimatedRotateDrawable.java index 0fd4423..e3c03a9 100644 --- a/graphics/java/android/graphics/drawable/AnimatedRotateDrawable.java +++ b/graphics/java/android/graphics/drawable/AnimatedRotateDrawable.java @@ -171,8 +171,13 @@ public class AnimatedRotateDrawable extends Drawable implements Drawable.Callbac } @Override - public void setTint(ColorStateList tint, Mode tintMode) { - mState.mDrawable.setTint(tint, tintMode); + public void setTintList(ColorStateList tint) { + mState.mDrawable.setTintList(tint); + } + + @Override + public void setTintMode(Mode tintMode) { + mState.mDrawable.setTintMode(tintMode); } @Override diff --git a/graphics/java/android/graphics/drawable/BitmapDrawable.java b/graphics/java/android/graphics/drawable/BitmapDrawable.java index 525e01d..f5e63ae 100644 --- a/graphics/java/android/graphics/drawable/BitmapDrawable.java +++ b/graphics/java/android/graphics/drawable/BitmapDrawable.java @@ -623,12 +623,16 @@ public class BitmapDrawable extends Drawable { } @Override - public void setTint(ColorStateList tint, PorterDuff.Mode tintMode) { - final BitmapState state = mBitmapState; - state.mTint = tint; - state.mTintMode = tintMode; + public void setTintList(ColorStateList tint) { + mBitmapState.mTint = tint; + mTintFilter = updateTintFilter(mTintFilter, tint, mBitmapState.mTintMode); + invalidateSelf(); + } - mTintFilter = updateTintFilter(mTintFilter, tint, tintMode); + @Override + public void setTintMode(PorterDuff.Mode tintMode) { + mBitmapState.mTintMode = tintMode; + mTintFilter = updateTintFilter(mTintFilter, mBitmapState.mTint, tintMode); invalidateSelf(); } diff --git a/graphics/java/android/graphics/drawable/ClipDrawable.java b/graphics/java/android/graphics/drawable/ClipDrawable.java index 174de3a..f116376 100644 --- a/graphics/java/android/graphics/drawable/ClipDrawable.java +++ b/graphics/java/android/graphics/drawable/ClipDrawable.java @@ -174,8 +174,13 @@ public class ClipDrawable extends Drawable implements Drawable.Callback { } @Override - public void setTint(ColorStateList tint, Mode tintMode) { - mClipState.mDrawable.setTint(tint, tintMode); + public void setTintList(ColorStateList tint) { + mClipState.mDrawable.setTintList(tint); + } + + @Override + public void setTintMode(Mode tintMode) { + mClipState.mDrawable.setTintMode(tintMode); } @Override diff --git a/graphics/java/android/graphics/drawable/ColorDrawable.java b/graphics/java/android/graphics/drawable/ColorDrawable.java index 4f050e0..9e42a89 100644 --- a/graphics/java/android/graphics/drawable/ColorDrawable.java +++ b/graphics/java/android/graphics/drawable/ColorDrawable.java @@ -167,15 +167,17 @@ public class ColorDrawable extends Drawable { } @Override - public void setTint(ColorStateList tint, Mode tintMode) { - final ColorState state = mColorState; - if (state.mTint != tint || state.mTintMode != tintMode) { - state.mTint = tint; - state.mTintMode = tintMode; + public void setTintList(ColorStateList tint) { + mColorState.mTint = tint; + mTintFilter = updateTintFilter(mTintFilter, tint, mColorState.mTintMode); + invalidateSelf(); + } - mTintFilter = updateTintFilter(mTintFilter, tint, tintMode); - invalidateSelf(); - } + @Override + public void setTintMode(Mode tintMode) { + mColorState.mTintMode = tintMode; + mTintFilter = updateTintFilter(mTintFilter, mColorState.mTint, tintMode); + invalidateSelf(); } @Override diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java index df9f3c3..5a3e3a3 100644 --- a/graphics/java/android/graphics/drawable/Drawable.java +++ b/graphics/java/android/graphics/drawable/Drawable.java @@ -478,10 +478,48 @@ public abstract class Drawable { * @param tint Color state list to use for tinting this drawable, or null to * clear the tint * @param tintMode A Porter-Duff blending mode + * @hide TODO: Was in L-preview, remove this API for release */ public void setTint(ColorStateList tint, PorterDuff.Mode tintMode) {} /** + * Specifies a tint for this drawable. + * <p> + * Setting a color filter via {@link #setColorFilter(ColorFilter)} overrides + * tint. + * + * @param tint Color to use for tinting this drawable + * @see #setTintMode(PorterDuff.Mode) + */ + public void setTint(int tint) { + setTintList(ColorStateList.valueOf(tint)); + } + + /** + * Specifies a tint for this drawable as a color state list. + * <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 + * @see #setTintMode(PorterDuff.Mode) + */ + public void setTintList(ColorStateList tint) {} + + /** + * Specifies a tint blending mode for this drawable. + * <p> + * Setting a color filter via {@link #setColorFilter(ColorFilter)} overrides + * tint. + * + * @param tintMode Color state list to use for tinting this drawable, or null to + * clear the tint + * @param tintMode A Porter-Duff blending mode + */ + public void setTintMode(PorterDuff.Mode tintMode) {} + + /** * Returns the current color filter, or {@code null} if none set. * * @return the current color filter, or {@code null} if none set diff --git a/graphics/java/android/graphics/drawable/DrawableContainer.java b/graphics/java/android/graphics/drawable/DrawableContainer.java index 55bc35e..0b052f4 100644 --- a/graphics/java/android/graphics/drawable/DrawableContainer.java +++ b/graphics/java/android/graphics/drawable/DrawableContainer.java @@ -176,15 +176,29 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { } @Override - public void setTint(ColorStateList tint, Mode tintMode) { - mDrawableContainerState.mHasTint = (tint != null && tintMode != null); + public void setTintList(ColorStateList tint) { + mDrawableContainerState.mHasTint = tint != null + && mDrawableContainerState.mTintMode != null; - if (mDrawableContainerState.mTint != tint || mDrawableContainerState.mTintMode != tintMode) { + if (mDrawableContainerState.mTint != tint) { mDrawableContainerState.mTint = tint; + + if (mCurrDrawable != null) { + mCurrDrawable.mutate().setTintList(tint); + } + } + } + + @Override + public void setTintMode(Mode tintMode) { + mDrawableContainerState.mHasTint = mDrawableContainerState.mTint != null + && tintMode != null; + + if (mDrawableContainerState.mTintMode != tintMode) { mDrawableContainerState.mTintMode = tintMode; if (mCurrDrawable != null) { - mCurrDrawable.mutate().setTint(tint, tintMode); + mCurrDrawable.mutate().setTintMode(tintMode); } } } @@ -437,7 +451,8 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { if (mDrawableContainerState.mHasColorFilter) { d.setColorFilter(mDrawableContainerState.mColorFilter); } else if (mDrawableContainerState.mHasTint) { - d.setTint(mDrawableContainerState.mTint, mDrawableContainerState.mTintMode); + d.setTintList(mDrawableContainerState.mTint); + d.setTintMode(mDrawableContainerState.mTintMode); } d.setVisible(isVisible(), true); d.setDither(mDrawableContainerState.mDither); diff --git a/graphics/java/android/graphics/drawable/InsetDrawable.java b/graphics/java/android/graphics/drawable/InsetDrawable.java index f6ccbf5..ee5fe2e 100644 --- a/graphics/java/android/graphics/drawable/InsetDrawable.java +++ b/graphics/java/android/graphics/drawable/InsetDrawable.java @@ -260,8 +260,13 @@ public class InsetDrawable extends Drawable implements Drawable.Callback { } @Override - public void setTint(ColorStateList tint, Mode tintMode) { - mInsetState.mDrawable.setTint(tint, tintMode); + public void setTintList(ColorStateList tint) { + mInsetState.mDrawable.setTintList(tint); + } + + @Override + public void setTintMode(Mode tintMode) { + mInsetState.mDrawable.setTintMode(tintMode); } /** {@hide} */ diff --git a/graphics/java/android/graphics/drawable/LayerDrawable.java b/graphics/java/android/graphics/drawable/LayerDrawable.java index d094ce4..43bc89a 100644 --- a/graphics/java/android/graphics/drawable/LayerDrawable.java +++ b/graphics/java/android/graphics/drawable/LayerDrawable.java @@ -698,11 +698,20 @@ public class LayerDrawable extends Drawable implements Drawable.Callback { } @Override - public void setTint(ColorStateList tint, Mode tintMode) { + public void setTintList(ColorStateList tint) { final ChildDrawable[] array = mLayerState.mChildren; final int N = mLayerState.mNum; for (int i = 0; i < N; i++) { - array[i].mDrawable.setTint(tint, tintMode); + array[i].mDrawable.setTintList(tint); + } + } + + @Override + public void setTintMode(Mode tintMode) { + final ChildDrawable[] array = mLayerState.mChildren; + final int N = mLayerState.mNum; + for (int i = 0; i < N; i++) { + array[i].mDrawable.setTintMode(tintMode); } } diff --git a/graphics/java/android/graphics/drawable/NinePatchDrawable.java b/graphics/java/android/graphics/drawable/NinePatchDrawable.java index 758d42a..6ebb8b5 100644 --- a/graphics/java/android/graphics/drawable/NinePatchDrawable.java +++ b/graphics/java/android/graphics/drawable/NinePatchDrawable.java @@ -346,12 +346,16 @@ public class NinePatchDrawable extends Drawable { } @Override - public void setTint(ColorStateList tint, PorterDuff.Mode tintMode) { - final NinePatchState state = mNinePatchState; - state.mTint = tint; - state.mTintMode = tintMode; + public void setTintList(ColorStateList tint) { + mNinePatchState.mTint = tint; + mTintFilter = updateTintFilter(mTintFilter, tint, mNinePatchState.mTintMode); + invalidateSelf(); + } - mTintFilter = updateTintFilter(mTintFilter, tint, tintMode); + @Override + public void setTintMode(PorterDuff.Mode tintMode) { + mNinePatchState.mTintMode = tintMode; + mTintFilter = updateTintFilter(mTintFilter, mNinePatchState.mTint, tintMode); invalidateSelf(); } diff --git a/graphics/java/android/graphics/drawable/RotateDrawable.java b/graphics/java/android/graphics/drawable/RotateDrawable.java index 8f8fa98..983eb3b 100644 --- a/graphics/java/android/graphics/drawable/RotateDrawable.java +++ b/graphics/java/android/graphics/drawable/RotateDrawable.java @@ -139,8 +139,13 @@ public class RotateDrawable extends Drawable implements Drawable.Callback { } @Override - public void setTint(ColorStateList tint, Mode tintMode) { - mState.mDrawable.setTint(tint, tintMode); + public void setTintList(ColorStateList tint) { + mState.mDrawable.setTintList(tint); + } + + @Override + public void setTintMode(Mode tintMode) { + mState.mDrawable.setTintMode(tintMode); } @Override diff --git a/graphics/java/android/graphics/drawable/ScaleDrawable.java b/graphics/java/android/graphics/drawable/ScaleDrawable.java index 46c92fe..a954474 100644 --- a/graphics/java/android/graphics/drawable/ScaleDrawable.java +++ b/graphics/java/android/graphics/drawable/ScaleDrawable.java @@ -190,8 +190,13 @@ public class ScaleDrawable extends Drawable implements Drawable.Callback { } @Override - public void setTint(ColorStateList tint, Mode tintMode) { - mScaleState.mDrawable.setTint(tint, tintMode); + public void setTintList(ColorStateList tint) { + mScaleState.mDrawable.setTintList(tint); + } + + @Override + public void setTintMode(Mode tintMode) { + mScaleState.mDrawable.setTintMode(tintMode); } @Override diff --git a/graphics/java/android/graphics/drawable/ShapeDrawable.java b/graphics/java/android/graphics/drawable/ShapeDrawable.java index 394f584..6f18635 100644 --- a/graphics/java/android/graphics/drawable/ShapeDrawable.java +++ b/graphics/java/android/graphics/drawable/ShapeDrawable.java @@ -285,12 +285,16 @@ public class ShapeDrawable extends Drawable { } @Override - public void setTint(ColorStateList tint, PorterDuff.Mode tintMode) { - final ShapeState state = mShapeState; - state.mTint = tint; - state.mTintMode = tintMode; + public void setTintList(ColorStateList tint) { + mShapeState.mTint = tint; + mTintFilter = updateTintFilter(mTintFilter, tint, mShapeState.mTintMode); + invalidateSelf(); + } - mTintFilter = updateTintFilter(mTintFilter, tint, tintMode); + @Override + public void setTintMode(PorterDuff.Mode tintMode) { + mShapeState.mTintMode = tintMode; + mTintFilter = updateTintFilter(mTintFilter, mShapeState.mTint, tintMode); invalidateSelf(); } diff --git a/graphics/java/android/graphics/drawable/VectorDrawable.java b/graphics/java/android/graphics/drawable/VectorDrawable.java index 03d2326..813797f 100644 --- a/graphics/java/android/graphics/drawable/VectorDrawable.java +++ b/graphics/java/android/graphics/drawable/VectorDrawable.java @@ -307,14 +307,23 @@ public class VectorDrawable extends Drawable { } @Override - public void setTint(ColorStateList tint, Mode tintMode) { + public void setTintList(ColorStateList tint) { final VectorDrawableState state = mVectorState; - if (state.mTint != tint || state.mTintMode != tintMode) { + if (state.mTint != tint) { state.mTint = tint; - state.mTintMode = tintMode; + mTintFilter = updateTintFilter(mTintFilter, tint, state.mTintMode); + state.mVPathRenderer.setColorFilter(mTintFilter); + invalidateSelf(); + } + } - mTintFilter = updateTintFilter(mTintFilter, tint, tintMode); - mVectorState.mVPathRenderer.setColorFilter(mTintFilter); + @Override + public void setTintMode(Mode tintMode) { + final VectorDrawableState state = mVectorState; + if (state.mTintMode != tintMode) { + state.mTintMode = tintMode; + mTintFilter = updateTintFilter(mTintFilter, state.mTint, tintMode); + state.mVPathRenderer.setColorFilter(mTintFilter); invalidateSelf(); } } |