From 3ef91e087dc81bc95efa96e56a0c03a82ca95e61 Mon Sep 17 00:00:00 2001 From: Ajinkya Chalke Date: Wed, 5 Feb 2025 17:16:46 +0000 Subject: [PATCH] [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 --- .../KeyboardQuickSwitchController.java | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java index 23065b5f60..5afc5eda6d 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java @@ -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 tasks, Set taskIdsToExclude) { - // Find the single desktop task that contains a grouping of desktop tasks - DesktopTask desktopTask = findDesktopTask(tasks); + // Find all desktop tasks. + List 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 tasks) { - return (DesktopTask) tasks.stream() - .filter(t -> t instanceof DesktopTask) - .findFirst() - .orElse(null); - } - void closeQuickSwitchView() { closeQuickSwitchView(true); }