fix: transient navigation bar should work now for Android 8-15, closes #1199 (#1225)

This commit is contained in:
Huang Xin 2025-05-22 22:12:59 +08:00 committed by GitHub
parent e238b49fbf
commit 9700942e24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -221,6 +221,7 @@ class NativeBridgePlugin(private val activity: Activity): Plugin(activity) {
}
if (visible) {
controller.show(WindowInsets.Type.statusBars())
controller.hide(WindowInsets.Type.navigationBars())
} else {
controller.hide(WindowInsets.Type.systemBars())
}
@ -236,25 +237,27 @@ class NativeBridgePlugin(private val activity: Activity): Plugin(activity) {
}
if (visible) {
it.show(WindowInsetsCompat.Type.statusBars())
it.hide(WindowInsetsCompat.Type.navigationBars())
} else {
it.hide(WindowInsetsCompat.Type.systemBars())
}
}
} else {
@Suppress("DEPRECATION")
decorView.systemUiVisibility = when {
visible && !isDarkMode -> View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR or
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
visible -> View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
else -> View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_FULLSCREEN
}
decorView.systemUiVisibility = buildList {
add(View.SYSTEM_UI_FLAG_LAYOUT_STABLE)
add(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
add(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION)
add(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
add(View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
if (!visible) {
add(View.SYSTEM_UI_FLAG_FULLSCREEN)
}
if (visible && !isDarkMode) {
add(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)
}
}.reduce { acc, flag -> acc or flag }
}
window.statusBarColor = Color.TRANSPARENT
window.navigationBarColor = Color.TRANSPARENT