summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Garnes <matt@cyngn.com>2015-01-16 10:48:23 (GMT)
committerGerrit Code Review <gerrit@cyanogenmod.org>2015-01-16 12:00:16 (GMT)
commit19a8ed552e7453939c68ea7389f73412759f2e81 (patch)
treec91051f4af35e16171dc832f484b6bd00e6b2405
parent3f1f8fbfed868f864cf92138053c1160b3729682 (diff)
downloadandroid_packages_apps_Trebuchet-19a8ed552e7453939c68ea7389f73412759f2e81.zip
android_packages_apps_Trebuchet-19a8ed552e7453939c68ea7389f73412759f2e81.tar.gz
android_packages_apps_Trebuchet-19a8ed552e7453939c68ea7389f73412759f2e81.tar.bz2
Present default built-in wallpapers in WallPaperPicker.
If the given resource package name has been overriden by aapt, WallpaperPickerActivity can fail to find the built in default wallpapers. Retrieve these with the package name directly instead. Change-Id: I00fea3a46f13defe61056c5b9013a6f1b5457aec
-rwxr-xr-xWallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java36
1 files changed, 23 insertions, 13 deletions
diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
index a90cdba..e4fa637 100755
--- a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
+++ b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
@@ -1017,6 +1017,11 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
addWallpapers(bundled, wallpaperRes, r.first.packageName, r.second);
} catch (PackageManager.NameNotFoundException e) {
}
+ } else {
+ // Fall back to searching in our resources with the given package name if
+ // The above search fails. If the resource is not found, none will be added.
+ final String packageName = getResources().getResourcePackageName(R.array.wallpapers);
+ addWallpapers(bundled, getResources(), packageName, R.array.wallpapers);
}
if (partner == null || !partner.hideDefaultWallpaper()) {
@@ -1136,21 +1141,26 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
private void addWallpapers(ArrayList<WallpaperTileInfo> known, Resources res,
String packageName, int listResId) {
- final String[] extras = res.getStringArray(listResId);
- for (String extra : extras) {
- int resId = res.getIdentifier(extra, "drawable", packageName);
- if (resId != 0) {
- final int thumbRes = res.getIdentifier(extra + "_small", "drawable", packageName);
-
- if (thumbRes != 0) {
- ResourceWallpaperInfo wallpaperInfo =
- new ResourceWallpaperInfo(res, resId, res.getDrawable(thumbRes));
- known.add(wallpaperInfo);
- // Log.d(TAG, "add: [" + packageName + "]: " + extra + " (" + res + ")");
+ try {
+ final String[] extras = res.getStringArray(listResId);
+ for (String extra : extras) {
+ int resId = res.getIdentifier(extra, "drawable", packageName);
+ if (resId != 0) {
+ final int thumbRes = res.getIdentifier(extra + "_small", "drawable",
+ packageName);
+
+ if (thumbRes != 0) {
+ ResourceWallpaperInfo wallpaperInfo =
+ new ResourceWallpaperInfo(res, resId, res.getDrawable(thumbRes));
+ known.add(wallpaperInfo);
+ // Log.d(TAG, "add: [" + packageName + "]: " + extra + " (" + res + ")");
+ }
+ } else {
+ Log.e(TAG, "Couldn't find wallpaper " + extra);
}
- } else {
- Log.e(TAG, "Couldn't find wallpaper " + extra);
}
+ } catch (Resources.NotFoundException e) {
+ Log.e(TAG, "No wallpapers found, resource could not be located + " + listResId);
}
}