From 15a5ebc25941143d5fb65498ebc835d79351d3ad Mon Sep 17 00:00:00 2001 From: Jin Cao Date: Thu, 18 Sep 2014 16:43:32 -0700 Subject: Remove leading space when editing invalid address It looks like we add a trailing space after each chip to separate them. When we edit an invalid chip, remove that trailing space if it's the only chip. b/17292684 Change-Id: I320fe959142b3ec47f820b6ceef854afc5c00de1 --- src/com/android/ex/chips/RecipientEditTextView.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java index 6306498..e6f4c35 100644 --- a/src/com/android/ex/chips/RecipientEditTextView.java +++ b/src/com/android/ex/chips/RecipientEditTextView.java @@ -2185,6 +2185,10 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements int spanStart = spannable.getSpanStart(currentChip); int spanEnd = spannable.getSpanEnd(currentChip); spannable.removeSpan(currentChip); + // Don't need leading space if it's the only chip + if (spanEnd - spanStart == editable.length() - 1) { + spanEnd++; + } editable.delete(spanStart, spanEnd); setCursorVisible(true); setSelection(editable.length()); -- cgit v1.2.3