From ed68728b1f22bc849e0567f2be3aeaf6798440ca Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Mon, 20 Mar 2017 16:49:37 -0700 Subject: [PATCH] Add support for making nav bar light separately from status bar Bug: 34940468 Change-Id: Ie5543895e4c8b8753c84ef24633377cc985efc0d --- src/com/android/launcher3/Launcher.java | 25 +++++++++++-------- .../allapps/AllAppsTransitionController.java | 2 +- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index d4bfc4913c..308bb63e13 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -483,7 +483,7 @@ public class Launcher extends BaseActivity // It's possible that All Apps is visible when this is run, // so always use light status bar in that case. Only change nav bar color to status bar // color when All Apps is visible. - activateLightStatusBar(lightStatusBar || isAllAppsVisible(), isAllAppsVisible()); + activateLightSystemBars(lightStatusBar || isAllAppsVisible(), true, isAllAppsVisible()); } } @@ -491,21 +491,26 @@ public class Launcher extends BaseActivity private static final int SYSTEM_UI_FLAG_LIGHT_NAV_BAR = 0x10; /** - * Sets the status bar to be light or not. Light status bar means dark icons. - * @param lightStatusBar make sure the status bar is light - * @param changeNavBar if true, make the nav bar theme in sync with status bar. + * Sets the status and/or nav bar to be light or not. Light status bar means dark icons. + * @param isLight make sure the system bar is light. + * @param statusBar if true, make the status bar theme match the isLight param. + * @param navBar if true, make the nav bar theme match the isLight param. */ - public void activateLightStatusBar(boolean lightStatusBar, boolean changeNavBar) { + public void activateLightSystemBars(boolean isLight, boolean statusBar, boolean navBar) { int oldSystemUiFlags = getWindow().getDecorView().getSystemUiVisibility(); int newSystemUiFlags = oldSystemUiFlags; - if (lightStatusBar) { - newSystemUiFlags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR ; - if (changeNavBar && Utilities.isAtLeastO()) { + if (isLight) { + if (statusBar) { + newSystemUiFlags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; + } + if (navBar && Utilities.isAtLeastO()) { newSystemUiFlags |= SYSTEM_UI_FLAG_LIGHT_NAV_BAR; } } else { - newSystemUiFlags &= ~(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); - if (changeNavBar && Utilities.isAtLeastO()) { + if (statusBar) { + newSystemUiFlags &= ~(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); + } + if (navBar && Utilities.isAtLeastO()) { newSystemUiFlags &= ~(SYSTEM_UI_FLAG_LIGHT_NAV_BAR); } } diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index 3b370bd3e9..30ed180e7e 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -260,7 +260,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul // Use a light status bar (dark icons) if all apps is behind at least half of the status // bar. If the status bar is already light due to wallpaper extraction, keep it that way. boolean forceLight = shift <= mStatusBarHeight / 2; - mLauncher.activateLightStatusBar(forceLight, true); + mLauncher.activateLightSystemBars(forceLight, true /* statusBar */, true /* navBar */); } /**