From df2ceac06c592c9084a2e75f7930f6e6712c2863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cosmin=20B=C4=83ie=C8=99?= Date: Thu, 21 Sep 2023 18:08:19 +0200 Subject: [PATCH] Use stashedTaskbarHeight for IME insets override Previously [1] we removed the explicit insetsSizeOverride from the Taskbar for the IME window, as we now [2] enable hiding the IME nav bar. This would now send the normal insets the taskbar reports. When running on pre/postsubmit, with test harness setup, the non-transient taskbar would show, which is bigger than the IME's navigation bar height. Due to the current logic in InsetsSource#calculateInsets, this leads to the IME window receiving top navigation bar insets instead of bottom. As the IME nav bar is now treated as a (fixed on bottom) caption bar, the two would no longer overlap, and thus lead to a double insets dispatch, and also a (temporarily) bigger IME window, for IMEs that set their decorView height to WRAP_CONTENT (e.g. MockIME used in testing). This instead keeps the previous insetsSizeOverride for IME, and uses the stashedTasbarHeight when in gesture nav, which should account for both transient and normal taskbars. [1]: I86079cb6670a2ae3b6fa883694f8af81df212408 [2]: I8793db69fb846046300d5a56b3b0060138ef4cd5 Bug: 297000797 Test: atest WindowInsetsControllerTests#testDispatchApplyWindowInsetsCount_ime Change-Id: I102a8bc1f8869ebbce9f8f1fefa651d49a9538ec --- .../taskbar/TaskbarInsetsController.kt | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt index c51a7ec825..5a4534e651 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt @@ -198,24 +198,24 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas } - val imeInsetsSize = getInsetsForGravity(taskbarHeightForIme, gravity) + // When in gesture nav, report the stashed height to the IME, to allow hiding the + // IME navigation bar. + val imeInsetsSize = if (ENABLE_HIDE_IME_CAPTION_BAR && context.isGestureNav) { + getInsetsForGravity(controllers.taskbarStashController.stashedHeight, gravity); + } else { + getInsetsForGravity(taskbarHeightForIme, gravity) + } val imeInsetsSizeOverride = - if (!ENABLE_HIDE_IME_CAPTION_BAR) { - arrayOf( - InsetsFrameProvider.InsetsSizeOverride( - TYPE_INPUT_METHOD, - imeInsetsSize - ), - ) - } else { - arrayOf() - } + arrayOf( + InsetsFrameProvider.InsetsSizeOverride(TYPE_INPUT_METHOD, imeInsetsSize), + ) // Use 0 tappableElement insets for the VoiceInteractionWindow when gesture nav is enabled. val visInsetsSizeForTappableElement = if (context.isGestureNav) getInsetsForGravity(0, gravity) else getInsetsForGravity(tappableHeight, gravity) val insetsSizeOverrideForTappableElement = - imeInsetsSizeOverride + arrayOf( + arrayOf( + InsetsFrameProvider.InsetsSizeOverride(TYPE_INPUT_METHOD, imeInsetsSize), InsetsFrameProvider.InsetsSizeOverride( TYPE_VOICE_INTERACTION, visInsetsSizeForTappableElement @@ -224,7 +224,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas if ((context.isGestureNav || TaskbarManager.FLAG_HIDE_NAVBAR_WINDOW) && provider.type == tappableElement()) { provider.insetsSizeOverrides = insetsSizeOverrideForTappableElement - } else if (provider.type != systemGestures() && imeInsetsSizeOverride.isNotEmpty()) { + } else if (provider.type != systemGestures()) { // We only override insets at the bottom of the screen provider.insetsSizeOverrides = imeInsetsSizeOverride }