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

@ -61,6 +61,6 @@ android {
} }
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:4d36cc84e9' implementation 'com.github.SimpleMobileTools:Simple-Commons:52e88a4bfb'
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61' implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
} }

View File

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

View File

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

View File

@ -118,7 +118,7 @@ class ContactsAdapter(
@SuppressLint("MissingPermission") @SuppressLint("MissingPermission")
private fun callContact(useSimOne: Boolean) { private fun callContact(useSimOne: Boolean) {
val number = getSelectedPhoneNumber() ?: return val number = getSelectedPhoneNumber() ?: return
activity.callContactWithSim(number, useSimOne) activity.callContactWithSim(number.normalizedNumber, useSimOne)
} }
private fun removeDefaultSIM() { private fun removeDefaultSIM() {
@ -193,7 +193,7 @@ class ContactsAdapter(
activity.handlePermission(PERMISSION_CALL_PHONE) { hasPermission -> activity.handlePermission(PERMISSION_CALL_PHONE) { hasPermission ->
val action = if (hasPermission) Intent.ACTION_CALL else Intent.ACTION_DIAL val action = if (hasPermission) Intent.ACTION_CALL else Intent.ACTION_DIAL
val intent = Intent(action).apply { 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()) 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) { private fun callContact(simpleContact: SimpleContact) {
val phoneNumbers = simpleContact.phoneNumbers val phoneNumbers = simpleContact.phoneNumbers
if (phoneNumbers.size <= 1) { if (phoneNumbers.size <= 1) {
activity?.launchCallIntent(phoneNumbers.first()) activity?.launchCallIntent(phoneNumbers.first().normalizedNumber)
} else { } else {
val items = ArrayList<RadioItem>() val items = ArrayList<RadioItem>()
phoneNumbers.forEachIndexed { index, phoneNumber -> phoneNumbers.forEachIndexed { index, phoneNumber ->
items.add(RadioItem(index, phoneNumber)) items.add(RadioItem(index, phoneNumber.normalizedNumber))
} }
RadioGroupDialog(activity!!, items) { 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) { if (!wasNameFilled) {
val contact = contacts.firstOrNull { it.phoneNumbers.first() == recent.phoneNumber } val contact = contacts.firstOrNull { it.phoneNumbers.first().normalizedNumber == recent.phoneNumber }
if (contact != null) { if (contact != null) {
recent.name = contact.name recent.name = contact.name
} }

View File

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