Allow vanity numbers via paste/DIAL intent

https://googleplex-android-review.googlesource.com/#/c/253417/

Converts vanity numbers such as 1-800-FLOWERS to the numeric
equivalents when the number string is populated via a DIAL intent
or pasted from the clipboard. Does not remove valid formatting such
as dashes, periods, spaces, etc.

Bug: 8858358

Change-Id: I553c91628b8fd86ff38a8eeec7823ebdc96bfe6b
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java
index 3693e6a..20148b7 100644
--- a/src/com/android/dialer/dialpad/DialpadFragment.java
+++ b/src/com/android/dialer/dialpad/DialpadFragment.java
@@ -395,7 +395,9 @@
                     String data = uri.getSchemeSpecificPart();
                     // Remember it is filled via Intent.
                     mDigitsFilledByIntent = true;
-                    setFormattedDigits(data, null);
+                    final String converted = PhoneNumberUtils.convertKeypadLettersToDigits(
+                            PhoneNumberUtils.replaceUnicodeDigits(data));
+                    setFormattedDigits(converted, null);
                     return true;
                 } else {
                     String type = intent.getType();
diff --git a/src/com/android/dialer/dialpad/UnicodeDialerKeyListener.java b/src/com/android/dialer/dialpad/UnicodeDialerKeyListener.java
index c25c7a9..740b456 100644
--- a/src/com/android/dialer/dialpad/UnicodeDialerKeyListener.java
+++ b/src/com/android/dialer/dialpad/UnicodeDialerKeyListener.java
@@ -31,7 +31,8 @@
     @Override
     public CharSequence filter(CharSequence source, int start, int end,
             Spanned dest, int dstart, int dend) {
-        CharSequence converted = PhoneNumberUtils.replaceUnicodeDigits(source.toString());
+        final String converted = PhoneNumberUtils.convertKeypadLettersToDigits(
+                PhoneNumberUtils.replaceUnicodeDigits(source.toString()));
         // PhoneNumberUtils.replaceUnicodeDigits performs a character for character replacement,
         // so we can assume that start and end positions should remain unchanged.
         CharSequence result = super.filter(converted, start, end, dest, dstart, dend);