From fa3e0f31a16d35c5841786ff489269b28886d77d Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 31 Dec 2022 15:42:33 +0100 Subject: [PATCH] use different icons for some selected tabs --- app/build.gradle | 2 +- .../pro/activities/MainActivity.kt | 61 ++++++++++++++++--- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 0ba1b247..f5031794 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -64,7 +64,7 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:7408174438' + implementation 'com.github.SimpleMobileTools:Simple-Commons:afb485c357' implementation 'com.github.tibbi:PdfViewPager:d2af24208d' implementation 'com.github.Stericson:RootTools:df729dcb13' implementation 'com.github.Stericson:RootShell:1.6' diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt index b58312af..a64ac99e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt @@ -468,13 +468,16 @@ class MainActivity : SimpleActivity() { } } - main_tabs_holder.onTabSelectionChanged(tabUnselectedAction = { - updateBottomTabItemColors(it.customView, false) - }, tabSelectedAction = { - closeSearch() - main_view_pager.currentItem = it.position - updateBottomTabItemColors(it.customView, true) - }) + main_tabs_holder.onTabSelectionChanged( + tabUnselectedAction = { + updateBottomTabItemColors(it.customView, false, getDeselectedTabDrawableIds()[it.position]) + }, + tabSelectedAction = { + closeSearch() + main_view_pager.currentItem = it.position + updateBottomTabItemColors(it.customView, true, getSelectedTabDrawableIds()[it.position]) + } + ) main_tabs_holder.beGoneIf(main_tabs_holder.tabCount == 1) main_tabs_holder.onGlobalLayout { @@ -496,11 +499,11 @@ class MainActivity : SimpleActivity() { private fun setupTabColors() { val activeView = main_tabs_holder.getTabAt(main_view_pager.currentItem)?.customView - updateBottomTabItemColors(activeView, true) + updateBottomTabItemColors(activeView, true, getSelectedTabDrawableIds()[main_view_pager.currentItem]) getInactiveTabIndexes(main_view_pager.currentItem).forEach { index -> val inactiveView = main_tabs_holder.getTabAt(index)?.customView - updateBottomTabItemColors(inactiveView, false) + updateBottomTabItemColors(inactiveView, false, getDeselectedTabDrawableIds()[index]) } if (main_tabs_holder.isVisible()) { @@ -791,7 +794,45 @@ class MainActivity : SimpleActivity() { } } - private fun getInactiveTabIndexes(activeIndex: Int) = (0 until getTabsList().size).filter { it != activeIndex } + private fun getInactiveTabIndexes(activeIndex: Int) = (0 until main_tabs_holder.tabCount).filter { it != activeIndex } + + private fun getSelectedTabDrawableIds(): ArrayList { + val showTabs = config.showTabs + val icons = ArrayList() + + if (showTabs and TAB_FILES != 0) { + icons.add(R.drawable.ic_folder_vector) + } + + if (showTabs and TAB_RECENT_FILES != 0) { + icons.add(R.drawable.ic_clock_filled_vector) + } + + if (showTabs and TAB_STORAGE_ANALYSIS != 0) { + icons.add(R.drawable.ic_storage_vector) + } + + return icons + } + + private fun getDeselectedTabDrawableIds(): ArrayList { + val showTabs = config.showTabs + val icons = ArrayList() + + if (showTabs and TAB_FILES != 0) { + icons.add(R.drawable.ic_folder_outline_vector) + } + + if (showTabs and TAB_RECENT_FILES != 0) { + icons.add(R.drawable.ic_clock_vector) + } + + if (showTabs and TAB_STORAGE_ANALYSIS != 0) { + icons.add(R.drawable.ic_storage_vector) + } + + return icons + } private fun getAllFragments(): ArrayList = arrayListOf(items_fragment, recents_fragment, storage_fragment)