summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2014-07-21 10:55:04 -0700
committerAndrew Lee <anwlee@google.com>2014-07-21 17:27:55 -0700
commitddb824ecb3f052551b3ea97d5f5cb3037ec4c683 (patch)
treeff357d74a4c84c6913bb7ae106275dab6e581faf
parent746ee736f255772f7da308765fab22ba7512a10e (diff)
downloadpackages_apps_InCallUI-ddb824ecb3f052551b3ea97d5f5cb3037ec4c683.tar.gz
packages_apps_InCallUI-ddb824ecb3f052551b3ea97d5f5cb3037ec4c683.tar.bz2
packages_apps_InCallUI-ddb824ecb3f052551b3ea97d5f5cb3037ec4c683.zip
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
-rw-r--r--res/menu/incall_overflow_menu.xml33
-rw-r--r--res/values/strings.xml11
-rw-r--r--src/com/android/incallui/CallButtonFragment.java58
-rw-r--r--src/com/android/incallui/CallButtonPresenter.java43
4 files changed, 130 insertions, 15 deletions
diff --git a/res/menu/incall_overflow_menu.xml b/res/menu/incall_overflow_menu.xml
new file mode 100644
index 00000000..06208ebd
--- /dev/null
+++ b/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/res/values/strings.xml b/res/values/strings.xml
index 654eb7dd..0a0d86d5 100644
--- a/res/values/strings.xml
+++ b/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/src/com/android/incallui/CallButtonFragment.java b/src/com/android/incallui/CallButtonFragment.java
index 80119a40..dd844613 100644
--- a/src/com/android/incallui/CallButtonFragment.java
+++ b/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/src/com/android/incallui/CallButtonPresenter.java b/src/com/android/incallui/CallButtonPresenter.java
index 6e841a1c..622a74f3 100644
--- a/src/com/android/incallui/CallButtonPresenter.java
+++ b/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();