feat: add an option to revert bar hide (#242)
* feat: add an option to revert bar hide * fix: clarify the bars being hidden
This commit is contained in:
parent
291f61551a
commit
f0040b8392
3 changed files with 29 additions and 13 deletions
|
@ -149,7 +149,7 @@ fun initActivity(a: Activity) {
|
|||
if (navBarHeight == 0) {
|
||||
ViewCompat.getRootWindowInsets(window.decorView.findViewById(android.R.id.content))
|
||||
?.apply {
|
||||
navBarHeight = this.getInsets(WindowInsetsCompat.Type.systemBars()).bottom
|
||||
navBarHeight = this.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom
|
||||
}
|
||||
}
|
||||
WindowInsetsControllerCompat(window, window.decorView).hide(WindowInsetsCompat.Type.statusBars())
|
||||
|
@ -165,9 +165,8 @@ fun initActivity(a: Activity) {
|
|||
val windowInsets =
|
||||
ViewCompat.getRootWindowInsets(window.decorView.findViewById(android.R.id.content))
|
||||
if (windowInsets != null) {
|
||||
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
statusBarHeight = insets.top
|
||||
navBarHeight = insets.bottom
|
||||
statusBarHeight = windowInsets.getInsets(WindowInsetsCompat.Type.statusBars()).top
|
||||
navBarHeight = windowInsets.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom
|
||||
}
|
||||
}
|
||||
if (a !is MainActivity) a.setNavigationTheme()
|
||||
|
@ -181,6 +180,23 @@ fun Activity.hideSystemBars() {
|
|||
}
|
||||
}
|
||||
|
||||
fun Activity.hideSystemBarsExtendView() {
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
hideSystemBars()
|
||||
}
|
||||
|
||||
fun Activity.showSystemBars() {
|
||||
WindowInsetsControllerCompat(window, window.decorView).let { controller ->
|
||||
controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_DEFAULT
|
||||
controller.show(WindowInsetsCompat.Type.systemBars())
|
||||
}
|
||||
}
|
||||
|
||||
fun Activity.showSystemBarsRetractView() {
|
||||
WindowCompat.setDecorFitsSystemWindows(window, true)
|
||||
showSystemBars()
|
||||
}
|
||||
|
||||
fun Activity.setNavigationTheme() {
|
||||
val tv = TypedValue()
|
||||
theme.resolveAttribute(android.R.attr.colorBackground, tv, true)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue