take Default number into consideration at new conversations

This commit is contained in:
tibbi 2022-06-26 09:41:22 +02:00
parent 9755ab8c3a
commit ade0e86116

View File

@ -145,14 +145,19 @@ class NewConversationActivity : SimpleActivity() {
val contact = it as SimpleContact
val phoneNumbers = contact.phoneNumbers
if (phoneNumbers.size > 1) {
val items = ArrayList<RadioItem>()
phoneNumbers.forEachIndexed { index, phoneNumber ->
val type = getPhoneNumberTypeText(phoneNumber.type, phoneNumber.label)
items.add(RadioItem(index, "${phoneNumber.normalizedNumber} ($type)", phoneNumber.normalizedNumber))
}
val primaryNumber = contact.phoneNumbers.find { it.isPrimary }
if (primaryNumber != null) {
launchThreadActivity(primaryNumber.value, contact.name)
} else {
val items = ArrayList<RadioItem>()
phoneNumbers.forEachIndexed { index, phoneNumber ->
val type = getPhoneNumberTypeText(phoneNumber.type, phoneNumber.label)
items.add(RadioItem(index, "${phoneNumber.normalizedNumber} ($type)", phoneNumber.normalizedNumber))
}
RadioGroupDialog(this, items) {
launchThreadActivity(it as String, contact.name)
RadioGroupDialog(this, items) {
launchThreadActivity(it as String, contact.name)
}
}
} else {
launchThreadActivity(phoneNumbers.first().normalizedNumber, contact.name)