From 8f2424c624956e206883dae7dcc6eae47db437ed Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Mon, 21 Jul 2014 10:55:04 -0700 Subject: Implement InCall overflow button. - If there are more than 5 items (for a specifically identified case) collapse extra menu items into an overflow menu. - Construct/update menu, with appropriate click/dismiss listeners. This will happen every time something with the call buttons is updated, but I thought it was better to continue to track state in the presenter, rather than the fragment. - Add strings for associated menu items. Change-Id: Iaa036de3ed1c9abf16605181590d7241896c941d --- InCallUI/res/menu/incall_overflow_menu.xml | 33 ++++++++++++ InCallUI/res/values/strings.xml | 11 ++++ .../com/android/incallui/CallButtonFragment.java | 58 +++++++++++++++++++++- .../com/android/incallui/CallButtonPresenter.java | 43 ++++++++++------ 4 files changed, 130 insertions(+), 15 deletions(-) create mode 100644 InCallUI/res/menu/incall_overflow_menu.xml (limited to 'InCallUI') diff --git a/InCallUI/res/menu/incall_overflow_menu.xml b/InCallUI/res/menu/incall_overflow_menu.xml new file mode 100644 index 000000000..06208ebd8 --- /dev/null +++ b/InCallUI/res/menu/incall_overflow_menu.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/InCallUI/res/values/strings.xml b/InCallUI/res/values/strings.xml index 654eb7dd2..0a0d86d5f 100644 --- a/InCallUI/res/values/strings.xml +++ b/InCallUI/res/values/strings.xml @@ -288,6 +288,17 @@ to dial using the physical keyboard --> Use keyboard to dial + + Hold call + + Resume call + + Add call + + Merge calls + + Swap calls + Hold diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java index 80119a404..dd8446134 100644 --- a/InCallUI/src/com/android/incallui/CallButtonFragment.java +++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java @@ -56,6 +56,7 @@ public class CallButtonFragment private PopupMenu mAudioModePopup; private boolean mAudioModePopupVisible; + private PopupMenu mOverflowPopup; private View mExtraRowButton; private View mManageConferenceButton; private View mGenericMergeButton; @@ -190,7 +191,7 @@ public class CallButtonFragment !mPauseVideoButton.isSelected() /* pause */); break; case R.id.overflowButton: - // TODO: Implement. + mOverflowPopup.show(); break; case R.id.manageConferenceButton: getPresenter().manageConferenceButtonClicked(); @@ -313,6 +314,61 @@ public class CallButtonFragment mOverflowButton.setVisibility(show ? View.VISIBLE : View.GONE); } + @Override + public void configureOverflowMenu(boolean showMergeMenuOption, boolean showAddMenuOption, + boolean showHoldMenuOption, boolean showSwapMenuOption) { + if (mOverflowPopup == null) { + final ContextThemeWrapper contextWrapper = new ContextThemeWrapper(getActivity(), + R.style.InCallPopupMenuStyle); + mOverflowPopup = new PopupMenu(contextWrapper, mOverflowButton); + mOverflowPopup.getMenuInflater().inflate(R.menu.incall_overflow_menu, + mOverflowPopup.getMenu()); + mOverflowPopup.setOnMenuItemClickListener(new OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + switch (item.getItemId()) { + case R.id.overflow_merge_menu_item: + getPresenter().mergeClicked(); + break; + case R.id.overflow_add_menu_item: + getPresenter().addCallClicked(); + break; + case R.id.overflow_hold_menu_item: + getPresenter().holdClicked(true /* checked */); + break; + case R.id.overflow_resume_menu_item: + getPresenter().holdClicked(false /* checked */); + break; + case R.id.overflow_swap_menu_item: + getPresenter().addCallClicked(); + break; + default: + Log.wtf(this, "onMenuItemClick: unexpected overflow menu click"); + break; + } + return true; + } + }); + mOverflowPopup.setOnDismissListener(new OnDismissListener() { + @Override + public void onDismiss(PopupMenu popupMenu) { + popupMenu.dismiss(); + } + }); + } + + final Menu menu = mOverflowPopup.getMenu(); + menu.findItem(R.id.overflow_merge_menu_item).setVisible(showMergeMenuOption); + menu.findItem(R.id.overflow_add_menu_item).setVisible(showAddMenuOption); + menu.findItem(R.id.overflow_hold_menu_item).setVisible( + showHoldMenuOption && !mHoldButton.isSelected()); + menu.findItem(R.id.overflow_resume_menu_item).setVisible( + showHoldMenuOption && mHoldButton.isSelected()); + menu.findItem(R.id.overflow_swap_menu_item).setVisible(showSwapMenuOption); + + mOverflowButton.setEnabled(menu.hasVisibleItems()); + } + @Override public void setAudio(int mode) { updateAudioButtons(getPresenter().getSupportedAudio()); diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java index 6e841a1cc..622a74f39 100644 --- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java +++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java @@ -379,27 +379,40 @@ public class CallButtonPresenter extends Presenter