Merge "Add RemoteViews.setBlendMode and expose target methods" into sc-dev

This commit is contained in:
Stevie Kideckel
2021-02-17 17:37:38 +00:00
committed by Android (Google) Code Review
5 changed files with 31 additions and 0 deletions

View File

@@ -54709,6 +54709,7 @@ package android.widget {
method public void setAccessibilityTraversalAfter(@IdRes int, @IdRes int);
method public void setAccessibilityTraversalBefore(@IdRes int, @IdRes int);
method public void setBitmap(@IdRes int, String, android.graphics.Bitmap);
method public void setBlendMode(@IdRes int, @NonNull String, @Nullable android.graphics.BlendMode);
method public void setBoolean(@IdRes int, String, boolean);
method public void setBundle(@IdRes int, String, android.os.Bundle);
method public void setByte(@IdRes int, String, byte);

View File

@@ -24032,6 +24032,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* @see #getBackgroundTintMode()
* @see Drawable#setTintBlendMode(BlendMode)
*/
@RemotableViewMethod
public void setBackgroundTintBlendMode(@Nullable BlendMode blendMode) {
if (mBackgroundTint == null) {
mBackgroundTint = new TintInfo();
@@ -24294,6 +24295,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* @see #getForegroundTintMode()
* @see Drawable#setTintBlendMode(BlendMode)
*/
@RemotableViewMethod
public void setForegroundTintBlendMode(@Nullable BlendMode blendMode) {
if (mForegroundInfo == null) {
mForegroundInfo = new ForegroundInfo();

View File

@@ -695,6 +695,7 @@ public class ImageView extends View {
* @see #getImageTintMode()
* @see Drawable#setTintBlendMode(BlendMode)
*/
@RemotableViewMethod
public void setImageTintBlendMode(@Nullable BlendMode blendMode) {
mDrawableBlendMode = blendMode;
mHasDrawableBlendMode = true;

View File

@@ -823,6 +823,7 @@ public class ProgressBar extends View {
* @see #setIndeterminateTintList(ColorStateList)
* @see Drawable#setTintBlendMode(BlendMode)
*/
@RemotableViewMethod
public void setIndeterminateTintBlendMode(@Nullable BlendMode blendMode) {
if (mProgressTintInfo == null) {
mProgressTintInfo = new ProgressTintInfo();
@@ -1132,6 +1133,7 @@ public class ProgressBar extends View {
* @see #getProgressTintMode()
* @see Drawable#setTintBlendMode(BlendMode)
*/
@RemotableViewMethod
public void setProgressTintBlendMode(@Nullable BlendMode blendMode) {
if (mProgressTintInfo == null) {
mProgressTintInfo = new ProgressTintInfo();
@@ -1248,6 +1250,7 @@ public class ProgressBar extends View {
* @see #setProgressBackgroundTintList(ColorStateList)
* @see Drawable#setTintBlendMode(BlendMode)
*/
@RemotableViewMethod
public void setProgressBackgroundTintBlendMode(@Nullable BlendMode blendMode) {
if (mProgressTintInfo == null) {
mProgressTintInfo = new ProgressTintInfo();
@@ -1360,6 +1363,7 @@ public class ProgressBar extends View {
* @see #setSecondaryProgressTintList(ColorStateList)
* @see Drawable#setTintBlendMode(BlendMode)
*/
@RemotableViewMethod
public void setSecondaryProgressTintBlendMode(@Nullable BlendMode blendMode) {
if (mProgressTintInfo == null) {
mProgressTintInfo = new ProgressTintInfo();

View File

@@ -47,6 +47,7 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BlendMode;
import android.graphics.Outline;
import android.graphics.PointF;
import android.graphics.PorterDuff;
@@ -1054,6 +1055,8 @@ public class RemoteViews implements Parcelable, Filter {
return ColorStateList.class;
case BaseReflectionAction.ICON:
return Icon.class;
case BaseReflectionAction.BLEND_MODE:
return BlendMode.class;
default:
return null;
}
@@ -1400,6 +1403,7 @@ public class RemoteViews implements Parcelable, Filter {
static final int INTENT = 14;
static final int COLOR_STATE_LIST = 15;
static final int ICON = 16;
static final int BLEND_MODE = 17;
@UnsupportedAppUsage
String methodName;
@@ -1589,6 +1593,10 @@ public class RemoteViews implements Parcelable, Filter {
break;
case ICON:
this.value = in.readTypedObject(Icon.CREATOR);
break;
case BLEND_MODE:
this.value = BlendMode.fromValue(in.readInt());
break;
default:
break;
}
@@ -1632,6 +1640,9 @@ public class RemoteViews implements Parcelable, Filter {
case BUNDLE:
out.writeBundle((Bundle) this.value);
break;
case BLEND_MODE:
out.writeInt(BlendMode.toValue((BlendMode) this.value));
break;
case URI:
case BITMAP:
case INTENT:
@@ -4131,6 +4142,18 @@ public class RemoteViews implements Parcelable, Filter {
addAction(new BitmapReflectionAction(viewId, methodName, value));
}
/**
* Call a method taking one BlendMode on a view in the layout for this RemoteViews.
*
* @param viewId The id of the view on which to call the method.
* @param methodName The name of the method to call.
* @param value The value to pass to the method.
*/
public void setBlendMode(@IdRes int viewId, @NonNull String methodName,
@Nullable BlendMode value) {
addAction(new ReflectionAction(viewId, methodName, BaseReflectionAction.BLEND_MODE, value));
}
/**
* Call a method taking one Bundle on a view in the layout for this RemoteViews.
*