Improve app pairs disabled state

This CL fixes 2 issues with app pairs:
- When an app pair is incompatible with the screen size due to a non-resizeable app (e.g. Camera), the app pair will now be properly disabled and display an error message. If the user is on a foldable, it will prompt the user to unfold their phone.
- The app pair icon will now properly redraw with lower opacity when it is disabled.

Fixes: 323088270
Test: Manually paused and unpaused apps, created Camera app pairs and tested with foldable
Flag: ACONFIG com.android.wm.shell.enable_app_pairs TEAMFOOD
Change-Id: I66514c96bc19f480c9788661e4dffaa5b1cdc2ca
This commit is contained in:
Jeremy Sim
2024-02-16 17:39:56 -08:00
parent cda8adfad3
commit 3c1ee0dad4
11 changed files with 116 additions and 7 deletions

View File

@@ -41,6 +41,7 @@ import android.widget.Toast;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.BuildConfig;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.R;
@@ -149,7 +150,15 @@ public class ItemClickHandler {
private static void onClickAppPairIcon(View v) {
Launcher launcher = Launcher.getLauncher(v.getContext());
AppPairIcon appPairIcon = (AppPairIcon) v;
if (appPairIcon.getInfo().isDisabled()) {
if (!appPairIcon.isLaunchableAtScreenSize()) {
// Display a message for app pairs that are disabled due to screen size
boolean isFoldable = InvariantDeviceProfile.INSTANCE.get(launcher)
.supportedProfiles.stream().anyMatch(dp -> dp.isTwoPanels);
Toast.makeText(launcher, isFoldable
? R.string.app_pair_needs_unfold
: R.string.app_pair_unlaunchable_at_screen_size,
Toast.LENGTH_SHORT).show();
} else 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.