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

Commit e96d30bd authored by Jeremy Sim's avatar Jeremy Sim
Browse files

Make app pairs respond properly to disabled state

1) App pair member icons are now always redrawn when app pair icon is redrawn, allowing greyed out icons to be updated immediately when an app is disabled.
2) App pairs now check for disabled status when clicked. If one or both of the apps is disabled, app pair will not be launched, and the appropriate error message or affordance will be displayed.

Fixes: 323088270
Test: Manual
Flag: ACONFIG com.android.wm.shell.enable_app_pairs TEAMFOOD
Change-Id: I7f2af75db0d8579d5d04583c0d3ead32714768e4
parent ae741dec
Loading
Loading
Loading
Loading
+2 −10
Original line number Diff line number Diff line
@@ -112,7 +112,6 @@ class AppPairIconGraphic @JvmOverloads constructor(context: Context, attrs: Attr
        appIcon2?.setBounds(0, 0, memberIconSize.toInt(), memberIconSize.toInt())
    }


    /** Gets this icon graphic's bounds, with respect to the parent icon's coordinate system. */
    fun getIconBounds(outBounds: Rect) {
        outBounds.set(0, 0, backgroundSize.toInt(), backgroundSize.toInt())
@@ -138,15 +137,8 @@ class AppPairIconGraphic @JvmOverloads constructor(context: Context, attrs: Attr
        // Draw background
        appPairBackground.draw(canvas)

        // Make sure icons are loaded
        if (
            appIcon1 == null ||
                appIcon2 == null ||
                appIcon1 is PlaceHolderIconDrawable ||
                appIcon2 is PlaceHolderIconDrawable
        ) {
        // Make sure icons are loaded and fresh
        applyIcons(parentIcon.info.contents)
        }

        // Draw first icon
        canvas.save()
+9 −0
Original line number Diff line number Diff line
@@ -371,4 +371,13 @@ public class FolderInfo extends ItemInfo {
        }
        return LauncherAtom.ToState.TO_STATE_UNSPECIFIED;
    }

    @Override
    public boolean isDisabled() {
        if (itemType == LauncherSettings.Favorites.ITEM_TYPE_APP_PAIR) {
            return contents.stream().anyMatch((WorkspaceItemInfo::isDisabled));
        }

        return super.isDisabled();
    }
}
+14 −1
Original line number Diff line number Diff line
@@ -149,8 +149,21 @@ public class ItemClickHandler {
    private static void onClickAppPairIcon(View v) {
        Launcher launcher = Launcher.getLauncher(v.getContext());
        AppPairIcon appPairIcon = (AppPairIcon) v;
        if (appPairIcon.getInfo().isDisabled()) {
            WorkspaceItemInfo app1 = appPairIcon.getInfo().contents.get(0);
            WorkspaceItemInfo app2 = appPairIcon.getInfo().contents.get(1);
            // Show the user why the app pair is disabled.
            if (app1.isDisabled() && !handleDisabledItemClicked(app1, launcher)) {
                // If handleDisabledItemClicked() did not handle the error message, we initiate an
                // app launch so Framework can tell the user why the app is suspended.
                onClickAppShortcut(v, app1, launcher);
            } else if (app2.isDisabled() && !handleDisabledItemClicked(app2, launcher)) {
                onClickAppShortcut(v, app2, launcher);
            }
        } else {
            launcher.launchAppPair(appPairIcon);
        }
    }

    /**
     * Event handler for the app widget view which has not fully restored.