diff options
| author | Alina Zaidi <alinazaidi@google.com> | 2021-02-24 20:01:39 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2021-02-24 20:01:39 +0000 |
| commit | bfefff41158652e26ff7f89e275458b85b3153b2 (patch) | |
| tree | 6315028aab654bc1ab6a1196ea9f9311bd8c4f16 /core/java | |
| parent | ffbe40de1e34525a703c01469aee756cc0a45108 (diff) | |
| parent | 1c9092d1274378beb603f85fa72fef4202d2b6c9 (diff) | |
Merge "Adjust AppWidgetProviderInfo#getDescription to return CharSequence." into sc-dev
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/appwidget/AppWidgetProviderInfo.java | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/core/java/android/appwidget/AppWidgetProviderInfo.java b/core/java/android/appwidget/AppWidgetProviderInfo.java index d893a5e49aa9..6ac1c1ae61ec 100644 --- a/core/java/android/appwidget/AppWidgetProviderInfo.java +++ b/core/java/android/appwidget/AppWidgetProviderInfo.java @@ -332,12 +332,13 @@ public class AppWidgetProviderInfo implements Parcelable { /** * Resource id for the description of the AppWidget. + * * <p>This field corresponds to the <code>android:description</code> attribute in the AppWidget * meta-data file. */ @SuppressLint("MutableBareField") @IdRes - public int descriptionResource; + public int descriptionRes; /** * Flags indicating various features supported by the widget. These are hints to the widget @@ -385,7 +386,7 @@ public class AppWidgetProviderInfo implements Parcelable { this.widgetCategory = in.readInt(); this.providerInfo = in.readTypedObject(ActivityInfo.CREATOR); this.widgetFeatures = in.readInt(); - this.descriptionResource = in.readInt(); + this.descriptionRes = in.readInt(); } /** @@ -442,14 +443,22 @@ public class AppWidgetProviderInfo implements Parcelable { return loadDrawable(context, density, previewImage, false); } - /** Loads localized description for the app widget. */ + /** + * Loads localized description for the app widget. + * + * <p>Description is intended to be displayed in the UI of the widget picker. + * + * @param context Context for accessing resources. + * + * @return CharSequence for app widget description for the current locale. + */ @Nullable - public final String loadDescription(@NonNull Context context) { - if (ResourceId.isValid(descriptionResource)) { + public final CharSequence loadDescription(@NonNull Context context) { + if (ResourceId.isValid(descriptionRes)) { return context.getPackageManager() .getText( providerInfo.packageName, - descriptionResource, + descriptionRes, providerInfo.applicationInfo) .toString() .trim(); @@ -499,7 +508,7 @@ public class AppWidgetProviderInfo implements Parcelable { out.writeInt(this.widgetCategory); out.writeTypedObject(this.providerInfo, flags); out.writeInt(this.widgetFeatures); - out.writeInt(this.descriptionResource); + out.writeInt(this.descriptionRes); } @Override @@ -528,7 +537,7 @@ public class AppWidgetProviderInfo implements Parcelable { that.widgetCategory = this.widgetCategory; that.providerInfo = this.providerInfo; that.widgetFeatures = this.widgetFeatures; - that.descriptionResource = this.descriptionResource; + that.descriptionRes = this.descriptionRes; return that; } |
