From b8a916528876eeb1d073a890b80de846d3437ba6 Mon Sep 17 00:00:00 2001 From: Peter Liang Date: Mon, 31 Oct 2022 20:37:35 +0800 Subject: [PATCH] Fine-tune the insets type of the menu view layer. Goal: Avoid overlapping on the status or navigation bar when using the feature of hiding menu to edge, and easily computing the coordinate, set the fit insets type of the menu view layer as systemBars or display cutout. Bug: 246664957 Test: manual test Change-Id: I4954c2c439df771d52ce0dbcc607ab841922603c --- .../accessibility/floatingmenu/MenuViewAppearance.java | 6 +----- .../accessibility/floatingmenu/MenuViewLayerController.java | 3 ++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewAppearance.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewAppearance.java index 034e96a13029f..4a9807febc7f7 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewAppearance.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewAppearance.java @@ -136,11 +136,7 @@ class MenuViewAppearance { final Rect draggableBounds = getWindowAvailableBounds(); // Initializes start position for mapping the translation of the menu view. - final WindowMetrics windowMetrics = mWindowManager.getCurrentWindowMetrics(); - final WindowInsets windowInsets = windowMetrics.getWindowInsets(); - final Insets displayCutoutInsets = windowInsets.getInsetsIgnoringVisibility( - WindowInsets.Type.displayCutout()); - draggableBounds.offset(-displayCutoutInsets.left, -displayCutoutInsets.top); + draggableBounds.offsetTo(/* newLeft= */ 0, /* newTop= */ 0); draggableBounds.top += margin; draggableBounds.right -= getMenuWidth(); diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerController.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerController.java index b1a64eda46ff7..c7be907efc64d 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerController.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerController.java @@ -74,7 +74,8 @@ class MenuViewLayerController implements IAccessibilityFloatingMenu { params.receiveInsetsIgnoringZOrder = true; params.privateFlags |= PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION; params.windowAnimations = android.R.style.Animation_Translucent; - params.setFitInsetsTypes(WindowInsets.Type.navigationBars()); + params.setFitInsetsTypes( + WindowInsets.Type.systemBars() | WindowInsets.Type.displayCutout()); return params; } }