mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 18:58:19 +00:00
Merge "Showing a toast when the default wallpaper app is disabled. If there is no default defined, showing an intent picker with all options" into ub-launcher3-master
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
@@ -79,29 +76,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
|
||||
|
||||
Reference in New Issue
Block a user