Tapping overflow button toggles KQS

Updates the taskbar overflow button handler to toggle the KQS instead of
merely showing it. The toggle action will open KQS view if it's not
visible, or close it if it's visible and has been shown from the
taskbar. If the view is shown, but in response to Alt+Tab, the view will
be closed, and reshown above the task bar.

Requires CL:30016166 for tapping to work as expected, and CL:30074037
for tapping overflow button reopen KQS over shelf if KQS is already
active for Alt+Tab

Bug: 368119679
Test: Enter task bar overflow. Tap overflow button to show KQS, tap
overlow button to hide KQS. Press Alt+Tab, tap overflow button to
reshow KQS over taskbar, and with filtered set of tasks.
Flag: com.android.launcher3.taskbar_overflow

Change-Id: Id598f9cad649aa174aaf1c5802bf6b6837413d1e
This commit is contained in:
Toni Barzic
2024-10-22 23:50:29 +00:00
parent d6f39e3f45
commit 143edac127
3 changed files with 39 additions and 10 deletions
@@ -63,6 +63,11 @@ public final class KeyboardQuickSwitchController implements
private int mTaskListChangeId = -1;
// Only empty before the recent tasks list has been loaded the first time
@NonNull private List<GroupTask> mTasks = new ArrayList<>();
// Set of task IDs filtered out of tasks in recents model to generate list of tasks to show in
// the Keyboard Quick Switch view. Non empty only if the view has been shown in response to
// toggling taskbar overflow button.
@NonNull private Set<Integer> mExcludedTaskIds = Collections.emptySet();
private int mNumHiddenTasks = 0;
// Initialized in init
@@ -90,10 +95,12 @@ public final class KeyboardQuickSwitchController implements
return;
}
int currentFocusedIndex = mQuickSwitchViewController.getCurrentFocusedIndex();
boolean wasOpenedFromTaskbar = mQuickSwitchViewController.wasOpenedFromTaskbar();
onDestroy();
if (currentFocusedIndex != -1) {
mControllers.taskbarActivityContext.getMainThreadHandler().post(
() -> openQuickSwitchView(currentFocusedIndex));
() -> openQuickSwitchView(currentFocusedIndex, mExcludedTaskIds,
wasOpenedFromTaskbar));
}
}
@@ -102,10 +109,19 @@ public final class KeyboardQuickSwitchController implements
}
/**
* Opens the view with a filtered list of tasks.
* Opens or closes the view in response to taskbar action. The view shows a filtered list of
* tasks.
* @param taskIdsToExclude A list of tasks to exclude in the opened view.
*/
void openQuickSwitchView(@NonNull Set<Integer> taskIdsToExclude) {
void toggleQuickSwitchViewForTaskbar(@NonNull Set<Integer> taskIdsToExclude) {
// Close the view if its shown, and was opened from the taskbar.
if (mQuickSwitchViewController != null
&& !mQuickSwitchViewController.isCloseAnimationRunning()
&& mQuickSwitchViewController.wasOpenedFromTaskbar()) {
closeQuickSwitchView(true);
return;
}
openQuickSwitchView(-1, taskIdsToExclude, true);
}
@@ -117,10 +133,16 @@ public final class KeyboardQuickSwitchController implements
@NonNull Set<Integer> taskIdsToExclude,
boolean wasOpenedFromTaskbar) {
if (mQuickSwitchViewController != null) {
if (!mQuickSwitchViewController.isCloseAnimationRunning()) {
if (!mQuickSwitchViewController.isCloseAnimationRunning()
&& mQuickSwitchViewController.wasOpenedFromTaskbar() == wasOpenedFromTaskbar) {
return;
}
// Allow the KQS to be reopened during the close animation to make it more responsive
// Allow the KQS to be reopened during the close animation to make it more responsive.
// Similarly, if KQS was opened in different mode (from taskbar vs. keyboard event),
// close it so it can be reopened in the correct mode.
// TODO(b/368119679) Consider updating list of shown tasks in place, or at least reopen
// the view in the same vertical location.
closeQuickSwitchView(false);
}
mOverlayContext = mControllers.taskbarOverlayController.requestWindow();
@@ -139,9 +161,8 @@ public final class KeyboardQuickSwitchController implements
final boolean onDesktop =
mControllers.taskbarDesktopModeController.getAreDesktopTasksVisible();
// TODO(b/368119679) For now we will re-process the task list every time, but this can be
// optimized if we have the same set of task ids to exclude.
if (mModel.isTaskListValid(mTaskListChangeId) && !Flags.taskbarOverflow()) {
if (mModel.isTaskListValid(mTaskListChangeId)
&& taskIdsToExclude.equals(mExcludedTaskIds)) {
// When we are opening the KQS with no focus override, check if the first task is
// running. If not, focus that first task.
mQuickSwitchViewController.openQuickSwitchView(
@@ -157,6 +178,7 @@ public final class KeyboardQuickSwitchController implements
return;
}
mExcludedTaskIds = taskIdsToExclude;
mTaskListChangeId = mModel.getTasks((tasks) -> {
mHasDesktopTask = false;
mWasDesktopTaskFilteredOut = false;