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 --- .../hold/res/layout/incall_on_hold_banner.xml | 3 +- .../android/incallui/rtt/impl/RttChatFragment.java | 50 +++++++- .../android/incallui/rtt/impl/RttOverflowMenu.java | 38 ++++++- .../incallui/rtt/impl/res/layout/frag_rtt_chat.xml | 6 +- .../incallui/rtt/impl/res/layout/overflow_menu.xml | 6 + .../incallui/rtt/impl/res/layout/rtt_banner.xml | 126 +++++++++++---------- .../android/incallui/rtt/impl/res/values/ids.xml | 19 ++++ 7 files changed, 175 insertions(+), 73 deletions(-) create mode 100644 java/com/android/incallui/rtt/impl/res/values/ids.xml (limited to 'java') diff --git a/java/com/android/incallui/hold/res/layout/incall_on_hold_banner.xml b/java/com/android/incallui/hold/res/layout/incall_on_hold_banner.xml index 728cce2bc..c5c455362 100644 --- a/java/com/android/incallui/hold/res/layout/incall_on_hold_banner.xml +++ b/java/com/android/incallui/hold/res/layout/incall_on_hold_banner.xml @@ -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"> { @@ -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) {} diff --git a/java/com/android/incallui/rtt/impl/RttOverflowMenu.java b/java/com/android/incallui/rtt/impl/RttOverflowMenu.java index cca36318e..2a061c546 100644 --- a/java/com/android/incallui/rtt/impl/RttOverflowMenu.java +++ b/java/com/android/incallui/rtt/impl/RttOverflowMenu.java @@ -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); + } } diff --git a/java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml b/java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml index 6940569a3..753117904 100644 --- a/java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml +++ b/java/com/android/incallui/rtt/impl/res/layout/frag_rtt_chat.xml @@ -19,8 +19,6 @@ android:layout_height="match_parent" android:fitsSystemWindows="true"> - - + + - \ No newline at end of file + diff --git a/java/com/android/incallui/rtt/impl/res/layout/overflow_menu.xml b/java/com/android/incallui/rtt/impl/res/layout/overflow_menu.xml index a29fad5f1..eb7e38691 100644 --- a/java/com/android/incallui/rtt/impl/res/layout/overflow_menu.xml +++ b/java/com/android/incallui/rtt/impl/res/layout/overflow_menu.xml @@ -46,4 +46,10 @@ style="@style/RttButton" android:drawableStart="@drawable/quantum_ic_add_call_vd_theme_24" android:text="@string/incall_label_add_call"/> + \ No newline at end of file diff --git a/java/com/android/incallui/rtt/impl/res/layout/rtt_banner.xml b/java/com/android/incallui/rtt/impl/res/layout/rtt_banner.xml index f1938056f..c4d3a4290 100644 --- a/java/com/android/incallui/rtt/impl/res/layout/rtt_banner.xml +++ b/java/com/android/incallui/rtt/impl/res/layout/rtt_banner.xml @@ -14,64 +14,74 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License --> - - - - - - - + android:layout_height="wrap_content" + android:orientation="vertical"> + + + + + + + - \ No newline at end of file + + + + \ No newline at end of file diff --git a/java/com/android/incallui/rtt/impl/res/values/ids.xml b/java/com/android/incallui/rtt/impl/res/values/ids.xml new file mode 100644 index 000000000..3e4755b7c --- /dev/null +++ b/java/com/android/incallui/rtt/impl/res/values/ids.xml @@ -0,0 +1,19 @@ + + + + + -- cgit v1.2.3