Make Taskbar focusable when a popup is open.
- Added ArrowPopup#OnPopupClosedCallback to automatically remove Taskbar focus when the popup closes.
Fixes: 209917078
Test: opened popup in taskbar and closed it with switch access, touching anywhere on the screen and using the back gesture. went home to check if focus was removed.
Change-Id: Ie7aafc9cf0f03fadaa44e77818508e9e1d8db610
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index e48b26b..facdd1e 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -503,17 +503,28 @@
/**
* Either adds or removes {@link WindowManager.LayoutParams#FLAG_NOT_FOCUSABLE} on the taskbar
+ * window.
+ */
+ public void setTaskbarWindowFocusable(boolean focusable) {
+ if (focusable) {
+ mWindowLayoutParams.flags &= ~FLAG_NOT_FOCUSABLE;
+ } else {
+ mWindowLayoutParams.flags |= FLAG_NOT_FOCUSABLE;
+ }
+ mWindowManager.updateViewLayout(mDragLayer, mWindowLayoutParams);
+ }
+
+ /**
+ * Either adds or removes {@link WindowManager.LayoutParams#FLAG_NOT_FOCUSABLE} on the taskbar
* window. If we're now focusable, also move nav buttons to a separate window above IME.
*/
public void setTaskbarWindowFocusableForIme(boolean focusable) {
if (focusable) {
- mWindowLayoutParams.flags &= ~FLAG_NOT_FOCUSABLE;
mControllers.navbarButtonsViewController.moveNavButtonsToNewWindow();
} else {
- mWindowLayoutParams.flags |= FLAG_NOT_FOCUSABLE;
mControllers.navbarButtonsViewController.moveNavButtonsBackToTaskbarWindow();
}
- mWindowManager.updateViewLayout(mDragLayer, mWindowLayoutParams);
+ setTaskbarWindowFocusable(focusable);
}
/** Adds the given view to WindowManager with the provided LayoutParams (creates new window). */
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
index 7a50d0b..a654a56 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
@@ -27,6 +27,7 @@
import androidx.annotation.NonNull;
+import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.statemanager.StateManager;
@@ -256,6 +257,10 @@
if (hasAnyFlag(changedFlags, FLAG_RESUMED | FLAG_RECENTS_ANIMATION_RUNNING)) {
boolean goingToLauncher = hasAnyFlag(FLAG_RESUMED | FLAG_RECENTS_ANIMATION_RUNNING);
+ if (goingToLauncher) {
+ // Handle closing open popups when going home/overview
+ AbstractFloatingView.closeAllOpenViews(mControllers.taskbarActivityContext);
+ }
animatorSet.play(mTaskbarBackgroundAlpha.animateToValue(goingToLauncher ? 0 : 1)
.setDuration(duration));
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java
index 2dee506..7af9c9d 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java
@@ -154,6 +154,15 @@
.filter(Objects::nonNull)
.collect(Collectors.toList()));
container.requestFocus();
+
+ // Make focusable to receive back events
+ mControllers.taskbarActivityContext.setTaskbarWindowFocusable(true);
+ container.setOnCloseCallback(() -> {
+ mControllers.taskbarActivityContext.getDragLayer().post(
+ () -> mControllers.taskbarActivityContext.setTaskbarWindowFocusable(false));
+ container.setOnCloseCallback(null);
+ });
+
return container;
}
diff --git a/src/com/android/launcher3/popup/ArrowPopup.java b/src/com/android/launcher3/popup/ArrowPopup.java
index b1a4109..f06e5ce 100644
--- a/src/com/android/launcher3/popup/ArrowPopup.java
+++ b/src/com/android/launcher3/popup/ArrowPopup.java
@@ -48,7 +48,7 @@
import android.view.animation.Interpolator;
import android.widget.FrameLayout;
-import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.InsettableFrameLayout;
@@ -120,7 +120,7 @@
private final GradientDrawable mRoundedTop;
private final GradientDrawable mRoundedBottom;
- private Runnable mOnCloseCallback = () -> { };
+ @Nullable private Runnable mOnCloseCallback = null;
// The rect string of the view that the arrow is attached to, in screen reference frame.
protected int mArrowColor;
@@ -766,7 +766,6 @@
}
}
-
protected void animateClose() {
if (!mIsOpen) {
return;
@@ -816,7 +815,9 @@
mDeferContainerRemoval = false;
getPopupContainer().removeView(this);
getPopupContainer().removeView(mArrow);
- mOnCloseCallback.run();
+ if (mOnCloseCallback != null) {
+ mOnCloseCallback.run();
+ }
if (mColorExtractors != null) {
mColorExtractors.forEach(e -> e.setListener(null));
}
@@ -825,7 +826,7 @@
/**
* Callback to be called when the popup is closed
*/
- public void setOnCloseCallback(@NonNull Runnable callback) {
+ public void setOnCloseCallback(@Nullable Runnable callback) {
mOnCloseCallback = callback;
}