Clean up view tinting APIs, tileModeX/Y attribute docs

BUG: 16400590
BUG: 16403307
Change-Id: Ie924815a39eb0e683d1982b08ec478ed3edbfb7b
diff --git a/api/current.txt b/api/current.txt
index 4ed6839..e736d78 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -380,6 +380,8 @@
     field public static final int centerY = 16843171; // 0x10101a3
     field public static final int checkBoxPreferenceStyle = 16842895; // 0x101008f
     field public static final int checkMark = 16843016; // 0x1010108
+    field public static final int checkMarkTint = 16843949; // 0x10104ad
+    field public static final int checkMarkTintMode = 16843950; // 0x10104ae
     field public static final int checkable = 16843237; // 0x10101e5
     field public static final int checkableBehavior = 16843232; // 0x10101e0
     field public static final int checkboxStyle = 16842860; // 0x101006c
@@ -37638,9 +37640,13 @@
     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.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 setCheckMarkTintMode(android.graphics.PorterDuff.Mode);
     method public void setChecked(boolean);
     method public void toggle();
   }
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index e138345..90eb516 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -15546,7 +15546,8 @@
     }
 
     /**
-     * This function is called whenever the drawable hotspot changes.
+     * This function is called whenever the view hotspot changes and needs to
+     * be propagated to drawables managed by the view.
      * <p>
      * Be sure to call through to the superclass when overriding this function.
      *
@@ -15888,30 +15889,6 @@
     }
 
     /**
-     * Applies a tint to the background drawable.
-     * <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)}.
-     *
-     * @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#View_backgroundTint
-     * @attr ref android.R.styleable#View_backgroundTintMode
-     * @see Drawable#setTint(ColorStateList, PorterDuff.Mode)
-     */
-    private void setBackgroundTint(@Nullable ColorStateList tint,
-            @Nullable PorterDuff.Mode tintMode) {
-        mBackgroundTint = tint;
-        mBackgroundTintMode = tintMode;
-        mHasBackgroundTint = true;
-
-        applyBackgroundTint();
-    }
-
-    /**
      * Applies a tint to the background drawable. Does not modify the current tint
      * mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default.
      * <p>
@@ -15922,16 +15899,20 @@
      * @param tint the tint to apply, may be {@code null} to clear tint
      *
      * @attr ref android.R.styleable#View_backgroundTint
-     * @see #setBackgroundTint(ColorStateList, PorterDuff.Mode)
+     * @see #getBackgroundTint()
+     * @see Drawable#setTint(ColorStateList, PorterDuff.Mode)
      */
     public void setBackgroundTint(@Nullable ColorStateList tint) {
-        setBackgroundTint(tint, mBackgroundTintMode);
+        mBackgroundTint = tint;
+        mHasBackgroundTint = true;
+
+        applyBackgroundTint();
     }
 
     /**
      * @return the tint applied to the background drawable
      * @attr ref android.R.styleable#View_backgroundTint
-     * @see #setBackgroundTint(ColorStateList, PorterDuff.Mode)
+     * @see #setBackgroundTint(ColorStateList)
      */
     @Nullable
     public ColorStateList getBackgroundTint() {
@@ -15946,16 +15927,19 @@
      * @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 #setBackgroundTint(ColorStateList)
+     * @see #getBackgroundTintMode()
+     * @see Drawable#setTint(ColorStateList, PorterDuff.Mode)
      */
     public void setBackgroundTintMode(@Nullable PorterDuff.Mode tintMode) {
-        setBackgroundTint(mBackgroundTint, tintMode);
+        mBackgroundTintMode = tintMode;
+
+        applyBackgroundTint();
     }
 
     /**
      * @return the blending mode used to apply the tint to the background drawable
      * @attr ref android.R.styleable#View_backgroundTintMode
-     * @see #setBackgroundTint(ColorStateList, PorterDuff.Mode)
+     * @see #setBackgroundTintMode(PorterDuff.Mode)
      */
     @Nullable
     public PorterDuff.Mode getBackgroundTintMode() {
diff --git a/core/java/android/widget/AbsSeekBar.java b/core/java/android/widget/AbsSeekBar.java
index 7e2d809..be7e0bc 100644
--- a/core/java/android/widget/AbsSeekBar.java
+++ b/core/java/android/widget/AbsSeekBar.java
@@ -92,10 +92,11 @@
         final Drawable thumb = a.getDrawable(com.android.internal.R.styleable.SeekBar_thumb);
         setThumb(thumb);
 
+        mThumbTintMode = Drawable.parseTintMode(a.getInt(
+                R.styleable.SeekBar_thumbTintMode, -1), mThumbTintMode);
+
         if (a.hasValue(R.styleable.SeekBar_thumbTint)) {
             mThumbTint = a.getColorStateList(R.styleable.SeekBar_thumbTint);
-            mThumbTintMode = Drawable.parseTintMode(a.getInt(
-                    R.styleable.SeekBar_thumbTintMode, -1), mThumbTintMode);
             mHasThumbTint = true;
 
             applyThumbTint();
@@ -183,30 +184,6 @@
     }
 
     /**
-     * Applies a tint to the thumb drawable.
-     * <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)}.
-     *
-     * @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#SeekBar_thumbTint
-     * @attr ref android.R.styleable#SeekBar_thumbTintMode
-     * @see Drawable#setTint(ColorStateList, PorterDuff.Mode)
-     */
-    private void setThumbTint(@Nullable ColorStateList tint,
-            @Nullable PorterDuff.Mode tintMode) {
-        mThumbTint = tint;
-        mThumbTintMode = tintMode;
-        mHasThumbTint = true;
-
-        applyThumbTint();
-    }
-
-    /**
      * Applies a tint to the thumb drawable. Does not modify the current tint
      * mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default.
      * <p>
@@ -217,16 +194,20 @@
      * @param tint the tint to apply, may be {@code null} to clear tint
      *
      * @attr ref android.R.styleable#SeekBar_thumbTint
-     * @see #setThumbTint(ColorStateList, PorterDuff.Mode)
+     * @see #getThumbTint()
+     * @see Drawable#setTint(ColorStateList, PorterDuff.Mode)
      */
     public void setThumbTint(@Nullable ColorStateList tint) {
-        setThumbTint(tint, mThumbTintMode);
+        mThumbTint = tint;
+        mHasThumbTint = true;
+
+        applyThumbTint();
     }
 
     /**
      * @return the tint applied to the thumb drawable
      * @attr ref android.R.styleable#SeekBar_thumbTint
-     * @see #setThumbTint(ColorStateList, PorterDuff.Mode)
+     * @see #setThumbTint(ColorStateList)
      */
     @Nullable
     public ColorStateList getThumbTint() {
@@ -240,17 +221,21 @@
      *
      * @param tintMode the blending mode used to apply the tint, may be
      *                 {@code null} to clear tint
+     *
      * @attr ref android.R.styleable#SeekBar_thumbTintMode
-     * @see #setThumbTint(ColorStateList)
+     * @see #getThumbTintMode()
+     * @see Drawable#setTint(ColorStateList, PorterDuff.Mode)
      */
     public void setThumbTintMode(@Nullable PorterDuff.Mode tintMode) {
-        setThumbTint(mThumbTint, tintMode);
+        mThumbTintMode = tintMode;
+
+        applyThumbTint();
     }
 
     /**
      * @return the blending mode used to apply the tint to the thumb drawable
      * @attr ref android.R.styleable#SeekBar_thumbTintMode
-     * @see #setThumbTint(ColorStateList, PorterDuff.Mode)
+     * @see #setThumbTintMode(PorterDuff.Mode)
      */
     @Nullable
     public PorterDuff.Mode getThumbTintMode() {
diff --git a/core/java/android/widget/CheckedTextView.java b/core/java/android/widget/CheckedTextView.java
index 4aa2300..791151c 100644
--- a/core/java/android/widget/CheckedTextView.java
+++ b/core/java/android/widget/CheckedTextView.java
@@ -18,9 +18,12 @@
 
 import com.android.internal.R;
 
+import android.annotation.Nullable;
 import android.content.Context;
+import android.content.res.ColorStateList;
 import android.content.res.TypedArray;
 import android.graphics.Canvas;
+import android.graphics.PorterDuff;
 import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
 import android.view.Gravity;
@@ -41,8 +44,13 @@
  */
 public class CheckedTextView extends TextView implements Checkable {
     private boolean mChecked;
+
     private int mCheckMarkResource;
     private Drawable mCheckMarkDrawable;
+    private ColorStateList mCheckMarkTint = null;
+    private PorterDuff.Mode mCheckMarkTintMode = PorterDuff.Mode.SRC_ATOP;
+    private boolean mHasCheckMarkTint = false;
+
     private int mBasePadding;
     private int mCheckMarkWidth;
     private boolean mNeedRequestlayout;
@@ -74,6 +82,16 @@
             setCheckMarkDrawable(d);
         }
 
+        mCheckMarkTintMode = Drawable.parseTintMode(a.getInt(
+                R.styleable.CompoundButton_buttonTintMode, -1), mCheckMarkTintMode);
+
+        if (a.hasValue(R.styleable.CompoundButton_buttonTint)) {
+            mCheckMarkTint = a.getColorStateList(R.styleable.CompoundButton_buttonTint);
+            mHasCheckMarkTint = true;
+
+            applyCheckMarkTint();
+        }
+
         boolean checked = a.getBoolean(R.styleable.CheckedTextView_checked, false);
         setChecked(checked);
 
@@ -153,6 +171,7 @@
 
             mCheckMarkWidth = d.getIntrinsicWidth();
             d.setState(getDrawableState());
+            applyCheckMarkTint();
         } else {
             mCheckMarkWidth = 0;
         }
@@ -163,6 +182,72 @@
         resolvePadding();
     }
 
+    /**
+     * Applies a tint to the check mark drawable. Does not modify the
+     * current tint mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default.
+     * <p>
+     * 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)}.
+     *
+     * @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)
+     */
+    public void setCheckMarkTint(@Nullable ColorStateList tint) {
+        mCheckMarkTint = tint;
+        mHasCheckMarkTint = true;
+
+        applyCheckMarkTint();
+    }
+
+    /**
+     * @return the tint applied to the check mark drawable
+     * @attr ref android.R.styleable#CheckedTextView_checkMarkTint
+     * @see #setCheckMarkTint(ColorStateList)
+     */
+    @Nullable
+    public ColorStateList getCheckMarkTint() {
+        return mCheckMarkTint;
+    }
+
+    /**
+     * Specifies the blending mode used to apply the tint specified by
+     * {@link #setCheckMarkTint(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)
+     */
+    public void setCheckMarkTintMode(@Nullable PorterDuff.Mode tintMode) {
+        mCheckMarkTintMode = tintMode;
+
+        applyCheckMarkTint();
+    }
+
+    /**
+     * @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)
+     */
+    @Nullable
+    public PorterDuff.Mode getCheckMarkTintMode() {
+        return mCheckMarkTintMode;
+    }
+
+    private void applyCheckMarkTint() {
+        if (mCheckMarkDrawable != null && mHasCheckMarkTint) {
+            mCheckMarkDrawable = mCheckMarkDrawable.mutate();
+            mCheckMarkDrawable.setTint(mCheckMarkTint, mCheckMarkTintMode);
+        }
+    }
+
     @RemotableViewMethod
     @Override
     public void setVisibility(int visibility) {
diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java
index 9ba0fe1..a45777e 100644
--- a/core/java/android/widget/CompoundButton.java
+++ b/core/java/android/widget/CompoundButton.java
@@ -87,10 +87,11 @@
             setButtonDrawable(d);
         }
 
+        mButtonTintMode = Drawable.parseTintMode(a.getInt(
+                R.styleable.CompoundButton_buttonTintMode, -1), mButtonTintMode);
+
         if (a.hasValue(R.styleable.CompoundButton_buttonTint)) {
             mButtonTint = a.getColorStateList(R.styleable.CompoundButton_buttonTint);
-            mButtonTintMode = Drawable.parseTintMode(a.getInt(
-                    R.styleable.CompoundButton_buttonTintMode, -1), mButtonTintMode);
             mHasButtonTint = true;
 
             applyButtonTint();
@@ -238,52 +239,31 @@
     }
 
     /**
-     * Applies a tint to the button drawable.
-     * <p>
-     * Subsequent calls to {@link #setButtonDrawable(Drawable)} will
-     * automatically mutate the drawable and apply the specified tint and tint
-     * mode using
-     * {@link Drawable#setTint(ColorStateList, android.graphics.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#CompoundButton_buttonTint
-     * @attr ref android.R.styleable#CompoundButton_buttonTintMode
-     * @see Drawable#setTint(ColorStateList, android.graphics.PorterDuff.Mode)
-     */
-    private void setButtonTint(@Nullable ColorStateList tint,
-            @Nullable PorterDuff.Mode tintMode) {
-        mButtonTint = tint;
-        mButtonTintMode = tintMode;
-        mHasButtonTint = true;
-
-        applyButtonTint();
-    }
-
-    /**
      * Applies a tint to the button drawable. Does not modify the current tint
      * mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default.
      * <p>
      * Subsequent calls to {@link #setButtonDrawable(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#setTint(ColorStateList, PorterDuff.Mode)}.
      *
      * @param tint the tint to apply, may be {@code null} to clear tint
      *
      * @attr ref android.R.styleable#CompoundButton_buttonTint
-     * @see #setButtonTint(ColorStateList, android.graphics.PorterDuff.Mode)
+     * @see #setButtonTint(ColorStateList)
+     * @see Drawable#setTint(ColorStateList, PorterDuff.Mode)
      */
     public void setButtonTint(@Nullable ColorStateList tint) {
-        setButtonTint(tint, mButtonTintMode);
+        mButtonTint = tint;
+        mHasButtonTint = true;
+
+        applyButtonTint();
     }
 
     /**
      * @return the tint applied to the button drawable
      * @attr ref android.R.styleable#CompoundButton_buttonTint
-     * @see #setButtonTint(ColorStateList, PorterDuff.Mode)
+     * @see #setButtonTint(ColorStateList)
      */
     @Nullable
     public ColorStateList getButtonTint() {
@@ -298,16 +278,19 @@
      * @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 #setButtonTint(ColorStateList)
+     * @see #getButtonTintMode()
+     * @see Drawable#setTint(ColorStateList, PorterDuff.Mode)
      */
     public void setButtonTintMode(@Nullable PorterDuff.Mode tintMode) {
-        setButtonTint(mButtonTint, tintMode);
+        mButtonTintMode = tintMode;
+
+        applyButtonTint();
     }
 
     /**
      * @return the blending mode used to apply the tint to the button drawable
      * @attr ref android.R.styleable#CompoundButton_buttonTintMode
-     * @see #setButtonTint(ColorStateList, PorterDuff.Mode)
+     * @see #setButtonTintMode(PorterDuff.Mode)
      */
     @Nullable
     public PorterDuff.Mode getButtonTintMode() {
diff --git a/core/java/android/widget/FrameLayout.java b/core/java/android/widget/FrameLayout.java
index 34f333e..81dfcbb 100644
--- a/core/java/android/widget/FrameLayout.java
+++ b/core/java/android/widget/FrameLayout.java
@@ -127,10 +127,11 @@
             setMeasureAllChildren(true);
         }
 
+        mForegroundTintMode = Drawable.parseTintMode(a.getInt(
+                R.styleable.FrameLayout_foregroundTintMode, -1), mForegroundTintMode);
+
         if (a.hasValue(R.styleable.FrameLayout_foregroundTint)) {
             mForegroundTint = a.getColorStateList(R.styleable.FrameLayout_foregroundTint);
-            mForegroundTintMode = Drawable.parseTintMode(a.getInt(
-                    R.styleable.FrameLayout_foregroundTintMode, -1), mForegroundTintMode);
             mHasForegroundTint = true;
 
             applyForegroundTint();
@@ -316,11 +317,6 @@
      */
     private void setForegroundTint(@Nullable ColorStateList tint,
             @Nullable PorterDuff.Mode tintMode) {
-        mForegroundTint = tint;
-        mForegroundTintMode = tintMode;
-        mHasForegroundTint = true;
-
-        applyForegroundTint();
     }
 
     /**
@@ -334,16 +330,20 @@
      * @param tint the tint to apply, may be {@code null} to clear tint
      *
      * @attr ref android.R.styleable#FrameLayout_foregroundTint
-     * @see #setForegroundTint(ColorStateList, PorterDuff.Mode)
+     * @see #getForegroundTint()
+     * @see Drawable#setTint(ColorStateList, PorterDuff.Mode)
      */
     public void setForegroundTint(@Nullable ColorStateList tint) {
-        setForegroundTint(tint, mForegroundTintMode);
+        mForegroundTint = tint;
+        mHasForegroundTint = true;
+
+        applyForegroundTint();
     }
 
     /**
      * @return the tint applied to the foreground drawable
      * @attr ref android.R.styleable#FrameLayout_foregroundTint
-     * @see #setForegroundTint(ColorStateList, PorterDuff.Mode)
+     * @see #setForegroundTint(ColorStateList)
      */
     @Nullable
     public ColorStateList getForegroundTint() {
@@ -358,17 +358,20 @@
      * @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 #setForegroundTint(ColorStateList)
+     * @see #getForegroundTintMode()
+     * @see Drawable#setTint(ColorStateList, PorterDuff.Mode)
      */
     public void setForegroundTintMode(@Nullable PorterDuff.Mode tintMode) {
-        setForegroundTint(mForegroundTint, tintMode);
+        mForegroundTintMode = tintMode;
+
+        applyForegroundTint();
     }
 
     /**
      * @return the blending mode used to apply the tint to the foreground
      *         drawable
      * @attr ref android.R.styleable#FrameLayout_foregroundTintMode
-     * @see #setForegroundTint(ColorStateList, PorterDuff.Mode)
+     * @see #setForegroundTintMode(PorterDuff.Mode)
      */
     @Nullable
     public PorterDuff.Mode getForegroundTintMode() {
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 @@
             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,30 +449,6 @@
     }
 
     /**
-     * Applies a tint to the image drawable.
-     * <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)}.
-     *
-     * @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 Drawable#setTint(ColorStateList, PorterDuff.Mode)
-     */
-    private void setTint(@Nullable ColorStateList tint,
-            @Nullable PorterDuff.Mode tintMode) {
-        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.
      * <p>
@@ -482,16 +459,20 @@
      * @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)
      */
     public void setTint(@Nullable ColorStateList tint) {
-        setTint(tint, mDrawableTintMode);
+        mDrawableTint = tint;
+        mHasDrawableTint = true;
+
+        applyDrawableTint();
     }
 
     /**
      * @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 @@
      * @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() {
diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java
index 394b255..20c1aa4 100644
--- a/core/java/android/widget/ProgressBar.java
+++ b/core/java/android/widget/ProgressBar.java
@@ -326,48 +326,48 @@
 
         mMirrorForRtl = a.getBoolean(R.styleable.ProgressBar_mirrorForRtl, mMirrorForRtl);
 
+        mProgressTintMode = Drawable.parseTintMode(a.getInt(
+                R.styleable.ProgressBar_progressBackgroundTintMode, -1), mProgressTintMode);
+
         if (a.hasValue(R.styleable.ProgressBar_progressTint)) {
             mProgressTint = a.getColorStateList(
                     R.styleable.ProgressBar_progressTint);
-            mProgressTintMode = Drawable.parseTintMode(a.getInt(
-                    R.styleable.ProgressBar_progressBackgroundTintMode, -1),
-                    mProgressTintMode);
             mHasProgressTint = true;
 
             applyProgressLayerTint(R.id.progress, mProgressTint,
                     mProgressTintMode, true);
         }
 
+        mProgressBackgroundTintMode = Drawable.parseTintMode(a.getInt(
+                R.styleable.ProgressBar_progressTintMode, -1), mProgressBackgroundTintMode);
+
         if (a.hasValue(R.styleable.ProgressBar_progressBackgroundTint)) {
             mProgressBackgroundTint = a.getColorStateList(
                     R.styleable.ProgressBar_progressBackgroundTint);
-            mProgressBackgroundTintMode = Drawable.parseTintMode(a.getInt(
-                    R.styleable.ProgressBar_progressTintMode, -1),
-                    mProgressBackgroundTintMode);
             mHasProgressBackgroundTint = true;
 
             applyProgressLayerTint(R.id.background, mProgressBackgroundTint,
                     mProgressBackgroundTintMode, false);
         }
 
+        mSecondaryProgressTintMode = Drawable.parseTintMode(a.getInt(
+                R.styleable.ProgressBar_secondaryProgressTintMode, -1), mSecondaryProgressTintMode);
+
         if (a.hasValue(R.styleable.ProgressBar_secondaryProgressTint)) {
             mSecondaryProgressTint = a.getColorStateList(
                     R.styleable.ProgressBar_secondaryProgressTint);
-            mSecondaryProgressTintMode = Drawable.parseTintMode(a.getInt(
-                    R.styleable.ProgressBar_secondaryProgressTintMode, -1),
-                    mSecondaryProgressTintMode);
             mHasSecondaryProgressTint = true;
 
             applyProgressLayerTint(R.id.secondaryProgress, mSecondaryProgressTint,
                     mSecondaryProgressTintMode, false);
         }
 
+        mIndeterminateTintMode = Drawable.parseTintMode(a.getInt(
+                R.styleable.ProgressBar_indeterminateTintMode, -1), mIndeterminateTintMode);
+
         if (a.hasValue(R.styleable.ProgressBar_indeterminateTint)) {
             mIndeterminateTint = a.getColorStateList(
                     R.styleable.ProgressBar_indeterminateTint);
-            mIndeterminateTintMode = Drawable.parseTintMode(a.getInt(
-                    R.styleable.ProgressBar_indeterminateTintMode, -1),
-                    mIndeterminateTintMode);
             mHasIndeterminateTint = true;
 
             applyIndeterminateTint();
@@ -574,31 +574,6 @@
     }
 
     /**
-     * Applies a tint to the indeterminate drawable.
-     * <p>
-     * Subsequent calls to {@link #setVisibilminateDrawable(Drawable)} will
-     * automatically mutate the drawable and apply the specified tint and
-     * tint mode using
-     * {@link Drawable#setTint(ColorStateList, android.graphics.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#ProgressBar_indeterminateTint
-     * @attr ref android.R.styleable#ProgressBar_indeterminateTintMode
-     * @see Drawable#setTint(ColorStateList, android.graphics.PorterDuff.Mode)
-     */
-    private void setIndeterminateTint(@Nullable ColorStateList tint,
-            @Nullable PorterDuff.Mode tintMode) {
-        mIndeterminateTint = tint;
-        mIndeterminateTintMode = tintMode;
-        mHasIndeterminateTint = true;
-
-        applyIndeterminateTint();
-    }
-
-    /**
      * Applies a tint to the indeterminate drawable. Does not modify the
      * current tint mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default.
      * <p>
@@ -610,16 +585,20 @@
      * @param tint the tint to apply, may be {@code null} to clear tint
      *
      * @attr ref android.R.styleable#ProgressBar_indeterminateTint
-     * @see #setIndeterminateTint(ColorStateList, PorterDuff.Mode)
+     * @see #getIndeterminateTint()
+     * @see Drawable#setTint(ColorStateList, PorterDuff.Mode)
      */
     public void setIndeterminateTint(@Nullable ColorStateList tint) {
-        setIndeterminateTint(tint, mIndeterminateTintMode);
+        mIndeterminateTint = tint;
+        mHasIndeterminateTint = true;
+
+        applyIndeterminateTint();
     }
 
     /**
      * @return the tint applied to the indeterminate drawable
      * @attr ref android.R.styleable#ProgressBar_indeterminateTint
-     * @see #setIndeterminateTint(ColorStateList, PorterDuff.Mode)
+     * @see #setIndeterminateTint(ColorStateList)
      */
     @Nullable
     public ColorStateList getIndeterminateTint() {
@@ -635,15 +614,18 @@
      *                 {@code null} to clear tint
      * @attr ref android.R.styleable#ProgressBar_indeterminateTintMode
      * @see #setIndeterminateTint(ColorStateList)
+     * @see Drawable#setTint(ColorStateList, PorterDuff.Mode)
      */
     public void setIndeterminateTintMode(@Nullable PorterDuff.Mode tintMode) {
-        setIndeterminateTint(mIndeterminateTint, tintMode);
+        mIndeterminateTintMode = tintMode;
+
+        applyIndeterminateTint();
     }
 
     /**
      * @return the blending mode used to apply the tint to the indeterminate drawable
      * @attr ref android.R.styleable#ProgressBar_indeterminateTintMode
-     * @see #setIndeterminateTint(ColorStateList, PorterDuff.Mode)
+     * @see #setIndeterminateTintMode(PorterDuff.Mode)
      */
     @Nullable
     public PorterDuff.Mode getIndeterminateTintMode() {
@@ -749,36 +731,6 @@
 
     /**
      * Applies a tint to the progress indicator, if one exists, or to the
-     * entire progress drawable otherwise.
-     * <p>
-     * The progress indicator should be specified as a layer with
-     * id {@link android.R.id#progress} in a {@link LayerDrawable}
-     * used as the progress drawable.
-     * <p>
-     * 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)}.
-     *
-     * @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#ProgressBar_progressTint
-     * @attr ref android.R.styleable#ProgressBar_progressTintMode
-     * @see Drawable#setTint(ColorStateList, android.graphics.PorterDuff.Mode)
-     */
-    private void setProgressTint(@Nullable ColorStateList tint,
-            @Nullable PorterDuff.Mode tintMode) {
-        mProgressTint = tint;
-        mProgressTintMode = tintMode;
-        mHasProgressTint = true;
-
-        applyProgressLayerTint(R.id.progress, tint, tintMode, true);
-    }
-
-    /**
-     * Applies a tint to the progress indicator, if one exists, or to the
      * entire progress drawable otherwise. Does not modify the current tint
      * mode, which is {@link PorterDuff.Mode#SRC_ATOP} by default.
      * <p>
@@ -794,16 +746,20 @@
      * @param tint the tint to apply, may be {@code null} to clear tint
      *
      * @attr ref android.R.styleable#ProgressBar_progressTint
-     * @see #setProgressTint(ColorStateList)
+     * @see #getProgressTint()
+     * @see Drawable#setTint(ColorStateList, PorterDuff.Mode)
      */
     public void setProgressTint(@Nullable ColorStateList tint) {
-        setProgressTint(tint, mProgressTintMode);
+        mProgressTint = tint;
+        mHasProgressTint = true;
+
+        applyProgressLayerTint(R.id.progress, tint, mProgressTintMode, true);
     }
 
     /**
      * @return the tint applied to the progress drawable
      * @attr ref android.R.styleable#ProgressBar_progressTint
-     * @see #setProgressTint(ColorStateList, PorterDuff.Mode)
+     * @see #setProgressTint(ColorStateList)
      */
     @Nullable
     public ColorStateList getProgressTint() {
@@ -818,16 +774,19 @@
      * @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 #setProgressTint(ColorStateList)
+     * @see #getProgressTintMode()
+     * @see Drawable#setTint(ColorStateList, PorterDuff.Mode)
      */
     public void setProgressTintMode(@Nullable PorterDuff.Mode tintMode) {
-        setProgressTint(mProgressTint, tintMode);
+        mProgressTintMode = tintMode;
+
+        applyProgressLayerTint(R.id.progress, mProgressTint, tintMode, true);
     }
 
     /**
      * @return the blending mode used to apply the tint to the progress drawable
      * @attr ref android.R.styleable#ProgressBar_progressTintMode
-     * @see #setProgressTint(ColorStateList, PorterDuff.Mode)
+     * @see #setProgressTintMode(PorterDuff.Mode)
      */
     @Nullable
     public PorterDuff.Mode getProgressTintMode() {
@@ -835,35 +794,6 @@
     }
 
     /**
-     * Applies a tint to the progress background, if one exists.
-     * <p>
-     * The progress background must be specified as a layer with
-     * id {@link android.R.id#background} in a {@link LayerDrawable}
-     * used as the progress drawable.
-     * <p>
-     * 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)}.
-     *
-     * @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#ProgressBar_progressBackgroundTint
-     * @attr ref android.R.styleable#ProgressBar_progressBackgroundTintMode
-     * @see Drawable#setTint(ColorStateList, android.graphics.PorterDuff.Mode)
-     */
-    private void setProgressBackgroundTint(@Nullable ColorStateList tint,
-            @Nullable PorterDuff.Mode tintMode) {
-        mProgressBackgroundTint = tint;
-        mProgressBackgroundTintMode = tintMode;
-        mHasProgressBackgroundTint = true;
-
-        applyProgressLayerTint(R.id.background, tint, tintMode, false);
-    }
-
-    /**
      * Applies a tint to the progress background, if one exists. Does not
      * modify the current tint mode, which is
      * {@link PorterDuff.Mode#SRC_ATOP} by default.
@@ -880,16 +810,20 @@
      * @param tint the tint to apply, may be {@code null} to clear tint
      *
      * @attr ref android.R.styleable#ProgressBar_progressBackgroundTint
-     * @see #setProgressBackgroundTint(ColorStateList, PorterDuff.Mode)
+     * @see #getProgressBackgroundTint()
+     * @see Drawable#setTint(ColorStateList, PorterDuff.Mode)
      */
     public void setProgressBackgroundTint(@Nullable ColorStateList tint) {
-        setProgressBackgroundTint(tint, mProgressBackgroundTintMode);
+        mProgressBackgroundTint = tint;
+        mHasProgressBackgroundTint = true;
+
+        applyProgressLayerTint(R.id.background, tint, mProgressBackgroundTintMode, false);
     }
 
     /**
      * @return the tint applied to the progress background
      * @attr ref android.R.styleable#ProgressBar_progressBackgroundTint
-     * @see #setProgressBackgroundTint(ColorStateList, PorterDuff.Mode)
+     * @see #setProgressBackgroundTint(ColorStateList)
      */
     @Nullable
     public ColorStateList getProgressBackgroundTint() {
@@ -905,16 +839,19 @@
      *                 {@code null} to clear tint
      * @attr ref android.R.styleable#ProgressBar_progressBackgroundTintMode
      * @see #setProgressBackgroundTint(ColorStateList)
+     * @see Drawable#setTint(ColorStateList, PorterDuff.Mode)
      */
     public void setProgressBackgroundTintMode(@Nullable PorterDuff.Mode tintMode) {
-        setProgressBackgroundTint(mProgressBackgroundTint, tintMode);
+        mProgressBackgroundTintMode = tintMode;
+
+        applyProgressLayerTint(R.id.background, mProgressBackgroundTint, tintMode, false);
     }
 
     /**
      * @return the blending mode used to apply the tint to the progress
      *         background
      * @attr ref android.R.styleable#ProgressBar_progressBackgroundTintMode
-     * @see #setProgressBackgroundTint(ColorStateList, PorterDuff.Mode)
+     * @see #setProgressBackgroundTintMode(PorterDuff.Mode)
      */
     @Nullable
     public PorterDuff.Mode getProgressBackgroundTintMode() {
@@ -923,35 +860,6 @@
 
     /**
      * Applies a tint to the secondary progress indicator, if one exists.
-     * <p>
-     * The secondary progress indicator must be specified as a layer with
-     * id {@link android.R.id#secondaryProgress} in a {@link LayerDrawable}
-     * used as the progress drawable.
-     * <p>
-     * 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)}.
-     *
-     * @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#ProgressBar_secondaryProgressTint
-     * @attr ref android.R.styleable#ProgressBar_secondaryProgressTintMode
-     * @see Drawable#setTint(ColorStateList, android.graphics.PorterDuff.Mode)
-     */
-    private void setSecondaryProgressTint(@Nullable ColorStateList tint,
-            @Nullable PorterDuff.Mode tintMode) {
-        mSecondaryProgressTint = tint;
-        mSecondaryProgressTintMode = tintMode;
-        mHasSecondaryProgressTint = true;
-
-        applyProgressLayerTint(R.id.secondaryProgress, tint, tintMode, false);
-    }
-
-    /**
-     * Applies a tint to the secondary progress indicator, if one exists.
      * Does not modify the current tint mode, which is
      * {@link PorterDuff.Mode#SRC_ATOP} by default.
      * <p>
@@ -967,16 +875,20 @@
      * @param tint the tint to apply, may be {@code null} to clear tint
      *
      * @attr ref android.R.styleable#ProgressBar_secondaryProgressTint
-     * @see #setSecondaryProgressTint(ColorStateList, PorterDuff.Mode)
+     * @see #getSecondaryProgressTint()
+     * @see Drawable#setTint(ColorStateList, PorterDuff.Mode)
      */
     public void setSecondaryProgressTint(@Nullable ColorStateList tint) {
-        setSecondaryProgressTint(tint, mSecondaryProgressTintMode);
+        mSecondaryProgressTint = tint;
+        mHasSecondaryProgressTint = true;
+
+        applyProgressLayerTint(R.id.secondaryProgress, tint, mSecondaryProgressTintMode, false);
     }
 
     /**
      * @return the tint applied to the secondary progress drawable
      * @attr ref android.R.styleable#ProgressBar_secondaryProgressTint
-     * @see #setSecondaryProgressTint(ColorStateList, PorterDuff.Mode)
+     * @see #setSecondaryProgressTint(ColorStateList)
      */
     @Nullable
     public ColorStateList getSecondaryProgressTint() {
@@ -993,16 +905,19 @@
      *                 {@code null} to clear tint
      * @attr ref android.R.styleable#ProgressBar_secondaryProgressTintMode
      * @see #setSecondaryProgressTint(ColorStateList)
+     * @see Drawable#setTint(ColorStateList, PorterDuff.Mode)
      */
     public void setSecondaryProgressTintMode(@Nullable PorterDuff.Mode tintMode) {
-        setSecondaryProgressTint(mSecondaryProgressTint, tintMode);
+        mSecondaryProgressTintMode = tintMode;
+
+        applyProgressLayerTint(R.id.secondaryProgress, mSecondaryProgressTint, tintMode, false);
     }
 
     /**
      * @return the blending mode used to apply the tint to the secondary
      *         progress drawable
      * @attr ref android.R.styleable#ProgressBar_secondaryProgressTintMode
-     * @see #setSecondaryProgressTint(ColorStateList, PorterDuff.Mode)
+     * @see #setSecondaryProgressTintMode(PorterDuff.Mode)
      */
     @Nullable
     public PorterDuff.Mode getSecondaryProgressTintMode() {
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 2c5cfe1..f69ab0f 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -3114,6 +3114,28 @@
         <attr name="checked" />
         <!-- Drawable used for the check mark graphic. -->
         <attr name="checkMark" format="reference"/>
+        <!-- Tint to apply to the check mark. -->
+        <attr name="checkMarkTint" format="color" />
+        <!-- Blending mode used to apply the check mark tint. -->
+        <attr name="checkMarkTintMode">
+            <!-- The tint is drawn on top of the drawable.
+                 [Sa + (1 - Sa)*Da, Rc = Sc + (1 - Sa)*Dc] -->
+            <enum name="src_over" value="3" />
+            <!-- The tint is masked by the alpha channel of the drawable. The drawable’s
+                 color channels are thrown out. [Sa * Da, Sc * Da] -->
+            <enum name="src_in" value="5" />
+            <!-- The tint is drawn above the drawable, but with the drawable’s alpha
+                 channel masking the result. [Da, Sc * Da + (1 - Sa) * Dc] -->
+            <enum name="src_atop" value="9" />
+            <!-- Multiplies the color and alpha channels of the drawable with those of
+                 the tint. [Sa * Da, Sc * Dc] -->
+            <enum name="multiply" value="14" />
+            <!-- [Sa + Da - Sa * Da, Sc + Dc - Sc * Dc] -->
+            <enum name="screen" value="15" />
+            <!-- Combines the tint and drawable color and alpha channels, clamping the
+                 result to valid color values. Saturate(S + D) -->
+            <enum name="add" value="16" />
+        </attr>
     </declare-styleable>
     <declare-styleable name="EditText">
     </declare-styleable>
@@ -3579,7 +3601,7 @@
                  result to valid color values. Saturate(S + D) -->
             <enum name="add" value="16" />
         </attr>
-        <!-- Tint to apply to the indepterminate progress indicator. -->
+        <!-- Tint to apply to the indeterminate progress indicator. -->
         <attr name="indeterminateTint" format="color" />
         <!-- Blending mode used to apply the indeterminate progress indicator tint. -->
         <attr name="indeterminateTintMode">
@@ -4887,9 +4909,9 @@
             <enum name="disabled" value="-1" />
             <!-- Replicates the edge color. -->
             <enum name="clamp" value="0" />
-            <!-- Repeats the bitmap in both direction. -->
+            <!-- Repeats the bitmap horizontally. -->
             <enum name="repeat" value="1" />
-            <!-- Repeats the shader's image horizontally and vertically, alternating
+            <!-- Repeats the shader's image horizontally, alternating
                  mirror images so that adjacent images always seam. -->
             <enum name="mirror" value="2" />
         </attr>
@@ -4900,9 +4922,9 @@
             <enum name="disabled" value="-1" />
             <!-- Replicates the edge color. -->
             <enum name="clamp" value="0" />
-            <!-- Repeats the bitmap in both direction. -->
+            <!-- Repeats the bitmap vertically. -->
             <enum name="repeat" value="1" />
-            <!-- Repeats the shader's image horizontally and vertically, alternating
+            <!-- Repeats the shader's image vertically, alternating
                  mirror images so that adjacent images always seam. -->
             <enum name="mirror" value="2" />
         </attr>
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index e4484ad..a441382 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2240,7 +2240,7 @@
   <public type="attr" name="launchTaskBehindSourceAnimation" />
   <!-- Attribute specified in a restriction entry to denote the type of restriction. -->
   <public type="attr" name="restrictionType" />
-
+  <!-- For the DatePicker -->
   <public type="attr" name="dateSelectorDayOfWeekBackgroundColor" />
   <public type="attr" name="dateSelectorDayOfWeekTextAppearance" />
   <public type="attr" name="dateSelectorBackgroundColor" />
@@ -2251,7 +2251,6 @@
   <public type="attr" name="dateSelectorYearListSelectedCircleColor" />
   <public type="attr" name="calendarTextColor" />
   <public type="attr" name="recognitionService" />
-
   <!-- For the TimePicker -->
   <public type="attr" name="timePickerStyle" />
   <public type="attr" name="timePickerDialogTheme" />
@@ -2265,8 +2264,9 @@
   <public type="attr" name="amPmTextColor" />
   <public type="attr" name="amPmUnselectedBackgroundColor" />
   <public type="attr" name="amPmSelectedBackgroundColor" />
-
   <public type="attr" name="searchKeyphraseRecognitionFlags" />
+  <public type="attr" name="checkMarkTint" />
+  <public type="attr" name="checkMarkTintMode" />
 
   <public-padding type="dimen" name="l_resource_pad" end="0x01050010" />
 
diff --git a/graphics/java/android/graphics/drawable/BitmapDrawable.java b/graphics/java/android/graphics/drawable/BitmapDrawable.java
index db5c8e3..525e01d 100644
--- a/graphics/java/android/graphics/drawable/BitmapDrawable.java
+++ b/graphics/java/android/graphics/drawable/BitmapDrawable.java
@@ -386,6 +386,7 @@
      *
      * @see #setTileModeY(android.graphics.Shader.TileMode)
      * @see #setTileModeXY(android.graphics.Shader.TileMode, android.graphics.Shader.TileMode)
+     * @attr ref android.R.styleable#BitmapDrawable_tileModeX
      */
     public void setTileModeX(Shader.TileMode mode) {
         setTileModeXY(mode, mBitmapState.mTileModeY);
@@ -401,6 +402,7 @@
      *
      * @see #setTileModeX(android.graphics.Shader.TileMode)
      * @see #setTileModeXY(android.graphics.Shader.TileMode, android.graphics.Shader.TileMode)
+     * @attr ref android.R.styleable#BitmapDrawable_tileModeY
      */
     public final void setTileModeY(Shader.TileMode mode) {
         setTileModeXY(mBitmapState.mTileModeX, mode);