[CD][Alt+Tab] Show apps from all desktops for KQS on CD

- Even without multiple desktops, apps that are moved to connected display show up in separate desktop task.
- Further changes may be required to launch a desktop after multiple desktops is implemented.

Bug: 382762871
Flag: com.android.launcher3.enable_alt_tab_kqs_on_connected_displays
Test: manually built and run the CUJ
Change-Id: If104c67d95a1ec3de404998b06352edfa02c0f09
This commit is contained in:
Ajinkya Chalke
2025-02-05 17:16:46 +00:00
parent 4078347cbf
commit 3ef91e087d
@@ -15,6 +15,8 @@
*/
package com.android.launcher3.taskbar;
import static com.android.launcher3.Flags.enableAltTabKqsOnConnectedDisplays;
import android.content.ComponentName;
import android.content.pm.ActivityInfo;
import android.view.MotionEvent;
@@ -272,11 +274,26 @@ public final class KeyboardQuickSwitchController implements
}
private void processLoadedTasksOnDesktop(List<GroupTask> tasks, Set<Integer> taskIdsToExclude) {
// Find the single desktop task that contains a grouping of desktop tasks
DesktopTask desktopTask = findDesktopTask(tasks);
// Find all desktop tasks.
List<DesktopTask> desktopTasks = tasks.stream()
.filter(t -> t instanceof DesktopTask)
.map(t -> (DesktopTask) t)
.toList();
if (desktopTask != null) {
mTasks = desktopTask.getTasks().stream()
// Apps on the connected displays seem to be in different Desktop tasks even with the
// multiple desktops flag disabled. So, until multiple desktops is implemented the following
// should help with team-fooding Alt+tab on connected displays. Post multiple desktop,
// further changes maybe required to support launching selected desktops.
if (enableAltTabKqsOnConnectedDisplays()) {
mTasks = desktopTasks.stream()
.flatMap(t -> t.getTasks().stream())
.map(SingleTask::new)
.filter(task -> !shouldExcludeTask(task, taskIdsToExclude))
.collect(Collectors.toList());
mNumHiddenTasks = Math.max(0, tasks.size() - desktopTasks.size());
} else if (!desktopTasks.isEmpty()) {
mTasks = desktopTasks.get(0).getTasks().stream()
.map(SingleTask::new)
.filter(task -> !shouldExcludeTask(task, taskIdsToExclude))
.collect(Collectors.toList());
@@ -289,14 +306,6 @@ public final class KeyboardQuickSwitchController implements
}
}
@Nullable
private DesktopTask findDesktopTask(List<GroupTask> tasks) {
return (DesktopTask) tasks.stream()
.filter(t -> t instanceof DesktopTask)
.findFirst()
.orElse(null);
}
void closeQuickSwitchView() {
closeQuickSwitchView(true);
}