Merge "Improve docs for drawable tint and color filters"
diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java
index dcbd669..badb606 100644
--- a/core/java/android/app/WallpaperManager.java
+++ b/core/java/android/app/WallpaperManager.java
@@ -188,7 +188,7 @@
}
@Override
- public void setColorFilter(ColorFilter cf) {
+ public void setColorFilter(ColorFilter colorFilter) {
throw new UnsupportedOperationException("Not supported with this drawable");
}
diff --git a/core/java/android/widget/ScrollBarDrawable.java b/core/java/android/widget/ScrollBarDrawable.java
index 6fd90c3..91d6232 100644
--- a/core/java/android/widget/ScrollBarDrawable.java
+++ b/core/java/android/widget/ScrollBarDrawable.java
@@ -339,21 +339,21 @@
}
@Override
- public void setColorFilter(ColorFilter cf) {
- mColorFilter = cf;
+ public void setColorFilter(ColorFilter colorFilter) {
+ mColorFilter = colorFilter;
mHasSetColorFilter = true;
if (mVerticalTrack != null) {
- mVerticalTrack.setColorFilter(cf);
+ mVerticalTrack.setColorFilter(colorFilter);
}
if (mVerticalThumb != null) {
- mVerticalThumb.setColorFilter(cf);
+ mVerticalThumb.setColorFilter(colorFilter);
}
if (mHorizontalTrack != null) {
- mHorizontalTrack.setColorFilter(cf);
+ mHorizontalTrack.setColorFilter(colorFilter);
}
if (mHorizontalThumb != null) {
- mHorizontalThumb.setColorFilter(cf);
+ mHorizontalThumb.setColorFilter(colorFilter);
}
}
diff --git a/core/java/com/android/internal/widget/ActionBarContainer.java b/core/java/com/android/internal/widget/ActionBarContainer.java
index 847a47d..eaf0bbc 100644
--- a/core/java/com/android/internal/widget/ActionBarContainer.java
+++ b/core/java/com/android/internal/widget/ActionBarContainer.java
@@ -384,7 +384,7 @@
}
@Override
- public void setColorFilter(ColorFilter cf) {
+ public void setColorFilter(ColorFilter colorFilter) {
}
@Override
diff --git a/graphics/java/android/graphics/PorterDuffColorFilter.java b/graphics/java/android/graphics/PorterDuffColorFilter.java
index fe4f8b8..bddd224 100644
--- a/graphics/java/android/graphics/PorterDuffColorFilter.java
+++ b/graphics/java/android/graphics/PorterDuffColorFilter.java
@@ -16,6 +16,8 @@
package android.graphics;
+import android.annotation.NonNull;
+
/**
* A color filter that can be used to tint the source pixels using a single
* color and a specific {@link PorterDuff Porter-Duff composite mode}.
@@ -34,7 +36,7 @@
* @see #setColor(int)
* @see #setMode(android.graphics.PorterDuff.Mode)
*/
- public PorterDuffColorFilter(int color, PorterDuff.Mode mode) {
+ public PorterDuffColorFilter(int color, @NonNull PorterDuff.Mode mode) {
mColor = color;
mMode = mode;
update();
@@ -93,7 +95,7 @@
*
* @hide
*/
- public void setMode(PorterDuff.Mode mode) {
+ public void setMode(@NonNull PorterDuff.Mode mode) {
mMode = mode;
update();
}
diff --git a/graphics/java/android/graphics/drawable/BitmapDrawable.java b/graphics/java/android/graphics/drawable/BitmapDrawable.java
index 945ae2e..68ffed6 100644
--- a/graphics/java/android/graphics/drawable/BitmapDrawable.java
+++ b/graphics/java/android/graphics/drawable/BitmapDrawable.java
@@ -628,8 +628,8 @@
}
@Override
- public void setColorFilter(ColorFilter cf) {
- mBitmapState.mPaint.setColorFilter(cf);
+ public void setColorFilter(ColorFilter colorFilter) {
+ mBitmapState.mPaint.setColorFilter(colorFilter);
invalidateSelf();
}
diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java
index 247f94a..2cc192c 100644
--- a/graphics/java/android/graphics/drawable/Drawable.java
+++ b/graphics/java/android/graphics/drawable/Drawable.java
@@ -17,6 +17,7 @@
package android.graphics.drawable;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
@@ -477,67 +478,111 @@
}
/**
- * @hide Consider for future API inclusion
+ * @hide
+ *
+ * Internal-only method for setting xfermode on certain supported drawables.
+ *
+ * Should not be made public since the layers and drawing area with which
+ * Drawables draw is private implementation detail, and not something apps
+ * should rely upon.
*/
public void setXfermode(Xfermode mode) {
// Base implementation drops it on the floor for compatibility. Whee!
- // TODO: For this to be included in the API proper, all framework drawables need impls.
- // For right now only BitmapDrawable has it.
}
/**
- * Specify an optional color filter for the drawable. Pass {@code null} to
- * remove any existing color filter.
+ * Specify an optional color filter for the drawable.
+ * <p>
+ * If a Drawable has a ColorFilter, each output pixel of the Drawable's
+ * drawing contents will be modified by the color filter before it is
+ * blended onto the render target of a Canvas.
+ * </p>
+ * <p>
+ * Pass {@code null} to remove any existing color filter.
+ * </p>
+ * <p class="note"><strong>Note:</strong> Setting a non-{@code null} color
+ * filter disables {@link #setTintList(ColorStateList) tint}.
+ * </p>
*
- * @param cf the color filter to apply, or {@code null} to remove the
+ * @param colorFilter The color filter to apply, or {@code null} to remove the
* existing color filter
*/
- public abstract void setColorFilter(ColorFilter cf);
+ public abstract void setColorFilter(@Nullable ColorFilter colorFilter);
/**
* Specify a color and Porter-Duff mode to be the color filter for this
* drawable.
+ * <p>
+ * Convenience for {@link #setColorFilter(ColorFilter)} which constructs a
+ * {@link PorterDuffColorFilter}.
+ * </p>
+ * <p class="note"><strong>Note:</strong> Setting a color filter disables
+ * {@link #setTintList(ColorStateList) tint}.
+ * </p>
*/
- public void setColorFilter(int color, PorterDuff.Mode mode) {
+ public void setColorFilter(int color, @NonNull PorterDuff.Mode mode) {
setColorFilter(new PorterDuffColorFilter(color, mode));
}
/**
- * Specifies a tint for this drawable.
+ * Specifies tint color for this drawable.
* <p>
- * Setting a color filter via {@link #setColorFilter(ColorFilter)} overrides
- * tint.
+ * A Drawable's drawing content will be blended together with its tint
+ * before it is drawn to the screen. This functions similarly to
+ * {@link #setColorFilter(int, PorterDuff.Mode)}.
+ * </p>
+ * <p>
+ * To clear the tint, pass {@code null} to
+ * {@link #setTintList(ColorStateList)}.
+ * </p>
+ * <p class="note"><strong>Note:</strong> Setting a color filter via
+ * {@link #setColorFilter(ColorFilter)} or
+ * {@link #setColorFilter(int, PorterDuff.Mode)} overrides tint.
+ * </p>
*
- * @param tint Color to use for tinting this drawable
+ * @param tintColor Color to use for tinting this drawable
+ * @see #setTintList(ColorStateList)
* @see #setTintMode(PorterDuff.Mode)
*/
- public void setTint(int tint) {
- setTintList(ColorStateList.valueOf(tint));
+ public void setTint(int tintColor) {
+ setTintList(ColorStateList.valueOf(tintColor));
}
/**
- * Specifies a tint for this drawable as a color state list.
+ * Specifies tint color for this drawable as a color state list.
* <p>
- * Setting a color filter via {@link #setColorFilter(ColorFilter)} overrides
- * tint.
+ * A Drawable's drawing content will be blended together with its tint
+ * before it is drawn to the screen. This functions similarly to
+ * {@link #setColorFilter(int, PorterDuff.Mode)}.
+ * </p>
+ * <p class="note"><strong>Note:</strong> Setting a color filter via
+ * {@link #setColorFilter(ColorFilter)} or
+ * {@link #setColorFilter(int, PorterDuff.Mode)} overrides tint.
+ * </p>
*
- * @param tint Color state list to use for tinting this drawable, or null to
- * clear the tint
+ * @param tint Color state list to use for tinting this drawable, or
+ * {@code null} to clear the tint
+ * @see #setTint(int)
* @see #setTintMode(PorterDuff.Mode)
*/
- public void setTintList(ColorStateList tint) {}
+ public void setTintList(@Nullable ColorStateList tint) {}
/**
* Specifies a tint blending mode for this drawable.
* <p>
- * Setting a color filter via {@link #setColorFilter(ColorFilter)} overrides
- * tint.
+ * Defines how this drawable's tint color should be blended into the drawable
+ * before it is drawn to screen. Default tint mode is {@link PorterDuff.Mode#MULTIPLY}.
+ * </p>
+ * <p class="note"><strong>Note:</strong> Setting a color filter via
+ * {@link #setColorFilter(ColorFilter)} or
+ * {@link #setColorFilter(int, PorterDuff.Mode)} overrides tint.
+ * </p>
*
- * @param tintMode Color state list to use for tinting this drawable, or null to
- * clear the tint
* @param tintMode A Porter-Duff blending mode
+ * @see #setTint(int)
+ * @see #setTintList(ColorStateList)
*/
- public void setTintMode(PorterDuff.Mode tintMode) {}
+ public void setTintMode(@NonNull PorterDuff.Mode tintMode) {}
/**
* Returns the current color filter, or {@code null} if none set.
diff --git a/graphics/java/android/graphics/drawable/DrawableContainer.java b/graphics/java/android/graphics/drawable/DrawableContainer.java
index 434134a..ddcb48b 100644
--- a/graphics/java/android/graphics/drawable/DrawableContainer.java
+++ b/graphics/java/android/graphics/drawable/DrawableContainer.java
@@ -172,14 +172,14 @@
}
@Override
- public void setColorFilter(ColorFilter cf) {
+ public void setColorFilter(ColorFilter colorFilter) {
mDrawableContainerState.mHasColorFilter = true;
- if (mDrawableContainerState.mColorFilter != cf) {
- mDrawableContainerState.mColorFilter = cf;
+ if (mDrawableContainerState.mColorFilter != colorFilter) {
+ mDrawableContainerState.mColorFilter = colorFilter;
if (mCurrDrawable != null) {
- mCurrDrawable.mutate().setColorFilter(cf);
+ mCurrDrawable.mutate().setColorFilter(colorFilter);
}
}
}
diff --git a/graphics/java/android/graphics/drawable/DrawableWrapper.java b/graphics/java/android/graphics/drawable/DrawableWrapper.java
index b17bab0..a213af8 100644
--- a/graphics/java/android/graphics/drawable/DrawableWrapper.java
+++ b/graphics/java/android/graphics/drawable/DrawableWrapper.java
@@ -238,9 +238,9 @@
}
@Override
- public void setColorFilter(@Nullable ColorFilter cf) {
+ public void setColorFilter(@Nullable ColorFilter colorFilter) {
if (mDrawable != null) {
- mDrawable.setColorFilter(cf);
+ mDrawable.setColorFilter(colorFilter);
}
}
diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java
index cc2de22..6ea23d4 100644
--- a/graphics/java/android/graphics/drawable/GradientDrawable.java
+++ b/graphics/java/android/graphics/drawable/GradientDrawable.java
@@ -832,9 +832,9 @@
}
@Override
- public void setColorFilter(ColorFilter cf) {
- if (cf != mColorFilter) {
- mColorFilter = cf;
+ public void setColorFilter(ColorFilter colorFilter) {
+ if (colorFilter != mColorFilter) {
+ mColorFilter = colorFilter;
invalidateSelf();
}
}
diff --git a/graphics/java/android/graphics/drawable/LayerDrawable.java b/graphics/java/android/graphics/drawable/LayerDrawable.java
index f5353d4..74f62be 100644
--- a/graphics/java/android/graphics/drawable/LayerDrawable.java
+++ b/graphics/java/android/graphics/drawable/LayerDrawable.java
@@ -1035,11 +1035,11 @@
}
@Override
- public void setColorFilter(ColorFilter cf) {
+ public void setColorFilter(ColorFilter colorFilter) {
final ChildDrawable[] array = mLayerState.mChildren;
final int N = mLayerState.mNum;
for (int i = 0; i < N; i++) {
- array[i].mDrawable.setColorFilter(cf);
+ array[i].mDrawable.setColorFilter(colorFilter);
}
}
diff --git a/graphics/java/android/graphics/drawable/NinePatchDrawable.java b/graphics/java/android/graphics/drawable/NinePatchDrawable.java
index 617bf7c..487162e 100644
--- a/graphics/java/android/graphics/drawable/NinePatchDrawable.java
+++ b/graphics/java/android/graphics/drawable/NinePatchDrawable.java
@@ -338,12 +338,12 @@
}
@Override
- public void setColorFilter(ColorFilter cf) {
- if (mPaint == null && cf == null) {
+ public void setColorFilter(ColorFilter colorFilter) {
+ if (mPaint == null && colorFilter == null) {
// Fast common case -- leave at no color filter.
return;
}
- getPaint().setColorFilter(cf);
+ getPaint().setColorFilter(colorFilter);
invalidateSelf();
}
diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java
index c6ea91d..b028eeb 100644
--- a/graphics/java/android/graphics/drawable/RippleDrawable.java
+++ b/graphics/java/android/graphics/drawable/RippleDrawable.java
@@ -241,8 +241,8 @@
}
@Override
- public void setColorFilter(ColorFilter cf) {
- super.setColorFilter(cf);
+ public void setColorFilter(ColorFilter colorFilter) {
+ super.setColorFilter(colorFilter);
// TODO: Should we support this?
}
diff --git a/graphics/java/android/graphics/drawable/ShapeDrawable.java b/graphics/java/android/graphics/drawable/ShapeDrawable.java
index c208c03..fc88c15 100644
--- a/graphics/java/android/graphics/drawable/ShapeDrawable.java
+++ b/graphics/java/android/graphics/drawable/ShapeDrawable.java
@@ -299,8 +299,8 @@
}
@Override
- public void setColorFilter(ColorFilter cf) {
- mShapeState.mPaint.setColorFilter(cf);
+ public void setColorFilter(ColorFilter colorFilter) {
+ mShapeState.mPaint.setColorFilter(colorFilter);
invalidateSelf();
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/FakeShadowDrawable.java b/packages/SystemUI/src/com/android/systemui/recents/views/FakeShadowDrawable.java
index 72f9001..509ad1b 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/FakeShadowDrawable.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/FakeShadowDrawable.java
@@ -159,9 +159,9 @@
}
@Override
- public void setColorFilter(ColorFilter cf) {
- mCornerShadowPaint.setColorFilter(cf);
- mEdgeShadowPaint.setColorFilter(cf);
+ public void setColorFilter(ColorFilter colorFilter) {
+ mCornerShadowPaint.setColorFilter(colorFilter);
+ mEdgeShadowPaint.setColorFilter(colorFilter);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java
index e89e15d..2d76645 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java
@@ -160,7 +160,7 @@
}
@Override
- public void setColorFilter(ColorFilter cf) {
+ public void setColorFilter(ColorFilter colorFilter) {
// noop
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardPreviewContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardPreviewContainer.java
index 287bb73..076e5f1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardPreviewContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardPreviewContainer.java
@@ -46,7 +46,7 @@
}
@Override
- public void setColorFilter(ColorFilter cf) {
+ public void setColorFilter(ColorFilter colorFilter) {
// noop
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 8aafe52..b14a70d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -2929,7 +2929,7 @@
}
@Override
- public void setColorFilter(ColorFilter cf) {
+ public void setColorFilter(ColorFilter colorFilter) {
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/TrustDrawable.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/TrustDrawable.java
index b89aa8f..56c1e10 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/TrustDrawable.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/TrustDrawable.java
@@ -120,7 +120,7 @@
}
@Override
- public void setColorFilter(ColorFilter cf) {
+ public void setColorFilter(ColorFilter colorFilter) {
throw new UnsupportedOperationException("not implemented");
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java
index 6998791..a3ebb09 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java
@@ -118,7 +118,7 @@
}
@Override
- public void setColorFilter(ColorFilter cf) {
+ public void setColorFilter(ColorFilter colorFilter) {
// Not supported.
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java
index 68ddfa6..2d04d8e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java
@@ -76,7 +76,7 @@
}
@Override
- public void setColorFilter(ColorFilter cf) {
+ public void setColorFilter(ColorFilter colorFilter) {
}
@Override