From 2bb428b3a4319a20a52c9c6fa27308501858d3f0 Mon Sep 17 00:00:00 2001 From: Roman Birg Date: Fri, 12 Aug 2016 15:55:03 -0700 Subject: 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 --- src/com/android/messaging/util/PhoneUtils.java | 19 ++++--------------- 1 file 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); } /** -- cgit v1.2.3