diff options
author | Sarah Chin <sarahchin@google.com> | 2019-09-24 17:51:49 -0700 |
---|---|---|
committer | Sarah Chin <sarahchin@google.com> | 2019-09-25 10:40:11 -0700 |
commit | e3567329b0482ece49c875cc9847a8bb926dfcf6 (patch) | |
tree | 7c077b770001ebffd409e5b1e341d811a86b6888 /repackaged/libphonenumber/src/com/android/i18n/phonenumbers/AsYouTypeFormatter.java | |
parent | 9477a2c74fe46a7f568bc9617ab02195d4294772 (diff) | |
download | libphonenumber-e3567329b0482ece49c875cc9847a8bb926dfcf6.tar.gz |
Update libphonenumber to v8.10.19
Fixes: 141349847
Test: cts and vogar
Change-Id: If0baa0bd6f6f0a3a329af92f59ef0b2675c88808
Diffstat (limited to 'repackaged/libphonenumber/src/com/android/i18n/phonenumbers/AsYouTypeFormatter.java')
-rw-r--r-- | repackaged/libphonenumber/src/com/android/i18n/phonenumbers/AsYouTypeFormatter.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/repackaged/libphonenumber/src/com/android/i18n/phonenumbers/AsYouTypeFormatter.java b/repackaged/libphonenumber/src/com/android/i18n/phonenumbers/AsYouTypeFormatter.java index 32339f9c..0bde5fb6 100644 --- a/repackaged/libphonenumber/src/com/android/i18n/phonenumbers/AsYouTypeFormatter.java +++ b/repackaged/libphonenumber/src/com/android/i18n/phonenumbers/AsYouTypeFormatter.java @@ -431,7 +431,19 @@ public class AsYouTypeFormatter { NATIONAL_PREFIX_SEPARATORS_PATTERN.matcher( numberFormat.getNationalPrefixFormattingRule()).find(); String formattedNumber = m.replaceAll(numberFormat.getFormat()); - return appendNationalNumber(formattedNumber); + // Check that we did not remove nor add any extra digits when we matched + // this formatting pattern. This usually happens after we entered the last + // digit during AYTF. Eg: In case of MX, we swallow mobile token (1) when + // formatted but AYTF should retain all the number entered and not change + // in order to match a format (of same leading digits and length) display + // in that way. + String fullOutput = appendNationalNumber(formattedNumber); + String formattedNumberDigitsOnly = PhoneNumberUtil.normalizeDiallableCharsOnly(fullOutput); + if (formattedNumberDigitsOnly.contentEquals(accruedInputWithoutFormatting)) { + // If it's the same (i.e entered number and format is same), then it's + // safe to return this in formatted number as nothing is lost / added. + return fullOutput; + } } } return ""; |