Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7430a795 authored by yueg's avatar yueg Committed by android-build-merger
Browse files

Merge changes I5e6a3c37,I33bd32fc,I3023b484,I0f0798a5 am: 7fa0c717

am: de3fa313

Change-Id: I16ef3c9e8f77028d1b1dbaf45db011b7d25f1f45
parents 1638ed7f de3fa313
Loading
Loading
Loading
Loading
+7 −10
Original line number Original line Diff line number Diff line
@@ -96,14 +96,11 @@
        android:textColor="@color/dialer_theme_color"/>
        android:textColor="@color/dialer_theme_color"/>
  </LinearLayout>
  </LinearLayout>


  <LinearLayout
  <View
      android:layout_width="0dip"
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_height="match_parent"
      android:layout_width="match_parent"
      android:layout_weight="1"
      android:layout_height="1dp"
      android:layout_gravity="center"
      android:layout_marginTop="8dp"
      android:divider="?android:dividerHorizontal"
      android:layout_marginBottom="8dp"
      android:gravity="center"
      android:background="#12000000"/>
      android:orientation="vertical"
      android:showDividers="middle">
  </LinearLayout>
</LinearLayout>
</LinearLayout>
+15 −2
Original line number Original line Diff line number Diff line
@@ -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
 * 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 {
public class NewReturnToCallController implements InCallUiListener, Listener, AudioModeListener {


@@ -171,7 +177,14 @@ public class NewReturnToCallController implements InCallUiListener, Listener, Au
  public void onSessionModificationStateChange(DialerCall call) {}
  public void onSessionModificationStateChange(DialerCall call) {}


  @Override
  @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
  @Override
  public void onDisconnect(DialerCall call) {
  public void onDisconnect(DialerCall call) {
+20 −8
Original line number Original line Diff line number Diff line
@@ -24,7 +24,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup;
import com.android.dialer.common.LogUtil;
import com.android.dialer.common.LogUtil;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.List;


/** Adapter class for holding RTT chat data. */
/** Adapter class for holding RTT chat data. */
@@ -76,21 +75,22 @@ public class RttChatAdapter extends RecyclerView.Adapter<RttChatMessageViewHolde
    if (lastIndexOfRemoteMessage >= 0) {
    if (lastIndexOfRemoteMessage >= 0) {
      rttChatMessage = rttMessages.get(lastIndexOfRemoteMessage);
      rttChatMessage = rttMessages.get(lastIndexOfRemoteMessage);
    }
    }
    RttChatMessage[] newMessages = RttChatMessage.getRemoteRttChatMessage(rttChatMessage, newText);
    List<RttChatMessage> newMessages =
        RttChatMessage.getRemoteRttChatMessage(rttChatMessage, newText);


    if (rttChatMessage == null) {
    if (rttChatMessage == null) {
      lastIndexOfRemoteMessage = rttMessages.size();
      lastIndexOfRemoteMessage = rttMessages.size();
      rttMessages.add(lastIndexOfRemoteMessage, newMessages[0]);
      rttMessages.add(lastIndexOfRemoteMessage, newMessages.get(0));
      rttMessages.addAll(Arrays.asList(newMessages).subList(1, newMessages.length));
      rttMessages.addAll(newMessages.subList(1, newMessages.size()));
      notifyItemRangeInserted(lastIndexOfRemoteMessage, newMessages.length);
      notifyItemRangeInserted(lastIndexOfRemoteMessage, newMessages.size());
      lastIndexOfRemoteMessage = rttMessages.size() - 1;
      lastIndexOfRemoteMessage = rttMessages.size() - 1;
    } else {
    } else {
      rttMessages.set(lastIndexOfRemoteMessage, newMessages[0]);
      rttMessages.set(lastIndexOfRemoteMessage, newMessages.get(0));
      int lastIndex = rttMessages.size();
      int lastIndex = rttMessages.size();
      rttMessages.addAll(Arrays.asList(newMessages).subList(1, newMessages.length));
      rttMessages.addAll(newMessages.subList(1, newMessages.size()));


      notifyItemChanged(lastIndexOfRemoteMessage);
      notifyItemChanged(lastIndexOfRemoteMessage);
      notifyItemRangeInserted(lastIndex, newMessages.length);
      notifyItemRangeInserted(lastIndex, newMessages.size());
    }
    }
    if (rttMessages.get(lastIndexOfRemoteMessage).isFinished()) {
    if (rttMessages.get(lastIndexOfRemoteMessage).isFinished()) {
      lastIndexOfRemoteMessage = -1;
      lastIndexOfRemoteMessage = -1;
@@ -139,6 +139,18 @@ public class RttChatAdapter extends RecyclerView.Adapter<RttChatMessageViewHolde
    lastIndexOfLocalMessage = -1;
    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) {
  void addRemoteMessage(String message) {
    LogUtil.enterBlock("RttChatAdapater.addRemoteMessage");
    LogUtil.enterBlock("RttChatAdapater.addRemoteMessage");
    if (TextUtils.isEmpty(message)) {
    if (TextUtils.isEmpty(message)) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -204,7 +204,7 @@ public class RttChatFragment extends Fragment
    if (isClearingInput) {
    if (isClearingInput) {
      return;
      return;
    }
    }
    String messageToAppend = RttChatMessage.getChangedString(s, start, before, count);
    String messageToAppend = adapter.computeChangeOfLocalMessage(s.toString());
    if (!TextUtils.isEmpty(messageToAppend)) {
    if (!TextUtils.isEmpty(messageToAppend)) {
      adapter.addLocalMessage(messageToAppend);
      adapter.addLocalMessage(messageToAppend);
      rttCallScreenDelegate.onLocalMessage(messageToAppend);
      rttCallScreenDelegate.onLocalMessage(messageToAppend);
+14 −15
Original line number Original line Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.incallui.rtt.impl;


import android.support.annotation.NonNull;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.Nullable;
import android.text.TextWatcher;
import com.android.incallui.rtt.protocol.Constants;
import com.android.incallui.rtt.protocol.Constants;
import com.google.common.base.Splitter;
import com.google.common.base.Splitter;
import java.util.ArrayList;
import java.util.ArrayList;
@@ -59,10 +58,7 @@ final class RttChatMessage {
  }
  }


  /**
  /**
   * Generates delta change to a text.
   * Computes delta change of two string.
   *
   * <p>This is used to track text change of input. See more details in {@link
   * TextWatcher#onTextChanged}
   *
   *
   * <p>e.g. "hello world" -> "hello" : "\b\b\b\b\b\b"
   * <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"
   * <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();
    StringBuilder modify = new StringBuilder();
    char c = '\b';
    int indexChangeStart = 0;
    int oldLength = s.length() - count + before;
    while (indexChangeStart < oldMessage.length()
    for (int i = 0; i < oldLength - start; i++) {
        && indexChangeStart < newMesssage.length()
      modify.append(c);
        && oldMessage.charAt(indexChangeStart) == newMesssage.charAt(indexChangeStart)) {
      indexChangeStart++;
    }
    for (int i = indexChangeStart; i < oldMessage.length(); i++) {
      modify.append('\b');
    }
    }
    modify.append(s, start, start + count);
    for (int i = indexChangeStart; i < newMesssage.length(); i++) {
    if (start + count < s.length()) {
      modify.append(newMesssage.charAt(i));
      modify.append(s, start + count, s.length());
    }
    }
    return modify.toString();
    return modify.toString();
  }
  }


  /** Convert remote input text into an array of {@code RttChatMessage}. */
  /** Convert remote input text into an array of {@code RttChatMessage}. */
  static RttChatMessage[] getRemoteRttChatMessage(
  static List<RttChatMessage> getRemoteRttChatMessage(
      @Nullable RttChatMessage currentMessage, @NonNull String text) {
      @Nullable RttChatMessage currentMessage, @NonNull String text) {
    Iterator<String> splitText = SPLITTER.split(text).iterator();
    Iterator<String> splitText = SPLITTER.split(text).iterator();
    List<RttChatMessage> messageList = new ArrayList<>();
    List<RttChatMessage> messageList = new ArrayList<>();
@@ -118,6 +117,6 @@ final class RttChatMessage {
      messageList.add(message);
      messageList.add(message);
    }
    }


    return messageList.toArray(new RttChatMessage[0]);
    return messageList;
  }
  }
}
}