No issue: Add back status/nav flags after fullscreen exit (#2003)
parent
ec64286eac
commit
10517580cc
|
@ -61,33 +61,29 @@ class DefaultThemeManager : ThemeManager {
|
||||||
fun applyStatusBarTheme(
|
fun applyStatusBarTheme(
|
||||||
window: Window,
|
window: Window,
|
||||||
themeManager: ThemeManager,
|
themeManager: ThemeManager,
|
||||||
context: Context,
|
context: Context
|
||||||
onHomeScreen: Boolean = true
|
|
||||||
) {
|
) {
|
||||||
window.statusBarColor = ContextCompat
|
window.statusBarColor = ContextCompat
|
||||||
.getColor(
|
.getColor(
|
||||||
context, DefaultThemeManager
|
context, resolveAttribute(android.R.attr.statusBarColor, context)
|
||||||
.resolveAttribute(android.R.attr.statusBarColor, context)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
when (themeManager.currentTheme) {
|
when (themeManager.currentTheme) {
|
||||||
ThemeManager.Theme.Normal -> {
|
ThemeManager.Theme.Normal -> {
|
||||||
val currentNightMode =
|
when (context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
|
||||||
context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
|
||||||
when (currentNightMode) {
|
|
||||||
Configuration.UI_MODE_NIGHT_NO -> {
|
Configuration.UI_MODE_NIGHT_NO -> {
|
||||||
updateLightNavigationBar(onHomeScreen, window, context)
|
updateLightNavigationBar(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)
|
updateNavigationBar(window, context)
|
||||||
}
|
}
|
||||||
Configuration.UI_MODE_NIGHT_UNDEFINED -> {
|
Configuration.UI_MODE_NIGHT_UNDEFINED -> {
|
||||||
// We assume light here per Android doc's recommendation
|
// We assume light here per Android doc's recommendation
|
||||||
updateLightNavigationBar(onHomeScreen, window, context)
|
updateLightNavigationBar(window, context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,19 +91,22 @@ 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)
|
updateNavigationBar(window, context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateLightNavigationBar(onHomeScreen: Boolean, window: Window, context: Context) {
|
private fun updateLightNavigationBar(
|
||||||
|
window: Window,
|
||||||
|
context: Context
|
||||||
|
) {
|
||||||
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.O) {
|
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.O) {
|
||||||
// API level can display handle light navigation bar color
|
// API level can display handle light navigation bar color
|
||||||
updateNavigationBar(onHomeScreen, window, context)
|
|
||||||
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
|
||||||
|
updateNavigationBar(window, context)
|
||||||
} else {
|
} else {
|
||||||
window.decorView.systemUiVisibility =
|
window.decorView.systemUiVisibility =
|
||||||
window.decorView.systemUiVisibility or
|
window.decorView.systemUiVisibility or
|
||||||
|
@ -115,20 +114,14 @@ class DefaultThemeManager : ThemeManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateNavigationBar(onHomeScreen: Boolean, window: Window, context: Context) {
|
private fun updateNavigationBar(
|
||||||
if (onHomeScreen) {
|
window: Window,
|
||||||
window.navigationBarColor = ContextCompat
|
context: Context
|
||||||
.getColor(
|
) {
|
||||||
context, DefaultThemeManager
|
window.navigationBarColor = ContextCompat
|
||||||
.resolveAttribute(R.attr.foundation, context)
|
.getColor(
|
||||||
)
|
context, resolveAttribute(R.attr.foundation, context)
|
||||||
} else {
|
)
|
||||||
window.navigationBarColor = ContextCompat
|
|
||||||
.getColor(
|
|
||||||
context, DefaultThemeManager
|
|
||||||
.resolveAttribute(R.attr.foundation, context)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
||||||
QuickActionComponent(view.nestedScrollQuickAction, ActionBusFactory.get(this))
|
QuickActionComponent(view.nestedScrollQuickAction, ActionBusFactory.get(this))
|
||||||
|
|
||||||
val activity = activity as HomeActivity
|
val activity = activity as HomeActivity
|
||||||
DefaultThemeManager.applyStatusBarTheme(activity.window, activity.themeManager, activity, false)
|
DefaultThemeManager.applyStatusBarTheme(activity.window, activity.themeManager, activity)
|
||||||
|
|
||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
@ -252,6 +252,13 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
|
||||||
nestedScrollQuickAction.visibility = View.GONE
|
nestedScrollQuickAction.visibility = View.GONE
|
||||||
} else {
|
} else {
|
||||||
activity?.exitImmersiveModeIfNeeded()
|
activity?.exitImmersiveModeIfNeeded()
|
||||||
|
(activity as HomeActivity).let { activity: HomeActivity ->
|
||||||
|
DefaultThemeManager.applyStatusBarTheme(
|
||||||
|
activity.window,
|
||||||
|
activity.themeManager,
|
||||||
|
activity
|
||||||
|
)
|
||||||
|
}
|
||||||
toolbar.visibility = View.VISIBLE
|
toolbar.visibility = View.VISIBLE
|
||||||
nestedScrollQuickAction.visibility = View.VISIBLE
|
nestedScrollQuickAction.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue