diff options
author | mindyp <mindyp@google.com> | 2012-09-10 12:06:35 -0700 |
---|---|---|
committer | mindyp <mindyp@google.com> | 2012-09-10 12:06:35 -0700 |
commit | 3aa118e72c877b4c176d025c56bfad2e518bf1ce (patch) | |
tree | ede7da1be963a89c1b8b55c572f4beb97de906f6 /chips/src | |
parent | 2b4059cdcd8014265b3ec7f06b9502cebb9e9972 (diff) | |
download | android_frameworks_ex-3aa118e72c877b4c176d025c56bfad2e518bf1ce.tar.gz android_frameworks_ex-3aa118e72c877b4c176d025c56bfad2e518bf1ce.tar.bz2 android_frameworks_ex-3aa118e72c877b4c176d025c56bfad2e518bf1ce.zip |
Be extra careful with commas in recipient chips
Fixes b/7132543 email addresses not recognized when using Gmail ICS
I added 2 in a row to be extra certain, and always check for the
LAST instance of ","
Change-Id: Id963971303a99642865a79c6264264e62a920151
Diffstat (limited to 'chips/src')
-rw-r--r-- | chips/src/com/android/ex/chips/RecipientEditTextView.java | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/chips/src/com/android/ex/chips/RecipientEditTextView.java b/chips/src/com/android/ex/chips/RecipientEditTextView.java index 9aefaaf..26de2fa 100644 --- a/chips/src/com/android/ex/chips/RecipientEditTextView.java +++ b/chips/src/com/android/ex/chips/RecipientEditTextView.java @@ -350,16 +350,19 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements super.append(text, start, end); if (!TextUtils.isEmpty(text) && TextUtils.getTrimmedLength(text) > 0) { String displayString = text.toString(); - int separatorPos = displayString.indexOf(COMMIT_CHAR_COMMA); + int separatorPos = displayString.lastIndexOf(COMMIT_CHAR_COMMA); // Verify that the separator pos is not within ""; if it is, look // past the closing quote. If there is no comma past ", this string // will resolve to an error chip. if (separatorPos > -1) { - displayString = displayString.substring(separatorPos); - int endQuotedTextPos = displayString.indexOf(NAME_WRAPPER_CHAR); + String parseDisplayString = displayString.substring(separatorPos); + int endQuotedTextPos = parseDisplayString.indexOf(NAME_WRAPPER_CHAR); if (endQuotedTextPos > separatorPos) { - displayString = displayString.substring(endQuotedTextPos); - separatorPos = displayString.indexOf(COMMIT_CHAR_COMMA); + separatorPos = parseDisplayString.lastIndexOf(COMMIT_CHAR_COMMA, + endQuotedTextPos); + } + if (separatorPos == -1) { + separatorPos = displayString.length(); } } if (separatorPos > 0 && !TextUtils.isEmpty(displayString) @@ -368,7 +371,8 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements mPendingChips.add(text.toString()); } } - // Put a message on the queue to make sure we ALWAYS handle pending chips. + // Put a message on the queue to make sure we ALWAYS handle pending + // chips. if (mPendingChipsCount > 0) { postHandlePendingChips(); } |