diff options
author | Ekin Oguz <ekinoguz@google.com> | 2017-02-02 19:27:08 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-02-02 19:27:08 +0000 |
commit | 553a9d403c6ef55c2f26f1f17a843dd1d39b92d6 (patch) | |
tree | 1283c5daf9a36e0d82fc4230ff001484f206925f | |
parent | 0e11ec08352d4de1e2efe716c3b2fdf3f196eced (diff) | |
parent | 8cd6353bdce56d423a9381f2efbc20d26f600710 (diff) | |
download | chips-553a9d403c6ef55c2f26f1f17a843dd1d39b92d6.tar.gz |
Call ChipDeleted when RecipientEditTextView's parent handles a delete.
am: 8cd6353bdc
Change-Id: Icd563c0b37f38c58a711ab829b6b58d5c26764e6
-rw-r--r-- | src/com/android/ex/chips/RecipientEditTextView.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java index 9597aa1..7140f24 100644 --- a/src/com/android/ex/chips/RecipientEditTextView.java +++ b/src/com/android/ex/chips/RecipientEditTextView.java @@ -1828,7 +1828,24 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements break; } - return super.onKeyDown(keyCode, event); + final DrawableRecipientChip lastRecipientChip = getLastChip(); + boolean isHandled = super.onKeyDown(keyCode, event); + + /* + * Hacky way to report a deleted chip: + * In some devices/configurations, {@link KeyEvent#KEYCODE_DEL} character is causing + * onKeyDown() to be called, which in turns handles the chip deletion instead of + * {@link RecipientTextWatcher#onTextChanged}. We want to call + * {@link RecipientChipDeletedListener#onRecipientChipDeleted} callback for these cases. + */ + if (keyCode == KeyEvent.KEYCODE_DEL && isHandled && lastRecipientChip != null) { + final RecipientEntry entry = lastRecipientChip.getEntry(); + if (!mNoChipMode && mRecipientChipDeletedListener != null && entry != null) { + mRecipientChipDeletedListener.onRecipientChipDeleted(entry); + } + } + + return isHandled; } // Visible for testing. |