diff options
author | Jeff Sharkey <jsharkey@android.com> | 2014-04-14 13:26:42 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2014-04-22 12:28:51 -0700 |
commit | 5aeef58131e1c330d1d9c1dfcacf2e6eea6ced4b (patch) | |
tree | b19471e6924d0cd3424fb5a8546e0212d1b49ae5 /WallpaperPicker | |
parent | 76ac344cb61a74267c04249c9e9feec41a82c504 (diff) | |
download | packages_apps_Trebuchet-5aeef58131e1c330d1d9c1dfcacf2e6eea6ced4b.tar.gz packages_apps_Trebuchet-5aeef58131e1c330d1d9c1dfcacf2e6eea6ced4b.tar.bz2 packages_apps_Trebuchet-5aeef58131e1c330d1d9c1dfcacf2e6eea6ced4b.zip |
Add support for partner customization.
Traditionally Launcher workspace customization is offered through
overlays at build time, but we don't have access to partner-specific
customization at build time. To solve this, this adds a new
"partner-folder" tag which points at an XML resource provided by
an external package.
The external package XML can't depend on the binary XML attributes
defined by Launcher3, so we switch to using manual string-based
attribute lookups. Partners can also provide extra wallpapers.
When a folder only results in a single item, promote that item into
the folder location instead of deleting completely.
Bug: 13340779
Change-Id: Ide558288bef4113565f288b700d8245055c0fee9
Diffstat (limited to 'WallpaperPicker')
-rw-r--r-- | WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java index 013606a50..232c6d167 100644 --- a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java +++ b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java @@ -887,14 +887,24 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { } private ArrayList<ResourceWallpaperInfo> findBundledWallpapers() { - ArrayList<ResourceWallpaperInfo> bundledWallpapers = - new ArrayList<ResourceWallpaperInfo>(24); + final PackageManager pm = getPackageManager(); + final ArrayList<ResourceWallpaperInfo> bundled = new ArrayList<ResourceWallpaperInfo>(24); + + Partner partner = Partner.get(pm); + if (partner != null) { + final Resources partnerRes = partner.getResources(); + final int resId = partnerRes.getIdentifier(Partner.RESOURCE_WALLPAPERS, "array", + partner.getPackageName()); + if (resId != 0) { + addWallpapers(bundled, partnerRes, partner.getPackageName(), resId); + } + } Pair<ApplicationInfo, Integer> r = getWallpaperArrayResourceId(); if (r != null) { try { Resources wallpaperRes = getPackageManager().getResourcesForApplication(r.first); - bundledWallpapers = addWallpapers(wallpaperRes, r.first.packageName, r.second); + addWallpapers(bundled, wallpaperRes, r.first.packageName, r.second); } catch (PackageManager.NameNotFoundException e) { } } @@ -903,10 +913,10 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { ResourceWallpaperInfo defaultWallpaperInfo = getPreKKDefaultWallpaperInfo(); if (defaultWallpaperInfo != null) { - bundledWallpapers.add(0, defaultWallpaperInfo); + bundled.add(0, defaultWallpaperInfo); } } - return bundledWallpapers; + return bundled; } private boolean writeImageToFileAsJpeg(File f, Bitmap b) { @@ -998,10 +1008,8 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { } } - private ArrayList<ResourceWallpaperInfo> addWallpapers( - Resources res, String packageName, int listResId) { - ArrayList<ResourceWallpaperInfo> bundledWallpapers = - new ArrayList<ResourceWallpaperInfo>(24); + private void addWallpapers(ArrayList<ResourceWallpaperInfo> known, Resources res, + String packageName, int listResId) { final String[] extras = res.getStringArray(listResId); for (String extra : extras) { int resId = res.getIdentifier(extra, "drawable", packageName); @@ -1011,14 +1019,13 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { if (thumbRes != 0) { ResourceWallpaperInfo wallpaperInfo = new ResourceWallpaperInfo(res, resId, res.getDrawable(thumbRes)); - bundledWallpapers.add(wallpaperInfo); + known.add(wallpaperInfo); // Log.d(TAG, "add: [" + packageName + "]: " + extra + " (" + res + ")"); } } else { Log.e(TAG, "Couldn't find wallpaper " + extra); } } - return bundledWallpapers; } public CropView getCropView() { |