summaryrefslogtreecommitdiffstats
path: root/chips/src/com/android/ex
diff options
context:
space:
mode:
authorScott Kennedy <skennedy@google.com>2013-03-04 13:26:22 -0800
committerScott Kennedy <skennedy@google.com>2013-03-05 09:53:31 -0800
commit3018e9acbdae15abe69c0f9423da52f23048d360 (patch)
tree1bd5f9f50cfc22dcdc0fbc776b8eb56545da58ff /chips/src/com/android/ex
parentffe5fa1168bc6192b50a5585e637ed507fd5a7de (diff)
downloadandroid_frameworks_ex-3018e9acbdae15abe69c0f9423da52f23048d360.tar.gz
android_frameworks_ex-3018e9acbdae15abe69c0f9423da52f23048d360.tar.bz2
android_frameworks_ex-3018e9acbdae15abe69c0f9423da52f23048d360.zip
Ensure appended emails have a comma separator
There was some code that checked for comma placement, but that is no longer necessary. Instead, we verify that the email address has a trailing comma (plus optional whitespace), and if not, we append a comma and space, to ensure the address is later chipified correctly. Bug: 8272316 Change-Id: Ifbb1bae466e3ae15c39d6b90a4bc22edc72a096f
Diffstat (limited to 'chips/src/com/android/ex')
-rw-r--r--chips/src/com/android/ex/chips/RecipientEditTextView.java22
1 files changed, 10 insertions, 12 deletions
diff --git a/chips/src/com/android/ex/chips/RecipientEditTextView.java b/chips/src/com/android/ex/chips/RecipientEditTextView.java
index ba238bc..c1a6f87 100644
--- a/chips/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/chips/src/com/android/ex/chips/RecipientEditTextView.java
@@ -111,6 +111,9 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
private static final char COMMIT_CHAR_SPACE = ' ';
+ private static final String SEPARATOR = String.valueOf(COMMIT_CHAR_COMMA)
+ + String.valueOf(COMMIT_CHAR_SPACE);
+
private static final String TAG = "RecipientEditTextView";
private static int DISMISS = "dismiss".hashCode();
@@ -371,22 +374,17 @@ 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.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) {
- String parseDisplayString = displayString.substring(separatorPos);
- int endQuotedTextPos = parseDisplayString.indexOf(NAME_WRAPPER_CHAR);
- if (endQuotedTextPos > separatorPos) {
- separatorPos = parseDisplayString.lastIndexOf(COMMIT_CHAR_COMMA,
- endQuotedTextPos);
- }
+
+ if (!displayString.trim().endsWith(String.valueOf(COMMIT_CHAR_COMMA))) {
+ // We have no separator, so we should add it
+ super.append(SEPARATOR, 0, SEPARATOR.length());
+ displayString += SEPARATOR;
}
+
if (!TextUtils.isEmpty(displayString)
&& TextUtils.getTrimmedLength(displayString) > 0) {
mPendingChipsCount++;
- mPendingChips.add(text.toString());
+ mPendingChips.add(displayString);
}
}
// Put a message on the queue to make sure we ALWAYS handle pending