Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6d41b33 authored by Arne Coucheron's avatar Arne Coucheron
Browse files

Enable custom wallpaper picker

Change-Id: Iad5638c43f38d240d87c5f5957ec7112cf1c14d7
parent 2bf589be
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -79,9 +79,6 @@
    <!-- Name of an icon provider class. -->
    <string name="icon_provider_class" translatable="false"></string>

    <!-- Package name of the default wallpaper picker. -->
    <string name="wallpaper_picker_package" translatable="false"></string>

    <!-- View ID to use for QSB widget -->
    <item type="id" name="qsb_widget" />

+0 −6
Original line number Diff line number Diff line
@@ -2641,17 +2641,11 @@ 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);
        intent.setSourceBounds(getViewBounds(v));
        startActivityForResult(intent, REQUEST_PICK_WALLPAPER, getActivityLaunchOptions(v));
+0 −23
Original line number Diff line number Diff line
@@ -79,29 +79,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