From eeb66e41e5a4a42f789b61d46d17ff1992094a55 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Wed, 27 Jul 2022 09:39:26 -0700 Subject: [PATCH] Cleanup taskbar+assistant interactions - Always move the taskbar layer when voice interaction window visibility changes, to ensure we remove the temporary taskbar background in all cases (e.g. swipe to home) - Move check to not draw taskbar background to the temporary view itself, so that it's at the proper layer when shown (e.g. during fulfillment on the home screen) - Don't add view to window if it's already added (we already have this check for the removal case) Test: Open an app, invoke Assistant, swipe home; Taskbar background is removed; invoke and fulfill assistant from home screen, in app, in 3 button mode, and in gesture mode (all permutations) Fixes: 236924161 Fixes: 240101132 Fixes: 235895444 Change-Id: I5958f1dbe14a6d190d3808014429f7f8146c9f96 --- .../taskbar/TaskbarActivityContext.java | 4 +++- .../taskbar/VoiceInteractionWindowController.kt | 17 +++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 439490e00c..24886dca3c 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -622,7 +622,9 @@ public class TaskbarActivityContext extends BaseTaskbarContext { /** Adds the given view to WindowManager with the provided LayoutParams (creates new window). */ public void addWindowView(View view, WindowManager.LayoutParams windowLayoutParams) { - mWindowManager.addView(view, windowLayoutParams); + if (!view.isAttachedToWindow()) { + mWindowManager.addView(view, windowLayoutParams); + } } /** Removes the given view from WindowManager. See {@link #addWindowView}. */ diff --git a/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt b/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt index 946873e7ab..81acda3d75 100644 --- a/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt @@ -36,7 +36,10 @@ class VoiceInteractionWindowController(val context: TaskbarActivityContext) override fun draw(canvas: Canvas) { super.draw(canvas) - taskbarBackgroundRenderer.draw(canvas) + if (this@VoiceInteractionWindowController.context.isGestureNav + && controllers.taskbarStashController.isInAppAndNotStashed) { + taskbarBackgroundRenderer.draw(canvas) + } } } separateWindowForTaskbarBackground.recreateControllers() @@ -74,18 +77,20 @@ class VoiceInteractionWindowController(val context: TaskbarActivityContext) fadeStashedHandle.end() } - if (context.isGestureNav && controllers.taskbarStashController.isInAppAndNotStashed) { - moveTaskbarBackgroundToLowerLayer() - } + moveTaskbarBackgroundToAppropriateLayer() } /** + * Either: * Hides the TaskbarDragLayer background and creates a new window to draw just that background. + * OR + * Removes the temporary window and show the TaskbarDragLayer background again. */ - private fun moveTaskbarBackgroundToLowerLayer() { + private fun moveTaskbarBackgroundToAppropriateLayer() { val taskbarBackgroundOverride = controllers.taskbarDragLayerController .overrideBackgroundAlpha - if (isVoiceInteractionWindowVisible) { + val moveToLowerLayer = isVoiceInteractionWindowVisible + if (moveToLowerLayer) { // First add the temporary window, then hide the overlapping taskbar background. context.addWindowView(separateWindowForTaskbarBackground, separateWindowLayoutParams) ViewRootSync.synchronizeNextDraw(separateWindowForTaskbarBackground, context.dragLayer