mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
#2112 fixed drawer hiding on any navigation except top level
This commit is contained in:
parent
3a4b09aabd
commit
06db90c55e
@ -56,6 +56,8 @@ class KiwixMainActivity : CoreMainActivity() {
|
||||
override val drawerNavView: NavigationView by lazy { drawer_nav_view }
|
||||
override val bookmarksFragmentResId: Int = R.id.bookmarksFragment
|
||||
override val historyFragmentResId: Int = R.id.historyFragment
|
||||
override val topLevelDestinations =
|
||||
setOf(R.id.navigation_downloads, R.id.navigation_library, R.id.navigation_reader)
|
||||
|
||||
override fun injection(coreComponent: CoreComponent) {
|
||||
cachedComponent.inject(this)
|
||||
@ -77,12 +79,15 @@ class KiwixMainActivity : CoreMainActivity() {
|
||||
onNavigationItemSelected(item)
|
||||
}
|
||||
bottom_nav_view.setupWithNavController(navController)
|
||||
}
|
||||
|
||||
val topLevelDestinations =
|
||||
setOf(R.id.navigation_downloads, R.id.navigation_library, R.id.navigation_reader)
|
||||
|
||||
override fun onPostCreate(savedInstanceState: Bundle?) {
|
||||
super.onPostCreate(savedInstanceState)
|
||||
navController.addOnDestinationChangedListener { _, destination, _ ->
|
||||
bottom_nav_view.isVisible = destination.id in topLevelDestinations
|
||||
if (destination.id !in topLevelDestinations) {
|
||||
handleDrawerOnNavigation()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,7 @@ abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
|
||||
abstract val bookmarksFragmentResId: Int
|
||||
abstract val historyFragmentResId: Int
|
||||
abstract val cachedComponent: CoreActivityComponent
|
||||
abstract val topLevelDestinations: Set<Int>
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
@ -190,7 +191,6 @@ abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
|
||||
|
||||
private fun openHistoryActivity() {
|
||||
navigate(historyFragmentResId)
|
||||
handleDrawerOnNavigation()
|
||||
}
|
||||
|
||||
private fun openBookmarksActivity() {
|
||||
@ -198,7 +198,7 @@ abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
|
||||
handleDrawerOnNavigation()
|
||||
}
|
||||
|
||||
private fun handleDrawerOnNavigation() {
|
||||
protected fun handleDrawerOnNavigation() {
|
||||
closeNavigationDrawer()
|
||||
disableDrawer()
|
||||
}
|
||||
|
@ -49,6 +49,8 @@ class CustomMainActivity : CoreMainActivity() {
|
||||
override val bookmarksFragmentResId: Int = R.id.bookmarksFragment
|
||||
override val historyFragmentResId: Int = R.id.historyFragment
|
||||
override val cachedComponent by lazy { customActivityComponent }
|
||||
override val topLevelDestinations =
|
||||
setOf(R.id.customReaderFragment)
|
||||
|
||||
override fun injection(coreComponent: CoreComponent) {
|
||||
customActivityComponent.inject(this)
|
||||
@ -62,6 +64,15 @@ class CustomMainActivity : CoreMainActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPostCreate(savedInstanceState: Bundle?) {
|
||||
super.onPostCreate(savedInstanceState)
|
||||
navController.addOnDestinationChangedListener { _, destination, _ ->
|
||||
if (destination.id !in topLevelDestinations) {
|
||||
handleDrawerOnNavigation()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (drawerToggle.isDrawerIndicatorEnabled) {
|
||||
return drawerToggle.onOptionsItemSelected(item)
|
||||
|
Loading…
x
Reference in New Issue
Block a user