updating commons, handle SimpleContact having multiple numbers

This commit is contained in:
tibbi
2020-07-12 15:50:57 +02:00
parent ae9eb4f320
commit cdd9efe4e9
8 changed files with 9 additions and 9 deletions

View File

@ -56,6 +56,6 @@ android {
}
dependencies {
implementation 'com.simplemobiletools:commons:5.29.13'
implementation 'com.simplemobiletools:commons:5.29.16'
implementation 'com.github.tibbi:IndicatorFastScroll:08f512858a'
}

View File

@ -201,7 +201,7 @@ class DialpadActivity : SimpleActivity() {
})
ContactsAdapter(this, filtered, dialpad_list, null, text) {
startCallIntent((it as SimpleContact).phoneNumber)
startCallIntent((it as SimpleContact).phoneNumbers.first())
}.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.phoneNumber
number = selectedContact.phoneNumbers.first()
}
updateAdapter()
}

View File

@ -147,7 +147,7 @@ class ContactsAdapter(activity: SimpleActivity, var contacts: ArrayList<SimpleCo
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.phoneNumber, null)
data = Uri.fromParts("tel", contact.phoneNumbers.first(), null)
}
val shortcut = ShortcutInfo.Builder(activity, contact.hashCode().toString())

View File

@ -76,7 +76,7 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
val currAdapter = fragment_list.adapter
if (currAdapter == null) {
ContactsAdapter(activity as SimpleActivity, contacts, fragment_list, this, showDeleteButton = false) {
activity?.launchCallIntent((it as SimpleContact).phoneNumber)
activity?.launchCallIntent((it as SimpleContact).phoneNumbers.first())
}.apply {
fragment_list.adapter = this
}

View File

@ -50,7 +50,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
recents.filter { it.phoneNumber == it.name }.forEach { recent ->
var wasNameFilled = false
if (privateContacts.isNotEmpty()) {
val privateContact = privateContacts.firstOrNull { it.phoneNumber == recent.phoneNumber }
val privateContact = privateContacts.firstOrNull { it.phoneNumbers.first() == recent.phoneNumber }
if (privateContact != null) {
recent.name = privateContact.name
wasNameFilled = true
@ -58,7 +58,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
}
if (!wasNameFilled) {
val contact = contacts.firstOrNull { it.phoneNumber == recent.phoneNumber }
val contact = contacts.firstOrNull { it.phoneNumbers.first() == recent.phoneNumber }
if (contact != null) {
recent.name = contact.name
}

View File

@ -74,7 +74,7 @@ class CallManager {
val privateCursor = context.getMyContactsCursor().loadInBackground()
ensureBackgroundThread {
val privateContacts = MyContactsContentProvider.getSimpleContacts(context, privateCursor)
val privateContact = privateContacts.firstOrNull { it.phoneNumber == callContact.number }
val privateContact = privateContacts.firstOrNull { it.phoneNumbers.first() == callContact.number }
if (privateContact != null) {
callContact.name = privateContact.name
}

View File

@ -71,7 +71,7 @@ class RecentsHelper(private val context: Context) {
val normalizedNumber = number.normalizePhoneNumber()
if (normalizedNumber!!.length >= COMPARABLE_PHONE_NUMBER_LENGTH) {
name = contacts.firstOrNull { contact ->
val curNumber = contact.phoneNumber.normalizePhoneNumber()
val curNumber = contact.phoneNumbers.first().normalizePhoneNumber()
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