From db30a13b91ff62021a3a14b30c6b2c1b2f1d5e3d Mon Sep 17 00:00:00 2001 From: wangqi Date: Thu, 8 Mar 2018 12:41:47 -0800 Subject: Refactor array of RttChatMessage to List. Bug: 67596257 Test: RttChatMessageTest PiperOrigin-RevId: 188373256 Change-Id: I0f0798a5310225456619757dcca5bbd5df372b91 --- java/com/android/incallui/rtt/impl/RttChatAdapter.java | 16 ++++++++-------- java/com/android/incallui/rtt/impl/RttChatMessage.java | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/java/com/android/incallui/rtt/impl/RttChatAdapter.java b/java/com/android/incallui/rtt/impl/RttChatAdapter.java index 69837188a..42bd2c60c 100644 --- a/java/com/android/incallui/rtt/impl/RttChatAdapter.java +++ b/java/com/android/incallui/rtt/impl/RttChatAdapter.java @@ -24,7 +24,6 @@ import android.view.View; import android.view.ViewGroup; import com.android.dialer.common.LogUtil; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; /** Adapter class for holding RTT chat data. */ @@ -76,21 +75,22 @@ public class RttChatAdapter extends RecyclerView.Adapter= 0) { rttChatMessage = rttMessages.get(lastIndexOfRemoteMessage); } - RttChatMessage[] newMessages = RttChatMessage.getRemoteRttChatMessage(rttChatMessage, newText); + List newMessages = + RttChatMessage.getRemoteRttChatMessage(rttChatMessage, newText); if (rttChatMessage == null) { lastIndexOfRemoteMessage = rttMessages.size(); - rttMessages.add(lastIndexOfRemoteMessage, newMessages[0]); - rttMessages.addAll(Arrays.asList(newMessages).subList(1, newMessages.length)); - notifyItemRangeInserted(lastIndexOfRemoteMessage, newMessages.length); + rttMessages.add(lastIndexOfRemoteMessage, newMessages.get(0)); + rttMessages.addAll(newMessages.subList(1, newMessages.size())); + notifyItemRangeInserted(lastIndexOfRemoteMessage, newMessages.size()); lastIndexOfRemoteMessage = rttMessages.size() - 1; } else { - rttMessages.set(lastIndexOfRemoteMessage, newMessages[0]); + rttMessages.set(lastIndexOfRemoteMessage, newMessages.get(0)); int lastIndex = rttMessages.size(); - rttMessages.addAll(Arrays.asList(newMessages).subList(1, newMessages.length)); + rttMessages.addAll(newMessages.subList(1, newMessages.size())); notifyItemChanged(lastIndexOfRemoteMessage); - notifyItemRangeInserted(lastIndex, newMessages.length); + notifyItemRangeInserted(lastIndex, newMessages.size()); } if (rttMessages.get(lastIndexOfRemoteMessage).isFinished()) { lastIndexOfRemoteMessage = -1; diff --git a/java/com/android/incallui/rtt/impl/RttChatMessage.java b/java/com/android/incallui/rtt/impl/RttChatMessage.java index b2974ef97..fe30364b8 100644 --- a/java/com/android/incallui/rtt/impl/RttChatMessage.java +++ b/java/com/android/incallui/rtt/impl/RttChatMessage.java @@ -87,7 +87,7 @@ final class RttChatMessage { } /** Convert remote input text into an array of {@code RttChatMessage}. */ - static RttChatMessage[] getRemoteRttChatMessage( + static List getRemoteRttChatMessage( @Nullable RttChatMessage currentMessage, @NonNull String text) { Iterator splitText = SPLITTER.split(text).iterator(); List messageList = new ArrayList<>(); @@ -118,6 +118,6 @@ final class RttChatMessage { messageList.add(message); } - return messageList.toArray(new RttChatMessage[0]); + return messageList; } } -- cgit v1.2.3 From 6b4f264f40a2b3386c4cd1d8134a8d821be94052 Mon Sep 17 00:00:00 2001 From: wangqi Date: Thu, 8 Mar 2018 14:24:06 -0800 Subject: Optimize characters sent to remote party for RTT chat. Instead of using things provided by Android of onTextChanged, we compare the text in EditText with the text in bubble before the change and compute the delta string need to send to remote party. This way we could minimize characters sent thus reduce latency. Bug: 67596257 Test: RttChatMessageTest PiperOrigin-RevId: 188389325 Change-Id: I3023b484c32b2369ca8720104da74cf6906bb46e --- .../android/incallui/rtt/impl/RttChatAdapter.java | 12 +++++++++++ .../android/incallui/rtt/impl/RttChatFragment.java | 2 +- .../android/incallui/rtt/impl/RttChatMessage.java | 25 +++++++++++----------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/java/com/android/incallui/rtt/impl/RttChatAdapter.java b/java/com/android/incallui/rtt/impl/RttChatAdapter.java index 42bd2c60c..912314945 100644 --- a/java/com/android/incallui/rtt/impl/RttChatAdapter.java +++ b/java/com/android/incallui/rtt/impl/RttChatAdapter.java @@ -139,6 +139,18 @@ public class RttChatAdapter extends RecyclerView.Adapter= 0) { + rttChatMessage = rttMessages.get(lastIndexOfLocalMessage); + } + if (rttChatMessage == null || rttChatMessage.isFinished()) { + return newMessage; + } else { + return RttChatMessage.computeChangedString(rttChatMessage.getContent(), newMessage); + } + } + void addRemoteMessage(String message) { LogUtil.enterBlock("RttChatAdapater.addRemoteMessage"); if (TextUtils.isEmpty(message)) { diff --git a/java/com/android/incallui/rtt/impl/RttChatFragment.java b/java/com/android/incallui/rtt/impl/RttChatFragment.java index 396b89e75..5094c318e 100644 --- a/java/com/android/incallui/rtt/impl/RttChatFragment.java +++ b/java/com/android/incallui/rtt/impl/RttChatFragment.java @@ -204,7 +204,7 @@ public class RttChatFragment extends Fragment if (isClearingInput) { return; } - String messageToAppend = RttChatMessage.getChangedString(s, start, before, count); + String messageToAppend = adapter.computeChangeOfLocalMessage(s.toString()); if (!TextUtils.isEmpty(messageToAppend)) { adapter.addLocalMessage(messageToAppend); rttCallScreenDelegate.onLocalMessage(messageToAppend); diff --git a/java/com/android/incallui/rtt/impl/RttChatMessage.java b/java/com/android/incallui/rtt/impl/RttChatMessage.java index fe30364b8..6c852cf92 100644 --- a/java/com/android/incallui/rtt/impl/RttChatMessage.java +++ b/java/com/android/incallui/rtt/impl/RttChatMessage.java @@ -18,7 +18,6 @@ package com.android.incallui.rtt.impl; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.text.TextWatcher; import com.android.incallui.rtt.protocol.Constants; import com.google.common.base.Splitter; import java.util.ArrayList; @@ -59,10 +58,7 @@ final class RttChatMessage { } /** - * Generates delta change to a text. - * - *

This is used to track text change of input. See more details in {@link - * TextWatcher#onTextChanged} + * Computes delta change of two string. * *

e.g. "hello world" -> "hello" : "\b\b\b\b\b\b" * @@ -72,16 +68,19 @@ final class RttChatMessage { * *

"hello world" -> "hello new world" : "\b\b\b\b\bnew world" */ - static String getChangedString(CharSequence s, int start, int before, int count) { + static String computeChangedString(String oldMessage, String newMesssage) { StringBuilder modify = new StringBuilder(); - char c = '\b'; - int oldLength = s.length() - count + before; - for (int i = 0; i < oldLength - start; i++) { - modify.append(c); + int indexChangeStart = 0; + while (indexChangeStart < oldMessage.length() + && indexChangeStart < newMesssage.length() + && oldMessage.charAt(indexChangeStart) == newMesssage.charAt(indexChangeStart)) { + indexChangeStart++; + } + for (int i = indexChangeStart; i < oldMessage.length(); i++) { + modify.append('\b'); } - modify.append(s, start, start + count); - if (start + count < s.length()) { - modify.append(s, start + count, s.length()); + for (int i = indexChangeStart; i < newMesssage.length(); i++) { + modify.append(newMesssage.charAt(i)); } return modify.toString(); } -- cgit v1.2.3 From 98ff44d0b311e4b659c61f7e78807c3f233fe1f9 Mon Sep 17 00:00:00 2001 From: uabdullah Date: Thu, 8 Mar 2018 14:24:43 -0800 Subject: Add divider line to nui voicemail alert Adds a divider line to differentiate the voicemail entries and the alerts. Bug: 73158572 Test: N/A PiperOrigin-RevId: 188389442 Change-Id: I33bd32fc310cdf52f20bcb2d0b2cd4266420cab6 --- .../listui/res/layout/new_voicemail_entry_alert.xml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry_alert.xml b/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry_alert.xml index 28d639118..18a368647 100644 --- a/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry_alert.xml +++ b/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry_alert.xml @@ -96,14 +96,11 @@ android:textColor="@color/dialer_theme_color"/> - - + -- cgit v1.2.3 From 724cc8f065b9ea737a11504d3f3c3691451c7914 Mon Sep 17 00:00:00 2001 From: yueg Date: Thu, 8 Mar 2018 15:48:44 -0800 Subject: Show bubble when call connected and in-call UI not showing. We used to only show bubble when leaving in-call UI, so answering from Bluetooth does not show bubble. Fix it by also showing bubble in onCallListChanged(). Test: NewReturnToCallControllerTest PiperOrigin-RevId: 188403460 Change-Id: I5e6a3c37b2773e426dcc73ae5661b9e145b20cb8 --- .../com/android/incallui/NewReturnToCallController.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/java/com/android/incallui/NewReturnToCallController.java b/java/com/android/incallui/NewReturnToCallController.java index b83462e12..e77920524 100644 --- a/java/com/android/incallui/NewReturnToCallController.java +++ b/java/com/android/incallui/NewReturnToCallController.java @@ -51,7 +51,13 @@ import java.util.List; /** * Listens for events relevant to the return-to-call bubble and updates the bubble's state as - * necessary + * necessary. + * + *

Bubble shows when one of following happens: 1. a new outgoing/ongoing call appears 2. leave + * in-call UI with an outgoing/ongoing call + * + *

Bubble hides when one of following happens: 1. a call disconnect and there is no more + * outgoing/ongoing call 2. show in-call UI */ public class NewReturnToCallController implements InCallUiListener, Listener, AudioModeListener { @@ -171,7 +177,14 @@ public class NewReturnToCallController implements InCallUiListener, Listener, Au public void onSessionModificationStateChange(DialerCall call) {} @Override - public void onCallListChange(CallList callList) {} + public void onCallListChange(CallList callList) { + if ((bubble == null || !bubble.isVisible()) + && getCall() != null + && !InCallPresenter.getInstance().isShowingInCallUi()) { + LogUtil.i("NewReturnToCallController.onCallListChange", "going to show bubble"); + show(); + } + } @Override public void onDisconnect(DialerCall call) { -- cgit v1.2.3