From ca3324e2b73a53c18675a4735d43e9c3ed37d7d9 Mon Sep 17 00:00:00 2001 From: linus_lee Date: Wed, 28 Jan 2015 11:21:23 -0800 Subject: Chips: Add more logic to dismiss selection dialog Check for address popup in addition to alternates with dismissing On shrink, dismiss phone generated contact chips Change-Id: I0e8b467e3faad15c0e7c46a03c8d8e4af8c3963e (cherry picked from commit 9677961ed1d8c2362890a83d30c53f5eb754031e) --- src/com/android/ex/chips/RecipientEditTextView.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java index 461b198..cf2a16f 100644 --- a/src/com/android/ex/chips/RecipientEditTextView.java +++ b/src/com/android/ex/chips/RecipientEditTextView.java @@ -524,8 +524,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements return; } long contactId = mSelectedChip != null ? mSelectedChip.getEntry().getContactId() : -1; - if (mSelectedChip != null && contactId != RecipientEntry.INVALID_CONTACT - && (!isPhoneQuery() && contactId != RecipientEntry.GENERATED_CONTACT)) { + if (mSelectedChip != null && contactId != RecipientEntry.INVALID_CONTACT) { clearSelectedChip(); } else { if (getWidth() <= 0) { @@ -2272,6 +2271,9 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements } setCursorVisible(true); setSelection(editable.length()); + if (mAddressPopup != null && mAddressPopup.isShowing()) { + mAddressPopup.dismiss(); + } if (mAlternatesPopup != null && mAlternatesPopup.isShowing()) { mAlternatesPopup.dismiss(); } -- cgit v1.2.3 From 28283b397dd8cffd0240bcfab84a86903e64673c Mon Sep 17 00:00:00 2001 From: linus_lee Date: Mon, 26 Jan 2015 15:44:21 -0800 Subject: Chips: Fix some crashes and missing default icon scenario Handle a NPE when directoryId is null Handle a NPE when the contact has no address Set the default icon for SINGLE_RECIPIENT or else there is a blank space Change-Id: Ic1231ed5d25cb4a567898f7b72abeb8880b3256c (cherry picked from commit 49d58be28e44edc33a6bb2aaab1319c3fc944f88) --- src/com/android/ex/chips/DropdownChipLayouter.java | 1 + .../android/ex/chips/RecipientEditTextView.java | 23 ++++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/com/android/ex/chips/DropdownChipLayouter.java b/src/com/android/ex/chips/DropdownChipLayouter.java index f88ea7d..6be5b35 100644 --- a/src/com/android/ex/chips/DropdownChipLayouter.java +++ b/src/com/android/ex/chips/DropdownChipLayouter.java @@ -206,6 +206,7 @@ public class DropdownChipLayouter { break; case SINGLE_RECIPIENT: default: + view.setImageResource(getDefaultPhotoResId()); break; } view.setVisibility(View.VISIBLE); diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java index cf2a16f..fe814da 100644 --- a/src/com/android/ex/chips/RecipientEditTextView.java +++ b/src/com/android/ex/chips/RecipientEditTextView.java @@ -2847,16 +2847,19 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements .getContactId()) && getSpannable().getSpanStart(temp) != -1) { // Replace this. - final RecipientEntry entry = createValidatedEntry(entries - .get(tokenizeAddress(temp.getEntry().getDestination()) - .toLowerCase())); - if (entry != null) { - mHandler.post(new Runnable() { - @Override - public void run() { - replaceChip(temp, entry); - } - }); + final String address = tokenizeAddress( + temp.getEntry().getDestination()); + if (!TextUtils.isEmpty(address)) { + final RecipientEntry entry = createValidatedEntry(entries + .get(address.toLowerCase())); + if (entry != null) { + mHandler.post(new Runnable() { + @Override + public void run() { + replaceChip(temp, entry); + } + }); + } } } } -- cgit v1.2.3