diff options
author | wangqi <wangqi@google.com> | 2018-03-22 14:08:28 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-03-26 22:15:30 -0700 |
commit | cdae908f0a3c3754c592996df092722e1a96bde3 (patch) | |
tree | 66314443937066fcaf4a65f305daca342be5eade /java/com/android/incallui/rtt/impl/RttChatFragment.java | |
parent | 57fdc2b9ab68bff217d4c9c605ef89cefd66f678 (diff) |
Allow user to delete previous bubbles.
After this change, user will be able to delete text in previous finished bubble. It will also correctly handle deletion from remote.
Bug: 67596257
Test: RttChatMessageTest
PiperOrigin-RevId: 190122728
Change-Id: Ifebcbe874e5f03857d109b58e758e53f408e7e44
Diffstat (limited to 'java/com/android/incallui/rtt/impl/RttChatFragment.java')
-rw-r--r-- | java/com/android/incallui/rtt/impl/RttChatFragment.java | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/java/com/android/incallui/rtt/impl/RttChatFragment.java b/java/com/android/incallui/rtt/impl/RttChatFragment.java index 90bf199b2..e14ee9b06 100644 --- a/java/com/android/incallui/rtt/impl/RttChatFragment.java +++ b/java/com/android/incallui/rtt/impl/RttChatFragment.java @@ -164,6 +164,26 @@ public class RttChatFragment extends Fragment editText = view.findViewById(R.id.rtt_chat_input); editText.setOnEditorActionListener(this); editText.addTextChangedListener(this); + + editText.setOnKeyListener( + (v, keyCode, event) -> { + // This is only triggered when input method doesn't handle delete key, which means the + // current + // input box is empty. + if (keyCode == KeyEvent.KEYCODE_DEL && event.getAction() == KeyEvent.ACTION_DOWN) { + String lastMessage = adapter.retrieveLastLocalMessage(); + if (lastMessage != null) { + isClearingInput = true; + editText.setText(lastMessage); + editText.setSelection(lastMessage.length()); + isClearingInput = false; + rttCallScreenDelegate.onLocalMessage("\b"); + return true; + } + return false; + } + return false; + }); recyclerView = view.findViewById(R.id.rtt_recycler_view); LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); layoutManager.setStackFromEnd(true); @@ -207,7 +227,9 @@ public class RttChatFragment extends Fragment @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEND) { - submitButton.performClick(); + if (!TextUtils.isEmpty(editText.getText())) { + submitButton.performClick(); + } return true; } return false; |