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

Commit 2fcee5ff authored by Amit Kumar's avatar Amit Kumar
Browse files

Add uninstall feature

parent 4d086943
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ android {
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "org.indin.blisslauncher"
        minSdkVersion 23
        minSdkVersion 22
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
+12 −1
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ public class AppItem {
    private Intent intent;
    private String componentName;
    private boolean iconFromIconPack;
    private boolean isSystemApp;

    // Folder specific
    private boolean belongsToFolder;
@@ -20,14 +21,16 @@ public class AppItem {
    private String folderID;
    private List<AppItem> subApps;


    public AppItem(CharSequence label, String packageName, Drawable icon,
                   Intent intent, String componentName, boolean iconFromIconPack) {
                   Intent intent, String componentName, boolean iconFromIconPack, boolean isSystemApp) {
        this.label = label;
        this.packageName = packageName;
        this.icon = icon;
        this.intent = intent;
        this.componentName = componentName;
        this.iconFromIconPack = iconFromIconPack;
        this.isSystemApp = isSystemApp;
    }

    public CharSequence getLabel() {
@@ -50,6 +53,14 @@ public class AppItem {
        return icon;
    }

    public boolean isSystemApp(){
        return isSystemApp;
    }

    public void setSystemApp(boolean isSystemApp){
        this.isSystemApp = isSystemApp;
    }

    public void setIcon(Drawable icon) {
        this.icon = icon;
    }
+19 −12
Original line number Diff line number Diff line
@@ -23,13 +23,13 @@ public class AppUtil {
    /**
     * Uses the PackageManager to find all launchable apps.
     */
    public static List<AppItem> loadLaunchableApps(Context context, int iconWidth) {
    public static List<AppItem> loadLaunchableApps(Context context) {
        PackageManager packageManager = context.getPackageManager();

        List<ApplicationInfo> apps = packageManager.getInstalledApplications(0);
        List<AppItem> launchableApps = new ArrayList<>();
        for (ApplicationInfo app : apps) {
            String packageName = app.packageName;
        for (ApplicationInfo appInfo : apps) {
            String packageName = appInfo.packageName;
            Intent intent = packageManager.getLaunchIntentForPackage(packageName);
            if (intent != null) {
                String componentName = intent.getComponent().toString();
@@ -41,19 +41,26 @@ public class AppUtil {
                    appIcon = IconPackUtil.getIconFromIconPack(context, componentName);
                }
                if (appIcon == null) {
                    appIcon = app.loadIcon(packageManager);
                    appIcon = appInfo.loadIcon(packageManager);
                    iconFromIconPack = false;
                    appIcon = GraphicsUtil.scaleImage(context, appIcon, 1f, iconWidth);
                    appIcon = GraphicsUtil.scaleImage(context, appIcon, 1f);
                    appIcon = GraphicsUtil.maskImage(context, appIcon);
                }

                boolean isSystemApp = false;

                if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
                    isSystemApp = true;
                }

                AppItem launchableApp = new AppItem(
                        app.loadLabel(packageManager),
                        appInfo.loadLabel(packageManager),
                        packageName,
                        appIcon,
                        intent,
                        componentName,
                        iconFromIconPack
                        iconFromIconPack,
                        isSystemApp
                );
                launchableApps.add(launchableApp);
            }
@@ -112,7 +119,7 @@ public class AppUtil {
    /**
     * Create an AppItem object given just a package name
     */
    public static AppItem createAppItem(Context context, String packageName, int iconWidth) {
    public static AppItem createAppItem(Context context, String packageName) {
        try {
            PackageManager packageManager = context.getPackageManager();
            ApplicationInfo appInfo = packageManager.getApplicationInfo(packageName, 0);
@@ -130,7 +137,7 @@ public class AppUtil {
                if (appIcon == null) {
                    appIcon = appInfo.loadIcon(packageManager);
                    iconFromIconPack = false;
                    appIcon = GraphicsUtil.scaleImage(context, appIcon, 1f, iconWidth);
                    appIcon = GraphicsUtil.scaleImage(context, appIcon, 1f);
                    appIcon = GraphicsUtil.maskImage(context, appIcon);
                }
            } else {
@@ -138,13 +145,13 @@ public class AppUtil {
                iconFromIconPack = false;
            }

            AppItem appItem = new AppItem(appInfo.loadLabel(packageManager),
            return new AppItem(appInfo.loadLabel(packageManager),
                    packageName,
                    appIcon,
                    intent,
                    componentName,
                    iconFromIconPack);
            return appItem;
                    iconFromIconPack,
                    (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0);
        } catch (PackageManager.NameNotFoundException e) {
            return null;
        }
Loading