diff options
author | Ekin Oguz <ekinoguz@google.com> | 2016-08-03 14:02:12 -0700 |
---|---|---|
committer | Ekin Oguz <ekinoguz@google.com> | 2016-08-03 14:32:28 -0700 |
commit | dbe88c3002c8a8d7f8cceaef988462502e4c557b (patch) | |
tree | a9705f8e528f8f600be095966aa4927543204b15 /src/com | |
parent | a233af88e381e4a8caf917176974aeb0aa259c19 (diff) | |
download | chips-dbe88c3002c8a8d7f8cceaef988462502e4c557b.tar.gz |
Convert valid email addresses to a chip.
There is a user visible side affect of this change:
1) Assume you have a recipient <ekinoguz@google.com> in your contact
list.
2.1) Before this change, typing "ekinoguz@google.co" and focusing out
from RecipientEditTextView will not convert "ekinoguz@google.co" to a
chip.
2.2) After this change, it will convert to a chip.
Converting to a chip will make the behavior consistent with a non-valid
email address. As an example, currently, typing "ekinoguz@google.c" or
"ekinoguz@google." and focusing out from view converts string to a chip
already. But typing a valid email address (in format of *@*.* where part
after . has at least 2 characters) and focusing out does not convert
string to a chip. Current change will make this consistent.
Follow-up to ag/1216979, which addresses the same bug but got reverted
due to b/30352337.
BUG: 30106082
Change-Id: I6ac30783667af5cef6f53f3ffb89b935e1905502
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/ex/chips/RecipientEditTextView.java | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java index fd817db..eab8ee9 100644 --- a/src/com/android/ex/chips/RecipientEditTextView.java +++ b/src/com/android/ex/chips/RecipientEditTextView.java @@ -1520,18 +1520,17 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements private boolean commitChip(int start, int end, Editable editable) { int position = positionOfFirstEntryWithTypePerson(); if (position != -1 && enoughToFilter() - && end == getSelectionEnd() && !isPhoneQuery()) { + && end == getSelectionEnd() && !isPhoneQuery() + && !isValidEmailAddress(editable.toString().substring(start, end).trim())) { // let's choose the selected or first entry if only the input text is NOT an email // address so we won't try to replace the user's potentially correct but // new/unencountered email input - if (!isValidEmailAddress(editable.toString().substring(start, end).trim())) { - final int selectedPosition = getListSelection(); - if (selectedPosition == -1 || !isEntryAtPositionTypePerson(selectedPosition)) { - // Nothing is selected or selected item is not type person; use the first item - submitItemAtPosition(position); - } else { - submitItemAtPosition(selectedPosition); - } + final int selectedPosition = getListSelection(); + if (selectedPosition == -1 || !isEntryAtPositionTypePerson(selectedPosition)) { + // Nothing is selected or selected item is not type person; use the first item + submitItemAtPosition(position); + } else { + submitItemAtPosition(selectedPosition); } dismissDropDown(); return true; |