summaryrefslogtreecommitdiffstats
path: root/chips/src
diff options
context:
space:
mode:
authorTom Taylor <tomtaylor@google.com>2012-06-25 13:44:48 -0700
committerTom Taylor <tomtaylor@google.com>2012-06-25 13:44:48 -0700
commitea9eeb8781cf1494cb17b2839a1d43e19e813e14 (patch)
treed7754c35c02641b4013c123b007d3f003601d6d1 /chips/src
parentba14c7b002c0ef9357bcaea64b5c5255183b1b52 (diff)
downloadandroid_frameworks_ex-ea9eeb8781cf1494cb17b2839a1d43e19e813e14.tar.gz
android_frameworks_ex-ea9eeb8781cf1494cb17b2839a1d43e19e813e14.tar.bz2
android_frameworks_ex-ea9eeb8781cf1494cb17b2839a1d43e19e813e14.zip
Area code truncated for the phone number in messaging app
Bug 6717762 When launching mms from the contacts app, numbers sometimes get munged, either by losing the area code (if in parens) or losing the number completely and just ending up with a contact name. Parse all the parts of a contact "fred flinstone <512-123-1231>" looking for the phone number. Also handle the case where the area code is lost when in parens (i.e. (800) 891-8923). Change-Id: I76976fa8004c1d7c03a651b3915537245fee16e4
Diffstat (limited to 'chips/src')
-rw-r--r--chips/src/com/android/ex/chips/RecipientEditTextView.java34
1 files changed, 30 insertions, 4 deletions
diff --git a/chips/src/com/android/ex/chips/RecipientEditTextView.java b/chips/src/com/android/ex/chips/RecipientEditTextView.java
index e1f4b37..5a20a32 100644
--- a/chips/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/chips/src/com/android/ex/chips/RecipientEditTextView.java
@@ -906,12 +906,38 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
if (TextUtils.isEmpty(token)) {
return null;
}
- if (isPhoneQuery() && isPhoneNumber(token)) {
- return RecipientEntry
- .constructFakeEntry(token);
- }
Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(token);
String display = null;
+ if (isPhoneQuery()) {
+ // The number often arrives as "(800) 123-1231, ".
+ // Trim the space and trailing comma if necessary.
+ token = token.trim();
+ char charAt = token.charAt(token.length() - 1);
+ if (charAt == COMMIT_CHAR_COMMA || charAt == COMMIT_CHAR_SEMICOLON) {
+ token = token.substring(0, token.length() - 1);
+ }
+
+ // look for something that looks like a phone number. At this point, the original
+ // token might have looked like this: "Fred Flinstone <(800) 425-2323>"
+ if (!isPhoneNumber(token) && isValid(token) && tokens != null && tokens.length > 0) {
+ for (int i = 0; i < tokens.length; i++) {
+ // If we can get a phone number from tokenizing, then generate an entry from
+ // this.
+ display = tokens[i].getName();
+ if (!TextUtils.isEmpty(display) && isPhoneNumber(display)) {
+ return RecipientEntry.constructGeneratedEntry(display, display);
+ } else {
+ display = tokens[i].getAddress();
+ if (!TextUtils.isEmpty(display) && isPhoneNumber(display)) {
+ return RecipientEntry.constructFakeEntry(display);
+ }
+ }
+ }
+ }
+ // If the original token is a phone number to start with or as a last resort, use the
+ // original token.
+ return RecipientEntry.constructFakeEntry(token);
+ }
if (isValid(token) && tokens != null && tokens.length > 0) {
// If we can get a name from tokenizing, then generate an entry from
// this.