summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/WallpaperPickerActivity.java
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2013-08-22 15:00:33 +0200
committerMichael Jurka <mikejurka@google.com>2013-08-22 15:05:45 +0200
commita805e1a297c0d1fa84d9fed51e0167aa32bd42bb (patch)
tree4dc586e56f0af98c0a6c176afd697dd600193bc8 /src/com/android/launcher3/WallpaperPickerActivity.java
parent2b931429dbf29633657f060151e5451522b44f15 (diff)
downloadandroid_packages_apps_Trebuchet-a805e1a297c0d1fa84d9fed51e0167aa32bd42bb.tar.gz
android_packages_apps_Trebuchet-a805e1a297c0d1fa84d9fed51e0167aa32bd42bb.tar.bz2
android_packages_apps_Trebuchet-a805e1a297c0d1fa84d9fed51e0167aa32bd42bb.zip
Finish support for third-party wallpaper pickers
Clicking on the pickers didn't do anything before. Change-Id: I103caafbe8d44d27d1797436ce479fb769c4c0f4
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 03274213f..dfc3ef94f 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);
@@ -150,6 +152,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();
}
}
@@ -242,6 +248,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);
@@ -266,21 +282,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);