From 8eed87ac895447edc3fd9de7358c47ff3cdd3103 Mon Sep 17 00:00:00 2001 From: Jeremy Sim Date: Tue, 14 Mar 2023 12:55:34 -0700 Subject: [PATCH] Fix bug where Taskbar was not auto-hiding after splitscreen launch from icon menu This patch fixes a bug where the transient Taskbar was not hiding properly after splitscreen was initiated. When the user is inside an app and launches splitscreen by longpressing on a Taskbar icon and selecting the split button, the transient Taskbar should hide right away. This is an equivalent action to dragging the Taskbar icon up to create a split, and should hide the Taskbar so that other UI elements (like system-level toasts and error messages) can be seen. The bug occurred because updateAndAnimateTransientTaskbar() is not being called in this specific code path to stash the Taskbar. Fixed by adding a new call to updateAndAnimateTransientTaskbar upon clicking the splitscreen menu button. Fixes: 272292897 Test: Manual Change-Id: I64a9acfc41ddcaba4d9f43eb216458de44b4c9a4 --- .../launcher3/taskbar/BaseTaskbarContext.java | 6 ++++++ .../launcher3/taskbar/TaskbarActivityContext.java | 12 +++++++++++- .../launcher3/taskbar/TaskbarPopupController.java | 12 +++++++++--- .../taskbar/overlay/TaskbarOverlayContext.java | 10 ++++------ .../LauncherAccessibilityDelegate.java | 2 +- src/com/android/launcher3/popup/ArrowPopup.java | 15 ++++++--------- 6 files changed, 37 insertions(+), 20 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/BaseTaskbarContext.java b/quickstep/src/com/android/launcher3/taskbar/BaseTaskbarContext.java index 48352a2935..331184a081 100644 --- a/quickstep/src/com/android/launcher3/taskbar/BaseTaskbarContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/BaseTaskbarContext.java @@ -65,4 +65,10 @@ public abstract class BaseTaskbarContext extends ContextThemeWrapper implements /** Callback invoked when a popup is shown or closed within this context. */ public abstract void onPopupVisibilityChanged(boolean isVisible); + + /** + * Callback invoked when user attempts to split the screen through a long-press menu in Taskbar + * or AllApps. + */ + public abstract void onSplitScreenMenuButtonClicked(); } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 57e11de26f..241b53e95a 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -56,7 +56,6 @@ import android.view.Gravity; import android.view.RoundedCorner; import android.view.View; import android.view.WindowManager; -import android.view.WindowManagerGlobal; import android.widget.FrameLayout; import android.widget.Toast; @@ -80,6 +79,7 @@ import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.FolderInfo; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; +import com.android.launcher3.popup.PopupContainerWithArrow; import com.android.launcher3.popup.PopupDataProvider; import com.android.launcher3.taskbar.TaskbarAutohideSuspendController.AutohideSuspendFlag; import com.android.launcher3.taskbar.TaskbarTranslationController.TransitionCallback; @@ -525,6 +525,16 @@ public class TaskbarActivityContext extends BaseTaskbarContext { setTaskbarWindowFocusable(isVisible); } + @Override + public void onSplitScreenMenuButtonClicked() { + PopupContainerWithArrow popup = PopupContainerWithArrow.getOpen(this); + if (popup != null) { + popup.addOnCloseCallback(() -> { + mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true); + }); + } + } + /** * Sets a new data-source for this taskbar instance */ diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java index 115b99e3be..6ae03a0926 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java @@ -65,6 +65,7 @@ import java.util.stream.Stream; /** * Implements interfaces required to show and allow interacting with a PopupContainerWithArrow. + * Controls the long-press menu on Taskbar and AllApps icons. */ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskbarController { @@ -190,9 +191,8 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba // Make focusable to receive back events context.onPopupVisibilityChanged(true); - container.setOnCloseCallback(() -> { + container.addOnCloseCallback(() -> { context.getDragLayer().post(() -> context.onPopupVisibilityChanged(false)); - container.setOnCloseCallback(null); }); return container; @@ -293,13 +293,19 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba @Override public void onClick(View view) { + // Add callbacks depending on what type of Taskbar context we're in (Taskbar or AllApps) + mTarget.onSplitScreenMenuButtonClicked(); AbstractFloatingView.closeAllOpenViews(mTarget); + + // Depending on what app state we're in, we either want to initiate the split screen + // staging process or immediately launch a split with an existing app. + // - Initiate the split screen staging process if (mAllowInitialSplitSelection) { super.onClick(view); return; } - // Initiate splitscreen from the in-app Taskbar or Taskbar All Apps + // - Immediately launch split with the running app Pair instanceIds = LogUtils.getShellShareableInstanceId(); mTarget.getStatsLogManager().logger() diff --git a/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayContext.java b/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayContext.java index 3edb3756b4..66d591889b 100644 --- a/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayContext.java @@ -15,8 +15,6 @@ */ package com.android.launcher3.taskbar.overlay; -import static android.app.ActivityTaskManager.INVALID_TASK_ID; - import android.content.Context; import android.view.View; @@ -33,10 +31,6 @@ import com.android.launcher3.taskbar.TaskbarStashController; import com.android.launcher3.taskbar.TaskbarUIController; import com.android.launcher3.taskbar.allapps.TaskbarAllAppsContainerView; import com.android.launcher3.util.SplitConfigurationOptions.SplitSelectSource; -import com.android.quickstep.views.RecentsView; -import com.android.systemui.shared.recents.model.Task; - -import java.util.function.Consumer; /** * Window context for the taskbar overlays such as All Apps and EDU. @@ -141,4 +135,8 @@ public class TaskbarOverlayContext extends BaseTaskbarContext { @Override public void onPopupVisibilityChanged(boolean isVisible) {} + + @Override + public void onSplitScreenMenuButtonClicked() { + } } diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java index 3c316b831b..27119ae67b 100644 --- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java +++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java @@ -174,7 +174,7 @@ public class LauncherAccessibilityDelegate extends BaseAccessibilityDelegate { + popup.addOnCloseCallback(() -> { host.requestFocus(); host.sendAccessibilityEvent(TYPE_VIEW_FOCUSED); host.performAccessibilityAction(ACTION_ACCESSIBILITY_FOCUS, null); diff --git a/src/com/android/launcher3/popup/ArrowPopup.java b/src/com/android/launcher3/popup/ArrowPopup.java index be3a09b673..9d06d4a6fa 100644 --- a/src/com/android/launcher3/popup/ArrowPopup.java +++ b/src/com/android/launcher3/popup/ArrowPopup.java @@ -48,14 +48,13 @@ import android.view.animation.Interpolator; import android.view.animation.PathInterpolator; import android.widget.FrameLayout; -import androidx.annotation.Nullable; - import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.InsettableFrameLayout; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.shortcuts.DeepShortcutView; +import com.android.launcher3.util.RunnableList; import com.android.launcher3.util.Themes; import com.android.launcher3.views.ActivityContext; import com.android.launcher3.views.BaseDragLayer; @@ -124,7 +123,7 @@ public abstract class ArrowPopup private final GradientDrawable mRoundedTop; private final GradientDrawable mRoundedBottom; - @Nullable private Runnable mOnCloseCallback = null; + private RunnableList mOnCloseCallbacks = new RunnableList(); // The rect string of the view that the arrow is attached to, in screen reference frame. protected int mArrowColor; @@ -785,16 +784,14 @@ public abstract class ArrowPopup mDeferContainerRemoval = false; getPopupContainer().removeView(this); getPopupContainer().removeView(mArrow); - if (mOnCloseCallback != null) { - mOnCloseCallback.run(); - } + mOnCloseCallbacks.executeAllAndClear(); } /** - * Callback to be called when the popup is closed + * Callbacks to be called when the popup is closed */ - public void setOnCloseCallback(@Nullable Runnable callback) { - mOnCloseCallback = callback; + public void addOnCloseCallback(Runnable callback) { + mOnCloseCallbacks.add(callback); } protected BaseDragLayer getPopupContainer() {