Merge "Update supported Drawable tinting modes and docs"
This commit is contained in:
committed by
Android (Google) Code Review
commit
514d4aaf53
@@ -10632,6 +10632,7 @@ package android.graphics.drawable {
|
||||
method public void setTileModeXY(android.graphics.Shader.TileMode, android.graphics.Shader.TileMode);
|
||||
method public final void setTileModeY(android.graphics.Shader.TileMode);
|
||||
method public void setTint(android.content.res.ColorStateList);
|
||||
method public void setTintMode(android.graphics.PorterDuff.Mode);
|
||||
}
|
||||
|
||||
public class ClipDrawable extends android.graphics.drawable.Drawable implements android.graphics.drawable.Drawable.Callback {
|
||||
@@ -10909,6 +10910,7 @@ package android.graphics.drawable {
|
||||
method public void setTargetDensity(android.util.DisplayMetrics);
|
||||
method public void setTargetDensity(int);
|
||||
method public void setTint(android.content.res.ColorStateList);
|
||||
method public void setTintMode(android.graphics.PorterDuff.Mode);
|
||||
}
|
||||
|
||||
public class PaintDrawable extends android.graphics.drawable.ShapeDrawable {
|
||||
@@ -10999,6 +11001,9 @@ package android.graphics.drawable {
|
||||
|
||||
public class TouchFeedbackDrawable extends android.graphics.drawable.LayerDrawable {
|
||||
method public android.graphics.Rect getDirtyBounds();
|
||||
method public android.content.res.ColorStateList getTint();
|
||||
method public void setTint(android.content.res.ColorStateList);
|
||||
method public void setTintMode(android.graphics.PorterDuff.Mode);
|
||||
}
|
||||
|
||||
public class TransitionDrawable extends android.graphics.drawable.LayerDrawable implements android.graphics.drawable.Drawable.Callback {
|
||||
|
||||
@@ -4409,14 +4409,23 @@
|
||||
<!-- When a tint color is set, specifies its Porter-Duff blending mode. The
|
||||
default value is src_in, which treats the drawable as an alpha mask. -->
|
||||
<attr name="tintMode">
|
||||
<!-- [Sa * Da, Sc * Da] -->
|
||||
<enum name="src_in" value="0" />
|
||||
<!-- [Da, Sc * Da + (1 - Sa) * Dc] -->
|
||||
<enum name="src_atop" value="1" />
|
||||
<!-- [Sa * Da, Sc * Dc] -->
|
||||
<enum name="multiply" value="2" />
|
||||
<!-- 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="3" />
|
||||
<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>
|
||||
|
||||
|
||||
@@ -595,7 +595,6 @@ public class BitmapDrawable extends Drawable {
|
||||
* Specifies the blending mode used to apply tint.
|
||||
*
|
||||
* @param tintMode A Porter-Duff blending mode
|
||||
* @hide Pending finalization of supported Modes
|
||||
*/
|
||||
public void setTintMode(Mode tintMode) {
|
||||
if (mBitmapState.mTintMode != tintMode) {
|
||||
@@ -606,10 +605,7 @@ public class BitmapDrawable extends Drawable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tint mode for this drawable, or {@code null} if none set.
|
||||
*
|
||||
* @return the tint mode for this drawable, or {@code null} if none set
|
||||
* @hide
|
||||
* @hide only needed by a hack within ProgressBar
|
||||
*/
|
||||
public Mode getTintMode() {
|
||||
return mBitmapState.mTintMode;
|
||||
|
||||
@@ -1248,16 +1248,14 @@ public abstract class Drawable {
|
||||
*/
|
||||
static PorterDuff.Mode parseTintMode(int value, Mode defaultMode) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return Mode.SRC_IN;
|
||||
case 1:
|
||||
return Mode.SRC_ATOP;
|
||||
case 2:
|
||||
return Mode.MULTIPLY;
|
||||
case 3:
|
||||
return Mode.SCREEN;
|
||||
case 3: return Mode.SRC_OVER;
|
||||
case 5: return Mode.SRC_IN;
|
||||
case 9: return Mode.SRC_ATOP;
|
||||
case 14: return Mode.MULTIPLY;
|
||||
case 15: return Mode.SCREEN;
|
||||
case 16: return Mode.ADD;
|
||||
default: return defaultMode;
|
||||
}
|
||||
return defaultMode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -345,7 +345,6 @@ public class NinePatchDrawable extends Drawable {
|
||||
* Specifies the blending mode used to apply tint.
|
||||
*
|
||||
* @param tintMode A Porter-Duff blending mode
|
||||
* @hide Pending finalization of supported Modes
|
||||
*/
|
||||
public void setTintMode(Mode tintMode) {
|
||||
if (mNinePatchState.mTintMode != tintMode) {
|
||||
|
||||
@@ -124,6 +124,41 @@ public class TouchFeedbackDrawable extends LayerDrawable {
|
||||
return super.isStateful() || mState.mTint != null && mState.mTint.isStateful();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
if (mState.mTintMode != tintMode) {
|
||||
mState.mTintMode = tintMode;
|
||||
invalidateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Theme theme)
|
||||
throws XmlPullParserException, IOException {
|
||||
|
||||
Reference in New Issue
Block a user