diff options
author | Daniel Sandler <dsandler@google.com> | 2009-11-05 15:05:27 -0500 |
---|---|---|
committer | Daniel Sandler <dsandler@google.com> | 2009-11-05 15:05:27 -0500 |
commit | 18a509d8fa3ff31aeb8a503f1f2a3dd63bd359d7 (patch) | |
tree | 7157cee55399ae00bac3b40791748d8e4138c795 /core | |
parent | 67b692920c18f99b096dce285adc6f7439fa866c (diff) | |
download | frameworks_base-18a509d8fa3ff31aeb8a503f1f2a3dd63bd359d7.zip frameworks_base-18a509d8fa3ff31aeb8a503f1f2a3dd63bd359d7.tar.gz frameworks_base-18a509d8fa3ff31aeb8a503f1f2a3dd63bd359d7.tar.bz2 |
New live wallpaper API to expose author and description strings.
First in a sequence of CLs to address
http://b/issue?id=2235307 .
Change-Id: Id1458b01c8a7918f345823b45e5726e02285d8b5
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/app/WallpaperInfo.java | 51 | ||||
-rw-r--r-- | core/res/res/values/attrs.xml | 6 | ||||
-rw-r--r-- | core/res/res/values/public.xml | 3 |
3 files changed, 60 insertions, 0 deletions
diff --git a/core/java/android/app/WallpaperInfo.java b/core/java/android/app/WallpaperInfo.java index 587e8f9..59d58aa 100644 --- a/core/java/android/app/WallpaperInfo.java +++ b/core/java/android/app/WallpaperInfo.java @@ -9,6 +9,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; +import android.content.res.Resources.NotFoundException; import android.content.res.TypedArray; import android.content.res.XmlResourceParser; import android.graphics.drawable.Drawable; @@ -45,6 +46,16 @@ public final class WallpaperInfo implements Parcelable { final int mThumbnailResource; /** + * Resource identifier for a string indicating the author of the wallpaper. + */ + final int mAuthorResource; + + /** + * Resource identifier for a string containing a short description of the wallpaper. + */ + final int mDescriptionResource; + + /** * Constructor. * * @param context The Context in which we are parsing the wallpaper. @@ -59,6 +70,8 @@ public final class WallpaperInfo implements Parcelable { PackageManager pm = context.getPackageManager(); String settingsActivityComponent = null; int thumbnailRes = -1; + int authorRes = -1; + int descriptionRes = -1; XmlResourceParser parser = null; try { @@ -89,6 +102,12 @@ public final class WallpaperInfo implements Parcelable { thumbnailRes = sa.getResourceId( com.android.internal.R.styleable.Wallpaper_thumbnail, -1); + authorRes = sa.getResourceId( + com.android.internal.R.styleable.Wallpaper_wallpaperAuthor, + -1); + descriptionRes = sa.getResourceId( + com.android.internal.R.styleable.Wallpaper_wallpaperDescription, + -1); sa.recycle(); } finally { @@ -97,11 +116,15 @@ public final class WallpaperInfo implements Parcelable { mSettingsActivityName = settingsActivityComponent; mThumbnailResource = thumbnailRes; + mAuthorResource = authorRes; + mDescriptionResource = descriptionRes; } WallpaperInfo(Parcel source) { mSettingsActivityName = source.readString(); mThumbnailResource = source.readInt(); + mAuthorResource = source.readInt(); + mDescriptionResource = source.readInt(); mService = ResolveInfo.CREATOR.createFromParcel(source); } @@ -169,6 +192,32 @@ public final class WallpaperInfo implements Parcelable { mThumbnailResource, null); } + + /** + * Return a string indicating the author(s) of this wallpaper. + */ + public CharSequence loadAuthor(PackageManager pm) throws NotFoundException { + if (mAuthorResource <= 0) throw new NotFoundException(); + return pm.getText( + (mService.resolvePackageName != null) + ? mService.resolvePackageName + : getPackageName(), + mAuthorResource, + null); + } + + /** + * Return a brief summary of this wallpaper's behavior. + */ + public CharSequence loadDescription(PackageManager pm) throws NotFoundException { + if (mDescriptionResource <= 0) throw new NotFoundException(); + return pm.getText( + (mService.resolvePackageName != null) + ? mService.resolvePackageName + : getPackageName(), + mDescriptionResource, + null); + } /** * Return the class name of an activity that provides a settings UI for @@ -206,6 +255,8 @@ public final class WallpaperInfo implements Parcelable { public void writeToParcel(Parcel dest, int flags) { dest.writeString(mSettingsActivityName); dest.writeInt(mThumbnailResource); + dest.writeInt(mAuthorResource); + dest.writeInt(mDescriptionResource); mService.writeToParcel(dest, flags); } diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 8aab595..7e6258e 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -3483,6 +3483,12 @@ <!-- Reference to a the wallpaper's thumbnail bitmap. --> <attr name="thumbnail" format="reference" /> + + <!-- Name of the author of a wallpaper, e.g. Google. --> + <attr name="wallpaperAuthor" format="reference" /> + + <!-- Short description of the wallpaper's purpose or behavior. --> + <attr name="wallpaperDescription" format="reference" /> </declare-styleable> <!-- =============================== --> diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index a0b56101..5eb1c8e 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -1201,5 +1201,8 @@ <public type="attr" name="quickContactBadgeStyleSmallWindowSmall" /> <public type="attr" name="quickContactBadgeStyleSmallWindowMedium" /> <public type="attr" name="quickContactBadgeStyleSmallWindowLarge" /> + + <public type="attr" name="wallpaperAuthor" /> + <public type="attr" name="wallpaperDescription" /> </resources> |