diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2015-08-31 13:38:44 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2015-08-31 13:39:25 -0700 |
commit | f4d017999a51e983b4997ef2e9513d508a718cb2 (patch) | |
tree | 03d7c665be8d6d9740003bfe7a3a993c54f98b4b /WallpaperPicker/src/com/android | |
parent | 7f9e00a4c8e641d381780152fc61183b9a5c55e7 (diff) | |
download | android_packages_apps_Trebuchet-f4d017999a51e983b4997ef2e9513d508a718cb2.tar.gz android_packages_apps_Trebuchet-f4d017999a51e983b4997ef2e9513d508a718cb2.tar.bz2 android_packages_apps_Trebuchet-f4d017999a51e983b4997ef2e9513d508a718cb2.zip |
Moving getWallpaperArrayResourceId to a separate functions, so that
it can be overriden by dependent projects
Change-Id: I565d85d9126e41cec3dd2cdb8f2c75283bce4b13
Diffstat (limited to 'WallpaperPicker/src/com/android')
-rw-r--r-- | WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java index f44c88ebf..1d3b0cc29 100644 --- a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java +++ b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java @@ -30,6 +30,7 @@ import android.graphics.drawable.BitmapDrawable; import android.net.Uri; import android.os.Bundle; import android.util.Log; +import android.util.Pair; import android.view.ActionMode; import android.view.Menu; import android.view.MenuInflater; @@ -478,17 +479,15 @@ public class WallpaperPickerActivity extends WallpaperCropActivity } } - // Context.getPackageName() may return the "original" package name, - // com.android.launcher3; Resources needs the real package name, - // com.android.launcher3. So we ask Resources for what it thinks the - // package name should be. - try { - final String packageName = getResources().getResourcePackageName(R.array.wallpapers); - ApplicationInfo info = getPackageManager().getApplicationInfo(packageName, 0); - Resources wallpaperRes = getContext().getPackageManager() - .getResourcesForApplication(info); - addWallpapers(bundled, wallpaperRes, info.packageName, R.array.wallpapers); - } catch (PackageManager.NameNotFoundException e) { } + Pair<ApplicationInfo, Integer> r = getWallpaperArrayResourceId(); + if (r != null) { + try { + Resources wallpaperRes = getContext().getPackageManager() + .getResourcesForApplication(r.first); + addWallpapers(bundled, wallpaperRes, r.first.packageName, r.second); + } catch (PackageManager.NameNotFoundException e) { + } + } if (partner == null || !partner.hideDefaultWallpaper()) { // Add an entry for the default wallpaper (stored in system resources) @@ -500,6 +499,20 @@ public class WallpaperPickerActivity extends WallpaperCropActivity return bundled; } + public Pair<ApplicationInfo, Integer> getWallpaperArrayResourceId() { + // Context.getPackageName() may return the "original" package name, + // com.android.launcher3; Resources needs the real package name, + // com.android.launcher3. So we ask Resources for what it thinks the + // package name should be. + final String packageName = getResources().getResourcePackageName(R.array.wallpapers); + try { + ApplicationInfo info = getContext().getPackageManager().getApplicationInfo(packageName, 0); + return new Pair<ApplicationInfo, Integer>(info, R.array.wallpapers); + } catch (PackageManager.NameNotFoundException e) { + return null; + } + } + private void addWallpapers(ArrayList<WallpaperTileInfo> known, Resources res, String packageName, int listResId) { final String[] extras = res.getStringArray(listResId); |