diff options
author | Roman Birg <roman@cyngn.com> | 2016-08-12 15:55:03 -0700 |
---|---|---|
committer | Roman Birg <roman@cyngn.com> | 2016-09-07 11:31:25 -0700 |
commit | 2bb428b3a4319a20a52c9c6fa27308501858d3f0 (patch) | |
tree | fa0b198f8935208a7c993cc00dc427cf460246e2 | |
parent | 5593d34c53c6424bc888a3cd1497753fa58880f8 (diff) | |
download | packages_apps_Messaging-2bb428b3a4319a20a52c9c6fa27308501858d3f0.tar.gz packages_apps_Messaging-2bb428b3a4319a20a52c9c6fa27308501858d3f0.tar.bz2 packages_apps_Messaging-2bb428b3a4319a20a52c9c6fa27308501858d3f0.zip |
Messaging: fix some int'l numbers from displaying incorrectly
The framework already handles a bunch of special cases and uses
libphonenumber to format the number.
Ticket: CYNGNOS-2945
Change-Id: If9b08b04b74bd1aa3b11214a42a15f7bfbc5ab48
Signed-off-by: Roman Birg <roman@cyngn.com>
-rw-r--r-- | src/com/android/messaging/util/PhoneUtils.java | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/src/com/android/messaging/util/PhoneUtils.java b/src/com/android/messaging/util/PhoneUtils.java index 3bf784e..65805e9 100644 --- a/src/com/android/messaging/util/PhoneUtils.java +++ b/src/com/android/messaging/util/PhoneUtils.java @@ -886,22 +886,11 @@ public abstract class PhoneUtils { phoneText.replaceAll("\\D", "").length() < MINIMUM_PHONE_NUMBER_LENGTH_TO_FORMAT) { return phoneText; } - final PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance(); final String systemCountry = getLocaleCountry(); - final int systemCountryCode = phoneNumberUtil.getCountryCodeForRegion(systemCountry); - try { - final PhoneNumber parsedNumber = phoneNumberUtil.parse(phoneText, systemCountry); - final PhoneNumberFormat phoneNumberFormat = - (systemCountryCode > 0 && parsedNumber.getCountryCode() == systemCountryCode) ? - PhoneNumberFormat.NATIONAL : PhoneNumberFormat.INTERNATIONAL; - return BidiFormatter.getInstance().unicodeWrap( - phoneNumberUtil.format(parsedNumber, phoneNumberFormat), - TextDirectionHeuristicsCompat.LTR); - } catch (NumberParseException e) { - LogUtil.e(TAG, "PhoneUtils.formatForDisplay: invalid phone number " - + LogUtil.sanitizePII(phoneText) + " with country " + systemCountry); - return phoneText; - } + String formatted = PhoneNumberUtils.formatNumber(phoneText, + PhoneNumberUtils.formatNumberToE164(phoneText, systemCountry), systemCountry); + return BidiFormatter.getInstance() + .unicodeWrap(formatted, TextDirectionHeuristicsCompat.LTR); } /** |