From 6c3d12fa8436b77832cdb840b236cabae330eae4 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 30 Dec 2022 18:17:36 +0100 Subject: [PATCH] use filled/empty icons at bottom tabs --- app/build.gradle | 2 +- .../dialer/activities/MainActivity.kt | 20 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 35ea4744..f0072841 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -62,7 +62,7 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:d82297ad77' + implementation 'com.github.SimpleMobileTools:Simple-Commons:e843eab1a5' implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61' implementation 'me.grantland:autofittextview:0.2.1' } diff --git a/app/src/main/kotlin/com/simplemobiletools/dialer/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/dialer/activities/MainActivity.kt index 529a3405..f52917df 100644 --- a/app/src/main/kotlin/com/simplemobiletools/dialer/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/dialer/activities/MainActivity.kt @@ -283,11 +283,11 @@ class MainActivity : SimpleActivity() { private fun setupTabColors() { val activeView = main_tabs_holder.getTabAt(view_pager.currentItem)?.customView - updateBottomTabItemColors(activeView, true) + updateBottomTabItemColors(activeView, true, getSelectedTabDrawableIds()[view_pager.currentItem]) getInactiveTabIndexes(view_pager.currentItem).forEach { index -> val inactiveView = main_tabs_holder.getTabAt(index)?.customView - updateBottomTabItemColors(inactiveView, false) + updateBottomTabItemColors(inactiveView, false, getDeselectedTabDrawableIds()[index]) } val bottomBarColor = getBottomNavigationBackgroundColor() @@ -297,6 +297,18 @@ class MainActivity : SimpleActivity() { private fun getInactiveTabIndexes(activeIndex: Int) = (0 until tabsList.size).filter { it != activeIndex } + private fun getSelectedTabDrawableIds() = arrayOf( + R.drawable.ic_person_vector, + R.drawable.ic_star_vector, + R.drawable.ic_clock_filled_vector + ) + + private fun getDeselectedTabDrawableIds() = arrayOf( + R.drawable.ic_person_outline_vector, + R.drawable.ic_star_outline_vector, + R.drawable.ic_clock_vector + ) + private fun initFragments() { view_pager.offscreenPageLimit = 2 view_pager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { @@ -363,12 +375,12 @@ class MainActivity : SimpleActivity() { main_tabs_holder.onTabSelectionChanged( tabUnselectedAction = { - updateBottomTabItemColors(it.customView, false) + updateBottomTabItemColors(it.customView, false, getDeselectedTabDrawableIds()[it.position]) }, tabSelectedAction = { closeSearch() view_pager.currentItem = it.position - updateBottomTabItemColors(it.customView, true) + updateBottomTabItemColors(it.customView, true, getSelectedTabDrawableIds()[it.position]) } )