store the local account type in shared prefs

This commit is contained in:
tibbi
2018-02-01 23:54:36 +01:00
parent 93e7d73d91
commit 6f82aadcb9
4 changed files with 53 additions and 0 deletions

View File

@ -51,6 +51,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
setContentView(R.layout.activity_main)
appLaunched()
setupTabColors()
storeLocalAccountType()
handlePermission(PERMISSION_READ_CONTACTS) {
if (it) {
@ -214,6 +215,30 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
}
}
private fun storeLocalAccountType() {
if (config.localAccountType == "-1") {
// some manufacturer contact account types from https://stackoverflow.com/a/44802016/1967672
val localAccountTypes = arrayListOf("vnd.sec.contact.phone",
"com.htc.android.pcsc",
"com.sonyericsson.localcontacts",
"com.lge.sync",
"com.lge.phone",
"vnd.tmobileus.contact.phone",
"com.android.huawei.phone",
"Local Phone Account")
ContactsHelper(this).getContactTypes {
var localAccountType = ""
it.forEach {
if (localAccountTypes.contains(it)) {
localAccountType = it
}
}
config.localAccountType = localAccountType
}
}
}
private fun getOtherViewPagerItem(used: Int) = if (used == 1) 0 else 1
private fun initFragments() {