summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-10-17 09:59:01 +0100
committerSunny Goyal <sunnygoyal@google.com>2016-10-25 09:49:09 -0700
commitc677b6b0ac5024381cc53b3e1bfe9ff2d8415777 (patch)
tree826dce059208efc1d496e2e2595114d5c72eae91 /src/com/android
parentd1f034708b591f0648f2a8ad47b6e857cd328e52 (diff)
downloadandroid_packages_apps_Trebuchet-c677b6b0ac5024381cc53b3e1bfe9ff2d8415777.tar.gz
android_packages_apps_Trebuchet-c677b6b0ac5024381cc53b3e1bfe9ff2d8415777.tar.bz2
android_packages_apps_Trebuchet-c677b6b0ac5024381cc53b3e1bfe9ff2d8415777.zip
Showing a toast when the default wallpaper app is disabled.
If there is no default defined, showing an intent picker with all options Bug: 32197478 Change-Id: Ia2337701a76a9bb00973ab64e2fa435607ce2820
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/launcher3/Launcher.java23
-rw-r--r--src/com/android/launcher3/util/PackageManagerHelper.java26
2 files changed, 15 insertions, 34 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 40820fa9a..09b5ad504 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -2469,20 +2469,27 @@ public class Launcher extends Activity
return;
}
- String pickerPackage = getString(R.string.wallpaper_picker_package);
- if (TextUtils.isEmpty(pickerPackage)) {
- pickerPackage = PackageManagerHelper.getWallpaperPickerPackage(getPackageManager());
- }
-
int pageScroll = mWorkspace.getScrollForPage(mWorkspace.getPageNearestToCenterOfScreen());
float offset = mWorkspace.mWallpaperOffset.wallpaperOffsetForScroll(pageScroll);
-
setWaitingForResult(new PendingRequestArgs(new ItemInfo()));
Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER)
- .setPackage(pickerPackage)
.putExtra(Utilities.EXTRA_WALLPAPER_OFFSET, offset);
+
+ String pickerPackage = getString(R.string.wallpaper_picker_package);
+ boolean hasTargetPackage = TextUtils.isEmpty(pickerPackage);
+ if (!hasTargetPackage) {
+ intent.setPackage(pickerPackage);
+ }
+
intent.setSourceBounds(getViewBounds(v));
- startActivityForResult(intent, REQUEST_PICK_WALLPAPER, getActivityLaunchOptions(v));
+ try {
+ startActivityForResult(intent, REQUEST_PICK_WALLPAPER,
+ // If there is no target package, use the default intent chooser animation
+ hasTargetPackage ? getActivityLaunchOptions(v) : null);
+ } catch (ActivityNotFoundException e) {
+ setWaitingForResult(null);
+ Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
+ }
}
/**
diff --git a/src/com/android/launcher3/util/PackageManagerHelper.java b/src/com/android/launcher3/util/PackageManagerHelper.java
index 3e15d05e1..afd9b8395 100644
--- a/src/com/android/launcher3/util/PackageManagerHelper.java
+++ b/src/com/android/launcher3/util/PackageManagerHelper.java
@@ -28,15 +28,12 @@ import android.text.TextUtils;
import com.android.launcher3.Utilities;
-import java.util.ArrayList;
-
/**
* Utility methods using package manager
*/
public class PackageManagerHelper {
private static final int FLAG_SUSPENDED = 1<<30;
- private static final String LIVE_WALLPAPER_PICKER_PKG = "com.android.wallpaper.livepicker";
/**
* Returns true if the app can possibly be on the SDCard. This is just a workaround and doesn't
@@ -80,29 +77,6 @@ public class PackageManagerHelper {
}
/**
- * Returns the package for a wallpaper picker system app giving preference to a app which
- * is not as image picker.
- */
- public static String getWallpaperPickerPackage(PackageManager pm) {
- ArrayList<String> excludePackages = new ArrayList<>();
- // Exclude packages which contain an image picker
- for (ResolveInfo info : pm.queryIntentActivities(
- new Intent(Intent.ACTION_GET_CONTENT).setType("image/*"), 0)) {
- excludePackages.add(info.activityInfo.packageName);
- }
- excludePackages.add(LIVE_WALLPAPER_PICKER_PKG);
-
- for (ResolveInfo info : pm.queryIntentActivities(
- new Intent(Intent.ACTION_SET_WALLPAPER), 0)) {
- if (!excludePackages.contains(info.activityInfo.packageName) &&
- (info.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
- return info.activityInfo.packageName;
- }
- }
- return excludePackages.get(0);
- }
-
- /**
* Returns true if {@param srcPackage} has the permission required to start the activity from
* {@param intent}. If {@param srcPackage} is null, then the activity should not need
* any permissions