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

Commit 66c17ebd authored by wangqi's avatar wangqi Committed by android-build-merger
Browse files

Merge "Add swap call button to RTT call."

am: ede6377e

Change-Id: I404a1d170c04082dc0cdb792dd76cea2560cada7
parents 6b1553d4 ede6377e
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2018 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License
  -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24.0"
    android:viewportHeight="24.0"
    android:tint="?attr/colorControlNormal">
  <path
      android:fillColor="@android:color/white"
      android:pathData="M18,4l-4,4h3v7c0,1.1 -0.9,2 -2,2s-2,-0.9 -2,-2V8c0,-2.21 -1.79,-4 -4,-4S5,5.79 5,8v7H2l4,4 4,-4H7V8c0,-1.1 0.9,-2 2,-2s2,0.9 2,2v7c0,2.21 1.79,4 4,4s4,-1.79 4,-4V8h3l-4,-4z"/>
</vector>
+1 −2
Original line number Diff line number Diff line
@@ -19,8 +19,7 @@
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:background="#CC212121"
  android:fitsSystemWindows="true">
  android:background="#CC212121">
  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
+44 −6
Original line number Diff line number Diff line
@@ -17,11 +17,13 @@
package com.android.incallui.rtt.impl;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.SystemClock;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.OnScrollListener;
@@ -49,6 +51,8 @@ import com.android.dialer.common.UiUtil;
import com.android.incallui.audioroute.AudioRouteSelectorDialogFragment;
import com.android.incallui.audioroute.AudioRouteSelectorDialogFragment.AudioRouteSelectorPresenter;
import com.android.incallui.call.DialerCall.State;
import com.android.incallui.hold.OnHoldFragment;
import com.android.incallui.incall.protocol.InCallButtonIds;
import com.android.incallui.incall.protocol.InCallButtonUi;
import com.android.incallui.incall.protocol.InCallButtonUiDelegate;
import com.android.incallui.incall.protocol.InCallButtonUiDelegateFactory;
@@ -99,6 +103,7 @@ public class RttChatFragment extends Fragment
  private Chronometer chronometer;
  private boolean isTimerStarted;
  private RttOverflowMenu overflowMenu;
  private SecondaryInfo savedSecondaryInfo;

  /**
   * Create a new instance of RttChatFragment.
@@ -124,6 +129,9 @@ public class RttChatFragment extends Fragment
    if (savedInstanceState != null) {
      inCallButtonUiDelegate.onRestoreInstanceState(savedInstanceState);
    }
    inCallScreenDelegate =
        FragmentUtils.getParentUnsafe(this, InCallScreenDelegateFactory.class)
            .newInCallScreenDelegate();
    // Prevent updating local message until UI is ready.
    isClearingInput = true;
  }
@@ -133,9 +141,6 @@ public class RttChatFragment extends Fragment
    super.onViewCreated(view, bundle);
    LogUtil.i("RttChatFragment.onViewCreated", null);

    inCallScreenDelegate =
        FragmentUtils.getParentUnsafe(this, InCallScreenDelegateFactory.class)
            .newInCallScreenDelegate();
    rttCallScreenDelegate =
        FragmentUtils.getParentUnsafe(this, RttCallScreenDelegateFactory.class)
            .newRttCallScreenDelegate(this);
@@ -185,7 +190,7 @@ public class RttChatFragment extends Fragment
          inCallButtonUiDelegate.onEndCallClicked();
        });

    overflowMenu = new RttOverflowMenu(getContext(), inCallButtonUiDelegate);
    overflowMenu = new RttOverflowMenu(getContext(), inCallButtonUiDelegate, inCallScreenDelegate);
    view.findViewById(R.id.rtt_overflow_button)
        .setOnClickListener(
            v -> {
@@ -311,7 +316,36 @@ public class RttChatFragment extends Fragment
  }

  @Override
  public void setSecondary(@NonNull SecondaryInfo secondaryInfo) {}
  public void onAttach(Context context) {
    super.onAttach(context);
    if (savedSecondaryInfo != null) {
      setSecondary(savedSecondaryInfo);
    }
  }

  @Override
  public void setSecondary(@NonNull SecondaryInfo secondaryInfo) {
    LogUtil.i("RttChatFragment.setSecondary", secondaryInfo.toString());
    if (!isAdded()) {
      savedSecondaryInfo = secondaryInfo;
      return;
    }
    savedSecondaryInfo = null;
    FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
    Fragment oldBanner = getChildFragmentManager().findFragmentById(R.id.rtt_on_hold_banner);
    if (secondaryInfo.shouldShow()) {
      OnHoldFragment onHoldFragment = OnHoldFragment.newInstance(secondaryInfo);
      onHoldFragment.setPadTopInset(false);
      transaction.replace(R.id.rtt_on_hold_banner, onHoldFragment);
    } else {
      if (oldBanner != null) {
        transaction.remove(oldBanner);
      }
    }
    transaction.setCustomAnimations(R.anim.abc_slide_in_top, R.anim.abc_slide_out_top);
    transaction.commitNowAllowingStateLoss();
    overflowMenu.enableSwitchToSecondaryButton(secondaryInfo.shouldShow());
  }

  @Override
  public void setCallState(@NonNull PrimaryCallState primaryCallState) {
@@ -372,7 +406,11 @@ public class RttChatFragment extends Fragment
  }

  @Override
  public void showButton(int buttonId, boolean show) {}
  public void showButton(int buttonId, boolean show) {
    if (buttonId == InCallButtonIds.BUTTON_SWAP) {
      overflowMenu.enableSwapCallButton(show);
    }
  }

  @Override
  public void enableButton(int buttonId, boolean enable) {}
+34 −4
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.telecom.CallAudioState;
import android.view.View;
import android.widget.PopupWindow;
import com.android.incallui.incall.protocol.InCallButtonUiDelegate;
import com.android.incallui.incall.protocol.InCallScreenDelegate;
import com.android.incallui.rtt.impl.RttCheckableButton.OnCheckedChangeListener;
import com.android.incallui.speakerbuttonlogic.SpeakerButtonInfo;
import com.android.incallui.speakerbuttonlogic.SpeakerButtonInfo.IconSize;
@@ -32,11 +33,19 @@ public class RttOverflowMenu extends PopupWindow implements OnCheckedChangeListe
  private final RttCheckableButton speakerButton;
  private final RttCheckableButton dialpadButton;
  private final RttCheckableButton addCallButton;
  private final RttCheckableButton swapCallButton;
  private final InCallButtonUiDelegate inCallButtonUiDelegate;
  private final InCallScreenDelegate inCallScreenDelegate;
  private boolean isSwitchToSecondaryButtonEnabled;
  private boolean isSwapCallButtonEnabled;

  RttOverflowMenu(Context context, InCallButtonUiDelegate inCallButtonUiDelegate) {
  RttOverflowMenu(
      Context context,
      InCallButtonUiDelegate inCallButtonUiDelegate,
      InCallScreenDelegate inCallScreenDelegate) {
    super(context);
    this.inCallButtonUiDelegate = inCallButtonUiDelegate;
    this.inCallScreenDelegate = inCallScreenDelegate;
    View view = View.inflate(context, R.layout.overflow_menu, null);
    setContentView(view);
    setOnDismissListener(this::dismiss);
@@ -49,7 +58,18 @@ public class RttOverflowMenu extends PopupWindow implements OnCheckedChangeListe
    dialpadButton = view.findViewById(R.id.menu_keypad);
    dialpadButton.setOnCheckedChangeListener(this);
    addCallButton = view.findViewById(R.id.menu_add_call);
    addCallButton.setOnCheckedChangeListener(this);
    addCallButton.setOnClickListener(v -> this.inCallButtonUiDelegate.addCallClicked());
    swapCallButton = view.findViewById(R.id.menu_swap_call);
    swapCallButton.setOnClickListener(
        v -> {
          if (isSwapCallButtonEnabled) {
            this.inCallButtonUiDelegate.swapClicked();
          }
          if (isSwitchToSecondaryButtonEnabled) {
            this.inCallScreenDelegate.onSecondaryInfoClicked();
          }
          dismiss();
        });
  }

  @Override
@@ -60,8 +80,6 @@ public class RttOverflowMenu extends PopupWindow implements OnCheckedChangeListe
      inCallButtonUiDelegate.toggleSpeakerphone();
    } else if (button == dialpadButton) {
      inCallButtonUiDelegate.showDialpadClicked(isChecked);
    } else if (button == addCallButton) {
      inCallButtonUiDelegate.addCallClicked();
    }
    dismiss();
  }
@@ -91,4 +109,16 @@ public class RttOverflowMenu extends PopupWindow implements OnCheckedChangeListe
  void setDialpadButtonChecked(boolean isChecked) {
    dialpadButton.setChecked(isChecked);
  }

  void enableSwapCallButton(boolean enabled) {
    isSwapCallButtonEnabled = enabled;
    swapCallButton.setVisibility(
        isSwapCallButtonEnabled || isSwitchToSecondaryButtonEnabled ? View.VISIBLE : View.GONE);
  }

  void enableSwitchToSecondaryButton(boolean enabled) {
    isSwitchToSecondaryButtonEnabled = enabled;
    swapCallButton.setVisibility(
        isSwapCallButtonEnabled || isSwitchToSecondaryButtonEnabled ? View.VISIBLE : View.GONE);
  }
}
+3 −3
Original line number Diff line number Diff line
@@ -19,8 +19,6 @@
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

  <include layout="@layout/rtt_banner"/>

  <android.support.v7.widget.RecyclerView
      android:id="@+id/rtt_recycler_view"
      android:layout_width="match_parent"
@@ -28,6 +26,8 @@
      android:paddingBottom="70dp"
      android:clipToPadding="false"/>

  <include layout="@layout/rtt_banner"/>

  <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
Loading