summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/WallpaperPickerActivity.java
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2013-08-22 22:13:41 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-08-22 22:13:43 +0000
commitfe14e04987a8baf77f0ffbd6d66839f33a4f0474 (patch)
tree4d2bc727dd78cebe071d846fc5c416ff5ac7a9f1 /src/com/android/launcher3/WallpaperPickerActivity.java
parent0cffae54f9b501144735cfc046c90da824840c08 (diff)
parenta805e1a297c0d1fa84d9fed51e0167aa32bd42bb (diff)
downloadandroid_packages_apps_Trebuchet-fe14e04987a8baf77f0ffbd6d66839f33a4f0474.tar.gz
android_packages_apps_Trebuchet-fe14e04987a8baf77f0ffbd6d66839f33a4f0474.tar.bz2
android_packages_apps_Trebuchet-fe14e04987a8baf77f0ffbd6d66839f33a4f0474.zip
Merge "Finish support for third-party wallpaper pickers" into jb-ub-gel-agar
Diffstat (limited to 'src/com/android/launcher3/WallpaperPickerActivity.java')
-rw-r--r--src/com/android/launcher3/WallpaperPickerActivity.java30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/com/android/launcher3/WallpaperPickerActivity.java b/src/com/android/launcher3/WallpaperPickerActivity.java
index 7c84c7fa6..bad84603e 100644
--- a/src/com/android/launcher3/WallpaperPickerActivity.java
+++ b/src/com/android/launcher3/WallpaperPickerActivity.java
@@ -61,6 +61,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
private static final String TAG = "Launcher.WallpaperPickerActivity";
private static final int IMAGE_PICK = 5;
+ private static final int PICK_WALLPAPER_THIRD_PARTY_ACTIVITY = 6;
private static final float WALLPAPER_SCREENS_SPAN = 2f;
private ArrayList<Integer> mThumbs;
@@ -91,7 +92,8 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
if (meta.mLaunchesGallery) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
- startActivityForResult(intent, IMAGE_PICK);
+ Utilities.startActivityForResultSafely(
+ WallpaperPickerActivity.this, intent, IMAGE_PICK);
} else if (meta.mGalleryImageUri != null) {
mCropView.setTileSource(new BitmapRegionTileSource(WallpaperPickerActivity.this,
meta.mGalleryImageUri, 1024, 0), null);
@@ -153,6 +155,10 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
meta.mGalleryImageUri = uri;
pickedImageThumbnail.setTag(meta);
mThumbnailOnClickListener.onClick(pickedImageThumbnail);
+ } else if (requestCode == PICK_WALLPAPER_THIRD_PARTY_ACTIVITY) {
+ // No result code is returned; just return
+ setResult(RESULT_OK);
+ finish();
}
}
@@ -245,6 +251,16 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
frameLayout.setForeground(new ZeroPaddingDrawable(frameLayout.getForeground()));
}
+ public boolean onMenuItemSelected(int featureId, MenuItem item) {
+ if (item.getIntent() == null) {
+ return super.onMenuItemSelected(featureId, item);
+ } else {
+ Utilities.startActivityForResultSafely(
+ this, item.getIntent(), PICK_WALLPAPER_THIRD_PARTY_ACTIVITY);
+ return true;
+ }
+ }
+
@Override
public boolean onCreateOptionsMenu(Menu menu) {
final Intent pickWallpaperIntent = new Intent(Intent.ACTION_SET_WALLPAPER);
@@ -269,21 +285,25 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
outerLoop:
for (ResolveInfo info : apps) {
- final ComponentName componentName =
+ final ComponentName itemComponentName =
new ComponentName(info.activityInfo.packageName, info.activityInfo.name);
+ final String itemPackageName = itemComponentName.getPackageName();
// Exclude anything from our own package, and the old Launcher
- if (componentName.getPackageName().equals(getPackageName()) ||
- componentName.getPackageName().equals("com.android.launcher")) {
+ if (itemPackageName.equals(getPackageName()) ||
+ itemPackageName.equals("com.android.launcher")) {
continue;
}
// Exclude any package that already responds to the image picker intent
for (ResolveInfo imagePickerActivityInfo : imagePickerActivities) {
- if (componentName.getPackageName().equals(
+ if (itemPackageName.equals(
imagePickerActivityInfo.activityInfo.packageName)) {
continue outerLoop;
}
}
MenuItem mi = sub.add(info.loadLabel(pm));
+ Intent launchIntent = new Intent(Intent.ACTION_SET_WALLPAPER);
+ launchIntent.setComponent(itemComponentName);
+ mi.setIntent(launchIntent);
Drawable icon = info.loadIcon(pm);
if (icon != null) {
mi.setIcon(icon);