summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2014-05-21 23:50:03 -0700
committerAlan Viverette <alanv@google.com>2014-05-21 23:50:03 -0700
commite7772d313b88e9fd3366670a9c8d1b145edef344 (patch)
tree6f59d75ab2cdad4302268a4ec89ef8e3d937dd54 /graphics
parentaaddbe20e38b5698f5d375a3df5c6ee8aa71906e (diff)
downloadframeworks_base-e7772d313b88e9fd3366670a9c8d1b145edef344.zip
frameworks_base-e7772d313b88e9fd3366670a9c8d1b145edef344.tar.gz
frameworks_base-e7772d313b88e9fd3366670a9c8d1b145edef344.tar.bz2
Move setTint into Drawable, unhide getDirtyBounds on Drawable
BUG: 15089957 Change-Id: Ib622ba24b3f4bcf430e1d524895ac5cb104a232e
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/drawable/BitmapDrawable.java40
-rw-r--r--graphics/java/android/graphics/drawable/Drawable.java15
-rw-r--r--graphics/java/android/graphics/drawable/NinePatchDrawable.java45
-rw-r--r--graphics/java/android/graphics/drawable/RippleDrawable.java65
4 files changed, 58 insertions, 107 deletions
diff --git a/graphics/java/android/graphics/drawable/BitmapDrawable.java b/graphics/java/android/graphics/drawable/BitmapDrawable.java
index 6755f3e..f3fcf2c 100644
--- a/graphics/java/android/graphics/drawable/BitmapDrawable.java
+++ b/graphics/java/android/graphics/drawable/BitmapDrawable.java
@@ -28,6 +28,7 @@ import android.graphics.ColorFilter;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PixelFormat;
+import android.graphics.PorterDuff;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
@@ -588,47 +589,22 @@ public class BitmapDrawable extends Drawable {
return mBitmapState.mPaint.getColorFilter();
}
- /**
- * Specifies a tint for this drawable.
- * <p>
- * Setting a color filter via {@link #setColorFilter(ColorFilter)} overrides
- * tint.
- *
- * @param tint Color state list to use for tinting this drawable, or null to
- * clear the tint
- */
- public void setTint(ColorStateList tint) {
- if (mBitmapState.mTint != tint) {
- mBitmapState.mTint = tint;
- computeTintFilter();
- invalidateSelf();
- }
+ @Override
+ public void setTint(ColorStateList tint, PorterDuff.Mode tintMode) {
+ mBitmapState.mTint = tint;
+ mBitmapState.mTintMode = tintMode;
+ computeTintFilter();
+ invalidateSelf();
}
/**
- * Returns the tint color for this drawable.
- *
- * @return Color state list to use for tinting this drawable, or null if
- * none set
+ * @hide only needed by a hack within ProgressBar
*/
public ColorStateList getTint() {
return mBitmapState.mTint;
}
/**
- * Specifies the blending mode used to apply tint.
- *
- * @param tintMode A Porter-Duff blending mode
- */
- public void setTintMode(Mode tintMode) {
- if (mBitmapState.mTintMode != tintMode) {
- mBitmapState.mTintMode = tintMode;
- computeTintFilter();
- invalidateSelf();
- }
- }
-
- /**
* @hide only needed by a hack within ProgressBar
*/
public Mode getTintMode() {
diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java
index d6fb9e0..cc2a595 100644
--- a/graphics/java/android/graphics/drawable/Drawable.java
+++ b/graphics/java/android/graphics/drawable/Drawable.java
@@ -24,6 +24,7 @@ import android.os.Trace;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
+import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.content.res.TypedArray;
@@ -226,7 +227,7 @@ public abstract class Drawable {
* By default, this returns the full drawable bounds. Custom drawables may
* override this method to perform more precise invalidation.
*
- * @hide
+ * @return The dirty bounds of this drawable
*/
public Rect getDirtyBounds() {
return getBounds();
@@ -469,6 +470,18 @@ public abstract class Drawable {
}
/**
+ * Specifies a tint and blending mode for this drawable.
+ * <p>
+ * Setting a color filter via {@link #setColorFilter(ColorFilter)} overrides
+ * tint.
+ *
+ * @param tint Color state list to use for tinting this drawable, or null to
+ * clear the tint
+ * @param tintMode A Porter-Duff blending mode
+ */
+ public void setTint(ColorStateList tint, PorterDuff.Mode tintMode) {}
+
+ /**
* Returns the current color filter, or {@code null} if none set.
*
* @return the current color filter, or {@code null} if none set
diff --git a/graphics/java/android/graphics/drawable/NinePatchDrawable.java b/graphics/java/android/graphics/drawable/NinePatchDrawable.java
index 3e09707..0a07332 100644
--- a/graphics/java/android/graphics/drawable/NinePatchDrawable.java
+++ b/graphics/java/android/graphics/drawable/NinePatchDrawable.java
@@ -28,6 +28,7 @@ import android.graphics.Insets;
import android.graphics.NinePatch;
import android.graphics.Paint;
import android.graphics.PixelFormat;
+import android.graphics.PorterDuff;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
@@ -327,44 +328,12 @@ public class NinePatchDrawable extends Drawable {
invalidateSelf();
}
- /**
- * Specifies a tint for this drawable.
- * <p>
- * Setting a color filter via {@link #setColorFilter(ColorFilter)} overrides
- * tint.
- *
- * @param tint Color state list to use for tinting this drawable, or null to
- * clear the tint
- */
- public void setTint(ColorStateList tint) {
- if (mNinePatchState.mTint != tint) {
- mNinePatchState.mTint = tint;
- computeTintFilter();
- invalidateSelf();
- }
- }
-
- /**
- * Returns the tint color for this drawable.
- *
- * @return Color state list to use for tinting this drawable, or null if
- * none set
- */
- public ColorStateList getTint() {
- return mNinePatchState.mTint;
- }
-
- /**
- * Specifies the blending mode used to apply tint.
- *
- * @param tintMode A Porter-Duff blending mode
- */
- public void setTintMode(Mode tintMode) {
- if (mNinePatchState.mTintMode != tintMode) {
- mNinePatchState.mTintMode = tintMode;
- computeTintFilter();
- invalidateSelf();
- }
+ @Override
+ public void setTint(ColorStateList tint, PorterDuff.Mode tintMode) {
+ mNinePatchState.mTint = tint;
+ mNinePatchState.mTintMode = tintMode;
+ computeTintFilter();
+ invalidateSelf();
}
private void computeTintFilter() {
diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java
index add3d84..1bd7cac 100644
--- a/graphics/java/android/graphics/drawable/RippleDrawable.java
+++ b/graphics/java/android/graphics/drawable/RippleDrawable.java
@@ -207,35 +207,9 @@ public class RippleDrawable extends LayerDrawable {
return true;
}
- /**
- * Specifies a tint for drawing touch feedback ripples.
- *
- * @param tint Color state list to use for tinting touch feedback ripples,
- * or null to clear the tint
- */
- public void setTint(ColorStateList tint) {
- if (mState.mTint != tint) {
- mState.mTint = tint;
- invalidateSelf();
- }
- }
-
- /**
- * Returns the tint color for touch feedback ripples.
- *
- * @return Color state list to use for tinting touch feedback ripples, or
- * null if none set
- */
- public ColorStateList getTint() {
- return mState.mTint;
- }
-
- /**
- * Specifies the blending mode used to draw touch feedback ripples.
- *
- * @param tintMode A Porter-Duff blending mode
- */
- public void setTintMode(Mode tintMode) {
+ @Override
+ public void setTint(ColorStateList tint, Mode tintMode) {
+ mState.mTint = tint;
mState.setTintMode(tintMode);
invalidateSelf();
}
@@ -243,11 +217,13 @@ public class RippleDrawable extends LayerDrawable {
@Override
public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Theme theme)
throws XmlPullParserException, IOException {
- final TypedArray a = obtainAttributes(
- r, theme, attrs, R.styleable.RippleDrawable);
+ final TypedArray a = obtainAttributes(r, theme, attrs, R.styleable.RippleDrawable);
updateStateFromTypedArray(a);
a.recycle();
+ // Force padding default to STACK before inflating.
+ setPaddingMode(PADDING_MODE_STACK);
+
super.inflate(r, parser, attrs, theme);
setTargetDensity(r.getDisplayMetrics());
@@ -275,6 +251,25 @@ public class RippleDrawable extends LayerDrawable {
}
/**
+ * Specifies how layer padding should affect the bounds of subsequent
+ * layers. The default and recommended value for RippleDrawable is
+ * {@link #PADDING_MODE_STACK}.
+ *
+ * @param mode padding mode, one of:
+ * <ul>
+ * <li>{@link #PADDING_MODE_NEST} to nest each layer inside the
+ * padding of the previous layer
+ * <li>{@link #PADDING_MODE_STACK} to stack each layer directly
+ * atop the previous layer
+ * </ul>
+ * @see #getPaddingMode()
+ */
+ @Override
+ public void setPaddingMode(int mode) {
+ super.setPaddingMode(mode);
+ }
+
+ /**
* Initializes the constant state from the values in the typed array.
*/
private void updateStateFromTypedArray(TypedArray a) {
@@ -643,8 +638,7 @@ public class RippleDrawable extends LayerDrawable {
Drawable mMask;
boolean mPinned = false;
- public RippleState(
- RippleState orig, RippleDrawable owner, Resources res) {
+ public RippleState(RippleState orig, RippleDrawable owner, Resources res) {
super(orig, owner, res);
if (orig != null) {
@@ -653,7 +647,6 @@ public class RippleDrawable extends LayerDrawable {
mTintXfermode = orig.mTintXfermode;
mTintXfermodeInverse = orig.mTintXfermodeInverse;
mPinned = orig.mPinned;
- mMask = orig.mMask;
}
}
@@ -740,6 +733,8 @@ public class RippleDrawable extends LayerDrawable {
}
mState = ns;
+ mState.mMask = findDrawableByLayerId(R.id.mask);
+
mLayerState = ns;
if (ns.mNum > 0) {
@@ -749,7 +744,5 @@ public class RippleDrawable extends LayerDrawable {
if (needsTheme) {
applyTheme(theme);
}
-
- setPaddingMode(PADDING_MODE_STACK);
}
}