Merge change 26415 into eclair

* changes:
  Add support for thumbnails to WallpaperInfo.
This commit is contained in:
Android (Google) Code Review
2009-09-22 22:06:38 -04:00
4 changed files with 43 additions and 0 deletions

View File

@ -8259,6 +8259,17 @@
visibility="public" visibility="public"
> >
</field> </field>
<field name="thumbnail"
type="int"
transient="false"
volatile="false"
value="16843429"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="tileMode" <field name="tileMode"
type="int" type="int"
transient="false" transient="false"

View File

@ -39,6 +39,11 @@ public final class WallpaperInfo implements Parcelable {
*/ */
final String mSettingsActivityName; final String mSettingsActivityName;
/**
* Resource identifier for this wallpaper's thumbnail image.
*/
final int mThumbnailResource;
/** /**
* Constructor. * Constructor.
* *
@ -53,6 +58,7 @@ public final class WallpaperInfo implements Parcelable {
PackageManager pm = context.getPackageManager(); PackageManager pm = context.getPackageManager();
String settingsActivityComponent = null; String settingsActivityComponent = null;
int thumbnailRes = -1;
XmlResourceParser parser = null; XmlResourceParser parser = null;
try { try {
@ -79,16 +85,23 @@ public final class WallpaperInfo implements Parcelable {
com.android.internal.R.styleable.Wallpaper); com.android.internal.R.styleable.Wallpaper);
settingsActivityComponent = sa.getString( settingsActivityComponent = sa.getString(
com.android.internal.R.styleable.Wallpaper_settingsActivity); com.android.internal.R.styleable.Wallpaper_settingsActivity);
thumbnailRes = sa.getResourceId(
com.android.internal.R.styleable.Wallpaper_thumbnail,
-1);
sa.recycle(); sa.recycle();
} finally { } finally {
if (parser != null) parser.close(); if (parser != null) parser.close();
} }
mSettingsActivityName = settingsActivityComponent; mSettingsActivityName = settingsActivityComponent;
mThumbnailResource = thumbnailRes;
} }
WallpaperInfo(Parcel source) { WallpaperInfo(Parcel source) {
mSettingsActivityName = source.readString(); mSettingsActivityName = source.readString();
mThumbnailResource = source.readInt();
mService = ResolveInfo.CREATOR.createFromParcel(source); mService = ResolveInfo.CREATOR.createFromParcel(source);
} }
@ -143,6 +156,20 @@ public final class WallpaperInfo implements Parcelable {
return mService.loadIcon(pm); return mService.loadIcon(pm);
} }
/**
* Load the thumbnail image for this wallpaper.
*
* @param pm Supply a PackageManager used to load the wallpaper's
* resources.
*/
public Drawable loadThumbnail(PackageManager pm) {
if (mThumbnailResource < 0) return null;
return pm.getDrawable(mService.serviceInfo.packageName,
mThumbnailResource,
null);
}
/** /**
* Return the class name of an activity that provides a settings UI for * Return the class name of an activity that provides a settings UI for
* the wallpaper. You can launch this activity be starting it with * the wallpaper. You can launch this activity be starting it with
@ -178,6 +205,7 @@ public final class WallpaperInfo implements Parcelable {
*/ */
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mSettingsActivityName); dest.writeString(mSettingsActivityName);
dest.writeInt(mThumbnailResource);
mService.writeToParcel(dest, flags); mService.writeToParcel(dest, flags);
} }

View File

@ -3451,6 +3451,9 @@
<!-- Component name of an activity that allows the user to modify <!-- Component name of an activity that allows the user to modify
the current settings for this wallpaper. --> the current settings for this wallpaper. -->
<attr name="settingsActivity" /> <attr name="settingsActivity" />
<!-- Reference to a the wallpaper's thumbnail bitmap. -->
<attr name="thumbnail" format="reference" />
</declare-styleable> </declare-styleable>
<!-- =============================== --> <!-- =============================== -->

View File

@ -1169,6 +1169,7 @@
<public type="attr" name="summaryColumn" /> <public type="attr" name="summaryColumn" />
<public type="attr" name="detailColumn" /> <public type="attr" name="detailColumn" />
<public type="attr" name="detailSocialSummary" /> <public type="attr" name="detailSocialSummary" />
<public type="attr" name="thumbnail" />
<public type="style" name="Theme.Wallpaper" /> <public type="style" name="Theme.Wallpaper" />
<public type="style" name="Theme.Wallpaper.NoTitleBar" /> <public type="style" name="Theme.Wallpaper.NoTitleBar" />