Some fixes to temporarily showing/hiding the reading menu in some cases

like showing system bars or opening notification drawer etc.
This commit is contained in:
Jays2Kings 2021-06-22 22:25:19 -04:00
parent 34fc0a662c
commit d0b4b33466

View File

@ -303,20 +303,6 @@ class ReaderActivity :
super.onSaveInstanceState(outState)
}
/**
* Called when the window focus changes. It sets the menu visibility to the last known state
* to apply again System UI (for immersive mode).
*/
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
if (hasFocus) {
when (menuStickyVisible) {
true -> setMenuVisibility(false)
false -> setMenuVisibility(menuVisible, animate = false)
}
}
}
/**
* Called when the options menu of the binding.toolbar is being created. It adds our custom menu.
*/
@ -1290,7 +1276,7 @@ class ReaderActivity :
}
override fun onVisibilityChange(visible: Boolean) {
if (visible && !menuStickyVisible && !menuVisible) {
if (visible && !menuStickyVisible && !menuVisible && !binding.readerMenu.isVisible) {
menuStickyVisible = visible
if (visible) {
coroutine = launchUI {
@ -1313,9 +1299,9 @@ class ReaderActivity :
)
binding.appBar.startAnimation(toolbarAnimation)
}
} else {
} else if (!visible && (menuStickyVisible || menuVisible)) {
if (menuStickyVisible && !menuVisible) {
setMenuVisibility(false, animate = false)
setMenuVisibility(false)
}
coroutine?.cancel()
}