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
diff --git a/chips/src/com/android/ex/chips/RecipientEditTextView.java b/chips/src/com/android/ex/chips/RecipientEditTextView.java
index eac398a..dc73933 100644
--- a/chips/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/chips/src/com/android/ex/chips/RecipientEditTextView.java
@@ -2023,8 +2023,7 @@
             } 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) == ' ') {
@@ -2236,7 +2235,8 @@
                 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) {
@@ -2388,8 +2388,8 @@
                 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