summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2018-03-09 01:40:21 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-03-09 01:40:21 +0000
commit7fa0c7172602dca56296d10d5d8b703ab2341ead (patch)
tree5afeec11dbb9904b38dd2e9ffc71e63f5e0669b2
parent683fdb16ae2f304587bc4ec0ff49e05343483d2c (diff)
parent724cc8f065b9ea737a11504d3f3c3691451c7914 (diff)
Merge changes I5e6a3c37,I33bd32fc,I3023b484,I0f0798a5
* changes: Show bubble when call connected and in-call UI not showing. Add divider line to nui voicemail alert Optimize characters sent to remote party for RTT chat. Refactor array of RttChatMessage to List.
-rw-r--r--java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry_alert.xml17
-rw-r--r--java/com/android/incallui/NewReturnToCallController.java17
-rw-r--r--java/com/android/incallui/rtt/impl/RttChatAdapter.java28
-rw-r--r--java/com/android/incallui/rtt/impl/RttChatFragment.java2
-rw-r--r--java/com/android/incallui/rtt/impl/RttChatMessage.java29
5 files changed, 57 insertions, 36 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"/>
</LinearLayout>
- <LinearLayout
- android:layout_width="0dip"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:layout_gravity="center"
- android:divider="?android:dividerHorizontal"
- android:gravity="center"
- android:orientation="vertical"
- android:showDividers="middle">
- </LinearLayout>
+ <View
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:layout_marginTop="8dp"
+ android:layout_marginBottom="8dp"
+ android:background="#12000000"/>
</LinearLayout>
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.
+ *
+ * <p>Bubble shows when one of following happens: 1. a new outgoing/ongoing call appears 2. leave
+ * in-call UI with an outgoing/ongoing call
+ *
+ * <p>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) {
diff --git a/java/com/android/incallui/rtt/impl/RttChatAdapter.java b/java/com/android/incallui/rtt/impl/RttChatAdapter.java
index 69837188a..912314945 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<RttChatMessageViewHolde
if (lastIndexOfRemoteMessage >= 0) {
rttChatMessage = rttMessages.get(lastIndexOfRemoteMessage);
}
- RttChatMessage[] newMessages = RttChatMessage.getRemoteRttChatMessage(rttChatMessage, newText);
+ List<RttChatMessage> 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;
@@ -139,6 +139,18 @@ public class RttChatAdapter extends RecyclerView.Adapter<RttChatMessageViewHolde
lastIndexOfLocalMessage = -1;
}
+ String computeChangeOfLocalMessage(String newMessage) {
+ RttChatMessage rttChatMessage = null;
+ if (lastIndexOfLocalMessage >= 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 b2974ef97..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.
- *
- * <p>This is used to track text change of input. See more details in {@link
- * TextWatcher#onTextChanged}
+ * Computes delta change of two string.
*
* <p>e.g. "hello world" -> "hello" : "\b\b\b\b\b\b"
*
@@ -72,22 +68,25 @@ final class RttChatMessage {
*
* <p>"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();
}
/** Convert remote input text into an array of {@code RttChatMessage}. */
- static RttChatMessage[] getRemoteRttChatMessage(
+ static List<RttChatMessage> getRemoteRttChatMessage(
@Nullable RttChatMessage currentMessage, @NonNull String text) {
Iterator<String> splitText = SPLITTER.split(text).iterator();
List<RttChatMessage> messageList = new ArrayList<>();
@@ -118,6 +117,6 @@ final class RttChatMessage {
messageList.add(message);
}
- return messageList.toArray(new RttChatMessage[0]);
+ return messageList;
}
}