summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ioana Alexandru <aioana@google.com> 2023-10-05 11:40:16 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-10-05 11:40:16 +0000
commit3c9a809e83eef8e0088db393d5f63ac8a0a5e3ff (patch)
tree5767480648fbd0703448702901973a63ddab50e4
parent67890dbee5f9d2cab296fd2037fc69034b6a5d50 (diff)
parent0bf8a7d8eefb1716c3364ebb395cacc952dc6d23 (diff)
Merge "Fix RemoteViews.java style." into main
-rw-r--r--core/java/android/widget/RemoteViews.java813
1 files changed, 399 insertions, 414 deletions
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 79acfbb0b39c..103725da9af0 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -638,9 +638,13 @@ public class RemoteViews implements Parcelable, Filter {
* Base class for all actions that can be performed on an
* inflated view.
*
- * SUBCLASSES MUST BE IMMUTABLE SO CLONE WORKS!!!!!
+ * SUBCLASSES MUST BE IMMUTABLE SO CLONE WORKS!!!!!
*/
private abstract static class Action implements Parcelable {
+ @IdRes
+ @UnsupportedAppUsage
+ int mViewId;
+
public abstract void apply(View root, ViewGroup rootParent, ActionApplyParams params)
throws ActionException;
@@ -664,7 +668,7 @@ public class RemoteViews implements Parcelable, Filter {
public abstract int getActionTag();
public String getUniqueKey() {
- return (getActionTag() + "_" + viewId);
+ return (getActionTag() + "_" + mViewId);
}
/**
@@ -684,16 +688,12 @@ public class RemoteViews implements Parcelable, Filter {
public void visitUris(@NonNull Consumer<Uri> visitor) {
// Nothing to visit by default
}
-
- @IdRes
- @UnsupportedAppUsage
- int viewId;
}
/**
* Action class used during async inflation of RemoteViews. Subclasses are not parcelable.
*/
- private static abstract class RuntimeAction extends Action {
+ private abstract static class RuntimeAction extends Action {
@Override
public final int getActionTag() {
return 0;
@@ -796,15 +796,16 @@ public class RemoteViews implements Parcelable, Filter {
for (int i = 0; i < mActions.size(); i++) {
Action action = mActions.get(i);
if (action instanceof SetRemoteCollectionItemListAdapterAction itemsAction
- && itemsAction.viewId == viewId
+ && itemsAction.mViewId == viewId
&& itemsAction.mServiceIntent != null) {
- mActions.set(i, new SetRemoteCollectionItemListAdapterAction(itemsAction.viewId,
- itemsAction.mServiceIntent));
+ mActions.set(i,
+ new SetRemoteCollectionItemListAdapterAction(itemsAction.mViewId,
+ itemsAction.mServiceIntent));
isActionReplaced = true;
} else if (action instanceof SetRemoteViewsAdapterIntent intentAction
- && intentAction.viewId == viewId) {
+ && intentAction.mViewId == viewId) {
mActions.set(i, new SetRemoteCollectionItemListAdapterAction(
- intentAction.viewId, intentAction.intent));
+ intentAction.mViewId, intentAction.mIntent));
isActionReplaced = true;
} else if (action instanceof ViewGroupActionAdd groupAction
&& groupAction.mNestedViews != null) {
@@ -838,7 +839,7 @@ public class RemoteViews implements Parcelable, Filter {
if ((action instanceof SetRemoteCollectionItemListAdapterAction itemsAction
&& itemsAction.mServiceIntent != null)
|| (action instanceof SetRemoteViewsAdapterIntent intentAction
- && intentAction.intent != null)
+ && intentAction.mIntent != null)
|| (action instanceof ViewGroupActionAdd groupAction
&& groupAction.mNestedViews != null
&& groupAction.mNestedViews.hasLegacyLists())) {
@@ -856,11 +857,7 @@ public class RemoteViews implements Parcelable, Filter {
if (mLandscape != null && mLandscape.hasLegacyLists()) {
return true;
}
- if (mPortrait != null && mPortrait.hasLegacyLists()) {
- return true;
- }
-
- return false;
+ return mPortrait != null && mPortrait.hasLegacyLists();
}
private static void visitIconUri(Icon icon, @NonNull Consumer<Uri> visitor) {
@@ -913,31 +910,31 @@ public class RemoteViews implements Parcelable, Filter {
}
private static class SetEmptyView extends Action {
- int emptyViewId;
+ int mEmptyViewId;
SetEmptyView(@IdRes int viewId, @IdRes int emptyViewId) {
- this.viewId = viewId;
- this.emptyViewId = emptyViewId;
+ this.mViewId = viewId;
+ this.mEmptyViewId = emptyViewId;
}
SetEmptyView(Parcel in) {
- this.viewId = in.readInt();
- this.emptyViewId = in.readInt();
+ this.mViewId = in.readInt();
+ this.mEmptyViewId = in.readInt();
}
public void writeToParcel(Parcel out, int flags) {
- out.writeInt(this.viewId);
- out.writeInt(this.emptyViewId);
+ out.writeInt(this.mViewId);
+ out.writeInt(this.mEmptyViewId);
}
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params) {
- final View view = root.findViewById(viewId);
+ final View view = root.findViewById(mViewId);
if (!(view instanceof AdapterView<?>)) return;
AdapterView<?> adapterView = (AdapterView<?>) view;
- final View emptyView = root.findViewById(emptyViewId);
+ final View emptyView = root.findViewById(mEmptyViewId);
if (emptyView == null) return;
adapterView.setEmptyView(emptyView);
@@ -950,24 +947,27 @@ public class RemoteViews implements Parcelable, Filter {
}
private static class SetPendingIntentTemplate extends Action {
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
+ PendingIntent mPendingIntentTemplate;
+
public SetPendingIntentTemplate(@IdRes int id, PendingIntent pendingIntentTemplate) {
- this.viewId = id;
- this.pendingIntentTemplate = pendingIntentTemplate;
+ this.mViewId = id;
+ this.mPendingIntentTemplate = pendingIntentTemplate;
}
public SetPendingIntentTemplate(Parcel parcel) {
- viewId = parcel.readInt();
- pendingIntentTemplate = PendingIntent.readPendingIntentOrNullFromParcel(parcel);
+ mViewId = parcel.readInt();
+ mPendingIntentTemplate = PendingIntent.readPendingIntentOrNullFromParcel(parcel);
}
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(viewId);
- PendingIntent.writePendingIntentOrNullToParcel(pendingIntentTemplate, dest);
+ dest.writeInt(mViewId);
+ PendingIntent.writePendingIntentOrNullToParcel(mPendingIntentTemplate, dest);
}
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params) {
- final View target = root.findViewById(viewId);
+ final View target = root.findViewById(mViewId);
if (target == null) return;
// If the view isn't an AdapterView, setting a PendingIntent template doesn't make sense
@@ -981,10 +981,10 @@ public class RemoteViews implements Parcelable, Filter {
}
};
av.setOnItemClickListener(listener);
- av.setTag(pendingIntentTemplate);
+ av.setTag(mPendingIntentTemplate);
} else {
Log.e(LOG_TAG, "Cannot setPendingIntentTemplate on a view which is not" +
- "an AdapterView (id: " + viewId + ")");
+ "an AdapterView (id: " + mViewId + ")");
return;
}
}
@@ -1015,65 +1015,65 @@ public class RemoteViews implements Parcelable, Filter {
public int getActionTag() {
return SET_PENDING_INTENT_TEMPLATE_TAG;
}
-
- @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
- PendingIntent pendingIntentTemplate;
}
private static class SetRemoteViewsAdapterList extends Action {
+ int mViewTypeCount;
+ ArrayList<RemoteViews> mList;
+
public SetRemoteViewsAdapterList(@IdRes int id, ArrayList<RemoteViews> list,
int viewTypeCount) {
- this.viewId = id;
- this.list = list;
- this.viewTypeCount = viewTypeCount;
+ this.mViewId = id;
+ this.mList = list;
+ this.mViewTypeCount = viewTypeCount;
}
public SetRemoteViewsAdapterList(Parcel parcel) {
- viewId = parcel.readInt();
- viewTypeCount = parcel.readInt();
- list = parcel.createTypedArrayList(RemoteViews.CREATOR);
+ mViewId = parcel.readInt();
+ mViewTypeCount = parcel.readInt();
+ mList = parcel.createTypedArrayList(RemoteViews.CREATOR);
}
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(viewId);
- dest.writeInt(viewTypeCount);
- dest.writeTypedList(list, flags);
+ dest.writeInt(mViewId);
+ dest.writeInt(mViewTypeCount);
+ dest.writeTypedList(mList, flags);
}
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params) {
- final View target = root.findViewById(viewId);
+ final View target = root.findViewById(mViewId);
if (target == null) return;
// Ensure that we are applying to an AppWidget root
if (!(rootParent instanceof AppWidgetHostView)) {
Log.e(LOG_TAG, "SetRemoteViewsAdapterIntent action can only be used for " +
- "AppWidgets (root id: " + viewId + ")");
+ "AppWidgets (root id: " + mViewId + ")");
return;
}
// Ensure that we are calling setRemoteAdapter on an AdapterView that supports it
if (!(target instanceof AbsListView) && !(target instanceof AdapterViewAnimator)) {
Log.e(LOG_TAG, "Cannot setRemoteViewsAdapter on a view which is not " +
- "an AbsListView or AdapterViewAnimator (id: " + viewId + ")");
+ "an AbsListView or AdapterViewAnimator (id: " + mViewId + ")");
return;
}
if (target instanceof AbsListView) {
AbsListView v = (AbsListView) target;
Adapter a = v.getAdapter();
- if (a instanceof RemoteViewsListAdapter && viewTypeCount <= a.getViewTypeCount()) {
- ((RemoteViewsListAdapter) a).setViewsList(list);
+ if (a instanceof RemoteViewsListAdapter && mViewTypeCount <= a.getViewTypeCount()) {
+ ((RemoteViewsListAdapter) a).setViewsList(mList);
} else {
- v.setAdapter(new RemoteViewsListAdapter(v.getContext(), list, viewTypeCount,
+ v.setAdapter(new RemoteViewsListAdapter(v.getContext(), mList, mViewTypeCount,
params.colorResources));
}
} else if (target instanceof AdapterViewAnimator) {
AdapterViewAnimator v = (AdapterViewAnimator) target;
Adapter a = v.getAdapter();
- if (a instanceof RemoteViewsListAdapter && viewTypeCount <= a.getViewTypeCount()) {
- ((RemoteViewsListAdapter) a).setViewsList(list);
+ if (a instanceof RemoteViewsListAdapter && mViewTypeCount <= a.getViewTypeCount()) {
+ ((RemoteViewsListAdapter) a).setViewsList(mList);
} else {
- v.setAdapter(new RemoteViewsListAdapter(v.getContext(), list, viewTypeCount,
+ v.setAdapter(new RemoteViewsListAdapter(v.getContext(), mList, mViewTypeCount,
params.colorResources));
}
}
@@ -1086,11 +1086,8 @@ public class RemoteViews implements Parcelable, Filter {
@Override
public String getUniqueKey() {
- return (SET_REMOTE_ADAPTER_TAG + "_" + viewId);
+ return (SET_REMOTE_ADAPTER_TAG + "_" + mViewId);
}
-
- int viewTypeCount;
- ArrayList<RemoteViews> list;
}
/**
@@ -1135,19 +1132,20 @@ public class RemoteViews implements Parcelable, Filter {
}
private class SetRemoteCollectionItemListAdapterAction extends Action {
- private @NonNull CompletableFuture<RemoteCollectionItems> mItemsFuture;
+ @NonNull
+ private CompletableFuture<RemoteCollectionItems> mItemsFuture;
final Intent mServiceIntent;
SetRemoteCollectionItemListAdapterAction(@IdRes int id,
@NonNull RemoteCollectionItems items) {
- viewId = id;
+ mViewId = id;
items.setHierarchyRootData(getHierarchyRootData());
mItemsFuture = CompletableFuture.completedFuture(items);
mServiceIntent = null;
}
SetRemoteCollectionItemListAdapterAction(@IdRes int id, Intent intent) {
- viewId = id;
+ mViewId = id;
mItemsFuture = getItemsFutureFromIntentWithTimeout(intent);
setHierarchyRootData(getHierarchyRootData());
mServiceIntent = intent;
@@ -1196,7 +1194,7 @@ public class RemoteViews implements Parcelable, Filter {
}
SetRemoteCollectionItemListAdapterAction(Parcel parcel) {
- viewId = parcel.readInt();
+ mViewId = parcel.readInt();
mItemsFuture = CompletableFuture.completedFuture(
new RemoteCollectionItems(parcel, getHierarchyRootData()));
mServiceIntent = parcel.readTypedObject(Intent.CREATOR);
@@ -1226,7 +1224,7 @@ public class RemoteViews implements Parcelable, Filter {
@Override
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(viewId);
+ dest.writeInt(mViewId);
RemoteCollectionItems items = getCollectionItemsFromFuture(mItemsFuture);
items.writeToParcel(dest, flags, /* attached= */ true);
dest.writeTypedObject(mServiceIntent, flags);
@@ -1235,7 +1233,7 @@ public class RemoteViews implements Parcelable, Filter {
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params)
throws ActionException {
- View target = root.findViewById(viewId);
+ View target = root.findViewById(mViewId);
if (target == null) return;
RemoteCollectionItems items = getCollectionItemsFromFuture(mItemsFuture);
@@ -1243,13 +1241,13 @@ public class RemoteViews implements Parcelable, Filter {
// Ensure that we are applying to an AppWidget root
if (!(rootParent instanceof AppWidgetHostView)) {
Log.e(LOG_TAG, "setRemoteAdapter can only be used for "
- + "AppWidgets (root id: " + viewId + ")");
+ + "AppWidgets (root id: " + mViewId + ")");
return;
}
if (!(target instanceof AdapterView)) {
Log.e(LOG_TAG, "Cannot call setRemoteAdapter on a view which is not "
- + "an AdapterView (id: " + viewId + ")");
+ + "an AdapterView (id: " + mViewId + ")");
return;
}
@@ -1289,59 +1287,62 @@ public class RemoteViews implements Parcelable, Filter {
@Override
public String getUniqueKey() {
- return (SET_REMOTE_ADAPTER_TAG + "_" + viewId);
+ return (SET_REMOTE_ADAPTER_TAG + "_" + mViewId);
}
}
private class SetRemoteViewsAdapterIntent extends Action {
+ Intent mIntent;
+ boolean mIsAsync = false;
+
public SetRemoteViewsAdapterIntent(@IdRes int id, Intent intent) {
- this.viewId = id;
- this.intent = intent;
+ this.mViewId = id;
+ this.mIntent = intent;
}
public SetRemoteViewsAdapterIntent(Parcel parcel) {
- viewId = parcel.readInt();
- intent = parcel.readTypedObject(Intent.CREATOR);
+ mViewId = parcel.readInt();
+ mIntent = parcel.readTypedObject(Intent.CREATOR);
}
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(viewId);
- dest.writeTypedObject(intent, flags);
+ dest.writeInt(mViewId);
+ dest.writeTypedObject(mIntent, flags);
}
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params) {
- final View target = root.findViewById(viewId);
+ final View target = root.findViewById(mViewId);
if (target == null) return;
// Ensure that we are applying to an AppWidget root
if (!(rootParent instanceof AppWidgetHostView)) {
Log.e(LOG_TAG, "setRemoteAdapter can only be used for "
- + "AppWidgets (root id: " + viewId + ")");
+ + "AppWidgets (root id: " + mViewId + ")");
return;
}
// Ensure that we are calling setRemoteAdapter on an AdapterView that supports it
if (!(target instanceof AbsListView) && !(target instanceof AdapterViewAnimator)) {
Log.e(LOG_TAG, "Cannot setRemoteAdapter on a view which is not "
- + "an AbsListView or AdapterViewAnimator (id: " + viewId + ")");
+ + "an AbsListView or AdapterViewAnimator (id: " + mViewId + ")");
return;
}
// Embed the AppWidget Id for use in RemoteViewsAdapter when connecting to the intent
// RemoteViewsService
AppWidgetHostView host = (AppWidgetHostView) rootParent;
- intent.putExtra(EXTRA_REMOTEADAPTER_APPWIDGET_ID, host.getAppWidgetId())
+ mIntent.putExtra(EXTRA_REMOTEADAPTER_APPWIDGET_ID, host.getAppWidgetId())
.putExtra(EXTRA_REMOTEADAPTER_ON_LIGHT_BACKGROUND,
hasFlags(FLAG_USE_LIGHT_BACKGROUND_LAYOUT));
if (target instanceof AbsListView) {
AbsListView v = (AbsListView) target;
- v.setRemoteViewsAdapter(intent, isAsync);
+ v.setRemoteViewsAdapter(mIntent, mIsAsync);
v.setRemoteViewsInteractionHandler(params.handler);
} else if (target instanceof AdapterViewAnimator) {
AdapterViewAnimator v = (AdapterViewAnimator) target;
- v.setRemoteViewsAdapter(intent, isAsync);
+ v.setRemoteViewsAdapter(mIntent, mIsAsync);
v.setRemoteViewsOnClickHandler(params.handler);
}
}
@@ -1349,8 +1350,8 @@ public class RemoteViews implements Parcelable, Filter {
@Override
public Action initActionAsync(ViewTree root, ViewGroup rootParent,
ActionApplyParams params) {
- SetRemoteViewsAdapterIntent copy = new SetRemoteViewsAdapterIntent(viewId, intent);
- copy.isAsync = true;
+ SetRemoteViewsAdapterIntent copy = new SetRemoteViewsAdapterIntent(mViewId, mIntent);
+ copy.mIsAsync = true;
return copy;
}
@@ -1358,9 +1359,6 @@ public class RemoteViews implements Parcelable, Filter {
public int getActionTag() {
return SET_REMOTE_VIEW_ADAPTER_INTENT_TAG;
}
-
- Intent intent;
- boolean isAsync = false;
}
/**
@@ -1369,26 +1367,27 @@ public class RemoteViews implements Parcelable, Filter {
* to launch the provided {@link PendingIntent}.
*/
private class SetOnClickResponse extends Action {
+ final RemoteResponse mResponse;
SetOnClickResponse(@IdRes int id, RemoteResponse response) {
- this.viewId = id;
+ this.mViewId = id;
this.mResponse = response;
}
SetOnClickResponse(Parcel parcel) {
- viewId = parcel.readInt();
+ mViewId = parcel.readInt();
mResponse = new RemoteResponse();
mResponse.readFromParcel(parcel);
}
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(viewId);
+ dest.writeInt(mViewId);
mResponse.writeToParcel(dest, flags);
}
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params) {
- final View target = root.findViewById(viewId);
+ final View target = root.findViewById(mViewId);
if (target == null) return;
if (mResponse.mPendingIntent != null) {
@@ -1397,7 +1396,7 @@ public class RemoteViews implements Parcelable, Filter {
// AdapterView's children?
if (hasFlags(FLAG_WIDGET_IS_COLLECTION_CHILD)) {
Log.w(LOG_TAG, "Cannot SetOnClickResponse for collection item "
- + "(id: " + viewId + ")");
+ + "(id: " + mViewId + ")");
ApplicationInfo appInfo = root.getContext().getApplicationInfo();
// We let this slide for HC and ICS so as to not break compatibility. It should
@@ -1435,8 +1434,6 @@ public class RemoteViews implements Parcelable, Filter {
public int getActionTag() {
return SET_ON_CLICK_RESPONSE_TAG;
}
-
- final RemoteResponse mResponse;
}
/**
@@ -1446,32 +1443,31 @@ public class RemoteViews implements Parcelable, Filter {
* to launch the provided {@link PendingIntent}.
*/
private class SetOnCheckedChangeResponse extends Action {
-
private final RemoteResponse mResponse;
SetOnCheckedChangeResponse(@IdRes int id, RemoteResponse response) {
- this.viewId = id;
+ this.mViewId = id;
this.mResponse = response;
}
SetOnCheckedChangeResponse(Parcel parcel) {
- viewId = parcel.readInt();
+ mViewId = parcel.readInt();
mResponse = new RemoteResponse();
mResponse.readFromParcel(parcel);
}
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(viewId);
+ dest.writeInt(mViewId);
mResponse.writeToParcel(dest, flags);
}
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params) {
- final View target = root.findViewById(viewId);
+ final View target = root.findViewById(mViewId);
if (target == null) return;
if (!(target instanceof CompoundButton)) {
Log.w(LOG_TAG, "setOnCheckedChange methods cannot be used on "
- + "non-CompoundButton child (id: " + viewId + ")");
+ + "non-CompoundButton child (id: " + mViewId + ")");
return;
}
CompoundButton button = (CompoundButton) target;
@@ -1481,7 +1477,7 @@ public class RemoteViews implements Parcelable, Filter {
// must use setOnCheckedChangeFillInIntent instead.
if (hasFlags(FLAG_WIDGET_IS_COLLECTION_CHILD)) {
Log.w(LOG_TAG, "Cannot setOnCheckedChangePendingIntent for collection item "
- + "(id: " + viewId + ")");
+ + "(id: " + mViewId + ")");
return;
}
target.setTagInternal(R.id.pending_intent_tag, mResponse.mPendingIntent);
@@ -1648,36 +1644,40 @@ public class RemoteViews implements Parcelable, Filter {
* <p>
*/
private static class SetDrawableTint extends Action {
+ boolean mTargetBackground;
+ @ColorInt int mColorFilter;
+ PorterDuff.Mode mFilterMode;
+
SetDrawableTint(@IdRes int id, boolean targetBackground,
@ColorInt int colorFilter, @NonNull PorterDuff.Mode mode) {
- this.viewId = id;
- this.targetBackground = targetBackground;
- this.colorFilter = colorFilter;
- this.filterMode = mode;
+ this.mViewId = id;
+ this.mTargetBackground = targetBackground;
+ this.mColorFilter = colorFilter;
+ this.mFilterMode = mode;
}
SetDrawableTint(Parcel parcel) {
- viewId = parcel.readInt();
- targetBackground = parcel.readInt() != 0;
- colorFilter = parcel.readInt();
- filterMode = PorterDuff.intToMode(parcel.readInt());
+ mViewId = parcel.readInt();
+ mTargetBackground = parcel.readInt() != 0;
+ mColorFilter = parcel.readInt();
+ mFilterMode = PorterDuff.intToMode(parcel.readInt());
}
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(viewId);
- dest.writeInt(targetBackground ? 1 : 0);
- dest.writeInt(colorFilter);
- dest.writeInt(PorterDuff.modeToInt(filterMode));
+ dest.writeInt(mViewId);
+ dest.writeInt(mTargetBackground ? 1 : 0);
+ dest.writeInt(mColorFilter);
+ dest.writeInt(PorterDuff.modeToInt(mFilterMode));
}
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params) {
- final View target = root.findViewById(viewId);
+ final View target = root.findViewById(mViewId);
if (target == null) return;
// Pick the correct drawable to modify for this view
Drawable targetDrawable = null;
- if (targetBackground) {
+ if (mTargetBackground) {
targetDrawable = target.getBackground();
} else if (target instanceof ImageView) {
ImageView imageView = (ImageView) target;
@@ -1685,7 +1685,7 @@ public class RemoteViews implements Parcelable, Filter {
}
if (targetDrawable != null) {
- targetDrawable.mutate().setColorFilter(colorFilter, filterMode);
+ targetDrawable.mutate().setColorFilter(mColorFilter, mFilterMode);
}
}
@@ -1693,10 +1693,6 @@ public class RemoteViews implements Parcelable, Filter {
public int getActionTag() {
return SET_DRAWABLE_TINT_TAG;
}
-
- boolean targetBackground;
- @ColorInt int colorFilter;
- PorterDuff.Mode filterMode;
}
/**
@@ -1709,27 +1705,26 @@ public class RemoteViews implements Parcelable, Filter {
* <p>
*/
private class SetRippleDrawableColor extends Action {
-
ColorStateList mColorStateList;
SetRippleDrawableColor(@IdRes int id, ColorStateList colorStateList) {
- this.viewId = id;
+ this.mViewId = id;
this.mColorStateList = colorStateList;
}
SetRippleDrawableColor(Parcel parcel) {
- viewId = parcel.readInt();
+ mViewId = parcel.readInt();
mColorStateList = parcel.readParcelable(null, android.content.res.ColorStateList.class);
}
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(viewId);
+ dest.writeInt(mViewId);
dest.writeParcelable(mColorStateList, 0);
}
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params) {
- final View target = root.findViewById(viewId);
+ final View target = root.findViewById(mViewId);
if (target == null) return;
// Pick the correct drawable to modify for this view
@@ -1756,23 +1751,23 @@ public class RemoteViews implements Parcelable, Filter {
final boolean mNext;
ViewContentNavigation(@IdRes int viewId, boolean next) {
- this.viewId = viewId;
+ this.mViewId = viewId;
this.mNext = next;
}
ViewContentNavigation(Parcel in) {
- this.viewId = in.readInt();
+ this.mViewId = in.readInt();
this.mNext = in.readBoolean();
}
public void writeToParcel(Parcel out, int flags) {
- out.writeInt(this.viewId);
+ out.writeInt(this.mViewId);
out.writeBoolean(this.mNext);
}
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params) {
- final View view = root.findViewById(viewId);
+ final View view = root.findViewById(mViewId);
if (view == null) return;
try {
@@ -1794,7 +1789,6 @@ public class RemoteViews implements Parcelable, Filter {
}
private static class BitmapCache {
-
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
ArrayList<Bitmap> mBitmaps;
SparseIntArray mBitmapHashes;
@@ -1861,45 +1855,45 @@ public class RemoteViews implements Parcelable, Filter {
}
private class BitmapReflectionAction extends Action {
- int bitmapId;
+ int mBitmapId;
@UnsupportedAppUsage
- Bitmap bitmap;
+ Bitmap mBitmap;
@UnsupportedAppUsage
- String methodName;
+ String mMethodName;
BitmapReflectionAction(@IdRes int viewId, String methodName, Bitmap bitmap) {
- this.bitmap = bitmap;
- this.viewId = viewId;
- this.methodName = methodName;
- bitmapId = mBitmapCache.getBitmapId(bitmap);
+ this.mBitmap = bitmap;
+ this.mViewId = viewId;
+ this.mMethodName = methodName;
+ mBitmapId = mBitmapCache.getBitmapId(bitmap);
}
BitmapReflectionAction(Parcel in) {
- viewId = in.readInt();
- methodName = in.readString8();
- bitmapId = in.readInt();
- bitmap = mBitmapCache.getBitmapForId(bitmapId);
+ mViewId = in.readInt();
+ mMethodName = in.readString8();
+ mBitmapId = in.readInt();
+ mBitmap = mBitmapCache.getBitmapForId(mBitmapId);
}
@Override
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(viewId);
- dest.writeString8(methodName);
- dest.writeInt(bitmapId);
+ dest.writeInt(mViewId);
+ dest.writeString8(mMethodName);
+ dest.writeInt(mBitmapId);
}
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params)
throws ActionException {
- ReflectionAction ra = new ReflectionAction(viewId, methodName,
+ ReflectionAction ra = new ReflectionAction(mViewId, mMethodName,
BaseReflectionAction.BITMAP,
- bitmap);
+ mBitmap);
ra.apply(root, rootParent, params);
}
@Override
public void setHierarchyRootData(HierarchyRootData rootData) {
- bitmapId = rootData.mBitmapCache.getBitmapId(bitmap);
+ mBitmapId = rootData.mBitmapCache.getBitmapId(mBitmap);
}
@Override
@@ -1933,30 +1927,30 @@ public class RemoteViews implements Parcelable, Filter {
static final int BLEND_MODE = 17;
@UnsupportedAppUsage
- String methodName;
- int type;
+ String mMethodName;
+ int mType;
BaseReflectionAction(@IdRes int viewId, String methodName, int type) {
- this.viewId = viewId;
- this.methodName = methodName;
- this.type = type;
+ this.mViewId = viewId;
+ this.mMethodName = methodName;
+ this.mType = type;
}
BaseReflectionAction(Parcel in) {
- this.viewId = in.readInt();
- this.methodName = in.readString8();
- this.type = in.readInt();
+ this.mViewId = in.readInt();
+ this.mMethodName = in.readString8();
+ this.mType = in.readInt();
//noinspection ConstantIfStatement
if (false) {
- Log.d(LOG_TAG, "read viewId=0x" + Integer.toHexString(this.viewId)
- + " methodName=" + this.methodName + " type=" + this.type);
+ Log.d(LOG_TAG, "read viewId=0x" + Integer.toHexString(this.mViewId)
+ + " methodName=" + this.mMethodName + " type=" + this.mType);
}
}
public void writeToParcel(Parcel out, int flags) {
- out.writeInt(this.viewId);
- out.writeString8(this.methodName);
- out.writeInt(this.type);
+ out.writeInt(this.mViewId);
+ out.writeString8(this.mMethodName);
+ out.writeInt(this.mType);
}
/**
@@ -1971,16 +1965,16 @@ public class RemoteViews implements Parcelable, Filter {
@Override
public final void apply(View root, ViewGroup rootParent, ActionApplyParams params) {
- final View view = root.findViewById(viewId);
+ final View view = root.findViewById(mViewId);
if (view == null) return;
- Class<?> param = getParameterType(this.type);
+ Class<?> param = getParameterType(this.mType);
if (param == null) {
- throw new ActionException("bad type: " + this.type);
+ throw new ActionException("bad type: " + this.mType);
}
Object value = getParameterValue(view);
try {
- getMethod(view, this.methodName, param, false /* async */).invoke(view, value);
+ getMethod(view, this.mMethodName, param, false /* async */).invoke(view, value);
} catch (Throwable ex) {
throw new ActionException(ex);
}
@@ -1989,17 +1983,17 @@ public class RemoteViews implements Parcelable, Filter {
@Override
public final Action initActionAsync(ViewTree root, ViewGroup rootParent,
ActionApplyParams params) {
- final View view = root.findViewById(viewId);
+ final View view = root.findViewById(mViewId);
if (view == null) return ACTION_NOOP;
- Class<?> param = getParameterType(this.type);
+ Class<?> param = getParameterType(this.mType);
if (param == null) {
- throw new ActionException("bad type: " + this.type);
+ throw new ActionException("bad type: " + this.mType);
}
Object value = getParameterValue(view);
try {
- MethodHandle method = getMethod(view, this.methodName, param, true /* async */);
+ MethodHandle method = getMethod(view, this.mMethodName, param, true /* async */);
// Upload the bitmap to GPU if the parameter is of type Bitmap or Icon.
// Since bitmaps in framework are seldomly modified, this is supposed to accelerate
// the operations.
@@ -2025,7 +2019,7 @@ public class RemoteViews implements Parcelable, Filter {
if (endAction instanceof ViewStub.ViewReplaceRunnable) {
root.createTree();
// Replace child tree
- root.findViewTreeById(viewId).replaceView(
+ root.findViewTreeById(mViewId).replaceView(
((ViewStub.ViewReplaceRunnable) endAction).view);
}
return new RunnableAction(endAction);
@@ -2039,7 +2033,7 @@ public class RemoteViews implements Parcelable, Filter {
public final int mergeBehavior() {
// smoothScrollBy is cumulative, everything else overwites.
- if (methodName.equals("smoothScrollBy")) {
+ if (mMethodName.equals("smoothScrollBy")) {
return MERGE_APPEND;
} else {
return MERGE_REPLACE;
@@ -2050,17 +2044,17 @@ public class RemoteViews implements Parcelable, Filter {
public final String getUniqueKey() {
// Each type of reflection action corresponds to a setter, so each should be seen as
// unique from the standpoint of merging.
- return super.getUniqueKey() + this.methodName + this.type;
+ return super.getUniqueKey() + this.mMethodName + this.mType;
}
@Override
public final boolean prefersAsyncApply() {
- return this.type == URI || this.type == ICON;
+ return this.mType == URI || this.mType == ICON;
}
@Override
public void visitUris(@NonNull Consumer<Uri> visitor) {
- switch (this.type) {
+ switch (this.mType) {
case URI:
final Uri uri = (Uri) getParameterValue(null);
if (uri != null) visitor.accept(uri);
@@ -2076,53 +2070,53 @@ public class RemoteViews implements Parcelable, Filter {
/** Class for the reflection actions. */
private static final class ReflectionAction extends BaseReflectionAction {
@UnsupportedAppUsage
- Object value;
+ Object mValue;
ReflectionAction(@IdRes int viewId, String methodName, int type, Object value) {
super(viewId, methodName, type);
- this.value = value;
+ this.mValue = value;
}
ReflectionAction(Parcel in) {
super(in);
// For some values that may have been null, we first check a flag to see if they were
// written to the parcel.
- switch (this.type) {
+ switch (this.mType) {
case BOOLEAN:
- this.value = in.readBoolean();
+ this.mValue = in.readBoolean();
break;
case BYTE:
- this.value = in.readByte();
+ this.mValue = in.readByte();
break;
case SHORT:
- this.value = (short) in.readInt();
+ this.mValue = (short) in.readInt();
break;
case INT:
- this.value = in.readInt();
+ this.mValue = in.readInt();
break;
case LONG:
- this.value = in.readLong();
+ this.mValue = in.readLong();
break;
case FLOAT:
- this.value = in.readFloat();
+ this.mValue = in.readFloat();
break;
case DOUBLE:
- this.value = in.readDouble();
+ this.mValue = in.readDouble();
break;
case CHAR:
- this.value = (char) in.readInt();
+ this.mValue = (char) in.readInt();
break;
case STRING:
- this.value = in.readString8();
+ this.mValue = in.readString8();
break;
case CHAR_SEQUENCE:
- this.value = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
+ this.mValue = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
break;
case URI:
- this.value = in.readTypedObject(Uri.CREATOR);
+ this.mValue = in.readTypedObject(Uri.CREATOR);
break;
case BITMAP:
- this.value = in.readTypedObject(Bitmap.CREATOR);
+ this.mValue = in.readTypedObject(Bitmap.CREATOR);
break;
case BUNDLE:
// Because we use Parcel.allowSquashing() when writing, and that affects
@@ -2131,24 +2125,24 @@ public class RemoteViews implements Parcelable, Filter {
// just happens to have that effect on Bundle.readFromParcel().
// TODO(b/212731590): build this state tracking into Bundle
if (in.hasReadWriteHelper()) {
- this.value = in.readBundle();
+ this.mValue = in.readBundle();
} else {
in.setReadWriteHelper(ALTERNATIVE_DEFAULT);
- this.value = in.readBundle();
+ this.mValue = in.readBundle();
in.setReadWriteHelper(null);
}
break;
case INTENT:
- this.value = in.readTypedObject(Intent.CREATOR);
+ this.mValue = in.readTypedObject(Intent.CREATOR);
break;
case COLOR_STATE_LIST:
- this.value = in.readTypedObject(ColorStateList.CREATOR);
+ this.mValue = in.readTypedObject(ColorStateList.CREATOR);
break;
case ICON:
- this.value = in.readTypedObject(Icon.CREATOR);
+ this.mValue = in.readTypedObject(Icon.CREATOR);
break;
case BLEND_MODE:
- this.value = BlendMode.fromValue(in.readInt());
+ this.mValue = BlendMode.fromValue(in.readInt());
break;
default:
break;
@@ -2159,49 +2153,49 @@ public class RemoteViews implements Parcelable, Filter {
super.writeToParcel(out, flags);
// For some values which are null, we record an integer flag to indicate whether
// we have written a valid value to the parcel.
- switch (this.type) {
+ switch (this.mType) {
case BOOLEAN:
- out.writeBoolean((Boolean) this.value);
+ out.writeBoolean((Boolean) this.mValue);
break;
case BYTE:
- out.writeByte((Byte) this.value);
+ out.writeByte((Byte) this.mValue);
break;
case SHORT:
- out.writeInt((Short) this.value);
+ out.writeInt((Short) this.mValue);
break;
case INT:
- out.writeInt((Integer) this.value);
+ out.writeInt((Integer) this.mValue);
break;
case LONG:
- out.writeLong((Long) this.value);
+ out.writeLong((Long) this.mValue);
break;
case FLOAT:
- out.writeFloat((Float) this.value);
+ out.writeFloat((Float) this.mValue);
break;
case DOUBLE:
- out.writeDouble((Double) this.value);
+ out.writeDouble((Double) this.mValue);
break;
case CHAR:
- out.writeInt((int) ((Character) this.value).charValue());
+ out.writeInt((int) ((Character) this.mValue).charValue());
break;
case STRING:
- out.writeString8((String) this.value);
+ out.writeString8((String) this.mValue);
break;
case CHAR_SEQUENCE:
- TextUtils.writeToParcel((CharSequence) this.value, out, flags);
+ TextUtils.writeToParcel((CharSequence) this.mValue, out, flags);
break;
case BUNDLE:
- out.writeBundle((Bundle) this.value);
+ out.writeBundle((Bundle) this.mValue);
break;
case BLEND_MODE:
- out.writeInt(BlendMode.toValue((BlendMode) this.value));
+ out.writeInt(BlendMode.toValue((BlendMode) this.mValue));
break;
case URI:
case BITMAP:
case INTENT:
case COLOR_STATE_LIST:
case ICON:
- out.writeTypedObject((Parcelable) this.value, flags);
+ out.writeTypedObject((Parcelable) this.mValue, flags);
break;
default:
break;
@@ -2211,7 +2205,7 @@ public class RemoteViews implements Parcelable, Filter {
@Nullable
@Override
protected Object getParameterValue(@Nullable View view) throws ActionException {
- return this.value;
+ return this.mValue;
}
@Override
@@ -2221,7 +2215,6 @@ public class RemoteViews implements Parcelable, Filter {
}
private static final class ResourceReflectionAction extends BaseReflectionAction {
-
static final int DIMEN_RESOURCE = 1;
static final int COLOR_RESOURCE = 2;
static final int STRING_RESOURCE = 3;
@@ -2258,7 +2251,7 @@ public class RemoteViews implements Parcelable, Filter {
try {
switch (this.mResourceType) {
case DIMEN_RESOURCE:
- switch (this.type) {
+ switch (this.mType) {
case BaseReflectionAction.INT:
return mResId == 0 ? 0 : resources.getDimensionPixelSize(mResId);
case BaseReflectionAction.FLOAT:
@@ -2266,10 +2259,10 @@ public class RemoteViews implements Parcelable, Filter {
default:
throw new ActionException(
"dimen resources must be used as INT or FLOAT, "
- + "not " + this.type);
+ + "not " + this.mType);
}
case COLOR_RESOURCE:
- switch (this.type) {
+ switch (this.mType) {
case BaseReflectionAction.INT:
return mResId == 0 ? 0 : view.getContext().getColor(mResId);
case BaseReflectionAction.COLOR_STATE_LIST:
@@ -2278,10 +2271,10 @@ public class RemoteViews implements Parcelable, Filter {
default:
throw new ActionException(
"color resources must be used as INT or COLOR_STATE_LIST,"
- + " not " + this.type);
+ + " not " + this.mType);
}
case STRING_RESOURCE:
- switch (this.type) {
+ switch (this.mType) {
case BaseReflectionAction.CHAR_SEQUENCE:
return mResId == 0 ? null : resources.getText(mResId);
case BaseReflectionAction.STRING:
@@ -2289,7 +2282,7 @@ public class RemoteViews implements Parcelable, Filter {
default:
throw new ActionException(
"string resources must be used as STRING or CHAR_SEQUENCE,"
- + " not " + this.type);
+ + " not " + this.mType);
}
default:
throw new ActionException("unknown resource type: " + this.mResourceType);
@@ -2308,7 +2301,6 @@ public class RemoteViews implements Parcelable, Filter {
}
private static final class AttributeReflectionAction extends BaseReflectionAction {
-
static final int DIMEN_RESOURCE = 1;
static final int COLOR_RESOURCE = 2;
static final int STRING_RESOURCE = 3;
@@ -2347,7 +2339,7 @@ public class RemoteViews implements Parcelable, Filter {
}
switch (this.mResourceType) {
case DIMEN_RESOURCE:
- switch (this.type) {
+ switch (this.mType) {
case BaseReflectionAction.INT:
return typedArray.getDimensionPixelSize(0, 0);
case BaseReflectionAction.FLOAT:
@@ -2356,10 +2348,10 @@ public class RemoteViews implements Parcelable, Filter {
throw new ActionException(
"dimen attribute 0x" + Integer.toHexString(this.mAttrId)
+ " must be used as INT or FLOAT,"
- + " not " + this.type);
+ + " not " + this.mType);
}
case COLOR_RESOURCE:
- switch (this.type) {
+ switch (this.mType) {
case BaseReflectionAction.INT:
return typedArray.getColor(0, 0);
case BaseReflectionAction.COLOR_STATE_LIST:
@@ -2368,10 +2360,10 @@ public class RemoteViews implements Parcelable, Filter {
throw new ActionException(
"color attribute 0x" + Integer.toHexString(this.mAttrId)
+ " must be used as INT or COLOR_STATE_LIST,"
- + " not " + this.type);
+ + " not " + this.mType);
}
case STRING_RESOURCE:
- switch (this.type) {
+ switch (this.mType) {
case BaseReflectionAction.CHAR_SEQUENCE:
return typedArray.getText(0);
case BaseReflectionAction.STRING:
@@ -2380,7 +2372,7 @@ public class RemoteViews implements Parcelable, Filter {
throw new ActionException(
"string attribute 0x" + Integer.toHexString(this.mAttrId)
+ " must be used as STRING or CHAR_SEQUENCE,"
- + " not " + this.type);
+ + " not " + this.mType);
}
default:
// Note: This can only be an implementation error.
@@ -2402,7 +2394,6 @@ public class RemoteViews implements Parcelable, Filter {
}
}
private static final class ComplexUnitDimensionReflectionAction extends BaseReflectionAction {
-
private final float mValue;
@ComplexDimensionUnit
private final int mUnit;
@@ -2435,14 +2426,14 @@ public class RemoteViews implements Parcelable, Filter {
DisplayMetrics dm = view.getContext().getResources().getDisplayMetrics();
try {
int data = TypedValue.createComplexDimension(this.mValue, this.mUnit);
- switch (this.type) {
+ switch (this.mType) {
case ReflectionAction.INT:
return TypedValue.complexToDimensionPixelSize(data, dm);
case ReflectionAction.FLOAT:
return TypedValue.complexToDimension(data, dm);
default:
throw new ActionException(
- "parameter type must be INT or FLOAT, not " + this.type);
+ "parameter type must be INT or FLOAT, not " + this.mType);
}
} catch (ActionException ex) {
throw ex;
@@ -2458,7 +2449,6 @@ public class RemoteViews implements Parcelable, Filter {
}
private static final class NightModeReflectionAction extends BaseReflectionAction {
-
private final Object mLightValue;
private final Object mDarkValue;
@@ -2475,7 +2465,7 @@ public class RemoteViews implements Parcelable, Filter {
NightModeReflectionAction(Parcel in) {
super(in);
- switch (this.type) {
+ switch (this.mType) {
case ICON:
mLightValue = in.readTypedObject(Icon.CREATOR);
mDarkValue = in.readTypedObject(Icon.CREATOR);
@@ -2489,14 +2479,14 @@ public class RemoteViews implements Parcelable, Filter {
mDarkValue = in.readInt();
break;
default:
- throw new ActionException("Unexpected night mode action type: " + this.type);
+ throw new ActionException("Unexpected night mode action type: " + this.mType);
}
}
@Override
public void writeToParcel(Parcel out, int flags) {
super.writeToParcel(out, flags);
- switch (this.type) {
+ switch (this.mType) {
case ICON:
case COLOR_STATE_LIST:
out.writeTypedObject((Parcelable) mLightValue, flags);
@@ -2525,7 +2515,7 @@ public class RemoteViews implements Parcelable, Filter {
@Override
public void visitUris(@NonNull Consumer<Uri> visitor) {
- if (this.type == ICON) {
+ if (this.mType == ICON) {
visitIconUri((Icon) mDarkValue, visitor);
visitIconUri((Icon) mLightValue, visitor);
}
@@ -2617,7 +2607,7 @@ public class RemoteViews implements Parcelable, Filter {
}
ViewGroupActionAdd(@IdRes int viewId, RemoteViews nestedViews, int index, int stableId) {
- this.viewId = viewId;
+ this.mViewId = viewId;
mNestedViews = nestedViews;
mIndex = index;
mStableId = stableId;
@@ -2625,7 +2615,7 @@ public class RemoteViews implements Parcelable, Filter {
}
ViewGroupActionAdd(Parcel parcel, ApplicationInfo info, int depth) {
- viewId = parcel.readInt();
+ mViewId = parcel.readInt();
mIndex = parcel.readInt();
mStableId = parcel.readInt();
mNestedViews = new RemoteViews(parcel, getHierarchyRootData(), info, depth);
@@ -2633,7 +2623,7 @@ public class RemoteViews implements Parcelable, Filter {
}
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(viewId);
+ dest.writeInt(mViewId);
dest.writeInt(mIndex);
dest.writeInt(mStableId);
mNestedViews.writeToParcel(dest, flags);
@@ -2658,7 +2648,7 @@ public class RemoteViews implements Parcelable, Filter {
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params) {
final Context context = root.getContext();
- final ViewGroup target = root.findViewById(viewId);
+ final ViewGroup target = root.findViewById(mViewId);
if (target == null) {
return;
@@ -2713,7 +2703,7 @@ public class RemoteViews implements Parcelable, Filter {
// In the async implementation, update the view tree so that subsequent calls to
// findViewById return the current view.
root.createTree();
- ViewTree target = root.findViewTreeById(viewId);
+ ViewTree target = root.findViewTreeById(mViewId);
if ((target == null) || !(target.mRoot instanceof ViewGroup)) {
return ACTION_NOOP;
}
@@ -2845,23 +2835,23 @@ public class RemoteViews implements Parcelable, Filter {
}
ViewGroupActionRemove(@IdRes int viewId, @IdRes int viewIdToKeep) {
- this.viewId = viewId;
+ this.mViewId = viewId;
mViewIdToKeep = viewIdToKeep;
}
ViewGroupActionRemove(Parcel parcel) {
- viewId = parcel.readInt();
+ mViewId = parcel.readInt();
mViewIdToKeep = parcel.readInt();
}
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(viewId);
+ dest.writeInt(mViewId);
dest.writeInt(mViewIdToKeep);
}
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params) {
- final ViewGroup target = root.findViewById(viewId);
+ final ViewGroup target = root.findViewById(mViewId);
if (target == null) {
return;
@@ -2888,7 +2878,7 @@ public class RemoteViews implements Parcelable, Filter {
// In the async implementation, update the view tree so that subsequent calls to
// findViewById return the current view.
root.createTree();
- ViewTree target = root.findViewTreeById(viewId);
+ ViewTree target = root.findViewTreeById(mViewId);
if ((target == null) || !(target.mRoot instanceof ViewGroup)) {
return ACTION_NOOP;
@@ -2953,22 +2943,21 @@ public class RemoteViews implements Parcelable, Filter {
* Action to remove a view from its parent.
*/
private static class RemoveFromParentAction extends Action {
-
RemoveFromParentAction(@IdRes int viewId) {
- this.viewId = viewId;
+ this.mViewId = viewId;
}
RemoveFromParentAction(Parcel parcel) {
- viewId = parcel.readInt();
+ mViewId = parcel.readInt();
}
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(viewId);
+ dest.writeInt(mViewId);
}
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params) {
- final View target = root.findViewById(viewId);
+ final View target = root.findViewById(mViewId);
if (target == null || target == root) {
return;
@@ -2986,7 +2975,7 @@ public class RemoteViews implements Parcelable, Filter {
// In the async implementation, update the view tree so that subsequent calls to
// findViewById return the correct view.
root.createTree();
- ViewTree target = root.findViewTreeById(viewId);
+ ViewTree target = root.findViewTreeById(mViewId);
if (target == null || target == root) {
return ACTION_NOOP;
@@ -3023,88 +3012,96 @@ public class RemoteViews implements Parcelable, Filter {
* (s/t/e/b) or cardinal (l/t/r/b) arrangement.
*/
private static class TextViewDrawableAction extends Action {
+ boolean mIsRelative = false;
+ boolean mUseIcons = false;
+ int mD1, mD2, mD3, mD4;
+ Icon mI1, mI2, mI3, mI4;
+
+ boolean mDrawablesLoaded = false;
+ Drawable mId1, mId2, mId3, mId4;
+
public TextViewDrawableAction(@IdRes int viewId, boolean isRelative, @DrawableRes int d1,
@DrawableRes int d2, @DrawableRes int d3, @DrawableRes int d4) {
- this.viewId = viewId;
- this.isRelative = isRelative;
- this.useIcons = false;
- this.d1 = d1;
- this.d2 = d2;
- this.d3 = d3;
- this.d4 = d4;
+ this.mViewId = viewId;
+ this.mIsRelative = isRelative;
+ this.mUseIcons = false;
+ this.mD1 = d1;
+ this.mD2 = d2;
+ this.mD3 = d3;
+ this.mD4 = d4;
}
public TextViewDrawableAction(@IdRes int viewId, boolean isRelative,
Icon i1, Icon i2, Icon i3, Icon i4) {
- this.viewId = viewId;
- this.isRelative = isRelative;
- this.useIcons = true;
- this.i1 = i1;
- this.i2 = i2;
- this.i3 = i3;
- this.i4 = i4;
+ this.mViewId = viewId;
+ this.mIsRelative = isRelative;
+ this.mUseIcons = true;
+ this.mI1 = i1;
+ this.mI2 = i2;
+ this.mI3 = i3;
+ this.mI4 = i4;
}
public TextViewDrawableAction(Parcel parcel) {
- viewId = parcel.readInt();
- isRelative = (parcel.readInt() != 0);
- useIcons = (parcel.readInt() != 0);
- if (useIcons) {
- i1 = parcel.readTypedObject(Icon.CREATOR);
- i2 = parcel.readTypedObject(Icon.CREATOR);
- i3 = parcel.readTypedObject(Icon.CREATOR);
- i4 = parcel.readTypedObject(Icon.CREATOR);
+ mViewId = parcel.readInt();
+ mIsRelative = (parcel.readInt() != 0);
+ mUseIcons = (parcel.readInt() != 0);
+ if (mUseIcons) {
+ mI1 = parcel.readTypedObject(Icon.CREATOR);
+ mI2 = parcel.readTypedObject(Icon.CREATOR);
+ mI3 = parcel.readTypedObject(Icon.CREATOR);
+ mI4 = parcel.readTypedObject(Icon.CREATOR);
} else {
- d1 = parcel.readInt();
- d2 = parcel.readInt();
- d3 = parcel.readInt();
- d4 = parcel.readInt();
+ mD1 = parcel.readInt();
+ mD2 = parcel.readInt();
+ mD3 = parcel.readInt();
+ mD4 = parcel.readInt();
}
}
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(viewId);
- dest.writeInt(isRelative ? 1 : 0);
- dest.writeInt(useIcons ? 1 : 0);
- if (useIcons) {
- dest.writeTypedObject(i1, 0);
- dest.writeTypedObject(i2, 0);
- dest.writeTypedObject(i3, 0);
- dest.writeTypedObject(i4, 0);
+ dest.writeInt(mViewId);
+ dest.writeInt(mIsRelative ? 1 : 0);
+ dest.writeInt(mUseIcons ? 1 : 0);
+ if (mUseIcons) {
+ dest.writeTypedObject(mI1, 0);
+ dest.writeTypedObject(mI2, 0);
+ dest.writeTypedObject(mI3, 0);
+ dest.writeTypedObject(mI4, 0);
} else {
- dest.writeInt(d1);
- dest.writeInt(d2);
- dest.writeInt(d3);
- dest.writeInt(d4);
+ dest.writeInt(mD1);
+ dest.writeInt(mD2);
+ dest.writeInt(mD3);
+ dest.writeInt(mD4);
}
}
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params) {
- final TextView target = root.findViewById(viewId);
+ final TextView target = root.findViewById(mViewId);
if (target == null) return;
- if (drawablesLoaded) {
- if (isRelative) {
- target.setCompoundDrawablesRelativeWithIntrinsicBounds(id1, id2, id3, id4);
+ if (mDrawablesLoaded) {
+ if (mIsRelative) {
+ target.setCompoundDrawablesRelativeWithIntrinsicBounds(mId1, mId2, mId3, mId4);
} else {
- target.setCompoundDrawablesWithIntrinsicBounds(id1, id2, id3, id4);
+ target.setCompoundDrawablesWithIntrinsicBounds(mId1, mId2, mId3, mId4);
}
- } else if (useIcons) {
+ } else if (mUseIcons) {
final Context ctx = target.getContext();
- final Drawable id1 = i1 == null ? null : i1.loadDrawable(ctx);
- final Drawable id2 = i2 == null ? null : i2.loadDrawable(ctx);
- final Drawable id3 = i3 == null ? null : i3.loadDrawable(ctx);
- final Drawable id4 = i4 == null ? null : i4.loadDrawable(ctx);
- if (isRelative) {
+ final Drawable id1 = mI1 == null ? null : mI1.loadDrawable(ctx);
+ final Drawable id2 = mI2 == null ? null : mI2.loadDrawable(ctx);
+ final Drawable id3 = mI3 == null ? null : mI3.loadDrawable(ctx);
+ final Drawable id4 = mI4 == null ? null : mI4.loadDrawable(ctx);
+ if (mIsRelative) {
target.setCompoundDrawablesRelativeWithIntrinsicBounds(id1, id2, id3, id4);
} else {
target.setCompoundDrawablesWithIntrinsicBounds(id1, id2, id3, id4);
}
} else {
- if (isRelative) {
- target.setCompoundDrawablesRelativeWithIntrinsicBounds(d1, d2, d3, d4);
+ if (mIsRelative) {
+ target.setCompoundDrawablesRelativeWithIntrinsicBounds(mD1, mD2, mD3, mD4);
} else {
- target.setCompoundDrawablesWithIntrinsicBounds(d1, d2, d3, d4);
+ target.setCompoundDrawablesWithIntrinsicBounds(mD1, mD2, mD3, mD4);
}
}
}
@@ -3112,34 +3109,34 @@ public class RemoteViews implements Parcelable, Filter {
@Override
public Action initActionAsync(ViewTree root, ViewGroup rootParent,
ActionApplyParams params) {
- final TextView target = root.findViewById(viewId);
+ final TextView target = root.findViewById(mViewId);
if (target == null) return ACTION_NOOP;
- TextViewDrawableAction copy = useIcons ?
- new TextViewDrawableAction(viewId, isRelative, i1, i2, i3, i4) :
- new TextViewDrawableAction(viewId, isRelative, d1, d2, d3, d4);
+ TextViewDrawableAction copy = mUseIcons
+ ? new TextViewDrawableAction(mViewId, mIsRelative, mI1, mI2, mI3, mI4)
+ : new TextViewDrawableAction(mViewId, mIsRelative, mD1, mD2, mD3, mD4);
// Load the drawables on the background thread.
- copy.drawablesLoaded = true;
+ copy.mDrawablesLoaded = true;
final Context ctx = target.getContext();
- if (useIcons) {
- copy.id1 = i1 == null ? null : i1.loadDrawable(ctx);
- copy.id2 = i2 == null ? null : i2.loadDrawable(ctx);
- copy.id3 = i3 == null ? null : i3.loadDrawable(ctx);
- copy.id4 = i4 == null ? null : i4.loadDrawable(ctx);
+ if (mUseIcons) {
+ copy.mId1 = mI1 == null ? null : mI1.loadDrawable(ctx);
+ copy.mId2 = mI2 == null ? null : mI2.loadDrawable(ctx);
+ copy.mId3 = mI3 == null ? null : mI3.loadDrawable(ctx);
+ copy.mId4 = mI4 == null ? null : mI4.loadDrawable(ctx);
} else {
- copy.id1 = d1 == 0 ? null : ctx.getDrawable(d1);
- copy.id2 = d2 == 0 ? null : ctx.getDrawable(d2);
- copy.id3 = d3 == 0 ? null : ctx.getDrawable(d3);
- copy.id4 = d4 == 0 ? null : ctx.getDrawable(d4);
+ copy.mId1 = mD1 == 0 ? null : ctx.getDrawable(mD1);
+ copy.mId2 = mD2 == 0 ? null : ctx.getDrawable(mD2);
+ copy.mId3 = mD3 == 0 ? null : ctx.getDrawable(mD3);
+ copy.mId4 = mD4 == 0 ? null : ctx.getDrawable(mD4);
}
return copy;
}
@Override
public boolean prefersAsyncApply() {
- return useIcons;
+ return mUseIcons;
}
@Override
@@ -3149,110 +3146,101 @@ public class RemoteViews implements Parcelable, Filter {
@Override
public void visitUris(@NonNull Consumer<Uri> visitor) {
- if (useIcons) {
- visitIconUri(i1, visitor);
- visitIconUri(i2, visitor);
- visitIconUri(i3, visitor);
- visitIconUri(i4, visitor);
+ if (mUseIcons) {
+ visitIconUri(mI1, visitor);
+ visitIconUri(mI2, visitor);
+ visitIconUri(mI3, visitor);
+ visitIconUri(mI4, visitor);
}
}
-
- boolean isRelative = false;
- boolean useIcons = false;
- int d1, d2, d3, d4;
- Icon i1, i2, i3, i4;
-
- boolean drawablesLoaded = false;
- Drawable id1, id2, id3, id4;
}
/**
* Helper action to set text size on a TextView in any supported units.
*/
private static class TextViewSizeAction extends Action {
+ int mUnits;
+ float mSize;
+
TextViewSizeAction(@IdRes int viewId, @ComplexDimensionUnit int units, float size) {
- this.viewId = viewId;
- this.units = units;
- this.size = size;
+ this.mViewId = viewId;
+ this.mUnits = units;
+ this.mSize = size;
}
TextViewSizeAction(Parcel parcel) {
- viewId = parcel.readInt();
- units = parcel.readInt();
- size = parcel.readFloat();
+ mViewId = parcel.readInt();
+ mUnits = parcel.readInt();
+ mSize = parcel.readFloat();
}
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(viewId);
- dest.writeInt(units);
- dest.writeFloat(size);
+ dest.writeInt(mViewId);
+ dest.writeInt(mUnits);
+ dest.writeFloat(mSize);
}
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params) {
- final TextView target = root.findViewById(viewId);
+ final TextView target = root.findViewById(mViewId);
if (target == null) return;
- target.setTextSize(units, size);
+ target.setTextSize(mUnits, mSize);
}
@Override
public int getActionTag() {
return TEXT_VIEW_SIZE_ACTION_TAG;
}
-
- int units;
- float size;
}
/**
* Helper action to set padding on a View.
*/
private static class ViewPaddingAction extends Action {
+ @Px int mLeft, mTop, mRight, mBottom;
+
public ViewPaddingAction(@IdRes int viewId, @Px int left, @Px int top,
@Px int right, @Px int bottom) {
- this.viewId = viewId;
- this.left = left;
- this.top = top;
- this.right = right;
- this.bottom = bottom;
+ this.mViewId = viewId;
+ this.mLeft = left;
+ this.mTop = top;
+ this.mRight = right;
+ this.mBottom = bottom;
}
public ViewPaddingAction(Parcel parcel) {
- viewId = parcel.readInt();
- left = parcel.readInt();
- top = parcel.readInt();
- right = parcel.readInt();
- bottom = parcel.readInt();
+ mViewId = parcel.readInt();
+ mLeft = parcel.readInt();
+ mTop = parcel.readInt();
+ mRight = parcel.readInt();
+ mBottom = parcel.readInt();
}
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(viewId);
- dest.writeInt(left);
- dest.writeInt(top);
- dest.writeInt(right);
- dest.writeInt(bottom);
+ dest.writeInt(mViewId);
+ dest.writeInt(mLeft);
+ dest.writeInt(mTop);
+ dest.writeInt(mRight);
+ dest.writeInt(mBottom);
}
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params) {
- final View target = root.findViewById(viewId);
+ final View target = root.findViewById(mViewId);
if (target == null) return;
- target.setPadding(left, top, right, bottom);
+ target.setPadding(mLeft, mTop, mRight, mBottom);
}
@Override
public int getActionTag() {
return VIEW_PADDING_ACTION_TAG;
}
-
- @Px int left, top, right, bottom;
}
/**
* Helper action to set layout params on a View.
*/
private static class LayoutParamAction extends Action {
-
static final int LAYOUT_MARGIN_LEFT = MARGIN_LEFT;
static final int LAYOUT_MARGIN_TOP = MARGIN_TOP;
static final int LAYOUT_MARGIN_RIGHT = MARGIN_RIGHT;
@@ -3274,7 +3262,7 @@ public class RemoteViews implements Parcelable, Filter {
*/
LayoutParamAction(@IdRes int viewId, int property, float value,
@ComplexDimensionUnit int units) {
- this.viewId = viewId;
+ this.mViewId = viewId;
this.mProperty = property;
this.mValueType = VALUE_TYPE_COMPLEX_UNIT;
this.mValue = TypedValue.createComplexDimension(value, units);
@@ -3289,21 +3277,21 @@ public class RemoteViews implements Parcelable, Filter {
* {@link #VALUE_TYPE_RAW}.
*/
LayoutParamAction(@IdRes int viewId, int property, int value, @ValueType int valueType) {
- this.viewId = viewId;
+ this.mViewId = viewId;
this.mProperty = property;
this.mValueType = valueType;
this.mValue = value;
}
public LayoutParamAction(Parcel parcel) {
- viewId = parcel.readInt();
+ mViewId = parcel.readInt();
mProperty = parcel.readInt();
mValueType = parcel.readInt();
mValue = parcel.readInt();
}
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(viewId);
+ dest.writeInt(mViewId);
dest.writeInt(mProperty);
dest.writeInt(mValueType);
dest.writeInt(mValue);
@@ -3311,7 +3299,7 @@ public class RemoteViews implements Parcelable, Filter {
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params) {
- final View target = root.findViewById(viewId);
+ final View target = root.findViewById(mViewId);
if (target == null) {
return;
}
@@ -3438,55 +3426,53 @@ public class RemoteViews implements Parcelable, Filter {
* Helper action to add a view tag with RemoteInputs.
*/
private static class SetRemoteInputsAction extends Action {
+ final Parcelable[] mRemoteInputs;
public SetRemoteInputsAction(@IdRes int viewId, RemoteInput[] remoteInputs) {
- this.viewId = viewId;
- this.remoteInputs = remoteInputs;
+ this.mViewId = viewId;
+ this.mRemoteInputs = remoteInputs;
}
public SetRemoteInputsAction(Parcel parcel) {
- viewId = parcel.readInt();
- remoteInputs = parcel.createTypedArray(RemoteInput.CREATOR);
+ mViewId = parcel.readInt();
+ mRemoteInputs = parcel.createTypedArray(RemoteInput.CREATOR);
}
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(viewId);
- dest.writeTypedArray(remoteInputs, flags);
+ dest.writeInt(mViewId);
+ dest.writeTypedArray(mRemoteInputs, flags);
}
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params) {
- final View target = root.findViewById(viewId);
+ final View target = root.findViewById(mViewId);
if (target == null) return;
- target.setTagInternal(R.id.remote_input_tag, remoteInputs);
+ target.setTagInternal(R.id.remote_input_tag, mRemoteInputs);
}
@Override
public int getActionTag() {
return SET_REMOTE_INPUTS_ACTION_TAG;
}
-
- final Parcelable[] remoteInputs;
}
/**
* Helper action to override all textViewColors
*/
private static class OverrideTextColorsAction extends Action {
-
- private final int textColor;
+ private final int mTextColor;
public OverrideTextColorsAction(int textColor) {
- this.textColor = textColor;
+ this.mTextColor = textColor;
}
public OverrideTextColorsAction(Parcel parcel) {
- textColor = parcel.readInt();
+ mTextColor = parcel.readInt();
}
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(textColor);
+ dest.writeInt(mTextColor);
}
@Override
@@ -3499,7 +3485,7 @@ public class RemoteViews implements Parcelable, Filter {
if (v instanceof TextView) {
TextView textView = (TextView) v;
textView.setText(ContrastColorUtil.clearColorSpans(textView.getText()));
- textView.setTextColor(textColor);
+ textView.setTextColor(mTextColor);
}
if (v instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) v;
@@ -3554,34 +3540,33 @@ public class RemoteViews implements Parcelable, Filter {
}
private static class SetCompoundButtonCheckedAction extends Action {
-
private final boolean mChecked;
SetCompoundButtonCheckedAction(@IdRes int viewId, boolean checked) {
- this.viewId = viewId;
+ this.mViewId = viewId;
mChecked = checked;
}
SetCompoundButtonCheckedAction(Parcel in) {
- viewId = in.readInt();
+ mViewId = in.readInt();
mChecked = in.readBoolean();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(viewId);
+ dest.writeInt(mViewId);
dest.writeBoolean(mChecked);
}
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params)
throws ActionException {
- final View target = root.findViewById(viewId);
+ final View target = root.findViewById(mViewId);
if (target == null) return;
if (!(target instanceof CompoundButton)) {
Log.w(LOG_TAG, "Cannot set checked to view "
- + viewId + " because it is not a CompoundButton");
+ + mViewId + " because it is not a CompoundButton");
return;
}
@@ -3605,33 +3590,32 @@ public class RemoteViews implements Parcelable, Filter {
}
private static class SetRadioGroupCheckedAction extends Action {
-
@IdRes private final int mCheckedId;
SetRadioGroupCheckedAction(@IdRes int viewId, @IdRes int checkedId) {
- this.viewId = viewId;
+ this.mViewId = viewId;
mCheckedId = checkedId;
}
SetRadioGroupCheckedAction(Parcel in) {
- viewId = in.readInt();
+ mViewId = in.readInt();
mCheckedId = in.readInt();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(viewId);
+ dest.writeInt(mViewId);
dest.writeInt(mCheckedId);
}
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params)
throws ActionException {
- final View target = root.findViewById(viewId);
+ final View target = root.findViewById(mViewId);
if (target == null) return;
if (!(target instanceof RadioGroup)) {
- Log.w(LOG_TAG, "Cannot check " + viewId + " because it's not a RadioGroup");
+ Log.w(LOG_TAG, "Cannot check " + mViewId + " because it's not a RadioGroup");
return;
}
@@ -3670,35 +3654,34 @@ public class RemoteViews implements Parcelable, Filter {
}
private static class SetViewOutlinePreferredRadiusAction extends Action {
-
@ValueType
private final int mValueType;
private final int mValue;
SetViewOutlinePreferredRadiusAction(@IdRes int viewId, int value,
@ValueType int valueType) {
- this.viewId = viewId;
+ this.mViewId = viewId;
this.mValueType = valueType;
this.mValue = value;
}
SetViewOutlinePreferredRadiusAction(
@IdRes int viewId, float radius, @ComplexDimensionUnit int units) {
- this.viewId = viewId;
+ this.mViewId = viewId;
this.mValueType = VALUE_TYPE_COMPLEX_UNIT;
this.mValue = TypedValue.createComplexDimension(radius, units);
}
SetViewOutlinePreferredRadiusAction(Parcel in) {
- viewId = in.readInt();
+ mViewId = in.readInt();
mValueType = in.readInt();
mValue = in.readInt();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(viewId);
+ dest.writeInt(mViewId);
dest.writeInt(mValueType);
dest.writeInt(mValue);
}
@@ -3706,7 +3689,7 @@ public class RemoteViews implements Parcelable, Filter {
@Override
public void apply(View root, ViewGroup rootParent, ActionApplyParams params)
throws ActionException {
- final View target = root.findViewById(viewId);
+ final View target = root.findViewById(mViewId);
if (target == null) return;
try {
@@ -3748,7 +3731,6 @@ public class RemoteViews implements Parcelable, Filter {
* {@link #setViewOutlinePreferredRadius(int, float, int)}.
*/
public static final class RemoteViewOutlineProvider extends ViewOutlineProvider {
-
private final float mRadius;
public RemoteViewOutlineProvider(float radius) {
@@ -3821,7 +3803,8 @@ public class RemoteViews implements Parcelable, Filter {
return mSizedRemoteViews != null;
}
- private @Nullable SizeF getIdealSize() {
+ @Nullable
+ private SizeF getIdealSize() {
return mIdealSize;
}
@@ -4174,7 +4157,7 @@ public class RemoteViews implements Parcelable, Filter {
default:
throw new ActionException("Tag " + tag + " not found");
}
- };
+ }
/**
* Returns a deep copy of the RemoteViews object. The RemoteView may not be
@@ -5907,7 +5890,7 @@ public class RemoteViews implements Parcelable, Filter {
* Callback when the RemoteView has finished inflating,
* but no actions have been applied yet.
*/
- default void onViewInflated(View v) {};
+ default void onViewInflated(View v) {}
void onViewApplied(View v);
@@ -6288,7 +6271,6 @@ public class RemoteViews implements Parcelable, Filter {
* @hide
*/
public class ActionApplyParams {
-
public InteractionHandler handler;
public ColorResources colorResources;
public Executor executor;
@@ -6575,15 +6557,17 @@ public class RemoteViews implements Parcelable, Filter {
/**
* Parcelable.Creator that instantiates RemoteViews objects
*/
- public static final @android.annotation.NonNull Parcelable.Creator<RemoteViews> CREATOR = new Parcelable.Creator<RemoteViews>() {
- public RemoteViews createFromParcel(Parcel parcel) {
- return new RemoteViews(parcel);
- }
+ @NonNull
+ public static final Parcelable.Creator<RemoteViews> CREATOR =
+ new Parcelable.Creator<RemoteViews>() {
+ public RemoteViews createFromParcel(Parcel parcel) {
+ return new RemoteViews(parcel);
+ }
- public RemoteViews[] newArray(int size) {
- return new RemoteViews[size];
- }
- };
+ public RemoteViews[] newArray(int size) {
+ return new RemoteViews[size];
+ }
+ };
/**
* A representation of the view hierarchy. Only views which have a valid ID are added
@@ -7284,7 +7268,8 @@ public class RemoteViews implements Parcelable, Filter {
* Get the ID of the top-level view of the XML layout, if set using
* {@link RemoteViews#RemoteViews(String, int, int)}.
*/
- public @IdRes int getViewId() {
+ @IdRes
+ public int getViewId() {
return mViewId;
}