fetch the proper default tab, if some tabs arent shown

This commit is contained in:
tibbi 2020-05-23 21:33:34 +02:00
parent 9b9d0231a5
commit 2967621c3e

View File

@ -55,7 +55,6 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
private var isFirstResume = true private var isFirstResume = true
private var isGettingContacts = false private var isGettingContacts = false
private var ignoredExportContactSources = HashSet<String>() private var ignoredExportContactSources = HashSet<String>()
private var handledShowTabs = 0
private var storedTextColor = 0 private var storedTextColor = 0
private var storedBackgroundColor = 0 private var storedBackgroundColor = 0
@ -71,9 +70,9 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)
appLaunched(BuildConfig.APPLICATION_ID) appLaunched(BuildConfig.APPLICATION_ID)
storeStateVariables()
setupTabColors() setupTabColors()
checkContactPermissions() checkContactPermissions()
storeStateVariables()
checkWhatsNewDialog() checkWhatsNewDialog()
checkDialerMigrationDialog() checkDialerMigrationDialog()
} }
@ -339,7 +338,6 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
} }
private fun setupTabColors() { private fun setupTabColors() {
handledShowTabs = config.showTabs
val lastUsedPage = getDefaultTab() val lastUsedPage = getDefaultTab()
main_tabs_holder.apply { main_tabs_holder.apply {
background = ColorDrawable(config.backgroundColor) background = ColorDrawable(config.backgroundColor)
@ -596,11 +594,28 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
private fun getAllFragments() = arrayListOf(contacts_fragment, favorites_fragment, groups_fragment) private fun getAllFragments() = arrayListOf(contacts_fragment, favorites_fragment, groups_fragment)
private fun getDefaultTab(): Int { private fun getDefaultTab(): Int {
val showTabsMask = config.showTabs
return when (config.defaultTab) { return when (config.defaultTab) {
TAB_LAST_USED -> config.lastUsedViewPagerPage TAB_LAST_USED -> config.lastUsedViewPagerPage
TAB_CONTACTS -> 0 TAB_CONTACTS -> 0
TAB_FAVORITES -> 1 TAB_FAVORITES -> {
else -> 2 if (showTabsMask and TAB_CONTACTS > 0) {
1
} else {
0
}
}
else -> {
if (showTabsMask and TAB_CONTACTS > 0) {
if (showTabsMask and TAB_FAVORITES > 0) {
2
} else {
1
}
} else {
0
}
}
} }
} }