mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-04 03:06:41 -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 drawerNavView: NavigationView by lazy { drawer_nav_view }
|
||||||
override val bookmarksFragmentResId: Int = R.id.bookmarksFragment
|
override val bookmarksFragmentResId: Int = R.id.bookmarksFragment
|
||||||
override val historyFragmentResId: Int = R.id.historyFragment
|
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) {
|
override fun injection(coreComponent: CoreComponent) {
|
||||||
cachedComponent.inject(this)
|
cachedComponent.inject(this)
|
||||||
@ -77,12 +79,15 @@ class KiwixMainActivity : CoreMainActivity() {
|
|||||||
onNavigationItemSelected(item)
|
onNavigationItemSelected(item)
|
||||||
}
|
}
|
||||||
bottom_nav_view.setupWithNavController(navController)
|
bottom_nav_view.setupWithNavController(navController)
|
||||||
|
}
|
||||||
|
|
||||||
val topLevelDestinations =
|
override fun onPostCreate(savedInstanceState: Bundle?) {
|
||||||
setOf(R.id.navigation_downloads, R.id.navigation_library, R.id.navigation_reader)
|
super.onPostCreate(savedInstanceState)
|
||||||
|
|
||||||
navController.addOnDestinationChangedListener { _, destination, _ ->
|
navController.addOnDestinationChangedListener { _, destination, _ ->
|
||||||
bottom_nav_view.isVisible = destination.id in topLevelDestinations
|
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 bookmarksFragmentResId: Int
|
||||||
abstract val historyFragmentResId: Int
|
abstract val historyFragmentResId: Int
|
||||||
abstract val cachedComponent: CoreActivityComponent
|
abstract val cachedComponent: CoreActivityComponent
|
||||||
|
abstract val topLevelDestinations: Set<Int>
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
@ -190,7 +191,6 @@ abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
|
|||||||
|
|
||||||
private fun openHistoryActivity() {
|
private fun openHistoryActivity() {
|
||||||
navigate(historyFragmentResId)
|
navigate(historyFragmentResId)
|
||||||
handleDrawerOnNavigation()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun openBookmarksActivity() {
|
private fun openBookmarksActivity() {
|
||||||
@ -198,7 +198,7 @@ abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
|
|||||||
handleDrawerOnNavigation()
|
handleDrawerOnNavigation()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleDrawerOnNavigation() {
|
protected fun handleDrawerOnNavigation() {
|
||||||
closeNavigationDrawer()
|
closeNavigationDrawer()
|
||||||
disableDrawer()
|
disableDrawer()
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,8 @@ class CustomMainActivity : CoreMainActivity() {
|
|||||||
override val bookmarksFragmentResId: Int = R.id.bookmarksFragment
|
override val bookmarksFragmentResId: Int = R.id.bookmarksFragment
|
||||||
override val historyFragmentResId: Int = R.id.historyFragment
|
override val historyFragmentResId: Int = R.id.historyFragment
|
||||||
override val cachedComponent by lazy { customActivityComponent }
|
override val cachedComponent by lazy { customActivityComponent }
|
||||||
|
override val topLevelDestinations =
|
||||||
|
setOf(R.id.customReaderFragment)
|
||||||
|
|
||||||
override fun injection(coreComponent: CoreComponent) {
|
override fun injection(coreComponent: CoreComponent) {
|
||||||
customActivityComponent.inject(this)
|
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 {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
if (drawerToggle.isDrawerIndicatorEnabled) {
|
if (drawerToggle.isDrawerIndicatorEnabled) {
|
||||||
return drawerToggle.onOptionsItemSelected(item)
|
return drawerToggle.onOptionsItemSelected(item)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user