diff options
Diffstat (limited to 'InCallUI')
-rw-r--r-- | InCallUI/res/menu/incall_overflow_menu.xml | 33 | ||||
-rw-r--r-- | InCallUI/res/values/strings.xml | 11 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/CallButtonFragment.java | 58 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/CallButtonPresenter.java | 43 |
4 files changed, 130 insertions, 15 deletions
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 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2014 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License + --> + +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:id="@+id/overflow_merge_menu_item" + android:title="@string/overflowMergeMenuItemText" /> + + <item android:id="@+id/overflow_add_menu_item" + android:title="@string/overflowAddMenuItemText" /> + + <item android:id="@+id/overflow_hold_menu_item" + android:title="@string/overflowHoldMenuItemText" /> + + <item android:id="@+id/overflow_resume_menu_item" + android:title="@string/overflowResumeMenuItemText" /> + + <item android:id="@+id/overflow_swap_menu_item" + android:title="@string/overflowSwapMenuItemText" /> +</menu> 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 --> <string name="dialerKeyboardHintText">Use keyboard to dial</string> + <!-- Text for the overflow "Hold call" menu item. --> + <string name="overflowHoldMenuItemText">Hold call</string> + <!-- Text for the overflow "Resume call" menu item. --> + <string name="overflowResumeMenuItemText">Resume call</string> + <!-- Text for the overflow "Add call" menu item. --> + <string name="overflowAddMenuItemText">Add call</string> + <!-- Text for the onscreen "Merge calls" menu item. --> + <string name="overflowMergeMenuItemText">Merge calls</string> + <!-- Text for the onscreen "Swap calls" menu item. --> + <string name="overflowSwapMenuItemText">Swap calls</string> + <!-- Text for the onscreen "Hold" button --> <string name="onscreenHoldText">Hold</string> <!-- Text for the onscreen "End call" button --> 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(); @@ -314,6 +315,61 @@ public class CallButtonFragment } @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()); refreshAudioModePopup(); 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<CallButtonPresenter.CallButto ui.showChangeToVideoButton(canVideoCall); - if (canVideoCall && (canHold || canSwap || supportHold)) { + // Show either MERGE or ADD, but not both. + final boolean showMergeOption = showMerge; + final boolean showAddCallOption = !showMerge; + final boolean enableAddCallOption = showAddCallOption && canAdd; + // Show either HOLD or SWAP, but not both. + // If neither HOLD or SWAP is available: + // (1) If the device normally can hold/swap, show HOLD in a disabled state. + // (2) If the device doesn't have the concept of hold/swap, remove the button. + final boolean showHoldOption = canHold || (!canSwap && supportHold); + final boolean enableHoldOption = canHold; + final boolean showSwapOption = !canHold && canSwap; + + ui.setHold(call.getState() == Call.State.ONHOLD); + if (canVideoCall && (showAddCallOption || showMergeOption) + && (showHoldOption || showSwapOption)) { ui.showHoldButton(false); ui.showSwapButton(false); ui.showAddCallButton(false); ui.showMergeButton(false); ui.showOverflowButton(true); + ui.configureOverflowMenu( + showMergeOption, + showAddCallOption && enableAddCallOption /* showAddMenuOption */, + showHoldOption && enableHoldOption /* showHoldMenuOption */, + showSwapOption); } else { - // Show either MERGE or ADD button, but not both. - ui.showMergeButton(showMerge); - ui.showAddCallButton(!showMerge); - ui.enableAddCall(!showMerge && canAdd); - - // Show either HOLD or SWAP button, but not both. - // If neither HOLD or SWAP is available: - // (1) If the device normally can hold/swap, show HOLD in a disabled state. - // (2) If the device doesn't have the concept of hold/swap, remove the button. - ui.showHoldButton(canHold || (!canSwap && supportHold)); - ui.showSwapButton(!canHold && canSwap); - ui.setHold(call.getState() == Call.State.ONHOLD); - ui.enableHold(canHold); + ui.showMergeButton(showMergeOption); + ui.showAddCallButton(showAddCallOption); + ui.enableAddCall(enableAddCallOption); + + ui.showHoldButton(showHoldOption); + ui.enableHold(enableHoldOption); + ui.showSwapButton(showSwapOption); } } @@ -490,6 +503,8 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto boolean isDialpadVisible(); void setAudio(int mode); void setSupportedAudio(int mask); + void configureOverflowMenu(boolean showMergeMenuOption, boolean showAddMenuOption, + boolean showHoldMenuOption, boolean showSwapMenuOption); void showManageConferenceCallButton(); void showGenericMergeButton(); void hideExtraRow(); |