Skip to content

Commit 86089c9

Browse files
committed
use different tab icons for inactive tabs
1 parent b85dd7d commit 86089c9

File tree

2 files changed

+44
-6
lines changed

2 files changed

+44
-6
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ android {
6363
}
6464

6565
dependencies {
66-
implementation 'com.github.SimpleMobileTools:Simple-Commons:db6122327f'
66+
implementation 'com.github.SimpleMobileTools:Simple-Commons:a6c22de9d6'
6767
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
6868
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
6969
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'

app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/MainActivity.kt

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,19 +300,57 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
300300

301301
private fun setupTabColors() {
302302
val activeView = main_tabs_holder.getTabAt(view_pager.currentItem)?.customView
303-
updateBottomTabItemColors(activeView, true)
303+
updateBottomTabItemColors(activeView, true, getSelectedTabDrawableIds()[view_pager.currentItem])
304304

305305
getInactiveTabIndexes(view_pager.currentItem).forEach { index ->
306306
val inactiveView = main_tabs_holder.getTabAt(index)?.customView
307-
updateBottomTabItemColors(inactiveView, false)
307+
updateBottomTabItemColors(inactiveView, false, getDeselectedTabDrawableIds()[index])
308308
}
309309

310310
val bottomBarColor = getBottomNavigationBackgroundColor()
311311
main_tabs_holder.setBackgroundColor(bottomBarColor)
312312
updateNavigationBarColor(bottomBarColor)
313313
}
314314

315-
private fun getInactiveTabIndexes(activeIndex: Int) = (0 until tabsList.size).filter { it != activeIndex }
315+
private fun getInactiveTabIndexes(activeIndex: Int) = (0 until main_tabs_holder.tabCount).filter { it != activeIndex }
316+
317+
private fun getSelectedTabDrawableIds(): ArrayList<Int> {
318+
val showTabs = config.showTabs
319+
val icons = ArrayList<Int>()
320+
321+
if (showTabs and TAB_CONTACTS != 0) {
322+
icons.add(R.drawable.ic_person_vector)
323+
}
324+
325+
if (showTabs and TAB_FAVORITES != 0) {
326+
icons.add(R.drawable.ic_star_vector)
327+
}
328+
329+
if (showTabs and TAB_GROUPS != 0) {
330+
icons.add(R.drawable.ic_people_vector)
331+
}
332+
333+
return icons
334+
}
335+
336+
private fun getDeselectedTabDrawableIds(): ArrayList<Int> {
337+
val showTabs = config.showTabs
338+
val icons = ArrayList<Int>()
339+
340+
if (showTabs and TAB_CONTACTS != 0) {
341+
icons.add(R.drawable.ic_person_outline_vector)
342+
}
343+
344+
if (showTabs and TAB_FAVORITES != 0) {
345+
icons.add(R.drawable.ic_star_outline_vector)
346+
}
347+
348+
if (showTabs and TAB_GROUPS != 0) {
349+
icons.add(R.drawable.ic_people_outline_vector)
350+
}
351+
352+
return icons
353+
}
316354

317355
private fun initFragments() {
318356
view_pager.offscreenPageLimit = tabsList.size - 1
@@ -360,12 +398,12 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
360398

361399
main_tabs_holder.onTabSelectionChanged(
362400
tabUnselectedAction = {
363-
updateBottomTabItemColors(it.customView, false)
401+
updateBottomTabItemColors(it.customView, false, getDeselectedTabDrawableIds()[it.position])
364402
},
365403
tabSelectedAction = {
366404
main_menu.closeSearch()
367405
view_pager.currentItem = it.position
368-
updateBottomTabItemColors(it.customView, true)
406+
updateBottomTabItemColors(it.customView, true, getSelectedTabDrawableIds()[it.position])
369407
}
370408
)
371409

0 commit comments

Comments
 (0)