From f29013427c2e9f5d87db7603613c905773b79191 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Mon, 15 May 2023 14:27:13 +0200 Subject: [PATCH] Deselect all bottom nav items when home tab not among them --- .../github/libretube/ui/activities/MainActivity.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt index 77e890072..f0069c6a3 100644 --- a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt @@ -131,6 +131,8 @@ class MainActivity : BaseActivity() { false } + if (binding.bottomNav.menu.children.none { it.itemId == startFragmentId }) deselectBottomBarItems() + binding.toolbar.title = ThemeHelper.getStyledAppName(this) // handle error logs @@ -179,6 +181,17 @@ class MainActivity : BaseActivity() { loadIntentData() } + /** + * Deselect all bottom bar items + */ + fun deselectBottomBarItems() { + binding.bottomNav.menu.setGroupCheckable(0, true, false) + for (child in binding.bottomNav.menu.children) { + child.isChecked = false + } + binding.bottomNav.menu.setGroupCheckable(0, true, true) + } + /** * Try to find a scroll or recycler view and scroll it back to the top */