From 40f94c84f81c3ffac7141463d4f00237ac287271 Mon Sep 17 00:00:00 2001 From: Sebastian Franco Date: Mon, 13 Feb 2023 16:07:42 -0800 Subject: [PATCH] Fix issue where bottom scrim appears in homescreen when it shouldn't The bottom scrim should be shown for the Pixel Launcher, other third party launchers show it when the 3 bottom navigation is activated. The existing condition for 3 bottom navigation is no longer valid because the insets at the bottom can be greather than 0 in other situations other than 3 bottom navigation. Test: the scrom should not show at all Test: It appears in some situations where the taskbar is showing and the scrim gets updates which not always happens so it's hard to manually recreate, but there is a test that is flaky because of it HomeScreenImageTabletTest#comparePixelTablet2023HomeScreen. Fix: 267614579 Change-Id: Iacaf93011aa3f2f643186560fe34b4b26ce52314 --- .../launcher3/graphics/SysUiScrim.java | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/com/android/launcher3/graphics/SysUiScrim.java b/src/com/android/launcher3/graphics/SysUiScrim.java index 11e7dc8630..e983a30837 100644 --- a/src/com/android/launcher3/graphics/SysUiScrim.java +++ b/src/com/android/launcher3/graphics/SysUiScrim.java @@ -32,11 +32,10 @@ import android.graphics.drawable.Drawable; import android.util.DisplayMetrics; import android.util.FloatProperty; import android.view.View; -import android.view.WindowInsets; import com.android.launcher3.BaseDraggingActivity; +import com.android.launcher3.DeviceProfile; import com.android.launcher3.R; -import com.android.launcher3.Utilities; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.testing.shared.ResourceUtils; import com.android.launcher3.util.DynamicResource; @@ -185,21 +184,18 @@ public class SysUiScrim implements View.OnAttachStateChangeListener { /** * Determines whether to draw the top and/or bottom scrim based on new insets. + * + * In order for the bottom scrim to be drawn this 3 condition should be meet at the same time: + * the device is in 3 button navigation, the taskbar is not present and the Hotseat is + * horizontal */ public void onInsetsChanged(Rect insets) { + DeviceProfile dp = mActivity.getDeviceProfile(); mDrawTopScrim = mTopScrim != null && insets.top > 0; mDrawBottomScrim = mBottomMask != null - && !mActivity.getDeviceProfile().isVerticalBarLayout() - && hasBottomNavButtons(); - } - - private boolean hasBottomNavButtons() { - if (Utilities.ATLEAST_Q && mActivity.getRootView() != null - && mActivity.getRootView().getRootWindowInsets() != null) { - WindowInsets windowInsets = mActivity.getRootView().getRootWindowInsets(); - return windowInsets.getTappableElementInsets().bottom > 0; - } - return true; + && !dp.isVerticalBarLayout() + && !dp.isGestureMode + && !dp.isTaskbarPresent; } @Override