Reparent folders and app pairs

Previously, app pairs and folders shared a common data model, FolderInfo. Now we need to separate them, so a new type, CollectionInfo, will serve as the parent of both types.

Bug: 315731527
Fixes: 326664798
Flag: ACONFIG com.android.wm.shell.enable_app_pairs TRUNKFOOD
Test: Manual, unit tests to follow
Change-Id: Ia8c429cf6e6a376f2554ae1866549ef0bcab2a22
This commit is contained in:
Jeremy Sim
2024-03-22 22:11:18 -07:00
parent 46ca78ee78
commit 742630c2f8
50 changed files with 517 additions and 341 deletions
@@ -53,6 +53,7 @@ import com.android.launcher3.logging.InstanceId;
import com.android.launcher3.logging.InstanceIdSequence;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.AppPairInfo;
import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
@@ -101,11 +102,9 @@ public class ItemClickHandler {
if (tag instanceof WorkspaceItemInfo) {
onClickAppShortcut(v, (WorkspaceItemInfo) tag, launcher);
} else if (tag instanceof FolderInfo) {
if (v instanceof FolderIcon) {
onClickFolderIcon(v);
} else if (v instanceof AppPairIcon) {
onClickAppPairIcon(v);
}
onClickFolderIcon(v);
} else if (tag instanceof AppPairInfo) {
onClickAppPairIcon(v);
} else if (tag instanceof AppInfo) {
startAppShortcutOrInfoActivity(v, (AppInfo) tag, launcher);
} else if (tag instanceof LauncherAppWidgetInfo) {
@@ -150,7 +149,7 @@ public class ItemClickHandler {
private static void onClickAppPairIcon(View v) {
Launcher launcher = Launcher.getLauncher(v.getContext());
AppPairIcon appPairIcon = (AppPairIcon) v;
if (!appPairIcon.isLaunchableAtScreenSize()) {
if (!appPairIcon.getInfo().isLaunchable(launcher)) {
// 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);
@@ -159,8 +158,8 @@ public class ItemClickHandler {
: 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);
WorkspaceItemInfo app1 = appPairIcon.getInfo().getFirstApp();
WorkspaceItemInfo app2 = appPairIcon.getInfo().getSecondApp();
// 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