diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-03-14 20:35:15 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-03-14 20:35:15 +0000 |
commit | ede6377e397f4b4d6f6a46d09c10efc52724531a (patch) | |
tree | 5afc256ca4698d4e03138cd5a315934897cab083 /java/com/android/incallui/rtt/impl/RttChatFragment.java | |
parent | c692948f41733a436f90d56da003d30ac7bf56eb (diff) | |
parent | b8d0f5029ebaf8e3a0bd32c8b54b3baee6f2876a (diff) |
Merge "Add swap call button to RTT call."
Diffstat (limited to 'java/com/android/incallui/rtt/impl/RttChatFragment.java')
-rw-r--r-- | java/com/android/incallui/rtt/impl/RttChatFragment.java | 50 |
1 files changed, 44 insertions, 6 deletions
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) {} |