From b8d0f5029ebaf8e3a0bd32c8b54b3baee6f2876a Mon Sep 17 00:00:00 2001 From: wangqi Date: Wed, 14 Mar 2018 12:12:32 -0700 Subject: Add swap call button to RTT call. Bug: 67596257 Test: manual PiperOrigin-RevId: 189064976 Change-Id: I3265881114baceb4d63fcc3d55d1c904cd3216dc --- .../android/incallui/rtt/impl/RttChatFragment.java | 50 +++++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) (limited to 'java/com/android/incallui/rtt/impl/RttChatFragment.java') diff --git a/java/com/android/incallui/rtt/impl/RttChatFragment.java b/java/com/android/incallui/rtt/impl/RttChatFragment.java index 3b943c431..c6eef9ca2 100644 --- a/java/com/android/incallui/rtt/impl/RttChatFragment.java +++ b/java/com/android/incallui/rtt/impl/RttChatFragment.java @@ -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) {} -- cgit v1.2.3