diff options
author | mindyp <mindyp@google.com> | 2012-08-27 10:32:17 -0700 |
---|---|---|
committer | mindyp <mindyp@google.com> | 2012-08-27 10:53:23 -0700 |
commit | 26e3f68ae8342cedd57353e399e7d0e920228a4e (patch) | |
tree | 5624427dd1d025a696d4ad63fc23de0cea5814fa /chips/src | |
parent | 3b32152852917f08eb2f196db6454c083f7acd15 (diff) | |
download | android_frameworks_ex-26e3f68ae8342cedd57353e399e7d0e920228a4e.tar.gz android_frameworks_ex-26e3f68ae8342cedd57353e399e7d0e920228a4e.tar.bz2 android_frameworks_ex-26e3f68ae8342cedd57353e399e7d0e920228a4e.zip |
Deal with commas within quoted text
If there is a comma within quoted text, it is NOT a chip ending token
Fixes b/7001805 Names appended to email ids like "Mathew, Deepthi E" are split into two chips while replying
Change-Id: I87f34a44282b3baf8d106dd21f8211ad301395be
Diffstat (limited to 'chips/src')
-rw-r--r-- | chips/src/com/android/ex/chips/RecipientEditTextView.java | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/chips/src/com/android/ex/chips/RecipientEditTextView.java b/chips/src/com/android/ex/chips/RecipientEditTextView.java index 618c215..9aefaaf 100644 --- a/chips/src/com/android/ex/chips/RecipientEditTextView.java +++ b/chips/src/com/android/ex/chips/RecipientEditTextView.java @@ -100,6 +100,8 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements private static final char COMMIT_CHAR_COMMA = ','; + private static final char NAME_WRAPPER_CHAR = '"'; + private static final char COMMIT_CHAR_SEMICOLON = ';'; private static final char COMMIT_CHAR_SPACE = ' '; @@ -347,9 +349,20 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements } super.append(text, start, end); if (!TextUtils.isEmpty(text) && TextUtils.getTrimmedLength(text) > 0) { - final String displayString = text.toString(); - int seperatorPos = displayString.indexOf(COMMIT_CHAR_COMMA); - if (seperatorPos != 0 && !TextUtils.isEmpty(displayString) + String displayString = text.toString(); + int separatorPos = displayString.indexOf(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); + if (endQuotedTextPos > separatorPos) { + displayString = displayString.substring(endQuotedTextPos); + separatorPos = displayString.indexOf(COMMIT_CHAR_COMMA); + } + } + if (separatorPos > 0 && !TextUtils.isEmpty(displayString) && TextUtils.getTrimmedLength(displayString) > 0) { mPendingChipsCount++; mPendingChips.add(text.toString()); |