use the new way of contact phone number fetching

This commit is contained in:
tibbi
2022-02-06 11:28:51 +01:00
parent 5aba83f772
commit 6333db4a8d
7 changed files with 11 additions and 11 deletions

View File

@ -235,7 +235,7 @@ class DialpadActivity : SimpleActivity() {
})
ContactsAdapter(this, filtered, dialpad_list, null, text) {
startCallIntent((it as SimpleContact).phoneNumbers.first())
startCallIntent((it as SimpleContact).phoneNumbers.first().normalizedNumber)
}.apply {
dialpad_list.adapter = this
}

View File

@ -45,7 +45,7 @@ class ManageSpeedDialActivity : SimpleActivity(), RemoveSpeedDialListener {
SelectContactDialog(this, allContacts) { selectedContact ->
speedDialValues.first { it.id == clickedContact.id }.apply {
displayName = selectedContact.name
number = selectedContact.phoneNumbers.first()
number = selectedContact.phoneNumbers.first().normalizedNumber
}
updateAdapter()
}

View File

@ -118,7 +118,7 @@ class ContactsAdapter(
@SuppressLint("MissingPermission")
private fun callContact(useSimOne: Boolean) {
val number = getSelectedPhoneNumber() ?: return
activity.callContactWithSim(number, useSimOne)
activity.callContactWithSim(number.normalizedNumber, useSimOne)
}
private fun removeDefaultSIM() {
@ -193,7 +193,7 @@ class ContactsAdapter(
activity.handlePermission(PERMISSION_CALL_PHONE) { hasPermission ->
val action = if (hasPermission) Intent.ACTION_CALL else Intent.ACTION_DIAL
val intent = Intent(action).apply {
data = Uri.fromParts("tel", contact.phoneNumbers.first(), null)
data = Uri.fromParts("tel", contact.phoneNumbers.first().normalizedNumber, null)
}
val shortcut = ShortcutInfo.Builder(activity, contact.hashCode().toString())

View File

@ -98,15 +98,15 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
private fun callContact(simpleContact: SimpleContact) {
val phoneNumbers = simpleContact.phoneNumbers
if (phoneNumbers.size <= 1) {
activity?.launchCallIntent(phoneNumbers.first())
activity?.launchCallIntent(phoneNumbers.first().normalizedNumber)
} else {
val items = ArrayList<RadioItem>()
phoneNumbers.forEachIndexed { index, phoneNumber ->
items.add(RadioItem(index, phoneNumber))
items.add(RadioItem(index, phoneNumber.normalizedNumber))
}
RadioGroupDialog(activity!!, items) {
activity?.launchCallIntent(phoneNumbers[it as Int])
activity?.launchCallIntent(phoneNumbers[it as Int].normalizedNumber)
}
}
}

View File

@ -63,7 +63,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
}
if (!wasNameFilled) {
val contact = contacts.firstOrNull { it.phoneNumbers.first() == recent.phoneNumber }
val contact = contacts.firstOrNull { it.phoneNumbers.first().normalizedNumber == recent.phoneNumber }
if (contact != null) {
recent.name = contact.name
}

View File

@ -90,8 +90,8 @@ class RecentsHelper(private val context: Context) {
val normalizedNumber = number.normalizePhoneNumber()
if (normalizedNumber!!.length >= COMPARABLE_PHONE_NUMBER_LENGTH) {
name = contacts.firstOrNull { contact ->
val curNumber = contact.phoneNumbers.first().normalizePhoneNumber()
if (curNumber!!.length >= COMPARABLE_PHONE_NUMBER_LENGTH) {
val curNumber = contact.phoneNumbers.first().normalizedNumber
if (curNumber.length >= COMPARABLE_PHONE_NUMBER_LENGTH) {
if (curNumber.substring(curNumber.length - COMPARABLE_PHONE_NUMBER_LENGTH) == normalizedNumber.substring(normalizedNumber.length - COMPARABLE_PHONE_NUMBER_LENGTH)) {
contactsNumbersMap[number] = contact.name
return@firstOrNull true