From 906c6b2f6c6eab68c46a8c32fec6eb82bd057cb2 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Fri, 18 Aug 2017 00:35:52 -0700 Subject: Fixing wrong intests being sent to DeviceProfile in case of lowRam device Also fixing the navbar to dark theme when a black bar is drawn behind nav bar Fixing left/right margins not getting updated on lowRam device when they change from non-zero value to 0 Bug: 64363693 Bug: 62547502 Change-Id: I4952ad2f564b71b39318350445f116a0f601a10f --- src/com/android/launcher3/LauncherRootView.java | 29 +++++++++++++++------- .../android/launcher3/util/SystemUiController.java | 3 ++- 2 files changed, 22 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/com/android/launcher3/LauncherRootView.java b/src/com/android/launcher3/LauncherRootView.java index 643d48adf..a81432363 100644 --- a/src/com/android/launcher3/LauncherRootView.java +++ b/src/com/android/launcher3/LauncherRootView.java @@ -11,6 +11,9 @@ import android.util.AttributeSet; import android.view.View; import android.view.ViewDebug; +import static com.android.launcher3.util.SystemUiController.FLAG_DARK_NAV; +import static com.android.launcher3.util.SystemUiController.UI_STATE_ROOT_VIEW; + public class LauncherRootView extends InsettableFrameLayout { private final Paint mOpaquePaint; @@ -44,20 +47,28 @@ public class LauncherRootView extends InsettableFrameLayout { @TargetApi(23) @Override protected boolean fitSystemWindows(Rect insets) { - boolean rawInsetsChanged = !mInsets.equals(insets); mDrawSideInsetBar = (insets.right > 0 || insets.left > 0) && (!Utilities.ATLEAST_MARSHMALLOW || - getContext().getSystemService(ActivityManager.class).isLowRamDevice()); - mRightInsetBarWidth = insets.right; - mLeftInsetBarWidth = insets.left; - setInsets(mDrawSideInsetBar ? new Rect(0, insets.top, 0, insets.bottom) : insets); + getContext().getSystemService(ActivityManager.class).isLowRamDevice()); + if (mDrawSideInsetBar) { + mLeftInsetBarWidth = insets.left; + mRightInsetBarWidth = insets.right; + insets = new Rect(0, insets.top, 0, insets.bottom); + } else { + mLeftInsetBarWidth = mRightInsetBarWidth = 0; + } + Launcher.getLauncher(getContext()).getSystemUiController().updateUiState( + UI_STATE_ROOT_VIEW, mDrawSideInsetBar ? FLAG_DARK_NAV : 0); + + boolean rawInsetsChanged = !mInsets.equals(insets); + setInsets(insets); - if (mAlignedView != null && mDrawSideInsetBar) { + if (mAlignedView != null) { // Apply margins on aligned view to handle left/right insets. MarginLayoutParams lp = (MarginLayoutParams) mAlignedView.getLayoutParams(); - if (lp.leftMargin != insets.left || lp.rightMargin != insets.right) { - lp.leftMargin = insets.left; - lp.rightMargin = insets.right; + if (lp.leftMargin != mLeftInsetBarWidth || lp.rightMargin != mRightInsetBarWidth) { + lp.leftMargin = mLeftInsetBarWidth; + lp.rightMargin = mRightInsetBarWidth; mAlignedView.setLayoutParams(lp); } } diff --git a/src/com/android/launcher3/util/SystemUiController.java b/src/com/android/launcher3/util/SystemUiController.java index 6b5b095c7..d7a2625e9 100644 --- a/src/com/android/launcher3/util/SystemUiController.java +++ b/src/com/android/launcher3/util/SystemUiController.java @@ -30,6 +30,7 @@ public class SystemUiController { public static final int UI_STATE_BASE_WINDOW = 0; public static final int UI_STATE_ALL_APPS = 1; public static final int UI_STATE_WIDGET_BOTTOM_SHEET = 2; + public static final int UI_STATE_ROOT_VIEW = 3; public static final int FLAG_LIGHT_NAV = 1 << 0; public static final int FLAG_DARK_NAV = 1 << 1; @@ -37,7 +38,7 @@ public class SystemUiController { public static final int FLAG_DARK_STATUS = 1 << 3; private final Window mWindow; - private final int[] mStates = new int[3]; + private final int[] mStates = new int[4]; public SystemUiController(Window window) { mWindow = window; -- cgit v1.2.3