From 3285da35cb357d09a98ff7bdf6c5b9f6fabbee8b Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Mon, 19 Dec 2016 14:46:21 -0800 Subject: [PATCH] Nav bar should change to light theme in sync with the status bar b/33708486 Nav bar should be in sync with status bar in all apps screen. Nave bar should not change with status bar when in workspace mode. Change-Id: Ib5a0d33d3e38f1b3ffa9693657ba7de3b6e01fed --- src/com/android/launcher3/Launcher.java | 28 +++++++++++----------- .../allapps/AllAppsTransitionController.java | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 8aa41588b..08f56d11d 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -475,9 +475,13 @@ public class Launcher extends Activity mExtractedColors.load(this); mHotseat.updateColor(mExtractedColors, !mPaused); mWorkspace.getPageIndicator().updateColor(mExtractedColors); + boolean lightStatusBar = (FeatureFlags.LIGHT_STATUS_BAR + && mExtractedColors.getColor(ExtractedColors.STATUS_BAR_INDEX, + ExtractedColors.DEFAULT_DARK) == ExtractedColors.DEFAULT_LIGHT); // It's possible that All Apps is visible when this is run, - // so always use light status bar in that case. - activateLightStatusBar(isAllAppsVisible(), false); + // 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()); } } @@ -486,28 +490,24 @@ public class Launcher extends Activity /** * Sets the status bar to be light or not. Light status bar means dark icons. - * @param activate if true, make sure the status bar is light, otherwise base on wallpaper. - * @param changeNavBar make sure the nav bar is light only if this param and {@param activate} - * is also true. + * @param lightStatusBar make sure the status bar is light + * @param changeNavBar if true, make the nav bar theme in sync with status bar. */ - public void activateLightStatusBar(boolean activate, boolean changeNavBar) { - boolean lightStatusBar = activate || (FeatureFlags.LIGHT_STATUS_BAR - && mExtractedColors.getColor(ExtractedColors.STATUS_BAR_INDEX, - ExtractedColors.DEFAULT_DARK) == ExtractedColors.DEFAULT_LIGHT); + public void activateLightStatusBar(boolean lightStatusBar, boolean changeNavBar) { int oldSystemUiFlags = getWindow().getDecorView().getSystemUiVisibility(); int newSystemUiFlags = oldSystemUiFlags; if (lightStatusBar) { newSystemUiFlags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR ; + if (changeNavBar && Utilities.isAtLeastO()) { + newSystemUiFlags |= SYSTEM_UI_FLAG_LIGHT_NAV_BAR; + } } else { newSystemUiFlags &= ~(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); - } - if (Utilities.isAtLeastO() && activate) { - if (changeNavBar) { - newSystemUiFlags |= SYSTEM_UI_FLAG_LIGHT_NAV_BAR; - } else { + if (changeNavBar && Utilities.isAtLeastO()) { newSystemUiFlags &= ~(SYSTEM_UI_FLAG_LIGHT_NAV_BAR); } } + if (newSystemUiFlags != oldSystemUiFlags) { getWindow().getDecorView().setSystemUiVisibility(newSystemUiFlags); } diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index 99cac4193..c199fef09 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -288,7 +288,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, forceLight); + mLauncher.activateLightStatusBar(forceLight, true); } /** -- 2.11.0