Update libphonenumber to 8.13.23
This commit is contained in:
parent
fed9c64113
commit
5a159ce01f
6 changed files with 43 additions and 3 deletions
|
@ -127,6 +127,7 @@ public class PhoneNumberFormatter {
|
|||
}
|
||||
|
||||
if (isShortCode(bareNumber, localCountryCode)) {
|
||||
Log.i(TAG, "Recognized number as short code.");
|
||||
return bareNumber;
|
||||
}
|
||||
|
||||
|
@ -134,7 +135,13 @@ public class PhoneNumberFormatter {
|
|||
|
||||
try {
|
||||
Phonenumber.PhoneNumber parsedNumber = phoneNumberUtil.parse(processedNumber, localCountryCode);
|
||||
return phoneNumberUtil.format(parsedNumber, PhoneNumberUtil.PhoneNumberFormat.E164);
|
||||
String formatted = phoneNumberUtil.format(parsedNumber, PhoneNumberUtil.PhoneNumberFormat.E164);
|
||||
|
||||
if (formatted.startsWith("+")) {
|
||||
return formatted;
|
||||
} else {
|
||||
throw new NumberParseException(NumberParseException.ErrorType.NOT_A_NUMBER, "After formatting, the number did not start with +! hasRawInput: " + parsedNumber.hasRawInput());
|
||||
}
|
||||
} catch (NumberParseException e) {
|
||||
Log.w(TAG, e.toString());
|
||||
if (bareNumber.charAt(0) == '+') {
|
||||
|
|
|
@ -712,7 +712,7 @@ object SystemContactsRepository {
|
|||
while (!cursor.isAfterLast && lookupKey == cursor.getLookupKey() && cursor.isPhoneMimeType()) {
|
||||
val displayNumber: String? = cursor.requireString(ContactsContract.CommonDataKinds.Phone.NUMBER)
|
||||
|
||||
if (displayNumber != null && displayNumber.isNotEmpty()) {
|
||||
if (!displayNumber.isNullOrEmpty()) {
|
||||
phoneDetails += ContactPhoneDetails(
|
||||
contactUri = ContactsContract.Contacts.getLookupUri(cursor.requireLong(ContactsContract.CommonDataKinds.Phone._ID), lookupKey),
|
||||
displayName = cursor.requireString(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME),
|
||||
|
|
|
@ -23,6 +23,8 @@ object Scrubber {
|
|||
private val E164_PATTERN = Pattern.compile("(\\+|%2B)(\\d{5,13})(\\d{2})")
|
||||
private const val E164_CENSOR = "*************"
|
||||
|
||||
private val E164_ZERO_PATTERN = Pattern.compile("\\b(0)(\\d{8})(\\d{2})\\b")
|
||||
|
||||
/** The second group will be censored.*/
|
||||
private val CRUDE_EMAIL_PATTERN = Pattern.compile("\\b([^\\s/])([^\\s/]*@[^\\s]+)")
|
||||
private const val EMAIL_CENSOR = "...@..."
|
||||
|
@ -77,6 +79,7 @@ object Scrubber {
|
|||
fun scrub(input: CharSequence): CharSequence {
|
||||
return input
|
||||
.scrubE164()
|
||||
.scrubE164Zero()
|
||||
.scrubEmail()
|
||||
.scrubGroupsV1()
|
||||
.scrubGroupsV2()
|
||||
|
@ -96,6 +99,15 @@ object Scrubber {
|
|||
}
|
||||
}
|
||||
|
||||
private fun CharSequence.scrubE164Zero(): CharSequence {
|
||||
return scrub(this, E164_ZERO_PATTERN) { matcher, output ->
|
||||
output
|
||||
.append(matcher.group(1))
|
||||
.append(E164_CENSOR, 0, matcher.group(2)!!.length)
|
||||
.append(matcher.group(3))
|
||||
}
|
||||
}
|
||||
|
||||
private fun CharSequence.scrubEmail(): CharSequence {
|
||||
return scrub(this, CRUDE_EMAIL_PATTERN) { matcher, output ->
|
||||
output
|
||||
|
|
|
@ -30,6 +30,22 @@ class ScrubberTest(private val input: String, private val expected: String) {
|
|||
"A UK number +447700900000",
|
||||
"A UK number +**********00"
|
||||
),
|
||||
arrayOf(
|
||||
"A Japanese number 08011112222",
|
||||
"A Japanese number 0********22"
|
||||
),
|
||||
arrayOf(
|
||||
"A Japanese number (08011112222)",
|
||||
"A Japanese number (0********22)"
|
||||
),
|
||||
arrayOf(
|
||||
"Not a Japanese number 08011112222333344445555",
|
||||
"Not a Japanese number 08011112222333344445555"
|
||||
),
|
||||
arrayOf(
|
||||
"Not a Japanese number 1234508011112222",
|
||||
"Not a Japanese number 1234508011112222"
|
||||
),
|
||||
arrayOf(
|
||||
"An avatar filename: file:///data/user/0/org.thoughtcrime.securesms/files/avatars/%2B447700900099",
|
||||
"An avatar filename: file:///data/user/0/org.thoughtcrime.securesms/files/avatars/%2B**********99"
|
||||
|
|
|
@ -96,7 +96,7 @@ dependencyResolutionManagement {
|
|||
|
||||
// Google
|
||||
library('google-protobuf-javalite', 'com.google.protobuf:protobuf-javalite:3.11.4')
|
||||
library('google-libphonenumber', 'com.googlecode.libphonenumber:libphonenumber:8.13.19')
|
||||
library('google-libphonenumber', 'com.googlecode.libphonenumber:libphonenumber:8.13.23')
|
||||
library('google-play-services-maps', 'com.google.android.gms:play-services-maps:18.1.0')
|
||||
library('google-play-services-auth', 'com.google.android.gms:play-services-auth:20.3.0')
|
||||
library('google-play-services-wallet', 'com.google.android.gms:play-services-wallet:19.1.0')
|
||||
|
|
|
@ -3046,6 +3046,11 @@ https://docs.gradle.org/current/userguide/dependency_verification.html
|
|||
<sha256 value="4d48d76055b37f0521564ee65b2ea91c623c71d46f63091a87ab0dbae02078a2" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="com.googlecode.libphonenumber" name="libphonenumber" version="8.13.23">
|
||||
<artifact name="libphonenumber-8.13.23.jar">
|
||||
<sha256 value="2171b8a1e87a040dab0e069f995eea489e19b741e3ed9c263f0a836e0c59e85d" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="com.ibm.icu" name="icu4j" version="70.1">
|
||||
<artifact name="icu4j-70.1.jar">
|
||||
<sha256 value="2b4d8d4e098e86aa5f905ec81c46751d218b16afd3f7fc02b64f80dd20fffa20" origin="Generated by Gradle"/>
|
||||
|
|
Loading…
Add table
Reference in a new issue