Skip to content

Commit

Permalink
Fixed: Navigation drawer showing while reading a book in fullscreen m…
Browse files Browse the repository at this point in the history
…ode.

* 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.
  • Loading branch information
MohitMaliDeveloper authored and kelson42 committed Jan 26, 2025
1 parent 99aae94 commit 22a3b4d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ class KiwixReaderFragment : CoreReaderFragment() {
} else {
showNavBar()
}
super.onFullscreenVideoToggled(isFullScreen)

Check warning on line 311 in app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt#L311

Added line #L311 was not covered by tests
}

override fun openFullScreen() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,16 @@ abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
}
}

open fun disableDrawer() {
open fun disableDrawer(disableRightDrawer: Boolean = true) {
drawerToggle?.isDrawerIndicatorEnabled = false
drawerContainerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
// Disable the right drawer
drawerContainerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, GravityCompat.END)
if (disableRightDrawer) {
// Disable the right drawer
drawerContainerLayout.setDrawerLockMode(
DrawerLayout.LOCK_MODE_LOCKED_CLOSED,
GravityCompat.END
)
}
}

open fun onNavigationItemSelected(item: MenuItem): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1643,12 +1643,29 @@ abstract class CoreReaderFragment :
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) {
// does nothing because custom doesn't have a nav bar
if (isFullScreen) {
(requireActivity() as CoreMainActivity).disableDrawer(false)

Check warning on line 1657 in core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt#L1657

Added line #L1657 was not covered by tests
} else {
if (!isInFullScreenMode()) {
toolbar?.let(::setUpDrawerToggle)
setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED)

Check warning on line 1661 in core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt#L1661

Added line #L1661 was not covered by tests
}
}
}

@Suppress("MagicNumber")
protected open fun openFullScreen() {
(requireActivity() as CoreMainActivity).disableDrawer(false)

Check warning on line 1668 in core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt#L1668

Added line #L1668 was not covered by tests
toolbarContainer?.visibility = View.GONE
bottomToolbar?.visibility = View.GONE
exitFullscreenButton?.visibility = View.VISIBLE
Expand All @@ -1664,6 +1681,8 @@ abstract class CoreReaderFragment :

@Suppress("MagicNumber")
open fun closeFullScreen() {
toolbar?.let(::setUpDrawerToggle)
setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED)

Check warning on line 1685 in core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt#L1685

Added line #L1685 was not covered by tests
sharedPreferenceUtil?.putPrefFullScreen(false)
toolbarContainer?.visibility = View.VISIBLE
updateBottomToolbarVisibility()
Expand Down

0 comments on commit 22a3b4d

Please sign in to comment.