diff options
Diffstat (limited to 'java/com/android/incallui/rtt')
4 files changed, 36 insertions, 7 deletions
diff --git a/java/com/android/incallui/rtt/impl/RttChatAdapter.java b/java/com/android/incallui/rtt/impl/RttChatAdapter.java index 1ea7f31b1..69837188a 100644 --- a/java/com/android/incallui/rtt/impl/RttChatAdapter.java +++ b/java/com/android/incallui/rtt/impl/RttChatAdapter.java @@ -110,7 +110,17 @@ public class RttChatAdapter extends RecyclerView.Adapter<RttChatMessageViewHolde notifyItemInserted(lastIndexOfLocalMessage); } else { rttChatMessage.append(newMessage); - notifyItemChanged(lastIndexOfLocalMessage); + // Clear empty message bubble. + if (TextUtils.isEmpty(rttChatMessage.getContent())) { + rttMessages.remove(lastIndexOfLocalMessage); + notifyItemRemoved(lastIndexOfLocalMessage); + if (lastIndexOfRemoteMessage > lastIndexOfLocalMessage) { + lastIndexOfRemoteMessage -= 1; + } + lastIndexOfLocalMessage = -1; + } else { + notifyItemChanged(lastIndexOfLocalMessage); + } } } diff --git a/java/com/android/incallui/rtt/impl/RttChatFragment.java b/java/com/android/incallui/rtt/impl/RttChatFragment.java index c7ee2ff67..a33029501 100644 --- a/java/com/android/incallui/rtt/impl/RttChatFragment.java +++ b/java/com/android/incallui/rtt/impl/RttChatFragment.java @@ -132,7 +132,7 @@ public class RttChatFragment extends Fragment FragmentUtils.getParentUnsafe(this, RttCallScreenDelegateFactory.class) .newRttCallScreenDelegate(this); - rttCallScreenDelegate.initRttCallScreenDelegate(getContext(), this); + rttCallScreenDelegate.initRttCallScreenDelegate(this); inCallScreenDelegate.onInCallScreenDelegateInit(this); inCallScreenDelegate.onInCallScreenReady(); @@ -193,7 +193,24 @@ public class RttChatFragment extends Fragment if (isClearingInput) { return; } - adapter.addLocalMessage(RttChatMessage.getChangedString(s, start, before, count)); + String messageToAppend = RttChatMessage.getChangedString(s, start, before, count); + if (!TextUtils.isEmpty(messageToAppend)) { + adapter.addLocalMessage(messageToAppend); + rttCallScreenDelegate.onLocalMessage(messageToAppend); + } + } + + @Override + public void onRemoteMessage(String message) { + adapter.addRemoteMessage(message); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + LogUtil.enterBlock("RttChatFragment.onDestroyView"); + inCallButtonUiDelegate.onInCallButtonUiUnready(); + inCallScreenDelegate.onInCallScreenUnready(); } @Override @@ -260,7 +277,7 @@ public class RttChatFragment extends Fragment @Override public void setPrimary(@NonNull PrimaryInfo primaryInfo) { LogUtil.i("RttChatFragment.setPrimary", primaryInfo.toString()); - nameTextView.setText(primaryInfo.name); + nameTextView.setText(primaryInfo.name()); } @Override diff --git a/java/com/android/incallui/rtt/protocol/RttCallScreen.java b/java/com/android/incallui/rtt/protocol/RttCallScreen.java index afacbae48..916dfb84d 100644 --- a/java/com/android/incallui/rtt/protocol/RttCallScreen.java +++ b/java/com/android/incallui/rtt/protocol/RttCallScreen.java @@ -25,6 +25,8 @@ public interface RttCallScreen { void onRttScreenStop(); + void onRemoteMessage(String message); + Fragment getRttCallScreenFragment(); String getCallId(); diff --git a/java/com/android/incallui/rtt/protocol/RttCallScreenDelegate.java b/java/com/android/incallui/rtt/protocol/RttCallScreenDelegate.java index e29c43d70..8c484a844 100644 --- a/java/com/android/incallui/rtt/protocol/RttCallScreenDelegate.java +++ b/java/com/android/incallui/rtt/protocol/RttCallScreenDelegate.java @@ -16,14 +16,14 @@ package com.android.incallui.rtt.protocol; -import android.content.Context; - /** Callbacks from the module out to the container. */ public interface RttCallScreenDelegate { - void initRttCallScreenDelegate(Context context, RttCallScreen rttCallScreen); + void initRttCallScreenDelegate(RttCallScreen rttCallScreen); void onRttCallScreenUiReady(); void onRttCallScreenUiUnready(); + + void onLocalMessage(String message); } |