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

Commit 803a4bec authored by Chris Wren's avatar Chris Wren
Browse files

Drop support for remove all dead promises.

Bug: 12764789
Change-Id: Id876b66cf8da4388cb3ed5670a0bbdcf73f2982d
parent 8d8d6224
Loading
Loading
Loading
Loading
+3 −9
Original line number Diff line number Diff line
@@ -288,13 +288,7 @@ s -->
    <string name="abandoned_promises_title">This app is not installed</string>
    <!-- Explanation for abandoned promise dialog. "The first 'it' refers to the shortcut icon.
    The second "it" refers to the app. -->
    <plurals name="abandoned_promises_explanation">
        <item quantity="one">The app for this icon isn\'t installed.
    <string name="abandoned_promise_explanation">The app for this icon isn\'t installed.
        You can remove it, or search for the app and install it manually.
        </item>
        <item quantity="other">The app for this icon isn\'t installed.
            You can remove all such broken icons, remove only this one,
            or search for the app and install it manually.
        </item>
    </plurals>
    </string>
</resources>
+1 −14
Original line number Diff line number Diff line
@@ -2545,12 +2545,9 @@ public class Launcher extends Activity

        // Check for abandoned promise
        if (shortcut.isAbandoned() && v instanceof BubbleTextView) {
            final ArrayList<BubbleTextView> abandoned =
                    mWorkspace.getAbandonedPromises(new ArrayList<BubbleTextView>());
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(R.string.abandoned_promises_title);
            builder.setMessage(getResources().getQuantityString(
                    R.plurals.abandoned_promises_explanation, abandoned.size()));
            builder.setMessage(R.string.abandoned_promise_explanation);
            builder.setPositiveButton(R.string.abandoned_search,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
@@ -2558,16 +2555,6 @@ public class Launcher extends Activity
                        }
                    }
            );
            if (abandoned.size() > 1) {
                builder.setNegativeButton(R.string.abandoned_clean_all,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                final UserHandleCompat user = UserHandleCompat.myUserHandle();
                                mWorkspace.removeAbandonedPromises(abandoned, user);
                            }
                        }
                );
            }
            builder.setNeutralButton(R.string.abandoned_clean_this,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
+8 −30
Original line number Diff line number Diff line
@@ -4857,39 +4857,17 @@ public class Workspace extends SmoothPagedView
        });
    }

    ArrayList<BubbleTextView> getAbandonedPromises(final ArrayList<BubbleTextView> abandoned) {
        mapOverShortcuts(Workspace.MAP_RECURSE, new Workspace.ShortcutOperator() {
            @Override
            public boolean evaluate(ItemInfo info, View view, View parent) {
                if (info instanceof ShortcutInfo
                        && ((ShortcutInfo) info).isAbandoned()
                        && view instanceof BubbleTextView) {
                    abandoned.add((BubbleTextView) view);
                }
                return false;
            }
        });
        return abandoned;
    }
    public void removeAbandonedPromise(BubbleTextView view, UserHandleCompat user) {
        ArrayList<BubbleTextView> views = new ArrayList<BubbleTextView>(1);
        views.add(view);
        removeAbandonedPromises(views, user);
    }

    public void removeAbandonedPromises(ArrayList<BubbleTextView> views, UserHandleCompat user) {
        HashSet<ComponentName> cns = new HashSet<ComponentName>(views.size());
        for (final BubbleTextView bubble : views) {
            if (bubble.getTag() != null && bubble.getTag() instanceof ShortcutInfo) {
                final ShortcutInfo shortcut = (ShortcutInfo) bubble.getTag();
    public void removeAbandonedPromise(BubbleTextView abandonedIcon, UserHandleCompat user) {
        if (abandonedIcon.getTag() != null && abandonedIcon.getTag() instanceof ShortcutInfo) {
            final ShortcutInfo shortcut = (ShortcutInfo) abandonedIcon.getTag();
            if (shortcut.isAbandoned()) {
                HashSet<ComponentName> cns = new HashSet<ComponentName>(1);
                cns.add(shortcut.getRestoredIntent().getComponent());
                LauncherModel.deleteItemFromDatabase(mLauncher, shortcut);
                removeItemsByComponentName(cns, user);
            }
        }
    }
        removeItemsByComponentName(cns, user);
    }

    public void updatePackageState(final String pkgName, final int state) {
        mapOverShortcuts(MAP_RECURSE, new ShortcutOperator() {