properly handle transforming contact source names to public names

This commit is contained in:
tibbi
2018-12-28 16:06:40 +01:00
parent cb7e281051
commit cfa9bdaf7a
2 changed files with 28 additions and 11 deletions

View File

@ -65,8 +65,11 @@ fun SimpleActivity.showContactSourcePicker(currentSource: String, callback: (new
)
val items = ArrayList<RadioItem>()
val sources = it.filter { !ignoredTypes.contains(it.type) }.map { it.name }
var currentSourceIndex = -1
val filteredSources = it.filter { !ignoredTypes.contains(it.type) }
var sources = filteredSources.map { it.name }
var currentSourceIndex = sources.indexOfFirst { it == currentSource }
sources = filteredSources.map { it.publicName }
sources.forEachIndexed { index, account ->
var publicAccount = account
if (account == config.localAccountName) {
@ -74,16 +77,14 @@ fun SimpleActivity.showContactSourcePicker(currentSource: String, callback: (new
}
items.add(RadioItem(index, publicAccount))
if (account == currentSource) {
currentSourceIndex = index
} else if (currentSource == SMT_PRIVATE && account == getString(R.string.phone_storage_hidden)) {
if (currentSource == SMT_PRIVATE && account == getString(R.string.phone_storage_hidden)) {
currentSourceIndex = index
}
}
runOnUiThread {
RadioGroupDialog(this, items, currentSourceIndex) {
callback(sources[it as Int])
callback(filteredSources[it as Int].name)
}
}
}