summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Taylor <tomtaylor@google.com>2012-10-16 12:06:26 -0700
committerTom Taylor <tomtaylor@google.com>2012-10-16 12:06:26 -0700
commitb32dd40aaa11a850f2ed273dd55bf25cea5d7b9d (patch)
tree755dcf7b8ebc6ec15ffdd5dc2642119e9824321a
parent14a4df6f91f3563ab956ed1730bdbf4e6976e5cd (diff)
downloadandroid_frameworks_ex-b32dd40aaa11a850f2ed273dd55bf25cea5d7b9d.tar.gz
android_frameworks_ex-b32dd40aaa11a850f2ed273dd55bf25cea5d7b9d.tar.bz2
android_frameworks_ex-b32dd40aaa11a850f2ed273dd55bf25cea5d7b9d.zip
SMS text messaging omits numbers in parentheses
Bug 7355280 Very localized fix. Tweak the phone number matching pattern to handle a "1" before parens. Change-Id: I67d878145fbc0b0ac17197043ea84f68e52b8156
-rw-r--r--chips/src/com/android/ex/chips/RecipientEditTextView.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/chips/src/com/android/ex/chips/RecipientEditTextView.java b/chips/src/com/android/ex/chips/RecipientEditTextView.java
index ec95e47..f4346b8 100644
--- a/chips/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/chips/src/com/android/ex/chips/RecipientEditTextView.java
@@ -88,6 +88,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* RecipientEditTextView is an auto complete text view for use with applications
@@ -194,6 +195,15 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
private boolean mDragEnabled = false;
+ // This pattern comes from android.util.Patterns. It has been tweaked to handle a "1" before
+ // parens, so numbers such as "1 (425) 222-2342" match.
+ private static final Pattern PHONE_PATTERN
+ = Pattern.compile( // sdd = space, dot, or dash
+ "(\\+[0-9]+[\\- \\.]*)?" // +<digits><sdd>*
+ + "(1?[ ]*\\([0-9]+\\)[\\- \\.]*)?" // 1(<digits>)<sdd>*
+ + "([0-9][0-9\\- \\.][0-9\\- \\.]+[0-9])"); // <digit><digit|sdd>+<digit>
+
+
private final Runnable mAddTextWatcher = new Runnable() {
@Override
public void run() {
@@ -912,7 +922,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
return false;
}
- Matcher match = Patterns.PHONE.matcher(number);
+ Matcher match = PHONE_PATTERN.matcher(number);
return match.matches();
}