2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-15 18:12:54 +00:00

For #1144 - Use System Black Navigation Bar for <API27 + Light Theme

This commit is contained in:
Emily Kager 2019-04-03 14:56:16 -07:00 committed by Emily Kager
parent 4b4d172e2e
commit fd44ddf278
3 changed files with 32 additions and 15 deletions

View File

@ -64,18 +64,10 @@ class DefaultThemeManager : ThemeManager {
onHomeScreen: Boolean = true onHomeScreen: Boolean = true
) { ) {
window.statusBarColor = ContextCompat window.statusBarColor = ContextCompat
.getColor(context, DefaultThemeManager .getColor(
.resolveAttribute(android.R.attr.statusBarColor, context)) context, DefaultThemeManager
.resolveAttribute(android.R.attr.statusBarColor, 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))
}
when (themeManager.currentTheme) { when (themeManager.currentTheme) {
ThemeManager.Theme.Normal -> { ThemeManager.Theme.Normal -> {
@ -87,18 +79,28 @@ class DefaultThemeManager : ThemeManager {
window.decorView.systemUiVisibility or window.decorView.systemUiVisibility or
View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR or
View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR 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 -> { Configuration.UI_MODE_NIGHT_YES -> {
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility =
window.decorView.systemUiVisibility and window.decorView.systemUiVisibility and
View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv() and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv() and
View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR.inv() View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR.inv()
updateNavigationBar(onHomeScreen, window, context)
} }
Configuration.UI_MODE_NIGHT_UNDEFINED -> { Configuration.UI_MODE_NIGHT_UNDEFINED -> {
// We assume light here per Android doc's recommendation
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility =
window.decorView.systemUiVisibility or window.decorView.systemUiVisibility or
View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR or
View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR 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 window.decorView.systemUiVisibility = window.decorView.systemUiVisibility and
View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv() and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv() and
View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR.inv() 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)
)
}
}
} }
} }

View File

@ -9,9 +9,6 @@
sure we also get them in 27+ --> sure we also get them in 27+ -->
<item name="android:statusBarColor">@android:color/transparent</item> <item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowLightStatusBar">@bool/theme_is_light</item> <item name="android:windowLightStatusBar">@bool/theme_is_light</item>
<!-- Style the navigation bar -->
<item name="android:navigationBarColor">@android:color/transparent</item>
</style> </style>
<style name="PrivateTheme" parent="PrivateThemeBase"> <style name="PrivateTheme" parent="PrivateThemeBase">

View File

@ -23,6 +23,7 @@
<item name="android:windowLightStatusBar">@bool/theme_is_light</item> <item name="android:windowLightStatusBar">@bool/theme_is_light</item>
<!-- Style the navigation bar --> <!-- Style the navigation bar -->
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:navigationBarDividerColor">@android:color/transparent</item> <item name="android:navigationBarDividerColor">@android:color/transparent</item>
<item name="android:windowLightNavigationBar">@bool/theme_is_light</item> <item name="android:windowLightNavigationBar">@bool/theme_is_light</item>
</style> </style>