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 contact = it as SimpleContact
val phoneNumbers = contact.phoneNumbers val phoneNumbers = contact.phoneNumbers
if (phoneNumbers.size > 1) { if (phoneNumbers.size > 1) {
val items = ArrayList<RadioItem>() val primaryNumber = contact.phoneNumbers.find { it.isPrimary }
phoneNumbers.forEachIndexed { index, phoneNumber -> if (primaryNumber != null) {
val type = getPhoneNumberTypeText(phoneNumber.type, phoneNumber.label) launchThreadActivity(primaryNumber.value, contact.name)
items.add(RadioItem(index, "${phoneNumber.normalizedNumber} ($type)", phoneNumber.normalizedNumber)) } 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) { 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)