diff options
author | Yorke Lee <yorkelee@google.com> | 2015-04-10 17:52:04 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2015-04-13 14:04:49 -0700 |
commit | 439365a9477ee0dfbc4ac0933db13a1614edd597 (patch) | |
tree | d9a316e524212b2256ba42cf2a3fa0a748787e7f | |
parent | c6fa624f73788760cf2fed413576662360101271 (diff) |
Simplify and rewire in-call buttons
* Fix bug where the switch camera option was never shown
* Fix bug where dialpad button was shown for video calls
* Move management of call button's actual visiblity into the
CallCardFragment. The CallCardPresenter is in charge of deciding
what functionality is available, but the CallCardFragment manages
the actual UI that is displayed.
* Simplify code that collapses call button functionality into
the overflow button. Any buttons that would cause the total number
of buttons to exceed the given threshold will be collapsed into
an overflow menu.
* Dynamically toggle the contentDescription of the hold button. This
is used for both accessibility as well as generating the menu option
if the button is collapsed into the overflow menu
* Removed some now unused strings and code.
Bug: 20127747
Bug: 20127925
Bug: 20090502
Change-Id: I33fda7ad74af926d8c3a507bff8f3c69c19ea57e
-rw-r--r-- | InCallUI/res/layout/call_button_fragment.xml | 12 | ||||
-rw-r--r-- | InCallUI/res/menu/incall_overflow_menu.xml | 36 | ||||
-rw-r--r-- | InCallUI/res/values/strings.xml | 25 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/CallButtonFragment.java | 178 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/CallButtonPresenter.java | 166 |
5 files changed, 153 insertions, 264 deletions
diff --git a/InCallUI/res/layout/call_button_fragment.xml b/InCallUI/res/layout/call_button_fragment.xml index 69d0ee3a0..4eac03482 100644 --- a/InCallUI/res/layout/call_button_fragment.xml +++ b/InCallUI/res/layout/call_button_fragment.xml @@ -68,7 +68,8 @@ <ToggleButton android:id="@+id/audioButton" style="@style/InCallCompoundButton" android:background="@drawable/btn_compound_audio" - android:contentDescription="@string/audio_mode_speaker" /> + android:contentDescription="@string/audio_mode_speaker" + android:visibility="gone" /> <!-- "Change to audio call" for video calls. --> <ImageButton android:id="@+id/changeToVoiceButton" @@ -83,7 +84,8 @@ <ToggleButton android:id="@+id/muteButton" style="@style/InCallCompoundButton" android:background="@drawable/btn_compound_mute" - android:contentDescription="@string/onscreenMuteText" /> + android:contentDescription="@string/onscreenMuteText" + android:visibility="gone" /> <!-- CENTER SLOT ======================================================================= --> @@ -91,7 +93,8 @@ <ToggleButton android:id="@+id/dialpadButton" style="@style/InCallCompoundButton" android:background="@drawable/btn_compound_dialpad" - android:contentDescription="@string/onscreenShowDialpadText" /> + android:contentDescription="@string/onscreenShowDialpadText" + android:visibility="gone" /> <!-- MIDDLE RIGHT SLOT ================================================================= --> @@ -102,7 +105,8 @@ <ToggleButton android:id="@+id/holdButton" style="@style/InCallCompoundButton" android:background="@drawable/btn_compound_hold" - android:contentDescription="@string/onscreenHoldText" /> + android:contentDescription="@string/onscreenHoldText_unselected" + android:visibility="gone" /> <!-- "Swap" (or "Manage calls" in some CDMA states) --> <ImageButton android:id="@+id/swapButton" diff --git a/InCallUI/res/menu/incall_overflow_menu.xml b/InCallUI/res/menu/incall_overflow_menu.xml deleted file mode 100644 index 2de858711..000000000 --- a/InCallUI/res/menu/incall_overflow_menu.xml +++ /dev/null @@ -1,36 +0,0 @@ -<?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" /> - - <item android:id="@+id/overflow_manage_conference_menu_item" - android:title="@string/overflowManageConferenceMenuItemText" /> -</menu> diff --git a/InCallUI/res/values/strings.xml b/InCallUI/res/values/strings.xml index 99b8111bb..cfe3d41ab 100644 --- a/InCallUI/res/values/strings.xml +++ b/InCallUI/res/values/strings.xml @@ -255,23 +255,14 @@ 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 overflow "Manage Conference Video Call" menu item. --> - <string name="overflowManageConferenceMenuItemText">Manage Conference</string> - - <!-- Text for the onscreen "Hold" button --> - <string name="onscreenHoldText">Hold</string> + <!-- Text for the onscreen "Hold" button when it is not selected. Pressing it will put + the call on hold. --> + <string name="onscreenHoldText_unselected">Hold Call</string> + <!-- Text for the onscreen "Hold" button when it is selected. Pressing it will resume + the call from a previously held state. --> + <string name="onscreenHoldText_selected">Resume Call</string> <!-- Text for the onscreen "End call" button --> - <string name="onscreenEndCallText">End</string> + <string name="onscreenEndCallText">End Call</string> <!-- Text for the onscreen "Show Dialpad" button --> <string name="onscreenShowDialpadText">Dialpad</string> <!-- Text for the onscreen "Mute" button --> @@ -456,7 +447,7 @@ <!-- This can be used in any application wanting to disable the text "Emergency number" --> <string name="emergency_call_dialog_number_for_display">Emergency number</string> - <!-- STOPSHIP These strings are for debugging only --> + <!-- STOPSHIP These strings are for debugging only --> <!-- Call substate label --> <string name="call_substate_label" translatable="false">Call substate - \u000a</string> <!-- Call substate label for call resumed --> diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java index a6ea334b3..1e9082791 100644 --- a/InCallUI/src/com/android/incallui/CallButtonFragment.java +++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java @@ -32,6 +32,7 @@ import android.os.Bundle; import android.telecom.AudioState; import android.telecom.TelecomManager; import android.telecom.VideoProfile; +import android.util.SparseIntArray; import android.view.ContextThemeWrapper; import android.view.HapticFeedbackConstants; import android.view.LayoutInflater; @@ -57,23 +58,31 @@ public class CallButtonFragment implements CallButtonPresenter.CallButtonUi, OnMenuItemClickListener, OnDismissListener, View.OnClickListener { private static final int INVALID_INDEX = -1; + private static final int BUTTON_MAX_VISIBLE = 5; + // The button is currently visible in the UI + private static final int BUTTON_VISIBLE = 1; + // The button is hidden in the UI + private static final int BUTTON_HIDDEN = 2; + // The button has been collapsed into the overflow menu + private static final int BUTTON_MENU = 3; public interface Buttons { - public static final int BUTTON_AUDIO = 1; - public static final int BUTTON_DOWNGRADE_TO_VOICE = 2; - public static final int BUTTON_MUTE = 3; - public static final int BUTTON_DIALPAD = 4; - public static final int BUTTON_HOLD = 5; - public static final int BUTTON_SWAP = 6; - public static final int BUTTON_UPGRADE_TO_VIDEO = 7; - public static final int BUTTON_SWITCH_CAMERA = 8; - public static final int BUTTON_ADD_CALL = 9; - public static final int BUTTON_MERGE = 10; - public static final int BUTTON_PAUSE_VIDEO = 11; - public static final int BUTTON_MANAGE_VIDEO_CONFERENCE = 12; - public static final int BUTTON_OVERFLOW = 13; - } - + public static final int BUTTON_AUDIO = 0; + public static final int BUTTON_DOWNGRADE_TO_VOICE = 1; + public static final int BUTTON_MUTE = 2; + public static final int BUTTON_DIALPAD = 3; + public static final int BUTTON_HOLD = 4; + public static final int BUTTON_SWAP = 5; + public static final int BUTTON_UPGRADE_TO_VIDEO = 6; + public static final int BUTTON_SWITCH_CAMERA = 7; + public static final int BUTTON_ADD_CALL = 8; + public static final int BUTTON_MERGE = 9; + public static final int BUTTON_PAUSE_VIDEO = 10; + public static final int BUTTON_MANAGE_VIDEO_CONFERENCE = 11; + public static final int BUTTON_COUNT = 12; + } + + private SparseIntArray mButtonVisibilityMap = new SparseIntArray(BUTTON_COUNT); private CompoundButton mAudioButton; private ImageButton mChangeToVoiceButton; @@ -116,6 +125,10 @@ public class CallButtonFragment @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + + for (int i = 0; i < BUTTON_COUNT; i++) { + mButtonVisibilityMap.put(i, BUTTON_HIDDEN); + } } @Override @@ -218,7 +231,9 @@ public class CallButtonFragment !mPauseVideoButton.isSelected() /* pause */); break; case R.id.overflowButton: - mOverflowPopup.show(); + if (mOverflowPopup != null) { + mOverflowPopup.show(); + } break; case R.id.manageVideoCallConferenceButton: onManageVideoCallConferenceClicked(); @@ -240,7 +255,6 @@ public class CallButtonFragment return; } - Resources res = getActivity().getResources(); View[] compoundButtons = { mAudioButton, mMuteButton, @@ -363,18 +377,8 @@ public class CallButtonFragment } @Override - public void setMute(boolean value) { - if (mMuteButton.isSelected() != value) { - mMuteButton.setSelected(value); - } - } - - @Override public void showButton(int buttonId, boolean show) { - final View button = getButtonById(buttonId); - if (button != null) { - button.setVisibility(show ? View.VISIBLE : View.GONE); - } + mButtonVisibilityMap.put(buttonId, show ? BUTTON_VISIBLE : BUTTON_HIDDEN); } @Override @@ -411,8 +415,6 @@ public class CallButtonFragment return mPauseVideoButton; case BUTTON_MANAGE_VIDEO_CONFERENCE: return mManageVideoCallConferenceButton; - case BUTTON_OVERFLOW: - return mOverflowButton; default: Log.w(this, "Invalid button id"); return null; @@ -423,6 +425,9 @@ public class CallButtonFragment public void setHold(boolean value) { if (mHoldButton.isSelected() != value) { mHoldButton.setSelected(value); + mHoldButton.setContentDescription(getContext().getString( + value ? R.string.onscreenHoldText_selected + : R.string.onscreenHoldText_unselected)); } } @@ -436,9 +441,17 @@ public class CallButtonFragment mPauseVideoButton.setSelected(isPaused); } + @Override + public void setMute(boolean value) { + if (mMuteButton.isSelected() != value) { + mMuteButton.setSelected(value); + } + } + /**The function is called when Modify Call button gets pressed. The function creates and * displays modify call options. */ + @Override public void displayModifyCallOptions() { CallButtonPresenter.CallButtonUi ui = getUi(); if (ui == null) { @@ -509,65 +522,68 @@ public class CallButtonFragment return ""; } + private void addToOverflowMenu(int id, View button, PopupMenu menu) { + button.setVisibility(View.GONE); + menu.getMenu().add(Menu.NONE, id, Menu.NONE, button.getContentDescription()); + mButtonVisibilityMap.put(id, BUTTON_MENU); + } + + private PopupMenu getPopupMenu() { + return new PopupMenu(new ContextThemeWrapper(getActivity(), R.style.InCallPopupMenuStyle), + mOverflowButton); + } + + /** + * Iterates through the list of buttons and toggles their visibility depending on the + * setting configured by the CallButtonPresenter. If there are more visible buttons than + * the allowed maximum, the excess buttons are collapsed into a single overflow menu. + */ @Override - public void configureOverflowMenu(boolean showMergeMenuOption, boolean showAddMenuOption, - boolean showHoldMenuOption, boolean showSwapMenuOption, - boolean showManageConferenceVideoCallOption) { - 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()); + public void updateButtonStates() { + View prevVisibleButton = null; + int prevVisibleId = -1; + PopupMenu menu = null; + int visibleCount = 0; + for (int i = 0; i < BUTTON_COUNT; i++) { + final int visibility = mButtonVisibilityMap.get(i); + final View button = getButtonById(i); + if (visibility == BUTTON_VISIBLE) { + visibleCount++; + if (visibleCount <= BUTTON_MAX_VISIBLE) { + button.setVisibility(View.VISIBLE); + prevVisibleButton = button; + prevVisibleId = i; + } else { + if (menu == null) { + menu = getPopupMenu(); + } + // Collapse the current button into the overflow menu. If is the first visible + // button that exceeds the threshold, also collapse the previous visible button + // so that the total number of visible buttons will never exceed the threshold. + if (prevVisibleButton != null) { + addToOverflowMenu(prevVisibleId, prevVisibleButton, menu); + prevVisibleButton = null; + prevVisibleId = -1; + } + addToOverflowMenu(i, button, menu); + } + } else if (visibility == BUTTON_HIDDEN){ + button.setVisibility(View.GONE); + } + } + + mOverflowButton.setVisibility(menu != null ? View.VISIBLE : View.GONE); + if (menu != null) { + mOverflowPopup = menu; 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; - case R.id.overflow_manage_conference_menu_item: - onManageVideoCallConferenceClicked(); - break; - default: - Log.wtf(this, "onMenuItemClick: unexpected overflow menu click"); - break; - } + final int id = item.getItemId(); + getButtonById(id).performClick(); 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); - menu.findItem(R.id.overflow_manage_conference_menu_item).setVisible( - showManageConferenceVideoCallOption); - - mOverflowButton.setEnabled(menu.hasVisibleItems()); } @Override diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java index 0faebfd29..cc13a87ef 100644 --- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java +++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java @@ -18,7 +18,6 @@ package com.android.incallui; import static com.android.incallui.CallButtonFragment.Buttons.*; -import android.app.AlertDialog; import android.content.Context; import android.os.Bundle; import android.telecom.AudioState; @@ -48,7 +47,6 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto private Call mCall; private boolean mAutomaticallyMuted = false; private boolean mPreviousMuteState = false; - private static final int BUTTON_THRESOLD_TO_DISPLAY_OVERFLOW_MENU = 5; public CallButtonPresenter() { } @@ -121,7 +119,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto @Override public void onDetailsChanged(Call call, android.telecom.Call.Details details) { if (getUi() != null && Objects.equals(call, mCall)) { - updateCallButtons(call, getUi().getContext()); + updateButtonsState(call); } } @@ -133,7 +131,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto @Override public void onCanAddCallChanged(boolean canAddCall) { if (getUi() != null && mCall != null) { - updateCallButtons(mCall, getUi().getContext()); + updateButtonsState(mCall); } } @@ -342,7 +340,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto return; } - updateCallButtons(call, ui.getContext()); + updateButtonsState(call); ui.enableButton(BUTTON_MUTE, call.can(android.telecom.Call.Details.CAPABILITY_MUTE)); } @@ -355,136 +353,49 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto * Updates the buttons applicable for the UI. * * @param call The active call. - * @param context The context. */ - private void updateCallButtons(Call call, Context context) { - if (CallUtils.isVideoCall(call)) { - updateVideoCallButtons(call); - } - updateVoiceCallButtons(call); - } - - private void updateVideoCallButtons(Call call) { - Log.v(this, "Showing buttons for video call."); - final CallButtonUi ui = getUi(); - - // Show all video-call-related buttons. - ui.showButton(BUTTON_SWITCH_CAMERA, true); - ui.showButton(BUTTON_PAUSE_VIDEO, true); - - final boolean supportHold = call.can(android.telecom.Call.Details.CAPABILITY_SUPPORT_HOLD); - final boolean enableHoldOption = call.can(android.telecom.Call.Details.CAPABILITY_HOLD); - ui.showButton(BUTTON_HOLD, supportHold); - ui.enableButton(BUTTON_HOLD, enableHoldOption); - ui.setHold(call.getState() == Call.State.ONHOLD); - } - - private void updateVoiceCallButtons(Call call) { + private void updateButtonsState(Call call) { Log.v(this, "Showing buttons for voice call."); final CallButtonUi ui = getUi(); - // Hide all video-call-related buttons. - ui.showButton(BUTTON_DOWNGRADE_TO_VOICE, false); - ui.showButton(BUTTON_SWITCH_CAMERA, false); - ui.showButton(BUTTON_PAUSE_VIDEO, false); - - // Show all voice-call-related buttons. - ui.showButton(BUTTON_AUDIO, true); - ui.showButton(BUTTON_DIALPAD, true); - - Log.v(this, "Show hold ", call.can(android.telecom.Call.Details.CAPABILITY_SUPPORT_HOLD)); - Log.v(this, "Enable hold", call.can(android.telecom.Call.Details.CAPABILITY_HOLD)); - Log.v(this, "Show merge ", call.can( - android.telecom.Call.Details.CAPABILITY_MERGE_CONFERENCE)); - Log.v(this, "Show swap ", call.can( - android.telecom.Call.Details.CAPABILITY_SWAP_CONFERENCE)); - Log.v(this, "Show add call ", TelecomAdapter.getInstance().canAddCall()); - Log.v(this, "Show mute ", call.can(android.telecom.Call.Details.CAPABILITY_MUTE)); - Log.v(this, "Show video call local:", - call.can(android.telecom.Call.Details.CAPABILITY_SUPPORTS_VT_LOCAL) - + " remote: " - + call.can(android.telecom.Call.Details.CAPABILITY_SUPPORTS_VT_REMOTE)); - - final boolean canAdd = TelecomAdapter.getInstance().canAddCall(); - final boolean enableHoldOption = call.can(android.telecom.Call.Details.CAPABILITY_HOLD); - final boolean supportHold = call.can(android.telecom.Call.Details.CAPABILITY_SUPPORT_HOLD); - final boolean isCallOnHold = call.getState() == Call.State.ONHOLD; - - boolean canVideoCall = call.can(android.telecom.Call.Details.CAPABILITY_SUPPORTS_VT_LOCAL) - && call.can(android.telecom.Call.Details.CAPABILITY_SUPPORTS_VT_REMOTE); - ui.showButton(BUTTON_UPGRADE_TO_VIDEO, canVideoCall); - - final boolean showMergeOption = call.can( - android.telecom.Call.Details.CAPABILITY_MERGE_CONFERENCE); - final boolean showAddCallOption = canAdd; - final boolean showManageVideoCallConferenceOption = call.can( - android.telecom.Call.Details.CAPABILITY_MANAGE_CONFERENCE) - && CallUtils.isVideoCall(call); + final boolean isVideo = CallUtils.isVideoCall(call); + // Common functionality (audio, hold, etc). // Show either HOLD or SWAP, but not both. If neither HOLD or SWAP is available: // (1) If the device normally can hold, show HOLD in a disabled state. // (2) If the device doesn't have the concept of hold/swap, remove the button. - final boolean showSwapOption = call.can( + final boolean showSwap = call.can( android.telecom.Call.Details.CAPABILITY_SWAP_CONFERENCE); - final boolean showHoldOption = !showSwapOption && (enableHoldOption || supportHold); + final boolean showHold = !showSwap + && call.can(android.telecom.Call.Details.CAPABILITY_SUPPORT_HOLD) + && call.can(android.telecom.Call.Details.CAPABILITY_HOLD); + final boolean isCallOnHold = call.getState() == Call.State.ONHOLD; + + final boolean showAddCall = TelecomAdapter.getInstance().canAddCall(); + final boolean showMerge = call.can( + android.telecom.Call.Details.CAPABILITY_MERGE_CONFERENCE); + final boolean showUpgradeToVideo = !isVideo + && call.can(android.telecom.Call.Details.CAPABILITY_SUPPORTS_VT_LOCAL) + && call.can(android.telecom.Call.Details.CAPABILITY_SUPPORTS_VT_REMOTE); + + final boolean showMute = call.can(android.telecom.Call.Details.CAPABILITY_MUTE); + ui.showButton(BUTTON_AUDIO, true); + ui.showButton(BUTTON_SWAP, showSwap); + ui.showButton(BUTTON_HOLD, showHold); ui.setHold(isCallOnHold); - //Initialize buttonCount = 2. Because speaker and dialpad these two always show in Call UI. - int buttonCount = 2; - buttonCount += toInteger(canVideoCall); - buttonCount += toInteger(showAddCallOption); - buttonCount += toInteger(showMergeOption); - buttonCount += toInteger(showHoldOption); - buttonCount += toInteger(showSwapOption); - buttonCount += toInteger(call.can(android.telecom.Call.Details.CAPABILITY_MUTE)); - buttonCount += toInteger(showManageVideoCallConferenceOption); - - Log.v(this, "show ManageVideoCallConference: " + showManageVideoCallConferenceOption); - Log.v(this, "No of InCall buttons: " + buttonCount + " canVideoCall: " + canVideoCall); - - // Show overflow menu if number of buttons is greater than 5. - final boolean showOverflowMenu = - buttonCount > BUTTON_THRESOLD_TO_DISPLAY_OVERFLOW_MENU; - final boolean isVideoOverflowScenario = canVideoCall && showOverflowMenu; - final boolean isOverflowScenario = !canVideoCall && showOverflowMenu; - - if (isVideoOverflowScenario) { - ui.showButton(BUTTON_HOLD, false); - ui.showButton(BUTTON_SWAP, false); - ui.showButton(BUTTON_ADD_CALL, false); - ui.showButton(BUTTON_MERGE, false); - ui.showButton(BUTTON_MANAGE_VIDEO_CONFERENCE, false); - - ui.configureOverflowMenu( - showMergeOption, - showAddCallOption /* showAddMenuOption */, - showHoldOption && enableHoldOption /* showHoldMenuOption */, - showSwapOption, - showManageVideoCallConferenceOption); - ui.showButton(BUTTON_OVERFLOW, true); - } else { - if (isOverflowScenario) { - ui.showButton(BUTTON_ADD_CALL, false); - ui.showButton(BUTTON_MERGE, false); - ui.showButton(BUTTON_MANAGE_VIDEO_CONFERENCE, false); - - ui.configureOverflowMenu( - showMergeOption, - showAddCallOption /* showAddMenuOption */, - false /* showHoldMenuOption */, - false /* showSwapMenuOption */, - showManageVideoCallConferenceOption); - } else { - ui.showButton(BUTTON_MERGE, showMergeOption); - ui.showButton(BUTTON_ADD_CALL, showAddCallOption); - ui.showButton(BUTTON_MANAGE_VIDEO_CONFERENCE, showManageVideoCallConferenceOption); - } + ui.showButton(BUTTON_MUTE, showMute); + ui.showButton(BUTTON_ADD_CALL, showAddCall); + // TODO: This button is currently being used for both upgrade and downgrade scenarios. + // It should be split into BUTTON_DOWNGRADE_TO_VOICE AND BUTTON_UPGRADE_TO_VIDEO + ui.showButton(BUTTON_UPGRADE_TO_VIDEO, true); + ui.showButton(BUTTON_DOWNGRADE_TO_VOICE, false); + ui.showButton(BUTTON_SWITCH_CAMERA, isVideo); + ui.showButton(BUTTON_PAUSE_VIDEO, isVideo); + ui.showButton(BUTTON_DIALPAD, !isVideo); + ui.showButton(BUTTON_MERGE, showMerge); - ui.showButton(BUTTON_OVERFLOW, isOverflowScenario); - ui.showButton(BUTTON_HOLD, showHoldOption); - ui.enableButton(BUTTON_HOLD, enableHoldOption); - ui.showButton(BUTTON_SWAP, showSwapOption); - } + ui.updateButtonStates(); } public void refreshMuteState() { @@ -528,9 +439,12 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto void displayDialpad(boolean on, boolean animate); void displayModifyCallOptions(); boolean isDialpadVisible(); - void configureOverflowMenu(boolean showMergeMenuOption, boolean showAddMenuOption, - boolean showHoldMenuOption, boolean showSwapMenuOption, - boolean showManageConferenceVideoCallOption); + + /** + * Once showButton() has been called on each of the individual buttons in the UI, call + * this to configure the overflow menu appropriately. + */ + void updateButtonStates(); Context getContext(); } |