store the local account name too
This commit is contained in:
parent
029db0d853
commit
3bb7860bb7
3 changed files with 15 additions and 6 deletions
|
@ -51,12 +51,12 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
appLaunched()
|
appLaunched()
|
||||||
setupTabColors()
|
setupTabColors()
|
||||||
storeLocalAccountType()
|
|
||||||
|
|
||||||
handlePermission(PERMISSION_READ_CONTACTS) {
|
handlePermission(PERMISSION_READ_CONTACTS) {
|
||||||
if (it) {
|
if (it) {
|
||||||
handlePermission(PERMISSION_WRITE_CONTACTS) {
|
handlePermission(PERMISSION_WRITE_CONTACTS) {
|
||||||
if (it) {
|
if (it) {
|
||||||
|
storeLocalAccountData()
|
||||||
initFragments()
|
initFragments()
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.no_contacts_permission)
|
toast(R.string.no_contacts_permission)
|
||||||
|
@ -215,7 +215,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun storeLocalAccountType() {
|
private fun storeLocalAccountData() {
|
||||||
if (config.localAccountType == "-1") {
|
if (config.localAccountType == "-1") {
|
||||||
// some manufacturer contact account types from https://stackoverflow.com/a/44802016/1967672
|
// some manufacturer contact account types from https://stackoverflow.com/a/44802016/1967672
|
||||||
val localAccountTypes = arrayListOf("vnd.sec.contact.phone",
|
val localAccountTypes = arrayListOf("vnd.sec.contact.phone",
|
||||||
|
@ -229,12 +229,16 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
|
|
||||||
ContactsHelper(this).getContactSources {
|
ContactsHelper(this).getContactSources {
|
||||||
var localAccountType = ""
|
var localAccountType = ""
|
||||||
it.map { it.type }.forEach {
|
var localAccountName = ""
|
||||||
if (localAccountTypes.contains(it)) {
|
it.forEach {
|
||||||
localAccountType = it
|
if (localAccountTypes.contains(it.type)) {
|
||||||
|
localAccountType = it.type
|
||||||
|
localAccountName = it.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config.localAccountType = localAccountType
|
config.localAccountType = localAccountType
|
||||||
|
config.localAccountName = localAccountName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ class Config(context: Context) : BaseConfig(context) {
|
||||||
|
|
||||||
fun showAllContacts() = displayContactSources.size == 1 && displayContactSources.first() == "-1"
|
fun showAllContacts() = displayContactSources.size == 1 && displayContactSources.first() == "-1"
|
||||||
|
|
||||||
var showContactThumbnails : Boolean
|
var showContactThumbnails: Boolean
|
||||||
get() = prefs.getBoolean(SHOW_CONTACT_THUMBNAILS, true)
|
get() = prefs.getBoolean(SHOW_CONTACT_THUMBNAILS, true)
|
||||||
set(showContactThumbnails) = prefs.edit().putBoolean(SHOW_CONTACT_THUMBNAILS, showContactThumbnails).apply()
|
set(showContactThumbnails) = prefs.edit().putBoolean(SHOW_CONTACT_THUMBNAILS, showContactThumbnails).apply()
|
||||||
|
|
||||||
|
@ -44,6 +44,10 @@ class Config(context: Context) : BaseConfig(context) {
|
||||||
get() = prefs.getInt(LAST_USED_VIEW_PAGER_PAGE, 0)
|
get() = prefs.getInt(LAST_USED_VIEW_PAGER_PAGE, 0)
|
||||||
set(lastUsedViewPagerPage) = prefs.edit().putInt(LAST_USED_VIEW_PAGER_PAGE, lastUsedViewPagerPage).apply()
|
set(lastUsedViewPagerPage) = prefs.edit().putInt(LAST_USED_VIEW_PAGER_PAGE, lastUsedViewPagerPage).apply()
|
||||||
|
|
||||||
|
var localAccountName: String
|
||||||
|
get() = prefs.getString(LOCAL_ACCOUNT_NAME, "-1")
|
||||||
|
set(localAccountName) = prefs.edit().putString(LOCAL_ACCOUNT_NAME, localAccountName).apply()
|
||||||
|
|
||||||
var localAccountType: String
|
var localAccountType: String
|
||||||
get() = prefs.getString(LOCAL_ACCOUNT_TYPE, "-1")
|
get() = prefs.getString(LOCAL_ACCOUNT_TYPE, "-1")
|
||||||
set(localAccountType) = prefs.edit().putString(LOCAL_ACCOUNT_TYPE, localAccountType).apply()
|
set(localAccountType) = prefs.edit().putString(LOCAL_ACCOUNT_TYPE, localAccountType).apply()
|
||||||
|
|
|
@ -10,6 +10,7 @@ const val DISPLAY_CONTACT_SOURCES = "display_contact_sources"
|
||||||
const val START_NAME_WITH_SURNAME = "start_name_with_surname"
|
const val START_NAME_WITH_SURNAME = "start_name_with_surname"
|
||||||
const val LAST_USED_CONTACT_SOURCE = "last_used_contact_source"
|
const val LAST_USED_CONTACT_SOURCE = "last_used_contact_source"
|
||||||
const val LAST_USED_VIEW_PAGER_PAGE = "last_used_view_pager_page"
|
const val LAST_USED_VIEW_PAGER_PAGE = "last_used_view_pager_page"
|
||||||
|
const val LOCAL_ACCOUNT_NAME = "local_account_name"
|
||||||
const val LOCAL_ACCOUNT_TYPE = "local_account_type"
|
const val LOCAL_ACCOUNT_TYPE = "local_account_type"
|
||||||
|
|
||||||
const val CONTACT_ID = "contact_id"
|
const val CONTACT_ID = "contact_id"
|
||||||
|
|
Loading…
Reference in a new issue