summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEkin Oguz <ekinoguz@google.com>2017-01-25 15:59:59 -0800
committerEkin Oguz <ekinoguz@google.com>2017-02-01 15:45:11 -0800
commit8cd6353bdce56d423a9381f2efbc20d26f600710 (patch)
tree3059321613b6d1042971e0bc18cd33e2cbe249d7
parent11c15260cb6878a67eb5d958277fce33e641720f (diff)
downloadchips-8cd6353bdce56d423a9381f2efbc20d26f600710.tar.gz
Call ChipDeleted when RecipientEditTextView's parent handles a delete.
In some configurations, delete character is causing onKeyDown() to be called, which handles the chip deletion instead of RecipientTextWatcher#onTextChanged. We want to call RecipientChipDeletedListener in these cases, similar to other chip deletion events. Bug: 34338361 Change-Id: I4c66c007646a36004ee9479b8cc9f78eab60c88d
-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 6ff8b57..33f54a2 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -1830,7 +1830,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.