From c16fb2a3bcc168fb69a92f43aebf6cfa4bf3a007 Mon Sep 17 00:00:00 2001 From: mindyp Date: Wed, 3 Oct 2012 11:57:42 -0700 Subject: cherrypick: Make sure we check the most up to date text for the token offsets. The issue here was that we were using the old version of the editable string (cached in var text) to look for the start/end of tokens, but the result of calling commitChip may have updated the text (added corrective rfc822 formatting, or a display name) Fixes b/7268603 [Manta] List of email addresses pasted into the To field is broken Change-Id: Iccc8dbf78a018c84fd818582d10ff2b02a787276 --- chips/src/com/android/ex/chips/RecipientEditTextView.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/chips/src/com/android/ex/chips/RecipientEditTextView.java b/chips/src/com/android/ex/chips/RecipientEditTextView.java index a604807..ec95e47 100644 --- a/chips/src/com/android/ex/chips/RecipientEditTextView.java +++ b/chips/src/com/android/ex/chips/RecipientEditTextView.java @@ -2049,8 +2049,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements } else { if (!TextUtils.isEmpty(chipText)) { // There may be a space to replace with this chip's new - // associated - // space. Check for it + // associated space. Check for it int toReplace = end; while (toReplace >= 0 && toReplace < editable.length() && editable.charAt(toReplace) == ' ') { @@ -2263,7 +2262,8 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements int tokenEnd; RecipientChip createdChip; while (tokenStart < originalTokenStart) { - tokenEnd = movePastTerminators(mTokenizer.findTokenEnd(text, tokenStart)); + tokenEnd = movePastTerminators(mTokenizer.findTokenEnd(getText().toString(), + tokenStart)); commitChip(tokenStart, tokenEnd, getText()); createdChip = findChip(tokenStart); if (createdChip == null) { @@ -2415,8 +2415,8 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements if (RecipientEntry.isCreatedRecipient(temp.getEntry().getContactId()) && getSpannable().getSpanStart(temp) != -1) { // Replace this. - final RecipientEntry entry = createValidatedEntry(entries - .get(tokenizeAddress(temp.getEntry().getDestination()).toLowerCase())); + final RecipientEntry entry = createValidatedEntry(entries.get(tokenizeAddress( + temp.getEntry().getDestination()).toLowerCase())); if (entry != null) { mHandler.post(new Runnable() { @Override -- cgit v1.2.3