summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhuiwan <huiwan@codeaurora.org>2014-08-05 09:07:48 +0800
committerRajesh Yengisetty <rajesh@cyngn.com>2014-11-21 00:21:13 +0000
commitcf64e4b646e6593ac97ef788cb03a8fdfff97aad (patch)
treecf8e07dd9cb920177ba8a18696319f14b7280806
parent6a8dada0a3a3e0f51890541e053830e84480fef4 (diff)
downloadandroid_packages_apps_Trebuchet-cf64e4b646e6593ac97ef788cb03a8fdfff97aad.tar.gz
android_packages_apps_Trebuchet-cf64e4b646e6593ac97ef788cb03a8fdfff97aad.tar.bz2
android_packages_apps_Trebuchet-cf64e4b646e6593ac97ef788cb03a8fdfff97aad.zip
Launcher: Add customization wallpaper
Add control WallpaperChooser to select Launcher resource or select carrier's wallpaper resouce. Change-Id: I7915b6e6f9537f0e96715a611d77d4db8bc0f694
-rw-r--r--WallpaperPicker/res/values/extra_wallpapers.xml21
-rwxr-xr-x[-rw-r--r--]WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java54
2 files changed, 73 insertions, 2 deletions
diff --git a/WallpaperPicker/res/values/extra_wallpapers.xml b/WallpaperPicker/res/values/extra_wallpapers.xml
new file mode 100644
index 000000000..9e0951cfa
--- /dev/null
+++ b/WallpaperPicker/res/values/extra_wallpapers.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2009 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<resources>
+ <string-array name="extra_wallpapers">
+ </string-array>
+</resources>
diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
index 07285372e..a90cdbaae 100644..100755
--- a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
+++ b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
@@ -45,6 +45,7 @@ import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
+import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
import android.view.ActionMode;
@@ -89,6 +90,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
private static final String OLD_DEFAULT_WALLPAPER_THUMBNAIL_FILENAME = "default_thumb.jpg";
private static final String DEFAULT_WALLPAPER_THUMBNAIL_FILENAME = "default_thumb2.jpg";
private static final int FLAG_POST_DELAY_MILLIS = 200;
+ private static final String INTENT_EXTRA_PACKAGE_NAME = "packagename";
private View mSelectedTile;
private boolean mIgnoreNextTap;
@@ -107,6 +109,8 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
private WallpaperInfo mLiveWallpaperInfoOnPickerLaunch;
private int mSelectedIndex = -1;
private WallpaperInfo mLastClickedLiveWallpaperInfo;
+ private String mSpecificPackage;
+ private Context mResPackageCtx = null;
public static abstract class WallpaperTileInfo {
protected View mView;
@@ -378,6 +382,20 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
mCropView = (CropView) findViewById(R.id.cropView);
mCropView.setVisibility(View.INVISIBLE);
+ Intent intent = getIntent();
+ if (intent != null) {
+ mSpecificPackage = intent.getStringExtra(INTENT_EXTRA_PACKAGE_NAME);
+ }
+
+ try {
+ if (!TextUtils.isEmpty(mSpecificPackage)) {
+ mResPackageCtx = createPackageContext(mSpecificPackage,
+ Context.CONTEXT_IGNORE_SECURITY);
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "Create third party package resources failed.");
+ }
+
mWallpaperStrip = findViewById(R.id.wallpaper_strip);
mCropView.setTouchCallback(new CropView.TouchCallback() {
ViewPropertyAnimator mAnim;
@@ -459,8 +477,14 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
}
};
- // Populate the built-in wallpapers
- ArrayList<WallpaperTileInfo> wallpapers = findBundledWallpapers();
+ // Populate the built-in wallpapers or load all wallpapers from a specific package
+ ArrayList<WallpaperTileInfo> wallpapers;
+ if (mResPackageCtx == null) {
+ wallpapers = findBundledWallpapers();
+ } else {
+ wallpapers = findSpecificPackageWallpapers();
+ }
+
mWallpapersView = (LinearLayout) findViewById(R.id.wallpaper_list);
SimpleWallpapersAdapter ia = new SimpleWallpapersAdapter(this, wallpapers);
populateWallpapersFromAdapter(mWallpapersView, ia, false);
@@ -652,6 +676,32 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
};
}
+ private ArrayList<WallpaperTileInfo> findSpecificPackageWallpapers() {
+ Resources resources = null;
+ int wallpaperId = 0;
+ int extraWallpaperId = 0;
+
+ if (null != mResPackageCtx) {
+ Log.i(TAG, "resPackageCtx = " + mResPackageCtx);
+ resources = mResPackageCtx.getResources();
+ wallpaperId = resources.getIdentifier("wallpapers", "array", mSpecificPackage);
+ extraWallpaperId = resources.getIdentifier("extra_wallpapers", "array",
+ mSpecificPackage);
+ }
+
+ // Context.getPackageName() may return the "original" package name,
+ // com.android.launcher2; Resources needs the real package name,
+ // com.android.launcher. So we ask Resources for what it thinks the
+ // package name should be.
+ final String packageName = resources.getResourcePackageName(wallpaperId);
+
+ ArrayList<WallpaperTileInfo> wallpapers = new ArrayList<WallpaperTileInfo>();
+ addWallpapers(wallpapers, resources, packageName, wallpaperId);
+ addWallpapers(wallpapers, resources, packageName, extraWallpaperId);
+
+ return wallpapers;
+ }
+
private void selectTile(View v) {
if (mSelectedTile != null) {
mSelectedTile.setSelected(false);