summaryrefslogtreecommitdiffstats
path: root/WallpaperPicker
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2015-07-15 00:19:16 (GMT)
committerd34d <clark@cyngn.com>2016-05-27 19:56:16 (GMT)
commit93e949f1a9931bf7188f4d2a43630603d7a388a8 (patch)
tree2a703665ea18868b7c9bb52aa3de8152dd7487c0 /WallpaperPicker
parentcb3431d16c22bba38a6560640d1efa1807486add (diff)
downloadandroid_packages_apps_Trebuchet-93e949f1a9931bf7188f4d2a43630603d7a388a8.zip
android_packages_apps_Trebuchet-93e949f1a9931bf7188f4d2a43630603d7a388a8.tar.gz
android_packages_apps_Trebuchet-93e949f1a9931bf7188f4d2a43630603d7a388a8.tar.bz2
Wallpaper: Allow multiple partners to be loaded
Current implementation only allowed for one partner, and any additional partner wallpapers would not be loaded. Partrner.get() still returns the first partner and a new method, getAllPartners is introduced which returns a list of all partners. Change-Id: I06b6cd4817d3f812e2110967f075d68ee31cb318
Diffstat (limited to 'WallpaperPicker')
-rw-r--r--WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java69
1 files changed, 38 insertions, 31 deletions
diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
index abf2026..4047ae8 100644
--- a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
+++ b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
@@ -84,6 +84,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.List;
public class WallpaperPickerActivity extends WallpaperCropActivity {
static final String TAG = "Launcher.WallpaperPickerActivity";
@@ -927,41 +928,47 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
final PackageManager pm = getContext().getPackageManager();
final ArrayList<WallpaperTileInfo> bundled = new ArrayList<WallpaperTileInfo>(24);
- Partner partner = Partner.get(pm);
- if (partner != null) {
- final Resources partnerRes = partner.getResources();
- final int resId = partnerRes.getIdentifier(Partner.RES_WALLPAPERS, "array",
- partner.getPackageName());
- if (resId != 0) {
- addWallpapers(bundled, partnerRes, partner.getPackageName(), resId);
- }
+ List<Partner> partners = Partner.getAllPartners(pm);
+ boolean hideDefault = false;
+ if (partners != null) {
+ for (Partner partner : partners) {
+ final Resources partnerRes = partner.getResources();
+ final int resId = partnerRes.getIdentifier(Partner.RES_WALLPAPERS, "array",
+ partner.getPackageName());
+ if (resId != 0) {
+ addWallpapers(bundled, partnerRes, partner.getPackageName(), resId);
+ }
- // Add system wallpapers
- File systemDir = partner.getWallpaperDirectory();
- if (systemDir != null && systemDir.isDirectory()) {
- for (File file : systemDir.listFiles()) {
- if (!file.isFile()) {
- continue;
- }
- String name = file.getName();
- int dotPos = name.lastIndexOf('.');
- String extension = "";
- if (dotPos >= -1) {
- extension = name.substring(dotPos);
- name = name.substring(0, dotPos);
- }
+ // Add system wallpapers
+ File systemDir = partner.getWallpaperDirectory();
+ if (systemDir != null && systemDir.isDirectory()) {
+ for (File file : systemDir.listFiles()) {
+ if (!file.isFile()) {
+ continue;
+ }
+ String name = file.getName();
+ int dotPos = name.lastIndexOf('.');
+ String extension = "";
+ if (dotPos >= -1) {
+ extension = name.substring(dotPos);
+ name = name.substring(0, dotPos);
+ }
- if (name.endsWith("_small")) {
- // it is a thumbnail
- continue;
- }
+ if (name.endsWith("_small")) {
+ // it is a thumbnail
+ continue;
+ }
- File thumbnail = new File(systemDir, name + "_small" + extension);
- Bitmap thumb = BitmapFactory.decodeFile(thumbnail.getAbsolutePath());
- if (thumb != null) {
- bundled.add(new FileWallpaperInfo(file, new BitmapDrawable(thumb)));
+ File thumbnail = new File(systemDir, name + "_small" + extension);
+ Bitmap thumb = BitmapFactory.decodeFile(thumbnail.getAbsolutePath());
+ if (thumb != null) {
+ bundled.add(new FileWallpaperInfo(file, new BitmapDrawable(thumb)));
+ }
}
}
+ if (partner.hideDefaultWallpaper()) {
+ hideDefault = true;
+ }
}
}
@@ -975,7 +982,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
}
}
- if (partner == null || !partner.hideDefaultWallpaper()) {
+ if (!hideDefault) {
// Add an entry for the default wallpaper (stored in system resources)
WallpaperTileInfo defaultWallpaperInfo = Utilities.ATLEAST_KITKAT
? getDefaultWallpaper() : getPreKKDefaultWallpaperInfo();