diff options
author | wangqi <wangqi@google.com> | 2018-02-23 18:01:27 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-02-23 18:25:15 -0800 |
commit | 1c1e4c7caa0edd1f8f9aa951c6468c1d653ee281 (patch) | |
tree | f665bdc8635f3208c20c93540e3b3d0913d7b9ce /java/com/android/incallui/rtt/impl/RttChatMessage.java | |
parent | 54c21601d950346278018738de6ed03e3d933921 (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/RttChatMessage.java')
-rw-r--r-- | java/com/android/incallui/rtt/impl/RttChatMessage.java | 25 |
1 files changed, 8 insertions, 17 deletions
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(); } |