Merge commit '2b0d6e7e43f92b1fb1dea207b3eb4121369594c3' * commit '2b0d6e7e43f92b1fb1dea207b3eb4121369594c3': Add support for thumbnails to WallpaperInfo.
This commit is contained in:
@@ -39,6 +39,11 @@ public final class WallpaperInfo implements Parcelable {
|
||||
*/
|
||||
final String mSettingsActivityName;
|
||||
|
||||
/**
|
||||
* Resource identifier for this wallpaper's thumbnail image.
|
||||
*/
|
||||
final int mThumbnailResource;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -53,6 +58,7 @@ public final class WallpaperInfo implements Parcelable {
|
||||
|
||||
PackageManager pm = context.getPackageManager();
|
||||
String settingsActivityComponent = null;
|
||||
int thumbnailRes = -1;
|
||||
|
||||
XmlResourceParser parser = null;
|
||||
try {
|
||||
@@ -79,16 +85,23 @@ public final class WallpaperInfo implements Parcelable {
|
||||
com.android.internal.R.styleable.Wallpaper);
|
||||
settingsActivityComponent = sa.getString(
|
||||
com.android.internal.R.styleable.Wallpaper_settingsActivity);
|
||||
|
||||
thumbnailRes = sa.getResourceId(
|
||||
com.android.internal.R.styleable.Wallpaper_thumbnail,
|
||||
-1);
|
||||
|
||||
sa.recycle();
|
||||
} finally {
|
||||
if (parser != null) parser.close();
|
||||
}
|
||||
|
||||
mSettingsActivityName = settingsActivityComponent;
|
||||
mThumbnailResource = thumbnailRes;
|
||||
}
|
||||
|
||||
WallpaperInfo(Parcel source) {
|
||||
mSettingsActivityName = source.readString();
|
||||
mThumbnailResource = source.readInt();
|
||||
mService = ResolveInfo.CREATOR.createFromParcel(source);
|
||||
}
|
||||
|
||||
@@ -143,6 +156,20 @@ public final class WallpaperInfo implements Parcelable {
|
||||
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
|
||||
* 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) {
|
||||
dest.writeString(mSettingsActivityName);
|
||||
dest.writeInt(mThumbnailResource);
|
||||
mService.writeToParcel(dest, flags);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user