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 --- .../com/android/incallui/CallButtonFragment.java | 58 +++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) (limited to 'InCallUI/src/com/android/incallui/CallButtonFragment.java') 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()); -- cgit v1.2.3