diff options
Diffstat (limited to 'java/com/android/incallui/rtt/impl/RttChatFragment.java')
-rw-r--r-- | java/com/android/incallui/rtt/impl/RttChatFragment.java | 42 |
1 files changed, 41 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..56ac2429c 100644 --- a/java/com/android/incallui/rtt/impl/RttChatFragment.java +++ b/java/com/android/incallui/rtt/impl/RttChatFragment.java @@ -103,6 +103,8 @@ public class RttChatFragment extends Fragment private boolean isTimerStarted; private RttOverflowMenu overflowMenu; private SecondaryInfo savedSecondaryInfo; + private TextView statusBanner; + private PrimaryInfo primaryInfo; /** * Create a new instance of RttChatFragment. @@ -164,6 +166,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); @@ -201,13 +223,16 @@ public class RttChatFragment extends Fragment nameTextView = view.findViewById(R.id.rtt_name_or_number); chronometer = view.findViewById(R.id.rtt_timer); + statusBanner = view.findViewById(R.id.rtt_status_banner); return view; } @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; @@ -312,6 +337,7 @@ public class RttChatFragment extends Fragment public void setPrimary(@NonNull PrimaryInfo primaryInfo) { LogUtil.i("RttChatFragment.setPrimary", primaryInfo.toString()); nameTextView.setText(primaryInfo.name()); + this.primaryInfo = primaryInfo; } @Override @@ -359,6 +385,20 @@ public class RttChatFragment extends Fragment chronometer.start(); isTimerStarted = true; } + if (primaryCallState.state() == State.DIALING) { + showWaitingForJoinBanner(); + } else { + hideWaitingForJoinBanner(); + } + } + + private void showWaitingForJoinBanner() { + statusBanner.setText(getString(R.string.rtt_status_banner_text, primaryInfo.name())); + statusBanner.setVisibility(View.VISIBLE); + } + + private void hideWaitingForJoinBanner() { + statusBanner.setVisibility(View.GONE); } @Override |