properly handle default contact numbers at calling

This commit is contained in:
tibbi 2022-06-24 22:40:24 +02:00
parent 8c4a78e298
commit ef4653512a
2 changed files with 13 additions and 8 deletions

View File

@ -61,6 +61,6 @@ android {
} }
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:b45fde5669' implementation 'com.github.SimpleMobileTools:Simple-Commons:fd1fde1dbd'
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61' implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
} }

View File

@ -144,14 +144,19 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
if (phoneNumbers.size <= 1) { if (phoneNumbers.size <= 1) {
activity?.launchCallIntent(phoneNumbers.first().normalizedNumber) activity?.launchCallIntent(phoneNumbers.first().normalizedNumber)
} else { } else {
val items = ArrayList<RadioItem>() val primaryNumber = simpleContact.phoneNumbers.find { it.isPrimary }
phoneNumbers.forEachIndexed { index, phoneNumber -> if (primaryNumber != null) {
val type = context.getPhoneNumberTypeText(phoneNumber.type, phoneNumber.label) activity?.launchCallIntent(primaryNumber.value)
items.add(RadioItem(index, "${phoneNumber.normalizedNumber} ($type)", phoneNumber.normalizedNumber)) } else {
} val items = ArrayList<RadioItem>()
phoneNumbers.forEachIndexed { index, phoneNumber ->
val type = context.getPhoneNumberTypeText(phoneNumber.type, phoneNumber.label)
items.add(RadioItem(index, "${phoneNumber.normalizedNumber} ($type)", phoneNumber.normalizedNumber))
}
RadioGroupDialog(activity!!, items) { RadioGroupDialog(activity!!, items) {
activity?.launchCallIntent(it as String) activity?.launchCallIntent(it as String)
}
} }
} }
} }