From fd44ddf2787aa327c51411c0807e2b492f7c9daf Mon Sep 17 00:00:00 2001 From: Emily Kager Date: Wed, 3 Apr 2019 14:56:16 -0700 Subject: [PATCH] For #1144 - Use System Black Navigation Bar for { @@ -87,18 +79,28 @@ class DefaultThemeManager : ThemeManager { window.decorView.systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR or View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR + if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.O) { + // API level can display handle light navigation bar color + updateNavigationBar(onHomeScreen, window, context) + } } Configuration.UI_MODE_NIGHT_YES -> { window.decorView.systemUiVisibility = window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv() and View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR.inv() + updateNavigationBar(onHomeScreen, window, context) } Configuration.UI_MODE_NIGHT_UNDEFINED -> { + // We assume light here per Android doc's recommendation window.decorView.systemUiVisibility = window.decorView.systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR or View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR + if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.O) { + // API level can display handle light navigation bar color + updateNavigationBar(onHomeScreen, window, context) + } } } } @@ -106,8 +108,25 @@ class DefaultThemeManager : ThemeManager { window.decorView.systemUiVisibility = window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv() and View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR.inv() + updateNavigationBar(onHomeScreen, window, context) } } } + + private fun updateNavigationBar(onHomeScreen: Boolean, window: Window, context: Context) { + if (onHomeScreen) { + window.navigationBarColor = ContextCompat + .getColor( + context, DefaultThemeManager + .resolveAttribute(R.attr.navigationBarColorHome, context) + ) + } else { + window.navigationBarColor = ContextCompat + .getColor( + context, DefaultThemeManager + .resolveAttribute(R.attr.navigationBarColorBrowser, context) + ) + } + } } } diff --git a/app/src/main/res/values-v23/styles.xml b/app/src/main/res/values-v23/styles.xml index a7600cd56d..2391968ad7 100644 --- a/app/src/main/res/values-v23/styles.xml +++ b/app/src/main/res/values-v23/styles.xml @@ -9,9 +9,6 @@ sure we also get them in 27+ --> @android:color/transparent @bool/theme_is_light - - - @android:color/transparent