From 4f64c048505a432e549ccb756634ecebf28f9e80 Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Mon, 21 Jul 2014 17:49:13 -0700 Subject: Clean up view tinting APIs, tileModeX/Y attribute docs BUG: 16400590 BUG: 16403307 Change-Id: Ie924815a39eb0e683d1982b08ec478ed3edbfb7b --- core/java/android/widget/ImageView.java | 44 +++++++++++---------------------- 1 file changed, 14 insertions(+), 30 deletions(-) (limited to 'core/java/android/widget/ImageView.java') diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index e97177d..0881f3e 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -168,10 +168,11 @@ public class ImageView extends View { setScaleType(sScaleTypeArray[index]); } + mDrawableTintMode = Drawable.parseTintMode(a.getInt( + R.styleable.ImageView_tintMode, -1), mDrawableTintMode); + if (a.hasValue(R.styleable.ImageView_tint)) { mDrawableTint = a.getColorStateList(R.styleable.ImageView_tint); - mDrawableTintMode = Drawable.parseTintMode(a.getInt( - R.styleable.ImageView_tintMode, -1), mDrawableTintMode); mHasDrawableTint = true; applyDrawableTint(); @@ -448,50 +449,30 @@ public class ImageView extends View { } /** - * Applies a tint to the image drawable. + * Applies a tint to the image drawable. Does not modify the current tint + * mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default. *

* 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)}. * * @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#ImageView_tint - * @attr ref android.R.styleable#ImageView_tintMode + * @see #getTint() * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) */ - private void setTint(@Nullable ColorStateList tint, - @Nullable PorterDuff.Mode tintMode) { + public void setTint(@Nullable ColorStateList tint) { mDrawableTint = tint; - mDrawableTintMode = tintMode; mHasDrawableTint = true; applyDrawableTint(); } /** - * Applies a tint to the image drawable. Does not modify the current tint - * mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default. - *

- * 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)}. - * - * @param tint the tint to apply, may be {@code null} to clear tint - * - * @attr ref android.R.styleable#ImageView_tint - * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) - */ - public void setTint(@Nullable ColorStateList tint) { - setTint(tint, mDrawableTintMode); - } - - /** * @return the tint applied to the image drawable * @attr ref android.R.styleable#ImageView_tint - * @see #setTint(ColorStateList, PorterDuff.Mode) + * @see #setTint(ColorStateList) */ @Nullable public ColorStateList getTint() { @@ -506,16 +487,19 @@ public class ImageView extends View { * @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 #setTint(ColorStateList) + * @see #getTintMode() + * @see Drawable#setTint(ColorStateList, PorterDuff.Mode) */ public void setTintMode(@Nullable PorterDuff.Mode tintMode) { - setTint(mDrawableTint, tintMode); + mDrawableTintMode = tintMode; + + applyDrawableTint(); } /** * @return the blending mode used to apply the tint to the image drawable * @attr ref android.R.styleable#ImageView_tintMode - * @see #setTint(ColorStateList, PorterDuff.Mode) + * @see #setTintMode(PorterDuff.Mode) */ @Nullable public PorterDuff.Mode getTintMode() { -- cgit v1.1