summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEkin Oguz <ekinoguz@google.com>2017-02-02 19:31:37 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-02-02 19:31:37 +0000
commit87a0f613004a32da0d300f503167138167266d24 (patch)
tree5d0af1c714e1bf4a5437e87f27816e45c324707e
parentd9d06d8d5f42e9d09157823c3fc8dd3275d24f7f (diff)
parente5ecd1888c57960b666adc67c3da9dcc96397ce2 (diff)
downloadchips-87a0f613004a32da0d300f503167138167266d24.tar.gz
Call ChipDeleted when RecipientEditTextView's parent handles a delete. am: 8cd6353bdc am: 553a9d403c
am: e5ecd1888c Change-Id: Id8f23c20ca4e50a9fe165400aeb77cae09721c7b
-rw-r--r--src/com/android/ex/chips/RecipientEditTextView.java19
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.