default number

This commit is contained in:
Pavel Poley
2022-05-18 13:48:38 +03:00
parent 6f6d03080f
commit 6566fadf85
6 changed files with 104 additions and 20 deletions

View File

@ -44,13 +44,18 @@ fun SimpleActivity.startCall(contact: Contact) {
if (numbers.size == 1) {
startCallIntent(numbers.first().value)
} else if (numbers.size > 1) {
val items = ArrayList<RadioItem>()
numbers.forEachIndexed { index, phoneNumber ->
items.add(RadioItem(index, "${phoneNumber.value} (${getPhoneNumberTypeText(phoneNumber.type, phoneNumber.label)})", phoneNumber.value))
}
val primaryNumber = contact.phoneNumbers.find { it.isPrimary }
if (primaryNumber != null) {
startCallIntent(primaryNumber.value)
} else {
val items = ArrayList<RadioItem>()
numbers.forEachIndexed { index, phoneNumber ->
items.add(RadioItem(index, "${phoneNumber.value} (${getPhoneNumberTypeText(phoneNumber.type, phoneNumber.label)})", phoneNumber.value))
}
RadioGroupDialog(this, items) {
startCallIntent(it as String)
RadioGroupDialog(this, items) {
startCallIntent(it as String)
}
}
}
}