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

Commit 44cba696 authored by Kenny Guy's avatar Kenny Guy Committed by Rubin Xu
Browse files

Grey out suspended applications.

Grey out application shortcuts and all apps entries
for packages that are suspended.

Bug: 22776761
Change-Id: I1b63da1816aca1de52b9f9bee62d1b162d0cdf4d
parent f076eae0
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -70,3 +70,10 @@
  public float getBackgroundAlpha();
  public void setBackgroundAlpha(float);
}

# Proguard will strip new callbacks in LauncherApps.Callback from
# WrappedCallback if compiled against an older SDK. Don't let this happen.
-keep class com.android.launcher3.compat.** {
  *;
}
+19 −0
Original line number Diff line number Diff line
@@ -118,6 +118,25 @@ class AllAppsList {
        }
    }

    /**
     * Suspend the apps for the given apk identified by packageName.
     */
    public void suspendPackage(String packageName, UserHandleCompat user, boolean suspend) {
        final List<AppInfo> data = this.data;
        for (int i = data.size() - 1; i >= 0; i--) {
            AppInfo info = data.get(i);
            final ComponentName component = info.intent.getComponent();
            if (info.user.equals(user) && packageName.equals(component.getPackageName())) {
                if (suspend) {
                    info.isDisabled |= ShortcutInfo.FLAG_DISABLED_SUSPENDED;
                } else {
                    info.isDisabled &= ~ShortcutInfo.FLAG_DISABLED_SUSPENDED;
                }
                modified.add(info);
            }
        }
    }

    public void updateIconsAndLabels(HashSet<String> packages, UserHandleCompat user,
            ArrayList<AppInfo> outUpdates) {
        for (AppInfo info : data) {
+14 −1
Original line number Diff line number Diff line
@@ -56,6 +56,11 @@ public class AppInfo extends ItemInfo {

    int flags = 0;

    /**
     * {@see ShortcutInfo#isDisabled}
     */
    int isDisabled = ShortcutInfo.DEFAULT;

    AppInfo() {
        itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_SHORTCUT;
    }
@@ -75,8 +80,10 @@ public class AppInfo extends ItemInfo {
            IconCache iconCache) {
        this.componentName = info.getComponentName();
        this.container = ItemInfo.NO_ID;

        flags = initFlags(info);
        if ((info.getApplicationInfo().flags & LauncherActivityInfoCompat.FLAG_SUSPENDED) != 0) {
            isDisabled |= ShortcutInfo.FLAG_DISABLED_SUSPENDED;
        }
        iconCache.getTitleAndIcon(this, info, true /* useLowResIcon */);
        intent = makeLaunchIntent(context, info, user);
        this.user = user;
@@ -101,6 +108,7 @@ public class AppInfo extends ItemInfo {
        title = Utilities.trim(info.title);
        intent = new Intent(info.intent);
        flags = info.flags;
        isDisabled = info.isDisabled;
        iconBitmap = info.iconBitmap;
    }

@@ -140,4 +148,9 @@ public class AppInfo extends ItemInfo {
            .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)
            .putExtra(EXTRA_PROFILE, serialNumber);
    }

    @Override
    public boolean isDisabled() {
        return isDisabled != 0;
    }
}
+10 −6
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ public class BubbleTextView extends TextView
        Bitmap b = info.getIcon(iconCache);

        FastBitmapDrawable iconDrawable = mLauncher.createIconDrawable(b);
        if (info.isDisabled != 0) {
        if (info.isDisabled()) {
            iconDrawable.setState(FastBitmapDrawable.State.DISABLED);
        }
        setIcon(iconDrawable, mIconSize);
@@ -166,7 +166,11 @@ public class BubbleTextView extends TextView
    }

    public void applyFromApplicationInfo(AppInfo info) {
        setIcon(mLauncher.createIconDrawable(info.iconBitmap), mIconSize);
        FastBitmapDrawable iconDrawable = mLauncher.createIconDrawable(info.iconBitmap);
        if (info.isDisabled()) {
            iconDrawable.setState(FastBitmapDrawable.State.DISABLED);
        }
        setIcon(iconDrawable, mIconSize);
        setText(info.title);
        if (info.contentDescription != null) {
            setContentDescription(info.contentDescription);
@@ -250,11 +254,11 @@ public class BubbleTextView extends TextView
    private void updateIconState() {
        if (mIcon instanceof FastBitmapDrawable) {
            FastBitmapDrawable d = (FastBitmapDrawable) mIcon;
            if (isPressed() || mStayPressed) {
                d.animateState(FastBitmapDrawable.State.PRESSED);
            } else if (getTag() instanceof ShortcutInfo
                    && ((ShortcutInfo) getTag()).isDisabled != 0) {
            if (getTag() instanceof ItemInfo
                    && ((ItemInfo) getTag()).isDisabled()) {
                d.animateState(FastBitmapDrawable.State.DISABLED);
            } else if (isPressed() || mStayPressed) {
                d.animateState(FastBitmapDrawable.State.PRESSED);
            } else {
                d.animateState(FastBitmapDrawable.State.NORMAL);
            }
+7 −0
Original line number Diff line number Diff line
@@ -198,4 +198,11 @@ public class ItemInfo {
            + " screen=" + screenId + " cellX=" + cellX + " cellY=" + cellY + " spanX=" + spanX
            + " spanY=" + spanY + " user=" + user + ")";
    }

    /**
     * Whether this item is disabled.
     */
    public boolean isDisabled() {
        return false;
    }
}
Loading