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;
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.
PackageManager pm = context.getPackageManager();
String settingsActivityComponent = null;
int thumbnailRes = -1;
+ int authorRes = -1;
+ int descriptionRes = -1;
XmlResourceParser parser = null;
try {
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 {
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);
}
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
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mSettingsActivityName);
dest.writeInt(mThumbnailResource);
+ dest.writeInt(mAuthorResource);
+ dest.writeInt(mDescriptionResource);
mService.writeToParcel(dest, flags);
}