From fa872f6cf7d08dd6f07e66a6ca55210238100460 Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 14 May 2021 18:26:39 -0400 Subject: [PATCH] Don't hide side nav when opening ActionToolbar on tablets --- .../kanade/tachiyomi/ui/library/LibraryController.kt | 4 ++-- .../java/eu/kanade/tachiyomi/ui/main/MainActivity.kt | 12 ++++++++++-- .../tachiyomi/ui/recent/updates/UpdatesController.kt | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index 3e41d4ab9..2909574be 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -367,7 +367,7 @@ class LibraryController( actionMode!!, R.menu.library_selection ) { onActionItemClicked(it!!) } - (activity as? MainActivity)?.showNav(visible = false, collapse = true) + (activity as? MainActivity)?.showBottomNav(visible = false, collapse = true) } } @@ -476,7 +476,7 @@ class LibraryController( selectionRelay.call(LibrarySelectionEvent.Cleared()) binding.actionToolbar.hide() - (activity as? MainActivity)?.showNav(visible = true, collapse = true) + (activity as? MainActivity)?.showBottomNav(visible = true, collapse = true) actionMode = null } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index bfe56ff4c..8e92225c0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -140,7 +140,7 @@ class MainActivity : BaseViewBindingActivity() { binding.toolbarLayout.appbar.addOnOffsetChangedListener( AppBarLayout.OnOffsetChangedListener { _, verticalOffset -> if (verticalOffset == 0) { - showNav(true) + showNav(visible = true) } } ) @@ -451,7 +451,13 @@ class MainActivity : BaseViewBindingActivity() { } } - fun showNav(visible: Boolean, collapse: Boolean = false) { + private fun showNav(visible: Boolean, collapse: Boolean = false) { + showBottomNav(visible, collapse) + showSideNav(visible) + } + + // Also used from some controllers to swap bottom nav with action toolbar + fun showBottomNav(visible: Boolean, collapse: Boolean = false) { binding.bottomNav?.let { val layoutParams = it.layoutParams as CoordinatorLayout.LayoutParams val bottomViewNavigationBehavior = @@ -470,7 +476,9 @@ class MainActivity : BaseViewBindingActivity() { bottomViewNavigationBehavior?.slideDown(it) } } + } + private fun showSideNav(visible: Boolean) { binding.sideNav?.let { it.isVisible = visible } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt index 11e8ab777..33077968a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt @@ -182,7 +182,7 @@ class UpdatesController : actionMode!!, R.menu.updates_chapter_selection ) { onActionItemClicked(it!!) } - (activity as? MainActivity)?.showNav(visible = false, collapse = true) + (activity as? MainActivity)?.showBottomNav(visible = false, collapse = true) } toggleSelection(position) @@ -380,7 +380,7 @@ class UpdatesController : adapter?.clearSelection() binding.actionToolbar.hide() - (activity as? MainActivity)?.showNav(visible = true, collapse = true) + (activity as? MainActivity)?.showBottomNav(visible = true, collapse = true) actionMode = null }