From 7946e72910b09b294c6d269f41ca2b356c41a50e Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Tue, 15 Dec 2020 15:47:45 -0500 Subject: [PATCH] Annotate method arguments with type annotations Fixes: 176818261 Test: n/a Change-Id: If8196c2e86ba7c6b35e3b96cc73191598bab6c8e --- core/api/current.txt | 96 +++++------ core/java/android/widget/RemoteViews.java | 191 ++++++++++++---------- 2 files changed, 150 insertions(+), 137 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index 4ad5e49bf6c0f..1f213c91f38c4 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -54046,7 +54046,7 @@ package android.widget { ctor public RemoteViews(android.widget.RemoteViews, android.widget.RemoteViews); ctor public RemoteViews(android.widget.RemoteViews); ctor public RemoteViews(android.os.Parcel); - method public void addView(int, android.widget.RemoteViews); + method public void addView(@IdRes int, android.widget.RemoteViews); method public android.view.View apply(android.content.Context, android.view.ViewGroup); method @Deprecated public android.widget.RemoteViews clone(); method public int describeContents(); @@ -54054,53 +54054,53 @@ package android.widget { method public String getPackage(); method @Deprecated public boolean onLoadClass(Class); method public void reapply(android.content.Context, android.view.View); - method public void removeAllViews(int); - method public void setAccessibilityTraversalAfter(int, int); - method public void setAccessibilityTraversalBefore(int, int); - method public void setBitmap(int, String, android.graphics.Bitmap); - method public void setBoolean(int, String, boolean); - method public void setBundle(int, String, android.os.Bundle); - method public void setByte(int, String, byte); - method public void setChar(int, String, char); - method public void setCharSequence(int, String, CharSequence); - method public void setChronometer(int, long, String, boolean); - method public void setChronometerCountDown(int, boolean); - method public void setContentDescription(int, CharSequence); - method public void setDisplayedChild(int, int); - method public void setDouble(int, String, double); - method public void setEmptyView(int, int); - method public void setFloat(int, String, float); - method public void setIcon(int, String, android.graphics.drawable.Icon); - method public void setImageViewBitmap(int, android.graphics.Bitmap); - method public void setImageViewIcon(int, android.graphics.drawable.Icon); - method public void setImageViewResource(int, int); - method public void setImageViewUri(int, android.net.Uri); - method public void setInt(int, String, int); - method public void setIntent(int, String, android.content.Intent); - method public void setLabelFor(int, int); + method public void removeAllViews(@IdRes int); + 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 setBoolean(@IdRes int, String, boolean); + method public void setBundle(@IdRes int, String, android.os.Bundle); + method public void setByte(@IdRes int, String, byte); + method public void setChar(@IdRes int, String, char); + method public void setCharSequence(@IdRes int, String, CharSequence); + method public void setChronometer(@IdRes int, long, String, boolean); + method public void setChronometerCountDown(@IdRes int, boolean); + method public void setContentDescription(@IdRes int, CharSequence); + method public void setDisplayedChild(@IdRes int, int); + method public void setDouble(@IdRes int, String, double); + method public void setEmptyView(@IdRes int, @IdRes int); + method public void setFloat(@IdRes int, String, float); + method public void setIcon(@IdRes int, String, android.graphics.drawable.Icon); + method public void setImageViewBitmap(@IdRes int, android.graphics.Bitmap); + method public void setImageViewIcon(@IdRes int, android.graphics.drawable.Icon); + method public void setImageViewResource(@IdRes int, @DrawableRes int); + method public void setImageViewUri(@IdRes int, android.net.Uri); + method public void setInt(@IdRes int, String, int); + method public void setIntent(@IdRes int, String, android.content.Intent); + method public void setLabelFor(@IdRes int, @IdRes int); method public void setLightBackgroundLayoutId(@LayoutRes int); - method public void setLong(int, String, long); - method public void setOnClickFillInIntent(int, android.content.Intent); - method public void setOnClickPendingIntent(int, android.app.PendingIntent); - method public void setOnClickResponse(int, @NonNull android.widget.RemoteViews.RemoteResponse); - method public void setPendingIntentTemplate(int, android.app.PendingIntent); - method public void setProgressBar(int, int, int, boolean); - method public void setRelativeScrollPosition(int, int); - method @Deprecated public void setRemoteAdapter(int, int, android.content.Intent); - method public void setRemoteAdapter(int, android.content.Intent); - method public void setScrollPosition(int, int); - method public void setShort(int, String, short); - method public void setString(int, String, String); - method public void setTextColor(int, @ColorInt int); - method public void setTextViewCompoundDrawables(int, int, int, int, int); - method public void setTextViewCompoundDrawablesRelative(int, int, int, int, int); - method public void setTextViewText(int, CharSequence); - method public void setTextViewTextSize(int, int, float); - method public void setUri(int, String, android.net.Uri); - method public void setViewPadding(int, int, int, int, int); - method public void setViewVisibility(int, int); - method public void showNext(int); - method public void showPrevious(int); + method public void setLong(@IdRes int, String, long); + method public void setOnClickFillInIntent(@IdRes int, android.content.Intent); + method public void setOnClickPendingIntent(@IdRes int, android.app.PendingIntent); + method public void setOnClickResponse(@IdRes int, @NonNull android.widget.RemoteViews.RemoteResponse); + method public void setPendingIntentTemplate(@IdRes int, android.app.PendingIntent); + method public void setProgressBar(@IdRes int, int, int, boolean); + method public void setRelativeScrollPosition(@IdRes int, int); + method @Deprecated public void setRemoteAdapter(int, @IdRes int, android.content.Intent); + method public void setRemoteAdapter(@IdRes int, android.content.Intent); + method public void setScrollPosition(@IdRes int, int); + method public void setShort(@IdRes int, String, short); + method public void setString(@IdRes int, String, String); + method public void setTextColor(@IdRes int, @ColorInt int); + method public void setTextViewCompoundDrawables(@IdRes int, @DrawableRes int, @DrawableRes int, @DrawableRes int, @DrawableRes int); + method public void setTextViewCompoundDrawablesRelative(@IdRes int, @DrawableRes int, @DrawableRes int, @DrawableRes int, @DrawableRes int); + method public void setTextViewText(@IdRes int, CharSequence); + method public void setTextViewTextSize(@IdRes int, int, float); + method public void setUri(@IdRes int, String, android.net.Uri); + method public void setViewPadding(@IdRes int, @Px int, @Px int, @Px int, @Px int); + method public void setViewVisibility(@IdRes int, int); + method public void showNext(@IdRes int); + method public void showPrevious(@IdRes int); method public void writeToParcel(android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator CREATOR; field public static final String EXTRA_SHARED_ELEMENT_BOUNDS = "android.widget.extra.SHARED_ELEMENT_BOUNDS"; @@ -54113,7 +54113,7 @@ package android.widget { public static class RemoteViews.RemoteResponse { ctor public RemoteViews.RemoteResponse(); - method @NonNull public android.widget.RemoteViews.RemoteResponse addSharedElement(int, @NonNull String); + method @NonNull public android.widget.RemoteViews.RemoteResponse addSharedElement(@IdRes int, @NonNull String); method @NonNull public static android.widget.RemoteViews.RemoteResponse fromFillInIntent(@NonNull android.content.Intent); method @NonNull public static android.widget.RemoteViews.RemoteResponse fromPendingIntent(@NonNull android.app.PendingIntent); } diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java index 4a84851eb0752..220a31c12f4e7 100644 --- a/core/java/android/widget/RemoteViews.java +++ b/core/java/android/widget/RemoteViews.java @@ -18,11 +18,13 @@ package android.widget; import android.annotation.ColorInt; import android.annotation.DimenRes; +import android.annotation.DrawableRes; import android.annotation.IdRes; import android.annotation.IntDef; import android.annotation.LayoutRes; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.Px; import android.annotation.StyleRes; import android.app.Activity; import android.app.ActivityOptions; @@ -329,7 +331,7 @@ public class RemoteViews implements Parcelable, Filter { /** * @hide */ - public void setRemoteInputs(int viewId, RemoteInput[] remoteInputs) { + public void setRemoteInputs(@IdRes int viewId, RemoteInput[] remoteInputs) { mActions.add(new SetRemoteInputsAction(viewId, remoteInputs)); } @@ -365,7 +367,7 @@ public class RemoteViews implements Parcelable, Filter { * * @hide */ - public void setIntTag(int viewId, int key, int tag) { + public void setIntTag(@IdRes int viewId, @IdRes int key, int tag) { addAction(new SetIntTagAction(viewId, key, tag)); } @@ -521,6 +523,7 @@ public class RemoteViews implements Parcelable, Filter { // Nothing to visit by default } + @IdRes @UnsupportedAppUsage int viewId; } @@ -645,7 +648,7 @@ public class RemoteViews implements Parcelable, Filter { private class SetEmptyView extends Action { int emptyViewId; - SetEmptyView(int viewId, int emptyViewId) { + SetEmptyView(@IdRes int viewId, @IdRes int emptyViewId) { this.viewId = viewId; this.emptyViewId = emptyViewId; } @@ -680,7 +683,7 @@ public class RemoteViews implements Parcelable, Filter { } private class SetPendingIntentTemplate extends Action { - public SetPendingIntentTemplate(int id, PendingIntent pendingIntentTemplate) { + public SetPendingIntentTemplate(@IdRes int id, PendingIntent pendingIntentTemplate) { this.viewId = id; this.pendingIntentTemplate = pendingIntentTemplate; } @@ -751,7 +754,8 @@ public class RemoteViews implements Parcelable, Filter { } private class SetRemoteViewsAdapterList extends Action { - public SetRemoteViewsAdapterList(int id, ArrayList list, int viewTypeCount) { + public SetRemoteViewsAdapterList(@IdRes int id, ArrayList list, + int viewTypeCount) { this.viewId = id; this.list = list; this.viewTypeCount = viewTypeCount; @@ -816,7 +820,7 @@ public class RemoteViews implements Parcelable, Filter { } private class SetRemoteViewsAdapterIntent extends Action { - public SetRemoteViewsAdapterIntent(int id, Intent intent) { + public SetRemoteViewsAdapterIntent(@IdRes int id, Intent intent) { this.viewId = id; this.intent = intent; } @@ -891,7 +895,7 @@ public class RemoteViews implements Parcelable, Filter { */ private class SetOnClickResponse extends Action { - SetOnClickResponse(int id, RemoteResponse response) { + SetOnClickResponse(@IdRes int id, RemoteResponse response) { this.viewId = id; this.mResponse = response; } @@ -1053,8 +1057,8 @@ public class RemoteViews implements Parcelable, Filter { *

*/ private class SetDrawableTint extends Action { - SetDrawableTint(int id, boolean targetBackground, - int colorFilter, @NonNull PorterDuff.Mode mode) { + SetDrawableTint(@IdRes int id, boolean targetBackground, + @ColorInt int colorFilter, @NonNull PorterDuff.Mode mode) { this.viewId = id; this.targetBackground = targetBackground; this.colorFilter = colorFilter; @@ -1100,7 +1104,7 @@ public class RemoteViews implements Parcelable, Filter { } boolean targetBackground; - int colorFilter; + @ColorInt int colorFilter; PorterDuff.Mode filterMode; } @@ -1117,7 +1121,7 @@ public class RemoteViews implements Parcelable, Filter { ColorStateList mColorStateList; - SetRippleDrawableColor(int id, ColorStateList colorStateList) { + SetRippleDrawableColor(@IdRes int id, ColorStateList colorStateList) { this.viewId = id; this.mColorStateList = colorStateList; } @@ -1154,7 +1158,7 @@ public class RemoteViews implements Parcelable, Filter { private final class ViewContentNavigation extends Action { final boolean mNext; - ViewContentNavigation(int viewId, boolean next) { + ViewContentNavigation(@IdRes int viewId, boolean next) { this.viewId = viewId; this.mNext = next; } @@ -1251,7 +1255,7 @@ public class RemoteViews implements Parcelable, Filter { @UnsupportedAppUsage String methodName; - BitmapReflectionAction(int viewId, String methodName, Bitmap bitmap) { + BitmapReflectionAction(@IdRes int viewId, String methodName, Bitmap bitmap) { this.bitmap = bitmap; this.viewId = viewId; this.methodName = methodName; @@ -1320,7 +1324,7 @@ public class RemoteViews implements Parcelable, Filter { @UnsupportedAppUsage Object value; - ReflectionAction(int viewId, String methodName, int type, Object value) { + ReflectionAction(@IdRes int viewId, String methodName, int type, Object value) { this.viewId = viewId; this.methodName = methodName; this.type = type; @@ -1614,11 +1618,11 @@ public class RemoteViews implements Parcelable, Filter { private RemoteViews mNestedViews; private int mIndex; - ViewGroupActionAdd(int viewId, RemoteViews nestedViews) { + ViewGroupActionAdd(@IdRes int viewId, RemoteViews nestedViews) { this(viewId, nestedViews, -1 /* index */); } - ViewGroupActionAdd(int viewId, RemoteViews nestedViews, int index) { + ViewGroupActionAdd(@IdRes int viewId, RemoteViews nestedViews, int index) { this.viewId = viewId; mNestedViews = nestedViews; mIndex = index; @@ -1728,11 +1732,11 @@ public class RemoteViews implements Parcelable, Filter { private int mViewIdToKeep; - ViewGroupActionRemove(int viewId) { + ViewGroupActionRemove(@IdRes int viewId) { this(viewId, REMOVE_ALL_VIEWS_ID); } - ViewGroupActionRemove(int viewId, int viewIdToKeep) { + ViewGroupActionRemove(@IdRes int viewId, @IdRes int viewIdToKeep) { this.viewId = viewId; mViewIdToKeep = viewIdToKeep; } @@ -1831,7 +1835,8 @@ public class RemoteViews implements Parcelable, Filter { * (s/t/e/b) or cardinal (l/t/r/b) arrangement. */ private class TextViewDrawableAction extends Action { - public TextViewDrawableAction(int viewId, boolean isRelative, int d1, int d2, int d3, int d4) { + 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; @@ -1841,7 +1846,7 @@ public class RemoteViews implements Parcelable, Filter { this.d4 = d4; } - public TextViewDrawableAction(int viewId, boolean isRelative, + public TextViewDrawableAction(@IdRes int viewId, boolean isRelative, Icon i1, Icon i2, Icon i3, Icon i4) { this.viewId = viewId; this.isRelative = isRelative; @@ -2014,7 +2019,8 @@ public class RemoteViews implements Parcelable, Filter { * Helper action to set padding on a View. */ private class ViewPaddingAction extends Action { - public ViewPaddingAction(int viewId, int left, int top, int right, int bottom) { + 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; @@ -2050,7 +2056,7 @@ public class RemoteViews implements Parcelable, Filter { return VIEW_PADDING_ACTION_TAG; } - int left, top, right, bottom; + @Px int left, top, right, bottom; } /** @@ -2209,7 +2215,7 @@ public class RemoteViews implements Parcelable, Filter { */ private class SetRemoteInputsAction extends Action { - public SetRemoteInputsAction(int viewId, RemoteInput[] remoteInputs) { + public SetRemoteInputsAction(@IdRes int viewId, RemoteInput[] remoteInputs) { this.viewId = viewId; this.remoteInputs = remoteInputs; } @@ -2287,11 +2293,11 @@ public class RemoteViews implements Parcelable, Filter { } private class SetIntTagAction extends Action { - private final int mViewId; - private final int mKey; + @IdRes private final int mViewId; + @IdRes private final int mKey; private final int mTag; - SetIntTagAction(int viewId, int key, int tag) { + SetIntTagAction(@IdRes int viewId, @IdRes int key, int tag) { mViewId = viewId; mKey = key; mTag = tag; @@ -2623,7 +2629,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the parent {@link ViewGroup} to add child into. * @param nestedView {@link RemoteViews} that describes the child. */ - public void addView(int viewId, RemoteViews nestedView) { + public void addView(@IdRes int viewId, RemoteViews nestedView) { // Clear all children when nested views omitted addAction(nestedView == null ? new ViewGroupActionRemove(viewId) @@ -2641,7 +2647,7 @@ public class RemoteViews implements Parcelable, Filter { * @hide */ @UnsupportedAppUsage - public void addView(int viewId, RemoteViews nestedView, int index) { + public void addView(@IdRes int viewId, RemoteViews nestedView, int index) { addAction(new ViewGroupActionAdd(viewId, nestedView, index)); } @@ -2651,7 +2657,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the parent {@link ViewGroup} to remove all * children from. */ - public void removeAllViews(int viewId) { + public void removeAllViews(@IdRes int viewId) { addAction(new ViewGroupActionRemove(viewId)); } @@ -2664,7 +2670,7 @@ public class RemoteViews implements Parcelable, Filter { * * @hide */ - public void removeAllViewsExceptId(int viewId, int viewIdToKeep) { + public void removeAllViewsExceptId(@IdRes int viewId, @IdRes int viewIdToKeep) { addAction(new ViewGroupActionRemove(viewId, viewIdToKeep)); } @@ -2673,7 +2679,7 @@ public class RemoteViews implements Parcelable, Filter { * * @param viewId The id of the view on which to call {@link AdapterViewAnimator#showNext()} */ - public void showNext(int viewId) { + public void showNext(@IdRes int viewId) { addAction(new ViewContentNavigation(viewId, true /* next */)); } @@ -2682,7 +2688,7 @@ public class RemoteViews implements Parcelable, Filter { * * @param viewId The id of the view on which to call {@link AdapterViewAnimator#showPrevious()} */ - public void showPrevious(int viewId) { + public void showPrevious(@IdRes int viewId) { addAction(new ViewContentNavigation(viewId, false /* next */)); } @@ -2692,7 +2698,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the view on which to call * {@link AdapterViewAnimator#setDisplayedChild(int)} */ - public void setDisplayedChild(int viewId, int childIndex) { + public void setDisplayedChild(@IdRes int viewId, int childIndex) { setInt(viewId, "setDisplayedChild", childIndex); } @@ -2702,7 +2708,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the view whose visibility should change * @param visibility The new visibility for the view */ - public void setViewVisibility(int viewId, int visibility) { + public void setViewVisibility(@IdRes int viewId, @View.Visibility int visibility) { setInt(viewId, "setVisibility", visibility); } @@ -2712,7 +2718,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the view whose text should change * @param text The new text for the view */ - public void setTextViewText(int viewId, CharSequence text) { + public void setTextViewText(@IdRes int viewId, CharSequence text) { setCharSequence(viewId, "setText", text); } @@ -2723,7 +2729,7 @@ public class RemoteViews implements Parcelable, Filter { * @param units The units of size (e.g. COMPLEX_UNIT_SP) * @param size The size of the text */ - public void setTextViewTextSize(int viewId, int units, float size) { + public void setTextViewTextSize(@IdRes int viewId, int units, float size) { addAction(new TextViewSizeAction(viewId, units, size)); } @@ -2737,7 +2743,8 @@ public class RemoteViews implements Parcelable, Filter { * @param right The id of a drawable to place to the right of the text, or 0 * @param bottom The id of a drawable to place below the text, or 0 */ - public void setTextViewCompoundDrawables(int viewId, int left, int top, int right, int bottom) { + public void setTextViewCompoundDrawables(@IdRes int viewId, @DrawableRes int left, + @DrawableRes int top, @DrawableRes int right, @DrawableRes int bottom) { addAction(new TextViewDrawableAction(viewId, false, left, top, right, bottom)); } @@ -2752,7 +2759,8 @@ public class RemoteViews implements Parcelable, Filter { * @param end The id of a drawable to place after the text, or 0 * @param bottom The id of a drawable to place below the text, or 0 */ - public void setTextViewCompoundDrawablesRelative(int viewId, int start, int top, int end, int bottom) { + public void setTextViewCompoundDrawablesRelative(@IdRes int viewId, @DrawableRes int start, + @DrawableRes int top, @DrawableRes int end, @DrawableRes int bottom) { addAction(new TextViewDrawableAction(viewId, true, start, top, end, bottom)); } @@ -2769,7 +2777,8 @@ public class RemoteViews implements Parcelable, Filter { * * @hide */ - public void setTextViewCompoundDrawables(int viewId, Icon left, Icon top, Icon right, Icon bottom) { + public void setTextViewCompoundDrawables(@IdRes int viewId, + Icon left, Icon top, Icon right, Icon bottom) { addAction(new TextViewDrawableAction(viewId, false, left, top, right, bottom)); } @@ -2787,7 +2796,8 @@ public class RemoteViews implements Parcelable, Filter { * * @hide */ - public void setTextViewCompoundDrawablesRelative(int viewId, Icon start, Icon top, Icon end, Icon bottom) { + public void setTextViewCompoundDrawablesRelative(@IdRes int viewId, + Icon start, Icon top, Icon end, Icon bottom) { addAction(new TextViewDrawableAction(viewId, true, start, top, end, bottom)); } @@ -2797,7 +2807,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the view whose drawable should change * @param srcId The new resource id for the drawable */ - public void setImageViewResource(int viewId, int srcId) { + public void setImageViewResource(@IdRes int viewId, @DrawableRes int srcId) { setInt(viewId, "setImageResource", srcId); } @@ -2807,7 +2817,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the view whose drawable should change * @param uri The Uri for the image */ - public void setImageViewUri(int viewId, Uri uri) { + public void setImageViewUri(@IdRes int viewId, Uri uri) { setUri(viewId, "setImageURI", uri); } @@ -2817,7 +2827,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the view whose bitmap should change * @param bitmap The new Bitmap for the drawable */ - public void setImageViewBitmap(int viewId, Bitmap bitmap) { + public void setImageViewBitmap(@IdRes int viewId, Bitmap bitmap) { setBitmap(viewId, "setImageBitmap", bitmap); } @@ -2827,7 +2837,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the view whose bitmap should change * @param icon The new Icon for the ImageView */ - public void setImageViewIcon(int viewId, Icon icon) { + public void setImageViewIcon(@IdRes int viewId, Icon icon) { setIcon(viewId, "setImageIcon", icon); } @@ -2837,7 +2847,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the view on which to set the empty view * @param emptyViewId The view id of the empty view */ - public void setEmptyView(int viewId, int emptyViewId) { + public void setEmptyView(@IdRes int viewId, @IdRes int emptyViewId) { addAction(new SetEmptyView(viewId, emptyViewId)); } @@ -2857,7 +2867,7 @@ public class RemoteViews implements Parcelable, Filter { * * @see #setChronometerCountDown(int, boolean) */ - public void setChronometer(int viewId, long base, String format, boolean started) { + public void setChronometer(@IdRes int viewId, long base, String format, boolean started) { setLong(viewId, "setBase", base); setString(viewId, "setFormat", format); setBoolean(viewId, "setStarted", started); @@ -2871,7 +2881,7 @@ public class RemoteViews implements Parcelable, Filter { * @param isCountDown True if you want the chronometer to count down to base instead of * counting up. */ - public void setChronometerCountDown(int viewId, boolean isCountDown) { + public void setChronometerCountDown(@IdRes int viewId, boolean isCountDown) { setBoolean(viewId, "setCountDown", isCountDown); } @@ -2888,7 +2898,7 @@ public class RemoteViews implements Parcelable, Filter { * @param indeterminate True if the progress bar is indeterminate, * false if not. */ - public void setProgressBar(int viewId, int max, int progress, + public void setProgressBar(@IdRes int viewId, int max, int progress, boolean indeterminate) { setBoolean(viewId, "setIndeterminate", indeterminate); if (!indeterminate) { @@ -2914,7 +2924,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the view that will trigger the {@link PendingIntent} when clicked * @param pendingIntent The {@link PendingIntent} to send when user clicks */ - public void setOnClickPendingIntent(int viewId, PendingIntent pendingIntent) { + public void setOnClickPendingIntent(@IdRes int viewId, PendingIntent pendingIntent) { setOnClickResponse(viewId, RemoteResponse.fromPendingIntent(pendingIntent)); } @@ -2926,7 +2936,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the view that will trigger the {@link RemoteResponse} when clicked * @param response The {@link RemoteResponse} to send when user clicks */ - public void setOnClickResponse(int viewId, @NonNull RemoteResponse response) { + public void setOnClickResponse(@IdRes int viewId, @NonNull RemoteResponse response) { addAction(new SetOnClickResponse(viewId, response)); } @@ -2942,7 +2952,7 @@ public class RemoteViews implements Parcelable, Filter { * @param pendingIntentTemplate The {@link PendingIntent} to be combined with extras specified * by a child of viewId and executed when that child is clicked */ - public void setPendingIntentTemplate(int viewId, PendingIntent pendingIntentTemplate) { + public void setPendingIntentTemplate(@IdRes int viewId, PendingIntent pendingIntentTemplate) { addAction(new SetPendingIntentTemplate(viewId, pendingIntentTemplate)); } @@ -2963,7 +2973,7 @@ public class RemoteViews implements Parcelable, Filter { * @param fillInIntent The intent which will be combined with the parent's PendingIntent * in order to determine the on-click behavior of the view specified by viewId */ - public void setOnClickFillInIntent(int viewId, Intent fillInIntent) { + public void setOnClickFillInIntent(@IdRes int viewId, Intent fillInIntent) { setOnClickResponse(viewId, RemoteResponse.fromFillInIntent(fillInIntent)); } @@ -2987,8 +2997,8 @@ public class RemoteViews implements Parcelable, Filter { * @param mode Specify a PorterDuff mode for this drawable, or null to leave * unchanged. */ - public void setDrawableTint(int viewId, boolean targetBackground, - int colorFilter, @NonNull PorterDuff.Mode mode) { + public void setDrawableTint(@IdRes int viewId, boolean targetBackground, + @ColorInt int colorFilter, @NonNull PorterDuff.Mode mode) { addAction(new SetDrawableTint(viewId, targetBackground, colorFilter, mode)); } @@ -3004,7 +3014,7 @@ public class RemoteViews implements Parcelable, Filter { * @param colorStateList Specify a color for a * {@link ColorStateList} for this drawable. */ - public void setRippleDrawableColor(int viewId, ColorStateList colorStateList) { + public void setRippleDrawableColor(@IdRes int viewId, ColorStateList colorStateList) { addAction(new SetRippleDrawableColor(viewId, colorStateList)); } @@ -3015,7 +3025,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the view whose tint should change * @param tint the tint to apply, may be {@code null} to clear tint */ - public void setProgressTintList(int viewId, ColorStateList tint) { + public void setProgressTintList(@IdRes int viewId, ColorStateList tint) { addAction(new ReflectionAction(viewId, "setProgressTintList", ReflectionAction.COLOR_STATE_LIST, tint)); } @@ -3027,7 +3037,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the view whose tint should change * @param tint the tint to apply, may be {@code null} to clear tint */ - public void setProgressBackgroundTintList(int viewId, ColorStateList tint) { + public void setProgressBackgroundTintList(@IdRes int viewId, ColorStateList tint) { addAction(new ReflectionAction(viewId, "setProgressBackgroundTintList", ReflectionAction.COLOR_STATE_LIST, tint)); } @@ -3039,7 +3049,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the view whose tint should change * @param tint the tint to apply, may be {@code null} to clear tint */ - public void setProgressIndeterminateTintList(int viewId, ColorStateList tint) { + public void setProgressIndeterminateTintList(@IdRes int viewId, ColorStateList tint) { addAction(new ReflectionAction(viewId, "setIndeterminateTintList", ReflectionAction.COLOR_STATE_LIST, tint)); } @@ -3051,7 +3061,7 @@ public class RemoteViews implements Parcelable, Filter { * @param color Sets the text color for all the states (normal, selected, * focused) to be this color. */ - public void setTextColor(int viewId, @ColorInt int color) { + public void setTextColor(@IdRes int viewId, @ColorInt int color) { setInt(viewId, "setTextColor", color); } @@ -3062,7 +3072,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the view whose text color should change * @param colors the text colors to set */ - public void setTextColor(int viewId, @ColorInt ColorStateList colors) { + public void setTextColor(@IdRes int viewId, ColorStateList colors) { addAction(new ReflectionAction(viewId, "setTextColor", ReflectionAction.COLOR_STATE_LIST, colors)); } @@ -3079,7 +3089,7 @@ public class RemoteViews implements Parcelable, Filter { * {@link android.widget.RemoteViews#setRemoteAdapter(int, Intent)} */ @Deprecated - public void setRemoteAdapter(int appWidgetId, int viewId, Intent intent) { + public void setRemoteAdapter(int appWidgetId, @IdRes int viewId, Intent intent) { setRemoteAdapter(viewId, intent); } @@ -3091,7 +3101,7 @@ public class RemoteViews implements Parcelable, Filter { * @param intent The intent of the service which will be * providing data to the RemoteViewsAdapter */ - public void setRemoteAdapter(int viewId, Intent intent) { + public void setRemoteAdapter(@IdRes int viewId, Intent intent) { addAction(new SetRemoteViewsAdapterIntent(viewId, intent)); } @@ -3119,7 +3129,8 @@ public class RemoteViews implements Parcelable, Filter { */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) @Deprecated - public void setRemoteAdapter(int viewId, ArrayList list, int viewTypeCount) { + public void setRemoteAdapter(@IdRes int viewId, ArrayList list, + int viewTypeCount) { addAction(new SetRemoteViewsAdapterList(viewId, list, viewTypeCount)); } @@ -3129,7 +3140,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the view to change * @param position Scroll to this adapter position */ - public void setScrollPosition(int viewId, int position) { + public void setScrollPosition(@IdRes int viewId, int position) { setInt(viewId, "smoothScrollToPosition", position); } @@ -3139,7 +3150,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the view to change * @param offset Scroll by this adapter position offset */ - public void setRelativeScrollPosition(int viewId, int offset) { + public void setRelativeScrollPosition(@IdRes int viewId, int offset) { setInt(viewId, "smoothScrollByOffset", offset); } @@ -3152,7 +3163,8 @@ public class RemoteViews implements Parcelable, Filter { * @param right the right padding in pixels * @param bottom the bottom padding in pixels */ - public void setViewPadding(int viewId, int left, int top, int right, int bottom) { + public void setViewPadding(@IdRes int viewId, + @Px int left, @Px int top, @Px int right, @Px int bottom) { addAction(new ViewPaddingAction(viewId, left, top, right, bottom)); } @@ -3254,7 +3266,7 @@ public class RemoteViews implements Parcelable, Filter { * @param methodName The name of the method to call. * @param value The value to pass to the method. */ - public void setBoolean(int viewId, String methodName, boolean value) { + public void setBoolean(@IdRes int viewId, String methodName, boolean value) { addAction(new ReflectionAction(viewId, methodName, ReflectionAction.BOOLEAN, value)); } @@ -3265,7 +3277,7 @@ public class RemoteViews implements Parcelable, Filter { * @param methodName The name of the method to call. * @param value The value to pass to the method. */ - public void setByte(int viewId, String methodName, byte value) { + public void setByte(@IdRes int viewId, String methodName, byte value) { addAction(new ReflectionAction(viewId, methodName, ReflectionAction.BYTE, value)); } @@ -3276,7 +3288,7 @@ public class RemoteViews implements Parcelable, Filter { * @param methodName The name of the method to call. * @param value The value to pass to the method. */ - public void setShort(int viewId, String methodName, short value) { + public void setShort(@IdRes int viewId, String methodName, short value) { addAction(new ReflectionAction(viewId, methodName, ReflectionAction.SHORT, value)); } @@ -3287,7 +3299,7 @@ public class RemoteViews implements Parcelable, Filter { * @param methodName The name of the method to call. * @param value The value to pass to the method. */ - public void setInt(int viewId, String methodName, int value) { + public void setInt(@IdRes int viewId, String methodName, int value) { addAction(new ReflectionAction(viewId, methodName, ReflectionAction.INT, value)); } @@ -3300,7 +3312,7 @@ public class RemoteViews implements Parcelable, Filter { * * @hide */ - public void setColorStateList(int viewId, String methodName, ColorStateList value) { + public void setColorStateList(@IdRes int viewId, String methodName, ColorStateList value) { addAction(new ReflectionAction(viewId, methodName, ReflectionAction.COLOR_STATE_LIST, value)); } @@ -3313,7 +3325,7 @@ public class RemoteViews implements Parcelable, Filter { * @param methodName The name of the method to call. * @param value The value to pass to the method. */ - public void setLong(int viewId, String methodName, long value) { + public void setLong(@IdRes int viewId, String methodName, long value) { addAction(new ReflectionAction(viewId, methodName, ReflectionAction.LONG, value)); } @@ -3324,7 +3336,7 @@ public class RemoteViews implements Parcelable, Filter { * @param methodName The name of the method to call. * @param value The value to pass to the method. */ - public void setFloat(int viewId, String methodName, float value) { + public void setFloat(@IdRes int viewId, String methodName, float value) { addAction(new ReflectionAction(viewId, methodName, ReflectionAction.FLOAT, value)); } @@ -3335,7 +3347,7 @@ public class RemoteViews implements Parcelable, Filter { * @param methodName The name of the method to call. * @param value The value to pass to the method. */ - public void setDouble(int viewId, String methodName, double value) { + public void setDouble(@IdRes int viewId, String methodName, double value) { addAction(new ReflectionAction(viewId, methodName, ReflectionAction.DOUBLE, value)); } @@ -3346,7 +3358,7 @@ public class RemoteViews implements Parcelable, Filter { * @param methodName The name of the method to call. * @param value The value to pass to the method. */ - public void setChar(int viewId, String methodName, char value) { + public void setChar(@IdRes int viewId, String methodName, char value) { addAction(new ReflectionAction(viewId, methodName, ReflectionAction.CHAR, value)); } @@ -3357,7 +3369,7 @@ public class RemoteViews implements Parcelable, Filter { * @param methodName The name of the method to call. * @param value The value to pass to the method. */ - public void setString(int viewId, String methodName, String value) { + public void setString(@IdRes int viewId, String methodName, String value) { addAction(new ReflectionAction(viewId, methodName, ReflectionAction.STRING, value)); } @@ -3368,7 +3380,7 @@ public class RemoteViews implements Parcelable, Filter { * @param methodName The name of the method to call. * @param value The value to pass to the method. */ - public void setCharSequence(int viewId, String methodName, CharSequence value) { + public void setCharSequence(@IdRes int viewId, String methodName, CharSequence value) { addAction(new ReflectionAction(viewId, methodName, ReflectionAction.CHAR_SEQUENCE, value)); } @@ -3379,7 +3391,7 @@ public class RemoteViews implements Parcelable, Filter { * @param methodName The name of the method to call. * @param value The value to pass to the method. */ - public void setUri(int viewId, String methodName, Uri value) { + public void setUri(@IdRes int viewId, String methodName, Uri value) { if (value != null) { // Resolve any filesystem path before sending remotely value = value.getCanonicalUri(); @@ -3400,7 +3412,7 @@ public class RemoteViews implements Parcelable, Filter { * @param methodName The name of the method to call. * @param value The value to pass to the method. */ - public void setBitmap(int viewId, String methodName, Bitmap value) { + public void setBitmap(@IdRes int viewId, String methodName, Bitmap value) { addAction(new BitmapReflectionAction(viewId, methodName, value)); } @@ -3411,7 +3423,7 @@ public class RemoteViews implements Parcelable, Filter { * @param methodName The name of the method to call. * @param value The value to pass to the method. */ - public void setBundle(int viewId, String methodName, Bundle value) { + public void setBundle(@IdRes int viewId, String methodName, Bundle value) { addAction(new ReflectionAction(viewId, methodName, ReflectionAction.BUNDLE, value)); } @@ -3422,7 +3434,7 @@ public class RemoteViews implements Parcelable, Filter { * @param methodName The name of the method to call. * @param value The {@link android.content.Intent} to pass the method. */ - public void setIntent(int viewId, String methodName, Intent value) { + public void setIntent(@IdRes int viewId, String methodName, Intent value) { addAction(new ReflectionAction(viewId, methodName, ReflectionAction.INTENT, value)); } @@ -3433,7 +3445,7 @@ public class RemoteViews implements Parcelable, Filter { * @param methodName The name of the method to call. * @param value The {@link android.graphics.drawable.Icon} to pass the method. */ - public void setIcon(int viewId, String methodName, Icon value) { + public void setIcon(@IdRes int viewId, String methodName, Icon value) { addAction(new ReflectionAction(viewId, methodName, ReflectionAction.ICON, value)); } @@ -3443,7 +3455,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the view whose content description should change. * @param contentDescription The new content description for the view. */ - public void setContentDescription(int viewId, CharSequence contentDescription) { + public void setContentDescription(@IdRes int viewId, CharSequence contentDescription) { setCharSequence(viewId, "setContentDescription", contentDescription); } @@ -3453,7 +3465,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the view whose before view in accessibility traversal to set. * @param nextId The id of the next in the accessibility traversal. **/ - public void setAccessibilityTraversalBefore(int viewId, int nextId) { + public void setAccessibilityTraversalBefore(@IdRes int viewId, @IdRes int nextId) { setInt(viewId, "setAccessibilityTraversalBefore", nextId); } @@ -3463,7 +3475,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the view whose after view in accessibility traversal to set. * @param nextId The id of the next in the accessibility traversal. **/ - public void setAccessibilityTraversalAfter(int viewId, int nextId) { + public void setAccessibilityTraversalAfter(@IdRes int viewId, @IdRes int nextId) { setInt(viewId, "setAccessibilityTraversalAfter", nextId); } @@ -3473,7 +3485,7 @@ public class RemoteViews implements Parcelable, Filter { * @param viewId The id of the view whose property to set. * @param labeledId The id of a view for which this view serves as a label. */ - public void setLabelFor(int viewId, int labeledId) { + public void setLabelFor(@IdRes int viewId, @IdRes int labeledId) { setInt(viewId, "setLabelFor", labeledId); } @@ -3997,7 +4009,7 @@ public class RemoteViews implements Parcelable, Filter { } } - public ViewTree findViewTreeById(int id) { + public ViewTree findViewTreeById(@IdRes int id) { if (mRoot.getId() == id) { return this; } @@ -4019,7 +4031,7 @@ public class RemoteViews implements Parcelable, Filter { createTree(); } - public T findViewById(int id) { + public T findViewById(@IdRes int id) { if (mChildren == null) { return mRoot.findViewById(id); } @@ -4153,7 +4165,8 @@ public class RemoteViews implements Parcelable, Filter { * @see ActivityOptions#makeSceneTransitionAnimation(Activity, Pair[]) */ @NonNull - public RemoteResponse addSharedElement(int viewId, @NonNull String sharedElementName) { + public RemoteResponse addSharedElement(@IdRes int viewId, + @NonNull String sharedElementName) { if (mViewIds == null) { mViewIds = new IntArray(); mElementNames = new ArrayList<>();