use different tab icons for inactive tabs
This commit is contained in:
parent
b85dd7d7d2
commit
86089c9a2a
|
@ -63,7 +63,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:db6122327f'
|
implementation 'com.github.SimpleMobileTools:Simple-Commons:a6c22de9d6'
|
||||||
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
|
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
|
||||||
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
|
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
|
||||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||||
|
|
|
@ -300,11 +300,11 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
|
|
||||||
private fun setupTabColors() {
|
private fun setupTabColors() {
|
||||||
val activeView = main_tabs_holder.getTabAt(view_pager.currentItem)?.customView
|
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 ->
|
getInactiveTabIndexes(view_pager.currentItem).forEach { index ->
|
||||||
val inactiveView = main_tabs_holder.getTabAt(index)?.customView
|
val inactiveView = main_tabs_holder.getTabAt(index)?.customView
|
||||||
updateBottomTabItemColors(inactiveView, false)
|
updateBottomTabItemColors(inactiveView, false, getDeselectedTabDrawableIds()[index])
|
||||||
}
|
}
|
||||||
|
|
||||||
val bottomBarColor = getBottomNavigationBackgroundColor()
|
val bottomBarColor = getBottomNavigationBackgroundColor()
|
||||||
|
@ -312,7 +312,45 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
updateNavigationBarColor(bottomBarColor)
|
updateNavigationBarColor(bottomBarColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getInactiveTabIndexes(activeIndex: Int) = (0 until tabsList.size).filter { it != activeIndex }
|
private fun getInactiveTabIndexes(activeIndex: Int) = (0 until main_tabs_holder.tabCount).filter { it != activeIndex }
|
||||||
|
|
||||||
|
private fun getSelectedTabDrawableIds(): ArrayList<Int> {
|
||||||
|
val showTabs = config.showTabs
|
||||||
|
val icons = ArrayList<Int>()
|
||||||
|
|
||||||
|
if (showTabs and TAB_CONTACTS != 0) {
|
||||||
|
icons.add(R.drawable.ic_person_vector)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showTabs and TAB_FAVORITES != 0) {
|
||||||
|
icons.add(R.drawable.ic_star_vector)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showTabs and TAB_GROUPS != 0) {
|
||||||
|
icons.add(R.drawable.ic_people_vector)
|
||||||
|
}
|
||||||
|
|
||||||
|
return icons
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getDeselectedTabDrawableIds(): ArrayList<Int> {
|
||||||
|
val showTabs = config.showTabs
|
||||||
|
val icons = ArrayList<Int>()
|
||||||
|
|
||||||
|
if (showTabs and TAB_CONTACTS != 0) {
|
||||||
|
icons.add(R.drawable.ic_person_outline_vector)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showTabs and TAB_FAVORITES != 0) {
|
||||||
|
icons.add(R.drawable.ic_star_outline_vector)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showTabs and TAB_GROUPS != 0) {
|
||||||
|
icons.add(R.drawable.ic_people_outline_vector)
|
||||||
|
}
|
||||||
|
|
||||||
|
return icons
|
||||||
|
}
|
||||||
|
|
||||||
private fun initFragments() {
|
private fun initFragments() {
|
||||||
view_pager.offscreenPageLimit = tabsList.size - 1
|
view_pager.offscreenPageLimit = tabsList.size - 1
|
||||||
|
@ -360,12 +398,12 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
|
|
||||||
main_tabs_holder.onTabSelectionChanged(
|
main_tabs_holder.onTabSelectionChanged(
|
||||||
tabUnselectedAction = {
|
tabUnselectedAction = {
|
||||||
updateBottomTabItemColors(it.customView, false)
|
updateBottomTabItemColors(it.customView, false, getDeselectedTabDrawableIds()[it.position])
|
||||||
},
|
},
|
||||||
tabSelectedAction = {
|
tabSelectedAction = {
|
||||||
main_menu.closeSearch()
|
main_menu.closeSearch()
|
||||||
view_pager.currentItem = it.position
|
view_pager.currentItem = it.position
|
||||||
updateBottomTabItemColors(it.customView, true)
|
updateBottomTabItemColors(it.customView, true, getSelectedTabDrawableIds()[it.position])
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue