Fix missing phone numbers (#1343)
This commit is contained in:
parent
bc2060a709
commit
ddeca24c35
@ -166,7 +166,7 @@ internal class ContactRepository(
|
|||||||
}
|
}
|
||||||
lookupKeyCursor.close()
|
lookupKeyCursor.close()
|
||||||
|
|
||||||
val mainLocaleISO3 = context.resources.configuration.locales[0].isO3Country
|
val defaultCountryIso = context.resources.configuration.locales[0].country
|
||||||
|
|
||||||
return@withContext AndroidContact(
|
return@withContext AndroidContact(
|
||||||
id = id,
|
id = id,
|
||||||
@ -175,15 +175,17 @@ internal class ContactRepository(
|
|||||||
displayName = displayName,
|
displayName = displayName,
|
||||||
phoneNumbers = phoneNumbers.sortedByDescending {
|
phoneNumbers = phoneNumbers.sortedByDescending {
|
||||||
it.number.count { !PhoneNumberUtils.isReallyDialable(it) }
|
it.number.count { !PhoneNumberUtils.isReallyDialable(it) }
|
||||||
|
}.map {
|
||||||
|
val formattedNumber =
|
||||||
|
PhoneNumberUtils.formatNumber(it.number, defaultCountryIso)
|
||||||
|
?: return@map it
|
||||||
|
it.copy(number = formattedNumber)
|
||||||
}.distinctByEquality { a, b ->
|
}.distinctByEquality { a, b ->
|
||||||
if (Build.VERSION.SDK_INT < 31) {
|
if (Build.VERSION.SDK_INT < 31) {
|
||||||
PhoneNumberUtils.compare(context, a.number, b.number)
|
PhoneNumberUtils.compare(context, a.number, b.number)
|
||||||
} else {
|
} else {
|
||||||
PhoneNumberUtils.areSamePhoneNumber(a.number, b.number, mainLocaleISO3)
|
PhoneNumberUtils.areSamePhoneNumber(a.number, b.number, defaultCountryIso)
|
||||||
}
|
}
|
||||||
}.mapNotNull {
|
|
||||||
val formattedNumber = PhoneNumberUtils.formatNumber(it.number, mainLocaleISO3) ?: return@mapNotNull null
|
|
||||||
it.copy(number = formattedNumber)
|
|
||||||
},
|
},
|
||||||
emailAddresses = emailAddresses.distinct(),
|
emailAddresses = emailAddresses.distinct(),
|
||||||
postalAddresses = postalAddresses.distinct(),
|
postalAddresses = postalAddresses.distinct(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user