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 {
implementation 'com.github.SimpleMobileTools:Simple-Commons:b45fde5669'
implementation 'com.github.SimpleMobileTools:Simple-Commons:fd1fde1dbd'
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
}

View File

@ -144,14 +144,19 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
if (phoneNumbers.size <= 1) {
activity?.launchCallIntent(phoneNumbers.first().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))
}
val primaryNumber = simpleContact.phoneNumbers.find { it.isPrimary }
if (primaryNumber != null) {
activity?.launchCallIntent(primaryNumber.value)
} 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) {
activity?.launchCallIntent(it as String)
RadioGroupDialog(activity!!, items) {
activity?.launchCallIntent(it as String)
}
}
}
}