summaryrefslogtreecommitdiff
path: root/java/com/android/incallui/rtt/impl
diff options
context:
space:
mode:
authorwangqi <wangqi@google.com>2018-02-23 18:01:27 -0800
committerCopybara-Service <copybara-piper@google.com>2018-02-23 18:25:15 -0800
commit1c1e4c7caa0edd1f8f9aa951c6468c1d653ee281 (patch)
treef665bdc8635f3208c20c93540e3b3d0913d7b9ce /java/com/android/incallui/rtt/impl
parent54c21601d950346278018738de6ed03e3d933921 (diff)
Fix bugs of RTT chat.
1. send bubble break characters to remote 2. correctly handle text replacement Bug: 67596257 Test: RttChatMessageTest PiperOrigin-RevId: 186850402 Change-Id: I0aebb0f4315a021da1463d7903d28e912918efca
Diffstat (limited to 'java/com/android/incallui/rtt/impl')
-rw-r--r--java/com/android/incallui/rtt/impl/RttChatFragment.java2
-rw-r--r--java/com/android/incallui/rtt/impl/RttChatMessage.java25
2 files changed, 10 insertions, 17 deletions
diff --git a/java/com/android/incallui/rtt/impl/RttChatFragment.java b/java/com/android/incallui/rtt/impl/RttChatFragment.java
index a33029501..2c8de09f4 100644
--- a/java/com/android/incallui/rtt/impl/RttChatFragment.java
+++ b/java/com/android/incallui/rtt/impl/RttChatFragment.java
@@ -56,6 +56,7 @@ import com.android.incallui.incall.protocol.PrimaryCallState;
import com.android.incallui.incall.protocol.PrimaryInfo;
import com.android.incallui.incall.protocol.SecondaryInfo;
import com.android.incallui.rtt.impl.RttChatAdapter.MessageListener;
+import com.android.incallui.rtt.protocol.Constants;
import com.android.incallui.rtt.protocol.RttCallScreen;
import com.android.incallui.rtt.protocol.RttCallScreenDelegate;
import com.android.incallui.rtt.protocol.RttCallScreenDelegateFactory;
@@ -162,6 +163,7 @@ public class RttChatFragment extends Fragment
isClearingInput = true;
editText.setText("");
isClearingInput = false;
+ rttCallScreenDelegate.onLocalMessage(Constants.BUBBLE_BREAKER);
});
submitButton.setEnabled(false);
endCallButton = view.findViewById(R.id.rtt_end_call_button);
diff --git a/java/com/android/incallui/rtt/impl/RttChatMessage.java b/java/com/android/incallui/rtt/impl/RttChatMessage.java
index b36da77cc..b2974ef97 100644
--- a/java/com/android/incallui/rtt/impl/RttChatMessage.java
+++ b/java/com/android/incallui/rtt/impl/RttChatMessage.java
@@ -74,23 +74,14 @@ final class RttChatMessage {
*/
static String getChangedString(CharSequence s, int start, int before, int count) {
StringBuilder modify = new StringBuilder();
- if (before > count) {
- int deleteStart = start + count;
- int deleted = before - count;
- int numberUnModifiedCharsAfterDeleted = s.length() - start - count;
- char c = '\b';
- for (int i = 0; i < deleted + numberUnModifiedCharsAfterDeleted; i++) {
- modify.append(c);
- }
- modify.append(s, deleteStart, s.length());
- } else {
- int insertStart = start + before;
- int numberUnModifiedCharsAfterInserted = s.length() - start - count;
- char c = '\b';
- for (int i = 0; i < numberUnModifiedCharsAfterInserted; i++) {
- modify.append(c);
- }
- modify.append(s, insertStart, s.length());
+ char c = '\b';
+ int oldLength = s.length() - count + before;
+ for (int i = 0; i < oldLength - start; i++) {
+ modify.append(c);
+ }
+ modify.append(s, start, start + count);
+ if (start + count < s.length()) {
+ modify.append(s, start + count, s.length());
}
return modify.toString();
}