From deaca33cc2702cfcebcef35113993be979292c93 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Wed, 25 Sep 2024 16:36:39 +0000 Subject: [PATCH] Position KQS to the bottom if opened via taskbar. Bug: 368119679 Test: open KQS via taskbar, observe view at bottom of screen open KQS via keyboard, observe view at top of screen Flag: com.android.launcher3.taskbar_overflow Change-Id: I3e6f0d2ba51ec15cf7cb1f41ddc2a4414dfd60d6 --- .../KeyboardQuickSwitchController.java | 14 ++++++++------ .../KeyboardQuickSwitchViewController.java | 19 ++++++++++++++++++- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java index f98245d23e..7792d4711c 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java @@ -102,16 +102,16 @@ public final class KeyboardQuickSwitchController implements * @param taskIdsToExclude A list of tasks to exclude in the opened view. */ void openQuickSwitchView(@NonNull Set taskIdsToExclude) { - openQuickSwitchView(-1, taskIdsToExclude); + openQuickSwitchView(-1, taskIdsToExclude, true); } - private void openQuickSwitchView(int currentFocusedIndex) { - openQuickSwitchView(currentFocusedIndex, Collections.emptySet()); + openQuickSwitchView(currentFocusedIndex, Collections.emptySet(), false); } private void openQuickSwitchView(int currentFocusedIndex, - @NonNull Set taskIdsToExclude) { + @NonNull Set taskIdsToExclude, + boolean wasOpenedFromTaskbar) { if (mQuickSwitchViewController != null) { if (!mQuickSwitchViewController.isCloseAnimationRunning()) { return; @@ -146,7 +146,8 @@ public final class KeyboardQuickSwitchController implements ? 0 : currentFocusedIndex, onDesktop, mHasDesktopTask, - mWasDesktopTaskFilteredOut); + mWasDesktopTaskFilteredOut, + wasOpenedFromTaskbar); return; } @@ -168,7 +169,8 @@ public final class KeyboardQuickSwitchController implements ? 0 : currentFocusedIndex, onDesktop, mHasDesktopTask, - mWasDesktopTaskFilteredOut); + mWasDesktopTaskFilteredOut, + wasOpenedFromTaskbar); }); } diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java index 40e77e2394..fd1dc4a752 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java @@ -19,6 +19,7 @@ import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; +import android.view.Gravity; import android.view.KeyEvent; import android.view.animation.AnimationUtils; import android.window.RemoteTransition; @@ -30,6 +31,7 @@ import com.android.internal.jank.Cuj; import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimatorListeners; import com.android.launcher3.taskbar.overlay.TaskbarOverlayContext; +import com.android.launcher3.views.BaseDragLayer; import com.android.quickstep.SystemUiProxy; import com.android.quickstep.util.GroupTask; import com.android.quickstep.util.SlideInRemoteTransition; @@ -83,7 +85,9 @@ public class KeyboardQuickSwitchViewController { int currentFocusIndexOverride, boolean onDesktop, boolean hasDesktopTask, - boolean wasDesktopTaskFilteredOut) { + boolean wasDesktopTaskFilteredOut, + boolean wasOpenedFromTaskbar) { + positionView(wasOpenedFromTaskbar); mOverlayContext.getDragLayer().addView(mKeyboardQuickSwitchView); mOnDesktop = onDesktop; mWasDesktopTaskFilteredOut = wasDesktopTaskFilteredOut; @@ -98,6 +102,19 @@ public class KeyboardQuickSwitchViewController { /* useDesktopTaskView= */ !onDesktop && hasDesktopTask); } + protected void positionView(boolean wasOpenedFromTaskbar) { + if (!wasOpenedFromTaskbar) { + // Keep the default positioning. + return; + } + + BaseDragLayer.LayoutParams lp = new BaseDragLayer.LayoutParams( + mKeyboardQuickSwitchView.getLayoutParams()); + lp.width = BaseDragLayer.LayoutParams.WRAP_CONTENT; + lp.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; + mKeyboardQuickSwitchView.setLayoutParams(lp); + } + boolean isCloseAnimationRunning() { return mCloseAnimation != null; }