Loading core/java/android/view/View.java +55 −20 Original line number Diff line number Diff line Loading @@ -3187,9 +3187,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, @ViewDebug.ExportedProperty(deepExport = true, prefix = "bg_") private Drawable mBackground; private ColorStateList mBackgroundTintList = null; private PorterDuff.Mode mBackgroundTintMode = PorterDuff.Mode.SRC_ATOP; private boolean mHasBackgroundTint = false; private TintInfo mBackgroundTint; /** * RenderNode used for backgrounds. Loading @@ -3205,6 +3203,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, private String mTransitionName; private static class TintInfo { ColorStateList mTintList; PorterDuff.Mode mTintMode; boolean mHasTintMode; boolean mHasTintList; } static class ListenerInfo { /** * Listener used to dispatch focus change events. Loading Loading @@ -4044,13 +4049,21 @@ public class View implements Drawable.Callback, KeyEvent.Callback, break; case R.styleable.View_backgroundTint: // This will get applied later during setBackground(). mBackgroundTintList = a.getColorStateList(R.styleable.View_backgroundTint); mHasBackgroundTint = true; if (mBackgroundTint == null) { mBackgroundTint = new TintInfo(); } mBackgroundTint.mTintList = a.getColorStateList( R.styleable.View_backgroundTint); mBackgroundTint.mHasTintList = true; break; case R.styleable.View_backgroundTintMode: // This will get applied later during setBackground(). mBackgroundTintMode = Drawable.parseTintMode(a.getInt( R.styleable.View_backgroundTintMode, -1), mBackgroundTintMode); if (mBackgroundTint == null) { mBackgroundTint = new TintInfo(); } mBackgroundTint.mTintMode = Drawable.parseTintMode(a.getInt( R.styleable.View_backgroundTintMode, -1), null); mBackgroundTint.mHasTintMode = true; break; case R.styleable.View_outlineProvider: setOutlineProviderFromAttribute(a.getInt(R.styleable.View_outlineProvider, Loading Loading @@ -16210,7 +16223,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, /** * Applies a tint to the background drawable. Does not modify the current tint * mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default. * mode, which is {@link PorterDuff.Mode#SRC_IN} by default. * <p> * Subsequent calls to {@link #setBackground(Drawable)} will automatically * mutate the drawable and apply the specified tint and tint mode using Loading @@ -16223,26 +16236,31 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @see Drawable#setTintList(ColorStateList) */ public void setBackgroundTintList(@Nullable ColorStateList tint) { mBackgroundTintList = tint; mHasBackgroundTint = true; if (mBackgroundTint == null) { mBackgroundTint = new TintInfo(); } mBackgroundTint.mTintList = tint; mBackgroundTint.mHasTintList = true; applyBackgroundTint(); } /** * Return the tint applied to the background drawable, if specified. * * @return the tint applied to the background drawable * @attr ref android.R.styleable#View_backgroundTint * @see #setBackgroundTintList(ColorStateList) */ @Nullable public ColorStateList getBackgroundTintList() { return mBackgroundTintList; return mBackgroundTint != null ? mBackgroundTint.mTintList : null; } /** * Specifies the blending mode used to apply the tint specified by * {@link #setBackgroundTintList(ColorStateList)}} to the background drawable. * The default mode is {@link PorterDuff.Mode#SRC_ATOP}. * {@link #setBackgroundTintList(ColorStateList)}} to the background * drawable. The default mode is {@link PorterDuff.Mode#SRC_IN}. * * @param tintMode the blending mode used to apply the tint, may be * {@code null} to clear tint Loading @@ -16251,26 +16269,43 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @see Drawable#setTintMode(PorterDuff.Mode) */ public void setBackgroundTintMode(@Nullable PorterDuff.Mode tintMode) { mBackgroundTintMode = tintMode; if (mBackgroundTint == null) { mBackgroundTint = new TintInfo(); } mBackgroundTint.mTintMode = tintMode; mBackgroundTint.mHasTintMode = true; applyBackgroundTint(); } /** * @return the blending mode used to apply the tint to the background drawable * Return the blending mode used to apply the tint to the background * drawable, if specified. * * @return the blending mode used to apply the tint to the background * drawable * @attr ref android.R.styleable#View_backgroundTintMode * @see #setBackgroundTintMode(PorterDuff.Mode) */ @Nullable public PorterDuff.Mode getBackgroundTintMode() { return mBackgroundTintMode; return mBackgroundTint != null ? mBackgroundTint.mTintMode : null; } private void applyBackgroundTint() { if (mBackground != null && mHasBackgroundTint) { if (mBackground != null && mBackgroundTint != null) { final TintInfo tintInfo = mBackgroundTint; if (tintInfo.mHasTintList || tintInfo.mHasTintMode) { mBackground = mBackground.mutate(); mBackground.setTintList(mBackgroundTintList); mBackground.setTintMode(mBackgroundTintMode); if (tintInfo.mHasTintList) { mBackground.setTintList(tintInfo.mTintList); } if (tintInfo.mHasTintMode) { mBackground.setTintMode(tintInfo.mTintMode); } } } } core/java/android/widget/AbsSeekBar.java +26 −10 Original line number Diff line number Diff line Loading @@ -42,8 +42,9 @@ public abstract class AbsSeekBar extends ProgressBar { private Drawable mThumb; private ColorStateList mThumbTintList = null; private PorterDuff.Mode mThumbTintMode = PorterDuff.Mode.SRC_ATOP; private PorterDuff.Mode mThumbTintMode = null; private boolean mHasThumbTint = false; private boolean mHasThumbTintMode = false; private int mThumbOffset; private boolean mSplitTrack; Loading Loading @@ -96,14 +97,15 @@ public abstract class AbsSeekBar extends ProgressBar { final Drawable thumb = a.getDrawable(com.android.internal.R.styleable.SeekBar_thumb); setThumb(thumb); if (a.hasValue(R.styleable.SeekBar_thumbTintMode)) { mThumbTintMode = Drawable.parseTintMode(a.getInt( R.styleable.SeekBar_thumbTintMode, -1), mThumbTintMode); mHasThumbTintMode = true; } if (a.hasValue(R.styleable.SeekBar_thumbTint)) { mThumbTintList = a.getColorStateList(R.styleable.SeekBar_thumbTint); mHasThumbTint = true; applyThumbTint(); } // Guess thumb offset if thumb != null, but allow layout to override. Loading @@ -119,6 +121,8 @@ public abstract class AbsSeekBar extends ProgressBar { mDisabledAlpha = a.getFloat(com.android.internal.R.styleable.Theme_disabledAlpha, 0.5f); a.recycle(); applyThumbTint(); mScaledTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); } Loading Loading @@ -189,7 +193,7 @@ public abstract class AbsSeekBar extends ProgressBar { /** * Applies a tint to the thumb drawable. Does not modify the current tint * mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default. * mode, which is {@link PorterDuff.Mode#SRC_IN} by default. * <p> * Subsequent calls to {@link #setThumb(Drawable)} will automatically * mutate the drawable and apply the specified tint and tint mode using Loading @@ -209,6 +213,8 @@ public abstract class AbsSeekBar extends ProgressBar { } /** * Returns the tint applied to the thumb drawable, if specified. * * @return the tint applied to the thumb drawable * @attr ref android.R.styleable#SeekBar_thumbTint * @see #setThumbTintList(ColorStateList) Loading @@ -221,7 +227,7 @@ public abstract class AbsSeekBar extends ProgressBar { /** * Specifies the blending mode used to apply the tint specified by * {@link #setThumbTintList(ColorStateList)}} to the thumb drawable. The * default mode is {@link PorterDuff.Mode#SRC_ATOP}. * default mode is {@link PorterDuff.Mode#SRC_IN}. * * @param tintMode the blending mode used to apply the tint, may be * {@code null} to clear tint Loading @@ -232,11 +238,15 @@ public abstract class AbsSeekBar extends ProgressBar { */ public void setThumbTintMode(@Nullable PorterDuff.Mode tintMode) { mThumbTintMode = tintMode; mHasThumbTintMode = true; applyThumbTint(); } /** * Returns the blending mode used to apply the tint to the thumb drawable, * if specified. * * @return the blending mode used to apply the tint to the thumb drawable * @attr ref android.R.styleable#SeekBar_thumbTintMode * @see #setThumbTintMode(PorterDuff.Mode) Loading @@ -247,12 +257,18 @@ public abstract class AbsSeekBar extends ProgressBar { } private void applyThumbTint() { if (mThumb != null && mHasThumbTint) { if (mThumb != null && (mHasThumbTint || mHasThumbTintMode)) { mThumb = mThumb.mutate(); if (mHasThumbTint) { mThumb.setTintList(mThumbTintList); } if (mHasThumbTintMode) { mThumb.setTintMode(mThumbTintMode); } } } /** * @see #setThumbOffset(int) Loading core/java/android/widget/CheckedTextView.java +30 −13 Original line number Diff line number Diff line Loading @@ -48,8 +48,9 @@ public class CheckedTextView extends TextView implements Checkable { private int mCheckMarkResource; private Drawable mCheckMarkDrawable; private ColorStateList mCheckMarkTintList = null; private PorterDuff.Mode mCheckMarkTintMode = PorterDuff.Mode.SRC_ATOP; private PorterDuff.Mode mCheckMarkTintMode = null; private boolean mHasCheckMarkTint = false; private boolean mHasCheckMarkTintMode = false; private int mBasePadding; private int mCheckMarkWidth; Loading Loading @@ -79,27 +80,30 @@ public class CheckedTextView extends TextView implements Checkable { final TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.CheckedTextView, defStyleAttr, defStyleRes); Drawable d = a.getDrawable(R.styleable.CheckedTextView_checkMark); final Drawable d = a.getDrawable(R.styleable.CheckedTextView_checkMark); if (d != null) { setCheckMarkDrawable(d); } if (a.hasValue(R.styleable.CheckedTextView_checkMarkTintMode)) { mCheckMarkTintMode = Drawable.parseTintMode(a.getInt( R.styleable.CheckedTextView_checkMarkTintMode, -1), mCheckMarkTintMode); mHasCheckMarkTintMode = true; } if (a.hasValue(R.styleable.CheckedTextView_checkMarkTint)) { mCheckMarkTintList = a.getColorStateList(R.styleable.CheckedTextView_checkMarkTint); mHasCheckMarkTint = true; applyCheckMarkTint(); } mCheckMarkGravity = a.getInt(R.styleable.CheckedTextView_checkMarkGravity, Gravity.END); boolean checked = a.getBoolean(R.styleable.CheckedTextView_checked, false); final boolean checked = a.getBoolean(R.styleable.CheckedTextView_checked, false); setChecked(checked); a.recycle(); applyCheckMarkTint(); } public void toggle() { Loading Loading @@ -188,7 +192,7 @@ public class CheckedTextView extends TextView implements Checkable { /** * Applies a tint to the check mark drawable. Does not modify the * current tint mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default. * current tint mode, which is {@link PorterDuff.Mode#SRC_IN} by default. * <p> * Subsequent calls to {@link #setCheckMarkDrawable(Drawable)} will * automatically mutate the drawable and apply the specified tint and Loading @@ -209,6 +213,8 @@ public class CheckedTextView extends TextView implements Checkable { } /** * Returns the tint applied to the check mark drawable, if specified. * * @return the tint applied to the check mark drawable * @attr ref android.R.styleable#CheckedTextView_checkMarkTint * @see #setCheckMarkTintList(ColorStateList) Loading @@ -221,7 +227,7 @@ public class CheckedTextView extends TextView implements Checkable { /** * Specifies the blending mode used to apply the tint specified by * {@link #setCheckMarkTintList(ColorStateList)} to the check mark * drawable. The default mode is {@link PorterDuff.Mode#SRC_ATOP}. * drawable. The default mode is {@link PorterDuff.Mode#SRC_IN}. * * @param tintMode the blending mode used to apply the tint, may be * {@code null} to clear tint Loading @@ -231,12 +237,17 @@ public class CheckedTextView extends TextView implements Checkable { */ public void setCheckMarkTintMode(@Nullable PorterDuff.Mode tintMode) { mCheckMarkTintMode = tintMode; mHasCheckMarkTintMode = true; applyCheckMarkTint(); } /** * @return the blending mode used to apply the tint to the check mark drawable * Returns the blending mode used to apply the tint to the check mark * drawable, if specified. * * @return the blending mode used to apply the tint to the check mark * drawable * @attr ref android.R.styleable#CheckedTextView_checkMarkTintMode * @see #setCheckMarkTintMode(PorterDuff.Mode) */ Loading @@ -246,12 +257,18 @@ public class CheckedTextView extends TextView implements Checkable { } private void applyCheckMarkTint() { if (mCheckMarkDrawable != null && mHasCheckMarkTint) { if (mCheckMarkDrawable != null && (mHasCheckMarkTint || mHasCheckMarkTintMode)) { mCheckMarkDrawable = mCheckMarkDrawable.mutate(); if (mHasCheckMarkTint) { mCheckMarkDrawable.setTintList(mCheckMarkTintList); } if (mHasCheckMarkTintMode) { mCheckMarkDrawable.setTintMode(mCheckMarkTintMode); } } } @RemotableViewMethod @Override Loading core/java/android/widget/CompoundButton.java +21 −10 Original line number Diff line number Diff line Loading @@ -54,8 +54,9 @@ public abstract class CompoundButton extends Button implements Checkable { private Drawable mButtonDrawable; private ColorStateList mButtonTintList = null; private PorterDuff.Mode mButtonTintMode = PorterDuff.Mode.SRC_ATOP; private PorterDuff.Mode mButtonTintMode = null; private boolean mHasButtonTint = false; private boolean mHasButtonTintMode = false; private OnCheckedChangeListener mOnCheckedChangeListener; private OnCheckedChangeListener mOnCheckedChangeWidgetListener; Loading Loading @@ -87,14 +88,15 @@ public abstract class CompoundButton extends Button implements Checkable { setButtonDrawable(d); } if (a.hasValue(R.styleable.CompoundButton_buttonTintMode)) { mButtonTintMode = Drawable.parseTintMode(a.getInt( R.styleable.CompoundButton_buttonTintMode, -1), mButtonTintMode); mHasButtonTintMode = true; } if (a.hasValue(R.styleable.CompoundButton_buttonTint)) { mButtonTintList = a.getColorStateList(R.styleable.CompoundButton_buttonTint); mHasButtonTint = true; applyButtonTint(); } final boolean checked = a.getBoolean( Loading @@ -102,6 +104,8 @@ public abstract class CompoundButton extends Button implements Checkable { setChecked(checked); a.recycle(); applyButtonTint(); } public void toggle() { Loading Loading @@ -240,7 +244,7 @@ public abstract class CompoundButton extends Button implements Checkable { /** * Applies a tint to the button drawable. Does not modify the current tint * mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default. * mode, which is {@link PorterDuff.Mode#SRC_IN} by default. * <p> * Subsequent calls to {@link #setButtonDrawable(Drawable)} will * automatically mutate the drawable and apply the specified tint and tint Loading Loading @@ -273,7 +277,7 @@ public abstract class CompoundButton extends Button implements Checkable { /** * Specifies the blending mode used to apply the tint specified by * {@link #setButtonTintList(ColorStateList)}} to the button drawable. The * default mode is {@link PorterDuff.Mode#SRC_ATOP}. * default mode is {@link PorterDuff.Mode#SRC_IN}. * * @param tintMode the blending mode used to apply the tint, may be * {@code null} to clear tint Loading @@ -283,6 +287,7 @@ public abstract class CompoundButton extends Button implements Checkable { */ public void setButtonTintMode(@Nullable PorterDuff.Mode tintMode) { mButtonTintMode = tintMode; mHasButtonTintMode = true; applyButtonTint(); } Loading @@ -298,12 +303,18 @@ public abstract class CompoundButton extends Button implements Checkable { } private void applyButtonTint() { if (mButtonDrawable != null && mHasButtonTint) { if (mButtonDrawable != null && (mHasButtonTint || mHasButtonTintMode)) { mButtonDrawable = mButtonDrawable.mutate(); if (mHasButtonTint) { mButtonDrawable.setTintList(mButtonTintList); } if (mHasButtonTintMode) { mButtonDrawable.setTintMode(mButtonTintMode); } } } @Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { Loading core/java/android/widget/FrameLayout.java +22 −12 Original line number Diff line number Diff line Loading @@ -68,8 +68,9 @@ public class FrameLayout extends ViewGroup { @ViewDebug.ExportedProperty(category = "drawing") private Drawable mForeground; private ColorStateList mForegroundTintList = null; private PorterDuff.Mode mForegroundTintMode = PorterDuff.Mode.SRC_ATOP; private PorterDuff.Mode mForegroundTintMode = null; private boolean mHasForegroundTint = false; private boolean mHasForegroundTintMode = false; @ViewDebug.ExportedProperty(category = "padding") private int mForegroundPaddingLeft = 0; Loading Loading @@ -127,20 +128,22 @@ public class FrameLayout extends ViewGroup { setMeasureAllChildren(true); } if (a.hasValue(R.styleable.FrameLayout_foregroundTintMode)) { mForegroundTintMode = Drawable.parseTintMode(a.getInt( R.styleable.FrameLayout_foregroundTintMode, -1), mForegroundTintMode); mHasForegroundTintMode = true; } if (a.hasValue(R.styleable.FrameLayout_foregroundTint)) { mForegroundTintList = a.getColorStateList(R.styleable.FrameLayout_foregroundTint); mHasForegroundTint = true; applyForegroundTint(); } mForegroundInPadding = a.getBoolean( com.android.internal.R.styleable.FrameLayout_foregroundInsidePadding, true); mForegroundInPadding = a.getBoolean(R.styleable.FrameLayout_foregroundInsidePadding, true); a.recycle(); applyForegroundTint(); } /** Loading Loading @@ -302,7 +305,7 @@ public class FrameLayout extends ViewGroup { /** * Applies a tint to the foreground drawable. Does not modify the current * tint mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default. * tint mode, which is {@link PorterDuff.Mode#SRC_IN} by default. * <p> * Subsequent calls to {@link #setForeground(Drawable)} will automatically * mutate the drawable and apply the specified tint and tint mode using Loading Loading @@ -334,7 +337,7 @@ public class FrameLayout extends ViewGroup { /** * Specifies the blending mode used to apply the tint specified by * {@link #setForegroundTintList(ColorStateList)}} to the foreground drawable. * The default mode is {@link PorterDuff.Mode#SRC_ATOP}. * The default mode is {@link PorterDuff.Mode#SRC_IN}. * * @param tintMode the blending mode used to apply the tint, may be * {@code null} to clear tint Loading @@ -344,6 +347,7 @@ public class FrameLayout extends ViewGroup { */ public void setForegroundTintMode(@Nullable PorterDuff.Mode tintMode) { mForegroundTintMode = tintMode; mHasForegroundTintMode = true; applyForegroundTint(); } Loading @@ -360,12 +364,18 @@ public class FrameLayout extends ViewGroup { } private void applyForegroundTint() { if (mForeground != null && mHasForegroundTint) { if (mForeground != null && (mHasForegroundTint || mHasForegroundTintMode)) { mForeground = mForeground.mutate(); if (mHasForegroundTint) { mForeground.setTintList(mForegroundTintList); } if (mHasForegroundTintMode) { mForeground.setTintMode(mForegroundTintMode); } } } int getPaddingLeftWithForeground() { return mForegroundInPadding ? Math.max(mPaddingLeft, mForegroundPaddingLeft) : Loading Loading
core/java/android/view/View.java +55 −20 Original line number Diff line number Diff line Loading @@ -3187,9 +3187,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, @ViewDebug.ExportedProperty(deepExport = true, prefix = "bg_") private Drawable mBackground; private ColorStateList mBackgroundTintList = null; private PorterDuff.Mode mBackgroundTintMode = PorterDuff.Mode.SRC_ATOP; private boolean mHasBackgroundTint = false; private TintInfo mBackgroundTint; /** * RenderNode used for backgrounds. Loading @@ -3205,6 +3203,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, private String mTransitionName; private static class TintInfo { ColorStateList mTintList; PorterDuff.Mode mTintMode; boolean mHasTintMode; boolean mHasTintList; } static class ListenerInfo { /** * Listener used to dispatch focus change events. Loading Loading @@ -4044,13 +4049,21 @@ public class View implements Drawable.Callback, KeyEvent.Callback, break; case R.styleable.View_backgroundTint: // This will get applied later during setBackground(). mBackgroundTintList = a.getColorStateList(R.styleable.View_backgroundTint); mHasBackgroundTint = true; if (mBackgroundTint == null) { mBackgroundTint = new TintInfo(); } mBackgroundTint.mTintList = a.getColorStateList( R.styleable.View_backgroundTint); mBackgroundTint.mHasTintList = true; break; case R.styleable.View_backgroundTintMode: // This will get applied later during setBackground(). mBackgroundTintMode = Drawable.parseTintMode(a.getInt( R.styleable.View_backgroundTintMode, -1), mBackgroundTintMode); if (mBackgroundTint == null) { mBackgroundTint = new TintInfo(); } mBackgroundTint.mTintMode = Drawable.parseTintMode(a.getInt( R.styleable.View_backgroundTintMode, -1), null); mBackgroundTint.mHasTintMode = true; break; case R.styleable.View_outlineProvider: setOutlineProviderFromAttribute(a.getInt(R.styleable.View_outlineProvider, Loading Loading @@ -16210,7 +16223,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, /** * Applies a tint to the background drawable. Does not modify the current tint * mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default. * mode, which is {@link PorterDuff.Mode#SRC_IN} by default. * <p> * Subsequent calls to {@link #setBackground(Drawable)} will automatically * mutate the drawable and apply the specified tint and tint mode using Loading @@ -16223,26 +16236,31 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @see Drawable#setTintList(ColorStateList) */ public void setBackgroundTintList(@Nullable ColorStateList tint) { mBackgroundTintList = tint; mHasBackgroundTint = true; if (mBackgroundTint == null) { mBackgroundTint = new TintInfo(); } mBackgroundTint.mTintList = tint; mBackgroundTint.mHasTintList = true; applyBackgroundTint(); } /** * Return the tint applied to the background drawable, if specified. * * @return the tint applied to the background drawable * @attr ref android.R.styleable#View_backgroundTint * @see #setBackgroundTintList(ColorStateList) */ @Nullable public ColorStateList getBackgroundTintList() { return mBackgroundTintList; return mBackgroundTint != null ? mBackgroundTint.mTintList : null; } /** * Specifies the blending mode used to apply the tint specified by * {@link #setBackgroundTintList(ColorStateList)}} to the background drawable. * The default mode is {@link PorterDuff.Mode#SRC_ATOP}. * {@link #setBackgroundTintList(ColorStateList)}} to the background * drawable. The default mode is {@link PorterDuff.Mode#SRC_IN}. * * @param tintMode the blending mode used to apply the tint, may be * {@code null} to clear tint Loading @@ -16251,26 +16269,43 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @see Drawable#setTintMode(PorterDuff.Mode) */ public void setBackgroundTintMode(@Nullable PorterDuff.Mode tintMode) { mBackgroundTintMode = tintMode; if (mBackgroundTint == null) { mBackgroundTint = new TintInfo(); } mBackgroundTint.mTintMode = tintMode; mBackgroundTint.mHasTintMode = true; applyBackgroundTint(); } /** * @return the blending mode used to apply the tint to the background drawable * Return the blending mode used to apply the tint to the background * drawable, if specified. * * @return the blending mode used to apply the tint to the background * drawable * @attr ref android.R.styleable#View_backgroundTintMode * @see #setBackgroundTintMode(PorterDuff.Mode) */ @Nullable public PorterDuff.Mode getBackgroundTintMode() { return mBackgroundTintMode; return mBackgroundTint != null ? mBackgroundTint.mTintMode : null; } private void applyBackgroundTint() { if (mBackground != null && mHasBackgroundTint) { if (mBackground != null && mBackgroundTint != null) { final TintInfo tintInfo = mBackgroundTint; if (tintInfo.mHasTintList || tintInfo.mHasTintMode) { mBackground = mBackground.mutate(); mBackground.setTintList(mBackgroundTintList); mBackground.setTintMode(mBackgroundTintMode); if (tintInfo.mHasTintList) { mBackground.setTintList(tintInfo.mTintList); } if (tintInfo.mHasTintMode) { mBackground.setTintMode(tintInfo.mTintMode); } } } }
core/java/android/widget/AbsSeekBar.java +26 −10 Original line number Diff line number Diff line Loading @@ -42,8 +42,9 @@ public abstract class AbsSeekBar extends ProgressBar { private Drawable mThumb; private ColorStateList mThumbTintList = null; private PorterDuff.Mode mThumbTintMode = PorterDuff.Mode.SRC_ATOP; private PorterDuff.Mode mThumbTintMode = null; private boolean mHasThumbTint = false; private boolean mHasThumbTintMode = false; private int mThumbOffset; private boolean mSplitTrack; Loading Loading @@ -96,14 +97,15 @@ public abstract class AbsSeekBar extends ProgressBar { final Drawable thumb = a.getDrawable(com.android.internal.R.styleable.SeekBar_thumb); setThumb(thumb); if (a.hasValue(R.styleable.SeekBar_thumbTintMode)) { mThumbTintMode = Drawable.parseTintMode(a.getInt( R.styleable.SeekBar_thumbTintMode, -1), mThumbTintMode); mHasThumbTintMode = true; } if (a.hasValue(R.styleable.SeekBar_thumbTint)) { mThumbTintList = a.getColorStateList(R.styleable.SeekBar_thumbTint); mHasThumbTint = true; applyThumbTint(); } // Guess thumb offset if thumb != null, but allow layout to override. Loading @@ -119,6 +121,8 @@ public abstract class AbsSeekBar extends ProgressBar { mDisabledAlpha = a.getFloat(com.android.internal.R.styleable.Theme_disabledAlpha, 0.5f); a.recycle(); applyThumbTint(); mScaledTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); } Loading Loading @@ -189,7 +193,7 @@ public abstract class AbsSeekBar extends ProgressBar { /** * Applies a tint to the thumb drawable. Does not modify the current tint * mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default. * mode, which is {@link PorterDuff.Mode#SRC_IN} by default. * <p> * Subsequent calls to {@link #setThumb(Drawable)} will automatically * mutate the drawable and apply the specified tint and tint mode using Loading @@ -209,6 +213,8 @@ public abstract class AbsSeekBar extends ProgressBar { } /** * Returns the tint applied to the thumb drawable, if specified. * * @return the tint applied to the thumb drawable * @attr ref android.R.styleable#SeekBar_thumbTint * @see #setThumbTintList(ColorStateList) Loading @@ -221,7 +227,7 @@ public abstract class AbsSeekBar extends ProgressBar { /** * Specifies the blending mode used to apply the tint specified by * {@link #setThumbTintList(ColorStateList)}} to the thumb drawable. The * default mode is {@link PorterDuff.Mode#SRC_ATOP}. * default mode is {@link PorterDuff.Mode#SRC_IN}. * * @param tintMode the blending mode used to apply the tint, may be * {@code null} to clear tint Loading @@ -232,11 +238,15 @@ public abstract class AbsSeekBar extends ProgressBar { */ public void setThumbTintMode(@Nullable PorterDuff.Mode tintMode) { mThumbTintMode = tintMode; mHasThumbTintMode = true; applyThumbTint(); } /** * Returns the blending mode used to apply the tint to the thumb drawable, * if specified. * * @return the blending mode used to apply the tint to the thumb drawable * @attr ref android.R.styleable#SeekBar_thumbTintMode * @see #setThumbTintMode(PorterDuff.Mode) Loading @@ -247,12 +257,18 @@ public abstract class AbsSeekBar extends ProgressBar { } private void applyThumbTint() { if (mThumb != null && mHasThumbTint) { if (mThumb != null && (mHasThumbTint || mHasThumbTintMode)) { mThumb = mThumb.mutate(); if (mHasThumbTint) { mThumb.setTintList(mThumbTintList); } if (mHasThumbTintMode) { mThumb.setTintMode(mThumbTintMode); } } } /** * @see #setThumbOffset(int) Loading
core/java/android/widget/CheckedTextView.java +30 −13 Original line number Diff line number Diff line Loading @@ -48,8 +48,9 @@ public class CheckedTextView extends TextView implements Checkable { private int mCheckMarkResource; private Drawable mCheckMarkDrawable; private ColorStateList mCheckMarkTintList = null; private PorterDuff.Mode mCheckMarkTintMode = PorterDuff.Mode.SRC_ATOP; private PorterDuff.Mode mCheckMarkTintMode = null; private boolean mHasCheckMarkTint = false; private boolean mHasCheckMarkTintMode = false; private int mBasePadding; private int mCheckMarkWidth; Loading Loading @@ -79,27 +80,30 @@ public class CheckedTextView extends TextView implements Checkable { final TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.CheckedTextView, defStyleAttr, defStyleRes); Drawable d = a.getDrawable(R.styleable.CheckedTextView_checkMark); final Drawable d = a.getDrawable(R.styleable.CheckedTextView_checkMark); if (d != null) { setCheckMarkDrawable(d); } if (a.hasValue(R.styleable.CheckedTextView_checkMarkTintMode)) { mCheckMarkTintMode = Drawable.parseTintMode(a.getInt( R.styleable.CheckedTextView_checkMarkTintMode, -1), mCheckMarkTintMode); mHasCheckMarkTintMode = true; } if (a.hasValue(R.styleable.CheckedTextView_checkMarkTint)) { mCheckMarkTintList = a.getColorStateList(R.styleable.CheckedTextView_checkMarkTint); mHasCheckMarkTint = true; applyCheckMarkTint(); } mCheckMarkGravity = a.getInt(R.styleable.CheckedTextView_checkMarkGravity, Gravity.END); boolean checked = a.getBoolean(R.styleable.CheckedTextView_checked, false); final boolean checked = a.getBoolean(R.styleable.CheckedTextView_checked, false); setChecked(checked); a.recycle(); applyCheckMarkTint(); } public void toggle() { Loading Loading @@ -188,7 +192,7 @@ public class CheckedTextView extends TextView implements Checkable { /** * Applies a tint to the check mark drawable. Does not modify the * current tint mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default. * current tint mode, which is {@link PorterDuff.Mode#SRC_IN} by default. * <p> * Subsequent calls to {@link #setCheckMarkDrawable(Drawable)} will * automatically mutate the drawable and apply the specified tint and Loading @@ -209,6 +213,8 @@ public class CheckedTextView extends TextView implements Checkable { } /** * Returns the tint applied to the check mark drawable, if specified. * * @return the tint applied to the check mark drawable * @attr ref android.R.styleable#CheckedTextView_checkMarkTint * @see #setCheckMarkTintList(ColorStateList) Loading @@ -221,7 +227,7 @@ public class CheckedTextView extends TextView implements Checkable { /** * Specifies the blending mode used to apply the tint specified by * {@link #setCheckMarkTintList(ColorStateList)} to the check mark * drawable. The default mode is {@link PorterDuff.Mode#SRC_ATOP}. * drawable. The default mode is {@link PorterDuff.Mode#SRC_IN}. * * @param tintMode the blending mode used to apply the tint, may be * {@code null} to clear tint Loading @@ -231,12 +237,17 @@ public class CheckedTextView extends TextView implements Checkable { */ public void setCheckMarkTintMode(@Nullable PorterDuff.Mode tintMode) { mCheckMarkTintMode = tintMode; mHasCheckMarkTintMode = true; applyCheckMarkTint(); } /** * @return the blending mode used to apply the tint to the check mark drawable * Returns the blending mode used to apply the tint to the check mark * drawable, if specified. * * @return the blending mode used to apply the tint to the check mark * drawable * @attr ref android.R.styleable#CheckedTextView_checkMarkTintMode * @see #setCheckMarkTintMode(PorterDuff.Mode) */ Loading @@ -246,12 +257,18 @@ public class CheckedTextView extends TextView implements Checkable { } private void applyCheckMarkTint() { if (mCheckMarkDrawable != null && mHasCheckMarkTint) { if (mCheckMarkDrawable != null && (mHasCheckMarkTint || mHasCheckMarkTintMode)) { mCheckMarkDrawable = mCheckMarkDrawable.mutate(); if (mHasCheckMarkTint) { mCheckMarkDrawable.setTintList(mCheckMarkTintList); } if (mHasCheckMarkTintMode) { mCheckMarkDrawable.setTintMode(mCheckMarkTintMode); } } } @RemotableViewMethod @Override Loading
core/java/android/widget/CompoundButton.java +21 −10 Original line number Diff line number Diff line Loading @@ -54,8 +54,9 @@ public abstract class CompoundButton extends Button implements Checkable { private Drawable mButtonDrawable; private ColorStateList mButtonTintList = null; private PorterDuff.Mode mButtonTintMode = PorterDuff.Mode.SRC_ATOP; private PorterDuff.Mode mButtonTintMode = null; private boolean mHasButtonTint = false; private boolean mHasButtonTintMode = false; private OnCheckedChangeListener mOnCheckedChangeListener; private OnCheckedChangeListener mOnCheckedChangeWidgetListener; Loading Loading @@ -87,14 +88,15 @@ public abstract class CompoundButton extends Button implements Checkable { setButtonDrawable(d); } if (a.hasValue(R.styleable.CompoundButton_buttonTintMode)) { mButtonTintMode = Drawable.parseTintMode(a.getInt( R.styleable.CompoundButton_buttonTintMode, -1), mButtonTintMode); mHasButtonTintMode = true; } if (a.hasValue(R.styleable.CompoundButton_buttonTint)) { mButtonTintList = a.getColorStateList(R.styleable.CompoundButton_buttonTint); mHasButtonTint = true; applyButtonTint(); } final boolean checked = a.getBoolean( Loading @@ -102,6 +104,8 @@ public abstract class CompoundButton extends Button implements Checkable { setChecked(checked); a.recycle(); applyButtonTint(); } public void toggle() { Loading Loading @@ -240,7 +244,7 @@ public abstract class CompoundButton extends Button implements Checkable { /** * Applies a tint to the button drawable. Does not modify the current tint * mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default. * mode, which is {@link PorterDuff.Mode#SRC_IN} by default. * <p> * Subsequent calls to {@link #setButtonDrawable(Drawable)} will * automatically mutate the drawable and apply the specified tint and tint Loading Loading @@ -273,7 +277,7 @@ public abstract class CompoundButton extends Button implements Checkable { /** * Specifies the blending mode used to apply the tint specified by * {@link #setButtonTintList(ColorStateList)}} to the button drawable. The * default mode is {@link PorterDuff.Mode#SRC_ATOP}. * default mode is {@link PorterDuff.Mode#SRC_IN}. * * @param tintMode the blending mode used to apply the tint, may be * {@code null} to clear tint Loading @@ -283,6 +287,7 @@ public abstract class CompoundButton extends Button implements Checkable { */ public void setButtonTintMode(@Nullable PorterDuff.Mode tintMode) { mButtonTintMode = tintMode; mHasButtonTintMode = true; applyButtonTint(); } Loading @@ -298,12 +303,18 @@ public abstract class CompoundButton extends Button implements Checkable { } private void applyButtonTint() { if (mButtonDrawable != null && mHasButtonTint) { if (mButtonDrawable != null && (mHasButtonTint || mHasButtonTintMode)) { mButtonDrawable = mButtonDrawable.mutate(); if (mHasButtonTint) { mButtonDrawable.setTintList(mButtonTintList); } if (mHasButtonTintMode) { mButtonDrawable.setTintMode(mButtonTintMode); } } } @Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { Loading
core/java/android/widget/FrameLayout.java +22 −12 Original line number Diff line number Diff line Loading @@ -68,8 +68,9 @@ public class FrameLayout extends ViewGroup { @ViewDebug.ExportedProperty(category = "drawing") private Drawable mForeground; private ColorStateList mForegroundTintList = null; private PorterDuff.Mode mForegroundTintMode = PorterDuff.Mode.SRC_ATOP; private PorterDuff.Mode mForegroundTintMode = null; private boolean mHasForegroundTint = false; private boolean mHasForegroundTintMode = false; @ViewDebug.ExportedProperty(category = "padding") private int mForegroundPaddingLeft = 0; Loading Loading @@ -127,20 +128,22 @@ public class FrameLayout extends ViewGroup { setMeasureAllChildren(true); } if (a.hasValue(R.styleable.FrameLayout_foregroundTintMode)) { mForegroundTintMode = Drawable.parseTintMode(a.getInt( R.styleable.FrameLayout_foregroundTintMode, -1), mForegroundTintMode); mHasForegroundTintMode = true; } if (a.hasValue(R.styleable.FrameLayout_foregroundTint)) { mForegroundTintList = a.getColorStateList(R.styleable.FrameLayout_foregroundTint); mHasForegroundTint = true; applyForegroundTint(); } mForegroundInPadding = a.getBoolean( com.android.internal.R.styleable.FrameLayout_foregroundInsidePadding, true); mForegroundInPadding = a.getBoolean(R.styleable.FrameLayout_foregroundInsidePadding, true); a.recycle(); applyForegroundTint(); } /** Loading Loading @@ -302,7 +305,7 @@ public class FrameLayout extends ViewGroup { /** * Applies a tint to the foreground drawable. Does not modify the current * tint mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default. * tint mode, which is {@link PorterDuff.Mode#SRC_IN} by default. * <p> * Subsequent calls to {@link #setForeground(Drawable)} will automatically * mutate the drawable and apply the specified tint and tint mode using Loading Loading @@ -334,7 +337,7 @@ public class FrameLayout extends ViewGroup { /** * Specifies the blending mode used to apply the tint specified by * {@link #setForegroundTintList(ColorStateList)}} to the foreground drawable. * The default mode is {@link PorterDuff.Mode#SRC_ATOP}. * The default mode is {@link PorterDuff.Mode#SRC_IN}. * * @param tintMode the blending mode used to apply the tint, may be * {@code null} to clear tint Loading @@ -344,6 +347,7 @@ public class FrameLayout extends ViewGroup { */ public void setForegroundTintMode(@Nullable PorterDuff.Mode tintMode) { mForegroundTintMode = tintMode; mHasForegroundTintMode = true; applyForegroundTint(); } Loading @@ -360,12 +364,18 @@ public class FrameLayout extends ViewGroup { } private void applyForegroundTint() { if (mForeground != null && mHasForegroundTint) { if (mForeground != null && (mHasForegroundTint || mHasForegroundTintMode)) { mForeground = mForeground.mutate(); if (mHasForegroundTint) { mForeground.setTintList(mForegroundTintList); } if (mHasForegroundTintMode) { mForeground.setTintMode(mForegroundTintMode); } } } int getPaddingLeftWithForeground() { return mForegroundInPadding ? Math.max(mPaddingLeft, mForegroundPaddingLeft) : Loading