summaryrefslogtreecommitdiff
path: root/core/java/android/widget/CompoundButton.java
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2014-07-21 17:49:13 -0700
committerAlan Viverette <alanv@google.com>2014-07-22 01:03:58 +0000
commit4f64c048505a432e549ccb756634ecebf28f9e80 (patch)
tree4ee51f737ee62e464f4b65e64608c9e9e5e0b42b /core/java/android/widget/CompoundButton.java
parent0d964e77b9a204417d0a24dcbacd354f9de589d9 (diff)
Clean up view tinting APIs, tileModeX/Y attribute docs
BUG: 16400590 BUG: 16403307 Change-Id: Ie924815a39eb0e683d1982b08ec478ed3edbfb7b
Diffstat (limited to 'core/java/android/widget/CompoundButton.java')
-rw-r--r--core/java/android/widget/CompoundButton.java49
1 files changed, 16 insertions, 33 deletions
diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java
index 9ba0fe1a55ba..a45777eba8cb 100644
--- a/core/java/android/widget/CompoundButton.java
+++ b/core/java/android/widget/CompoundButton.java
@@ -87,10 +87,11 @@ public abstract class CompoundButton extends Button implements Checkable {
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 @@ public abstract class CompoundButton extends Button implements Checkable {
}
/**
- * Applies a tint to the button drawable.
+ * 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
- * @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)
+ * @see #setButtonTint(ColorStateList)
+ * @see Drawable#setTint(ColorStateList, PorterDuff.Mode)
*/
- private void setButtonTint(@Nullable ColorStateList tint,
- @Nullable PorterDuff.Mode tintMode) {
+ public void setButtonTint(@Nullable ColorStateList tint) {
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)}.
- *
- * @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)
- */
- public void setButtonTint(@Nullable ColorStateList tint) {
- setButtonTint(tint, mButtonTintMode);
- }
-
- /**
* @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 @@ public abstract class CompoundButton extends Button implements Checkable {
* @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() {