Only apply insets when using gesture navigation

This commit is contained in:
Naveen 2023-05-10 22:44:44 +05:30
parent 11f9bfd8b4
commit c187d247e7

View file

@ -158,6 +158,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
hideKeyboard()
finish()
}
else -> return super.onOptionsItemSelected(item)
}
return true
@ -228,14 +229,14 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
if (navigationBarHeight > 0 || isUsingGestureNavigation()) {
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility.addBit(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
updateTopBottomInsets(statusBarHeight, navigationBarHeight)
onApplyWindowInsets {
val insets = it.getInsets(WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.ime())
updateTopBottomInsets(insets.top, insets.bottom)
}
} else {
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility.removeBit(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
updateTopBottomInsets(0, 0)
}
onApplyWindowInsets {
val insets = it.getInsets(WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.ime())
updateTopBottomInsets(insets.top, insets.bottom)
}
}
}