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
diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java
index 9912c6c..711a49a 100644
--- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java
@@ -63,6 +63,11 @@
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 @@
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 @@
}
/**
- * 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 @@
@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 @@
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 @@
return;
}
+ mExcludedTaskIds = taskIdsToExclude;
mTaskListChangeId = mModel.getTasks((tasks) -> {
mHasDesktopTask = false;
mWasDesktopTaskFilteredOut = false;
diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java
index a80c11c..fbbdc45 100644
--- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java
@@ -67,6 +67,7 @@
private boolean mOnDesktop;
private boolean mWasDesktopTaskFilteredOut;
+ private boolean mWasOpenedFromTaskbar;
protected KeyboardQuickSwitchViewController(
@NonNull TaskbarControllers controllers,
@@ -83,6 +84,10 @@
return mCurrentFocusIndex;
}
+ protected boolean wasOpenedFromTaskbar() {
+ return mWasOpenedFromTaskbar;
+ }
+
protected void openQuickSwitchView(
@NonNull List<GroupTask> tasks,
int numHiddenTasks,
@@ -96,6 +101,7 @@
mOverlayContext.getDragLayer().addView(mKeyboardQuickSwitchView);
mOnDesktop = onDesktop;
mWasDesktopTaskFilteredOut = wasDesktopTaskFilteredOut;
+ mWasOpenedFromTaskbar = wasOpenedFromTaskbar;
mKeyboardQuickSwitchView.applyLoadPlan(
mOverlayContext,
@@ -246,6 +252,7 @@
pw.println(prefix + "\tmCurrentFocusIndex=" + mCurrentFocusIndex);
pw.println(prefix + "\tmOnDesktop=" + mOnDesktop);
pw.println(prefix + "\tmWasDesktopTaskFilteredOut=" + mWasDesktopTaskFilteredOut);
+ pw.println(prefix + "\tmWasOpenedFromTaskbar=" + mWasOpenedFromTaskbar);
}
/**
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java
index 4591f9b..5d769d2 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java
@@ -148,7 +148,7 @@
return new View.OnClickListener() {
@Override
public void onClick(View v) {
- mControllers.keyboardQuickSwitchController.openQuickSwitchView(
+ mControllers.keyboardQuickSwitchController.toggleQuickSwitchViewForTaskbar(
mControllers.taskbarViewController.getTaskIdsForPinnedApps());
}
};
@@ -159,7 +159,7 @@
return new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
- mControllers.keyboardQuickSwitchController.openQuickSwitchView(
+ mControllers.keyboardQuickSwitchController.toggleQuickSwitchViewForTaskbar(
mControllers.taskbarViewController.getTaskIdsForPinnedApps());
return true;
}