Fixed: Navigation drawer showing while reading a book in fullscreen mode.

* Disabled the right drawer when the user is reading a book in fullscreen mode to ensure uninterrupted reading.
* Also disabled the drawer while a video is playing in fullscreen mode to avoid interruptions during video playback.
This commit is contained in:
MohitMaliFtechiz 2025-01-24 16:40:23 +05:30 committed by Kelson
parent 99aae9441b
commit 22a3b4d9d2
3 changed files with 29 additions and 4 deletions

View File

@ -308,6 +308,7 @@ class KiwixReaderFragment : CoreReaderFragment() {
} else { } else {
showNavBar() showNavBar()
} }
super.onFullscreenVideoToggled(isFullScreen)
} }
override fun openFullScreen() { override fun openFullScreen() {

View File

@ -283,11 +283,16 @@ abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
} }
} }
open fun disableDrawer() { open fun disableDrawer(disableRightDrawer: Boolean = true) {
drawerToggle?.isDrawerIndicatorEnabled = false drawerToggle?.isDrawerIndicatorEnabled = false
drawerContainerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED) drawerContainerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
if (disableRightDrawer) {
// Disable the right drawer // Disable the right drawer
drawerContainerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, GravityCompat.END) drawerContainerLayout.setDrawerLockMode(
DrawerLayout.LOCK_MODE_LOCKED_CLOSED,
GravityCompat.END
)
}
} }
open fun onNavigationItemSelected(item: MenuItem): Boolean { open fun onNavigationItemSelected(item: MenuItem): Boolean {

View File

@ -1643,12 +1643,29 @@ abstract class CoreReaderFragment :
return true return true
} }
/**
* Handles the toggling of fullscreen video mode and adjusts the drawer's behavior accordingly.
* - If a video is playing in fullscreen mode, the drawer is disabled to restrict interactions.
* - When fullscreen mode is exited, the drawer is re-enabled unless the reader is still
* in fullscreen mode.
* - Specifically, if the reader is in fullscreen mode and the user plays a video in
* fullscreen, then exits the video's fullscreen mode, the drawer remains disabled
* because the reader is still in fullscreen mode.
*/
override fun onFullscreenVideoToggled(isFullScreen: Boolean) { override fun onFullscreenVideoToggled(isFullScreen: Boolean) {
// does nothing because custom doesn't have a nav bar if (isFullScreen) {
(requireActivity() as CoreMainActivity).disableDrawer(false)
} else {
if (!isInFullScreenMode()) {
toolbar?.let(::setUpDrawerToggle)
setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED)
}
}
} }
@Suppress("MagicNumber") @Suppress("MagicNumber")
protected open fun openFullScreen() { protected open fun openFullScreen() {
(requireActivity() as CoreMainActivity).disableDrawer(false)
toolbarContainer?.visibility = View.GONE toolbarContainer?.visibility = View.GONE
bottomToolbar?.visibility = View.GONE bottomToolbar?.visibility = View.GONE
exitFullscreenButton?.visibility = View.VISIBLE exitFullscreenButton?.visibility = View.VISIBLE
@ -1664,6 +1681,8 @@ abstract class CoreReaderFragment :
@Suppress("MagicNumber") @Suppress("MagicNumber")
open fun closeFullScreen() { open fun closeFullScreen() {
toolbar?.let(::setUpDrawerToggle)
setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED)
sharedPreferenceUtil?.putPrefFullScreen(false) sharedPreferenceUtil?.putPrefFullScreen(false)
toolbarContainer?.visibility = View.VISIBLE toolbarContainer?.visibility = View.VISIBLE
updateBottomToolbarVisibility() updateBottomToolbarVisibility()