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,6 +145,10 @@ class NewConversationActivity : SimpleActivity() {
val contact = it as SimpleContact val contact = it as SimpleContact
val phoneNumbers = contact.phoneNumbers val phoneNumbers = contact.phoneNumbers
if (phoneNumbers.size > 1) { if (phoneNumbers.size > 1) {
val primaryNumber = contact.phoneNumbers.find { it.isPrimary }
if (primaryNumber != null) {
launchThreadActivity(primaryNumber.value, contact.name)
} else {
val items = ArrayList<RadioItem>() val items = ArrayList<RadioItem>()
phoneNumbers.forEachIndexed { index, phoneNumber -> phoneNumbers.forEachIndexed { index, phoneNumber ->
val type = getPhoneNumberTypeText(phoneNumber.type, phoneNumber.label) val type = getPhoneNumberTypeText(phoneNumber.type, phoneNumber.label)
@ -154,6 +158,7 @@ class NewConversationActivity : SimpleActivity() {
RadioGroupDialog(this, items) { RadioGroupDialog(this, items) {
launchThreadActivity(it as String, contact.name) launchThreadActivity(it as String, contact.name)
} }
}
} else { } else {
launchThreadActivity(phoneNumbers.first().normalizedNumber, contact.name) launchThreadActivity(phoneNumbers.first().normalizedNumber, contact.name)
} }