diff options
author | Ekin Oguz <ekinoguz@google.com> | 2017-02-02 19:39:11 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-02-02 19:39:11 +0000 |
commit | 856a8c3c4c2d1800972860fb94939904215a1d59 (patch) | |
tree | 148da6a9bb926684611a44bd04297736e0f52ff2 | |
parent | eeababc8d9f83dfc4e3b7104f15764dd7b598d3e (diff) | |
parent | 334775ff70387b0c9dd64f5a81a2c71e2770eda6 (diff) | |
download | chips-856a8c3c4c2d1800972860fb94939904215a1d59.tar.gz |
Call ChipDeleted when RecipientEditTextView's parent handles a delete. am: 8cd6353bdc am: 553a9d403c am: e5ecd1888c am: 87a0f61300 am: 3097592aba
am: 334775ff70
Change-Id: Ib97353b831bc22af285fe23eb3f9f6d9bf4ac326
-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. |