From 3570e970a2812b95ed82bf8e232d1e22f71f118e Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Wed, 8 Apr 2015 10:41:57 -0700 Subject: Cleanup of Video Call pause functionality. Whether the paused videoState is available is dependent on the carrier's implementation of the VT spec. The original VT implementation assumed that this was stored in a system property accessed via InCall; these CLs move this to a Call/Connection capability which will ultimately support multisim video capable devices. - Made some general cleanups in VideoPauseController (comments, some minor logic changes, renamed a few methods). - Removed access of system property to see if pause is supported and instead key in on the call capability. - Changed video call presenter to hide incoming video surface when a pause signal is received. Bug: 16680364 Bug: 19820114 Change-Id: I6d1a7789925c69e4022846f8d847b8bb1274c06b --- .../com/android/incallui/VideoCallPresenter.java | 14 +- .../com/android/incallui/VideoPauseController.java | 239 ++++++++++++++------- 2 files changed, 170 insertions(+), 83 deletions(-) diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java index 486a38da3..3f8a827c3 100644 --- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java +++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java @@ -412,7 +412,9 @@ public class VideoCallPresenter extends Presenter + * Reject incoming or hangup dialing call: Where the previous call was an incoming call or a + * call in dialing state, resume the new primary call. + * Call swap: Where the new primary call is incoming, pause video on the previous primary call. + * + * @param call The new primary call. + */ private void onPrimaryCallChanged(Call call) { log("onPrimaryCallChanged: New call = " + call); log("onPrimaryCallChanged: Old call = " + mPrimaryCallContext); @@ -200,25 +209,26 @@ class VideoPauseController implements InCallStateListener, IncomingCallListener, Preconditions.checkState(!areSame(call, mPrimaryCallContext)); final boolean canVideoPause = CallUtils.canVideoPause(call); - if (isWaitingCall(mPrimaryCallContext) && canVideoPause && !mIsInBackground) { - // Send resume request for the active call, if user rejects incoming - // call and UI is in foreground. + if ((isIncomingCall(mPrimaryCallContext) || isDialing(mPrimaryCallContext)) + && canVideoPause && !mIsInBackground) { + // Send resume request for the active call, if user rejects incoming call or ends + // dialing call and UI is in the foreground. sendRequest(call, true); - } else if (isWaitingCall(call) && canVideoPause(mPrimaryCallContext)) { + } else if (isIncomingCall(call) && canVideoPause(mPrimaryCallContext)) { // Send pause request if there is an active video call, and we just received a new // incoming call. sendRequest(mPrimaryCallContext.getCall(), false); - } else if (isOutgoing(mPrimaryCallContext) && canVideoPause && !mIsInBackground) { - // Send resume request for the active call, if user ends outgoing call - // and UI is in foreground. - sendRequest(call, true); } updatePrimaryCallContext(call); } /** - * The function gets called when InCallUI receives a new incoming call. + * Handles new incoming calls by triggering a change in the primary call. + * + * @param oldState the old {@link InCallState}. + * @param newState the new {@link InCallState}. + * @param call the incoming call. */ @Override public void onIncomingCall(InCallState oldState, InCallState newState, Call call) { @@ -231,6 +241,11 @@ class VideoPauseController implements InCallStateListener, IncomingCallListener, onPrimaryCallChanged(call); } + /** + * Caches a reference to the primary call and stores its previous state. + * + * @param call The new primary call. + */ private void updatePrimaryCallContext(Call call) { if (call == null) { mPrimaryCallContext = null; @@ -246,43 +261,67 @@ class VideoPauseController implements InCallStateListener, IncomingCallListener, * @param showing true if UI is in the foreground, false otherwise. */ public void onUiShowing(boolean showing) { - if (!isVideoPausedEnabled() || mInCallPresenter == null) { + // Only send pause/unpause requests if we are in the INCALL state. + if (mInCallPresenter == null || mInCallPresenter.getInCallState() != InCallState.INCALL) { return; } - final boolean notify = mInCallPresenter.getInCallState() == InCallState.INCALL; if (showing) { - onResume(notify); + onResume(); } else { - onPause(notify); + onPause(); } } + /** + * Handles requests to upgrade to video. + * + * @param call The call the request was received for. + * @param videoState The video state that the request wants to upgrade to. + */ @Override public void onUpgradeToVideoRequest(Call call, int videoState) { + // Not used. } + /** + * Handles successful upgrades to video. + * @param call The call the request was successful for. + */ @Override public void onUpgradeToVideoSuccess(Call call) { + // Not used. } + /** + * Handles a failure to upgrade a call to video. + * + * @param status The failure status. + * @param call The call the request was successful for. + */ @Override public void onUpgradeToVideoFail(int status, Call call) { // TODO (ims-vt) Automatically bring in call ui to foreground. } + /** + * Handles a downgrade of a call to audio-only. + * + * @param call The call which was downgraded to audio-only. + */ @Override public void onDowngradeToAudio(Call call) { } /** - * Called when UI becomes visible. This will send resume request for current video call, if any. + * Called when UI is brought to the foreground. Sends a session modification request to resume + * the outgoing video. */ - private void onResume(boolean notify) { - log("onResume: notify=" + notify); + private void onResume() { + log("onResume"); mIsInBackground = false; - if (canVideoPause(mPrimaryCallContext) && notify) { + if (canVideoPause(mPrimaryCallContext)) { sendRequest(mPrimaryCallContext.getCall(), true); } else { log("onResume. Ignoring..."); @@ -290,13 +329,14 @@ class VideoPauseController implements InCallStateListener, IncomingCallListener, } /** - * Called when UI becomes invisible. This will send pause request for current video call, if any. + * Called when UI is sent to the background. Sends a session modification request to pause the + * outgoing video. */ - private void onPause(boolean notify) { - log("onPause: notify=" + notify); + private void onPause() { + log("onPause"); mIsInBackground = true; - if (canVideoPause(mPrimaryCallContext) && notify) { + if (canVideoPause(mPrimaryCallContext)) { sendRequest(mPrimaryCallContext.getCall(), false); } else { log("onPause, Ignoring..."); @@ -314,75 +354,118 @@ class VideoPauseController implements InCallStateListener, IncomingCallListener, /** * Sends Pause/Resume request. + * * @param call Call to be paused/resumed. * @param resume If true resume request will be sent, otherwise pause request. */ private void sendRequest(Call call, boolean resume) { + // Check if this call supports pause/un-pause. + if (!call.can(android.telecom.Call.Details.CAPABILITY_CAN_PAUSE_VIDEO)) { + return; + } + if (resume) { log("sending resume request, call=" + call); - call.getVideoCall().sendSessionModifyRequest(CallUtils.makeVideoUnPauseProfile(call)); + call.getVideoCall() + .sendSessionModifyRequest(CallUtils.makeVideoUnPauseProfile(call)); } else { log("sending pause request, call=" + call); call.getVideoCall().sendSessionModifyRequest(CallUtils.makeVideoPauseProfile(call)); } } - private boolean isVideoPausedEnabled() { - return mVideoPauseMode != VIDEO_PAUSE_MODE_DISABLED; - } - + /** + * Determines if a given call is the same one stored in a {@link CallContext}. + * + * @param call The call. + * @param callContext The call context. + * @return {@code true} if the {@link Call} is the same as the one referenced in the + * {@link CallContext}. + */ private static boolean areSame(Call call, CallContext callContext) { if (call == null && callContext == null) { return true; } else if (call == null || callContext == null) { return false; } - return call.getId().equals(callContext.getId()); - } - - private static boolean areSame(CallContext callContext, Call call) { - return areSame(call, callContext); + return call.equals(callContext.getCall()); } + /** + * Determines if a video call can be paused. Only a video call which is active can be paused. + * + * @param callContext The call context to check. + * @return {@code true} if the call is an active video call. + */ private static boolean canVideoPause(CallContext callContext) { return isVideoCall(callContext) && callContext.getState() == Call.State.ACTIVE; } + /** + * Determines if a call referenced by a {@link CallContext} is a video call. + * + * @param callContext The call context. + * @return {@code true} if the call is a video call, {@code false} otherwise. + */ private static boolean isVideoCall(CallContext callContext) { return callContext != null && VideoProfile.VideoState.isVideo(callContext.getVideoState()); } /** - * Returns true if call is in incoming/waiting state, false otherwise. + * Determines if call is in incoming/waiting state. + * + * @param call The call context. + * @return {@code true} if the call is in incoming or waiting state, {@code false} otherwise. */ - private static boolean isWaitingCall(CallContext call) { - return call != null && (call.getState() == Call.State.CALL_WAITING - || call.getState() == Call.State.INCOMING); + private static boolean isIncomingCall(CallContext call) { + return call != null && isIncomingCall(call.getCall()); } - private static boolean isWaitingCall(Call call) { + /** + * Determines if a call is in incoming/waiting state. + * + * @param call The call. + * @return {@code true} if the call is in incoming or waiting state, {@code false} otherwise. + */ + private static boolean isIncomingCall(Call call) { return call != null && (call.getState() == Call.State.CALL_WAITING || call.getState() == Call.State.INCOMING); } /** - * Returns true if the call is outgoing, false otherwise + * Determines if a call is dialing. + * + * @param call The call context. + * @return {@code true} if the call is dialing, {@code false} otherwise. */ - private static boolean isOutgoing(CallContext call) { + private static boolean isDialing(CallContext call) { return call != null && Call.State.isDialing(call.getState()); } /** - * Returns true if the call is on hold, false otherwise + * Determines if a call is holding. + * + * @param call The call context. + * @return {@code true} if the call is holding, {@code false} otherwise. */ private static boolean isHolding(CallContext call) { return call != null && call.getState() == Call.State.ONHOLD; } + /** + * Logs a debug message. + * + * @param msg The message. + */ private void log(String msg) { Log.d(this, TAG + msg); } + /** + * Logs an error message. + * + * @param msg The message. + */ private void loge(String msg) { Log.e(this, TAG + msg); } -- cgit v1.2.3 From e96c83ad0a8f52a060d0ba7eac2290eb95b3b1c5 Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Wed, 8 Apr 2015 13:22:25 -0700 Subject: Adding video call icon in secondary call info. - Icon indicates that a call is a video call. Per mocks. Bug: 20119995 Change-Id: Ibccfccaa3f2762659282bbde433796fe20da361c --- InCallUI/res/layout/secondary_call_info.xml | 7 +++++++ InCallUI/src/com/android/incallui/CallCardFragment.java | 6 +++++- InCallUI/src/com/android/incallui/CallCardPresenter.java | 14 +++++++++----- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/InCallUI/res/layout/secondary_call_info.xml b/InCallUI/res/layout/secondary_call_info.xml index 85eef0ee1..e866795a6 100644 --- a/InCallUI/res/layout/secondary_call_info.xml +++ b/InCallUI/res/layout/secondary_call_info.xml @@ -40,6 +40,13 @@ android:paddingBottom="@dimen/secondary_call_info_vertical_padding" android:background="?android:attr/selectableItemBackground"> + + if (mSecondary == null) { // Clear the secondary display info. - ui.setSecondary(false, null, false, null, null, false /* isConference */); + ui.setSecondary(false, null, false, null, null, false /* isConference */, + false /* isVideoCall */); return; } @@ -536,7 +537,8 @@ public class CallCardPresenter extends Presenter false /* nameIsNumber */, null /* label */, getCallProviderLabel(mSecondary), - true /* isConference */); + true /* isConference */, + mSecondary.isVideoCall(mContext)); } else if (mSecondaryContactInfo != null) { Log.d(TAG, "updateSecondaryDisplayInfo() " + mSecondaryContactInfo); String name = getNameForCall(mSecondaryContactInfo); @@ -547,10 +549,12 @@ public class CallCardPresenter extends Presenter nameIsNumber, mSecondaryContactInfo.label, getCallProviderLabel(mSecondary), - false /* isConference */); + false /* isConference */, + mSecondary.isVideoCall(mContext)); } else { // Clear the secondary display info. - ui.setSecondary(false, null, false, null, null, false /* isConference */); + ui.setSecondary(false, null, false, null, null, false /* isConference */, + false /* isVideoCall */); } } @@ -735,7 +739,7 @@ public class CallCardPresenter extends Presenter void setPrimary(String number, String name, boolean nameIsNumber, String label, Drawable photo, boolean isSipCall); void setSecondary(boolean show, String name, boolean nameIsNumber, String label, - String providerLabel, boolean isConference); + String providerLabel, boolean isConference, boolean isVideoCall); void setCallState(int state, int videoState, int sessionModificationState, DisconnectCause disconnectCause, String connectionLabel, Drawable connectionIcon, String gatewayNumber, boolean isWifi); -- cgit v1.2.3 From 63310252e8ab53ac9dd705ac86a91d2dde8d7fbf Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Wed, 8 Apr 2015 15:00:42 -0700 Subject: Standardize fragment layout names Change-Id: I76814eb5b90130227eea8e2f8576c472b80d1435 --- InCallUI/res/layout-land/call_card_content.xml | 139 -------------------- InCallUI/res/layout-land/call_card_fragment.xml | 139 ++++++++++++++++++++ InCallUI/res/layout/call_card_content.xml | 146 --------------------- InCallUI/res/layout/call_card_fragment.xml | 146 +++++++++++++++++++++ .../res/layout/dtmf_twelve_key_dialer_view.xml | 30 ----- InCallUI/res/layout/incall_dialpad_fragment.xml | 30 +++++ .../src/com/android/incallui/CallCardFragment.java | 2 +- .../src/com/android/incallui/DialpadFragment.java | 2 +- 8 files changed, 317 insertions(+), 317 deletions(-) delete mode 100644 InCallUI/res/layout-land/call_card_content.xml create mode 100644 InCallUI/res/layout-land/call_card_fragment.xml delete mode 100644 InCallUI/res/layout/call_card_content.xml create mode 100644 InCallUI/res/layout/call_card_fragment.xml delete mode 100644 InCallUI/res/layout/dtmf_twelve_key_dialer_view.xml create mode 100644 InCallUI/res/layout/incall_dialpad_fragment.xml diff --git a/InCallUI/res/layout-land/call_card_content.xml b/InCallUI/res/layout-land/call_card_content.xml deleted file mode 100644 index 0bb45a244..000000000 --- a/InCallUI/res/layout-land/call_card_content.xml +++ /dev/null @@ -1,139 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/InCallUI/res/layout-land/call_card_fragment.xml b/InCallUI/res/layout-land/call_card_fragment.xml new file mode 100644 index 000000000..0bb45a244 --- /dev/null +++ b/InCallUI/res/layout-land/call_card_fragment.xml @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/InCallUI/res/layout/call_card_content.xml b/InCallUI/res/layout/call_card_content.xml deleted file mode 100644 index a5fd8f72a..000000000 --- a/InCallUI/res/layout/call_card_content.xml +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/InCallUI/res/layout/call_card_fragment.xml b/InCallUI/res/layout/call_card_fragment.xml new file mode 100644 index 000000000..a5fd8f72a --- /dev/null +++ b/InCallUI/res/layout/call_card_fragment.xml @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/InCallUI/res/layout/dtmf_twelve_key_dialer_view.xml b/InCallUI/res/layout/dtmf_twelve_key_dialer_view.xml deleted file mode 100644 index efd698286..000000000 --- a/InCallUI/res/layout/dtmf_twelve_key_dialer_view.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - diff --git a/InCallUI/res/layout/incall_dialpad_fragment.xml b/InCallUI/res/layout/incall_dialpad_fragment.xml new file mode 100644 index 000000000..efd698286 --- /dev/null +++ b/InCallUI/res/layout/incall_dialpad_fragment.xml @@ -0,0 +1,30 @@ + + + + + + + + + diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 805ff0c6b..13accf5fb 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -164,7 +164,7 @@ public class CallCardFragment extends BaseFragment Date: Wed, 8 Apr 2015 17:59:58 -0700 Subject: Show progress spinner when upgrading to video Show spinner when waiting for remote consent. Also correctly propagate sessionModification state when downgrading to audio. Bug: 20090442 Change-Id: If733ce99683436c751a26a6511e6a41bac637c30 --- InCallUI/res/layout-land/call_card_fragment.xml | 14 +++++++------- InCallUI/res/layout/call_card_fragment.xml | 14 +++++++------- InCallUI/src/com/android/incallui/CallCardPresenter.java | 8 ++++++++ .../src/com/android/incallui/InCallVideoCallListener.java | 4 +++- InCallUI/src/com/android/incallui/VideoCallPresenter.java | 1 + 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/InCallUI/res/layout-land/call_card_fragment.xml b/InCallUI/res/layout-land/call_card_fragment.xml index 0bb45a244..fb880e311 100644 --- a/InCallUI/res/layout-land/call_card_fragment.xml +++ b/InCallUI/res/layout-land/call_card_fragment.xml @@ -71,13 +71,6 @@ android:layout_height="wrap_content" android:layout_alignTop="@id/photo" /> - - + + - - + + diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index 401187a83..b327ed64c 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -249,6 +249,7 @@ public class CallCardPresenter extends Presenter } maybeShowManageConferenceCallButton(); + maybeShowProgressSpinner(); final boolean enableEndCallButton = Call.State.isConnectingOrConnected(callState) && callState != Call.State.INCOMING && mPrimary != null; @@ -309,6 +310,13 @@ public class CallCardPresenter extends Presenter getUi().showManageConferenceCallButton(shouldShowManageConference()); } + private void maybeShowProgressSpinner() { + final boolean show = mPrimary != null && mPrimary.getSessionModificationState() + == Call.SessionModificationState.WAITING_FOR_RESPONSE + && mPrimary.getState() == Call.State.ACTIVE; + getUi().setProgressSpinnerVisible(show); + } + /** * Determines if the manage conference button should be visible, based on the current primary * call. diff --git a/InCallUI/src/com/android/incallui/InCallVideoCallListener.java b/InCallUI/src/com/android/incallui/InCallVideoCallListener.java index cf2b859e0..24c911949 100644 --- a/InCallUI/src/com/android/incallui/InCallVideoCallListener.java +++ b/InCallUI/src/com/android/incallui/InCallVideoCallListener.java @@ -87,8 +87,10 @@ public class InCallVideoCallListener extends VideoCall.Listener { boolean isVideoCall = VideoProfile.VideoState.isVideo(responseProfile.getVideoState()); if (modifySucceeded && isVideoCall) { InCallVideoCallListenerNotifier.getInstance().upgradeToVideoSuccess(mCall); - } else if (!modifySucceeded) { + } else if (!modifySucceeded && isVideoCall) { InCallVideoCallListenerNotifier.getInstance().upgradeToVideoFail(status, mCall); + } else if (modifySucceeded && !isVideoCall) { + InCallVideoCallListenerNotifier.getInstance().downgradeToAudio(mCall); } } else { Log.d(this, "onSessionModifyResponseReceived request and response Profiles are null"); diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java index 3f8a827c3..8ee30f2b3 100644 --- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java +++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java @@ -941,6 +941,7 @@ public class VideoCallPresenter extends Presenter Date: Fri, 10 Apr 2015 12:31:23 -0700 Subject: Cleanup AnswerFragment glowpad UI * For incoming video requests, only show answer as video, answer as audio, or reject * For upgrade requests, only show upgrade to video, don't upgrade to video * Nuke unused tx/rx only assets Bug: 20090411 Change-Id: I51093bb702981256809020908442eb98b0d17606 --- .../res/drawable/ic_lockscreen_answer_rx_video.xml | 30 ------------------ ..._lockscreen_answer_rx_video_activated_layer.xml | 28 ----------------- .../ic_lockscreen_answer_rx_video_normal_layer.xml | 36 ---------------------- .../res/drawable/ic_lockscreen_answer_tx_video.xml | 30 ------------------ ..._lockscreen_answer_tx_video_activated_layer.xml | 28 ----------------- .../ic_lockscreen_answer_tx_video_normal_layer.xml | 36 ---------------------- InCallUI/res/values/array.xml | 21 +++++-------- .../src/com/android/incallui/GlowPadWrapper.java | 8 ----- 8 files changed, 8 insertions(+), 209 deletions(-) delete mode 100644 InCallUI/res/drawable/ic_lockscreen_answer_rx_video.xml delete mode 100644 InCallUI/res/drawable/ic_lockscreen_answer_rx_video_activated_layer.xml delete mode 100644 InCallUI/res/drawable/ic_lockscreen_answer_rx_video_normal_layer.xml delete mode 100644 InCallUI/res/drawable/ic_lockscreen_answer_tx_video.xml delete mode 100644 InCallUI/res/drawable/ic_lockscreen_answer_tx_video_activated_layer.xml delete mode 100644 InCallUI/res/drawable/ic_lockscreen_answer_tx_video_normal_layer.xml diff --git a/InCallUI/res/drawable/ic_lockscreen_answer_rx_video.xml b/InCallUI/res/drawable/ic_lockscreen_answer_rx_video.xml deleted file mode 100644 index c5a41d814..000000000 --- a/InCallUI/res/drawable/ic_lockscreen_answer_rx_video.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - diff --git a/InCallUI/res/drawable/ic_lockscreen_answer_rx_video_activated_layer.xml b/InCallUI/res/drawable/ic_lockscreen_answer_rx_video_activated_layer.xml deleted file mode 100644 index 750ef5e26..000000000 --- a/InCallUI/res/drawable/ic_lockscreen_answer_rx_video_activated_layer.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - diff --git a/InCallUI/res/drawable/ic_lockscreen_answer_rx_video_normal_layer.xml b/InCallUI/res/drawable/ic_lockscreen_answer_rx_video_normal_layer.xml deleted file mode 100644 index 5efd3d142..000000000 --- a/InCallUI/res/drawable/ic_lockscreen_answer_rx_video_normal_layer.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - diff --git a/InCallUI/res/drawable/ic_lockscreen_answer_tx_video.xml b/InCallUI/res/drawable/ic_lockscreen_answer_tx_video.xml deleted file mode 100644 index 15d11978e..000000000 --- a/InCallUI/res/drawable/ic_lockscreen_answer_tx_video.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - diff --git a/InCallUI/res/drawable/ic_lockscreen_answer_tx_video_activated_layer.xml b/InCallUI/res/drawable/ic_lockscreen_answer_tx_video_activated_layer.xml deleted file mode 100644 index c1dca4d06..000000000 --- a/InCallUI/res/drawable/ic_lockscreen_answer_tx_video_activated_layer.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - diff --git a/InCallUI/res/drawable/ic_lockscreen_answer_tx_video_normal_layer.xml b/InCallUI/res/drawable/ic_lockscreen_answer_tx_video_normal_layer.xml deleted file mode 100644 index b0ad943dc..000000000 --- a/InCallUI/res/drawable/ic_lockscreen_answer_tx_video_normal_layer.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - diff --git a/InCallUI/res/values/array.xml b/InCallUI/res/values/array.xml index 46592e126..2e38c2c46 100644 --- a/InCallUI/res/values/array.xml +++ b/InCallUI/res/values/array.xml @@ -74,8 +74,6 @@ @null @drawable/ic_lockscreen_decline @drawable/ic_lockscreen_answer_video - @drawable/ic_lockscreen_answer_tx_video - @drawable/ic_lockscreen_answer_rx_video @string/description_target_answer_video_call @@ -100,8 +98,6 @@ @drawable/ic_lockscreen_text @drawable/ic_lockscreen_decline @drawable/ic_lockscreen_answer - @drawable/ic_lockscreen_answer_tx_video - @drawable/ic_lockscreen_answer_rx_video @string/description_target_answer_video_call @@ -126,8 +122,6 @@ @null @drawable/ic_lockscreen_decline @drawable/ic_lockscreen_answer - @drawable/ic_lockscreen_answer_tx_video - @drawable/ic_lockscreen_answer_rx_video @string/description_target_accept_upgrade_to_video_request @@ -152,26 +146,27 @@ + - Decline upgrade to video request (drag left) + TODO: This should be automatically rejected in the lower layers --> - @drawable/ic_lockscreen_answer_tx_video + @drawable/ic_lockscreen_answer_video @drawable/ic_lockscreen_decline - @string/description_target_accept_upgrade_to_video_transmit_request - @string/description_target_decline_upgrade_to_video_transmit_request + @string/description_target_accept_upgrade_to_video_request + @string/description_target_decline_upgrade_to_video_request - @drawable/ic_lockscreen_answer_rx_video + @drawable/ic_lockscreen_answer_video @drawable/ic_lockscreen_decline - @string/description_target_accept_upgrade_to_video_receive_request - @string/description_target_decline_upgrade_to_video_receive_request + @string/description_target_accept_upgrade_to_video_request + @string/description_target_decline_upgrade_to_video_request diff --git a/InCallUI/src/com/android/incallui/GlowPadWrapper.java b/InCallUI/src/com/android/incallui/GlowPadWrapper.java index 584ce65de..58a5f30ea 100644 --- a/InCallUI/src/com/android/incallui/GlowPadWrapper.java +++ b/InCallUI/src/com/android/incallui/GlowPadWrapper.java @@ -128,14 +128,6 @@ public class GlowPadWrapper extends GlowPadView implements GlowPadView.OnTrigger mAnswerListener.onAnswer(VideoProfile.VideoState.BIDIRECTIONAL, getContext()); mTargetTriggered = true; break; - case R.drawable.ic_lockscreen_answer_tx_video: - mAnswerListener.onAnswer(VideoProfile.VideoState.TX_ENABLED, getContext()); - mTargetTriggered = true; - break; - case R.drawable.ic_lockscreen_answer_rx_video: - mAnswerListener.onAnswer(VideoProfile.VideoState.RX_ENABLED, getContext()); - mTargetTriggered = true; - break; case R.drawable.ic_toolbar_video_off: InCallPresenter.getInstance().declineUpgradeRequest(getContext()); mTargetTriggered = true; -- cgit v1.2.3 From fdf53779ba6d68e28e005e3645378aea7bd76ec0 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Fri, 10 Apr 2015 12:48:22 -0700 Subject: Hide end call button when video upgrade glowpad is showing Bug: 20090411 Change-Id: I25bca70e2e2a40bbd88b55ba386d39cd796cb414 --- .../src/com/android/incallui/CallCardPresenter.java | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index b327ed64c..9a7c9855d 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -251,11 +251,9 @@ public class CallCardPresenter extends Presenter maybeShowManageConferenceCallButton(); maybeShowProgressSpinner(); - final boolean enableEndCallButton = Call.State.isConnectingOrConnected(callState) && - callState != Call.State.INCOMING && mPrimary != null; // Hide the end call button instantly if we're receiving an incoming call. - getUi().setEndCallButtonEnabled( - enableEndCallButton, callState != Call.State.INCOMING /* animate */); + getUi().setEndCallButtonEnabled(shouldShowEndCallButton(mPrimary, callState), + callState != Call.State.INCOMING /* animate */); } @Override @@ -741,6 +739,20 @@ public class CallCardPresenter extends Presenter return photo; } + private boolean shouldShowEndCallButton(Call primary, int callState) { + if (primary == null) { + return false; + } + if (!Call.State.isConnectingOrConnected(callState) || callState == Call.State.INCOMING) { + return false; + } + if (mPrimary.getSessionModificationState() + == Call.SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST) { + return false; + } + return true; + } + public interface CallCardUi extends Ui { void setVisible(boolean on); void setCallCardVisible(boolean visible); -- cgit v1.2.3 From e700d3a392ed803d3102ab3f94a3bebec4e6e991 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Fri, 10 Apr 2015 14:51:57 -0700 Subject: Initial refactoring for call buttons Create common functions to show/enable call buttons Bug: 20127747 Change-Id: I22d45597a73a75954448cb3bd5b906af06d7d690 --- .../com/android/incallui/CallButtonFragment.java | 155 ++++++++++----------- .../com/android/incallui/CallButtonPresenter.java | 85 +++++------ 2 files changed, 107 insertions(+), 133 deletions(-) diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java index 8682d65e5..a6ea334b3 100644 --- a/InCallUI/src/com/android/incallui/CallButtonFragment.java +++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java @@ -16,6 +16,8 @@ package com.android.incallui; +import static com.android.incallui.CallButtonFragment.Buttons.*; + import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; @@ -44,7 +46,6 @@ import android.widget.Toast; import android.widget.PopupMenu.OnDismissListener; import android.widget.PopupMenu.OnMenuItemClickListener; -import com.android.contacts.common.util.MaterialColorMapUtils; import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette; import java.util.ArrayList; @@ -55,8 +56,26 @@ public class CallButtonFragment extends BaseFragment implements CallButtonPresenter.CallButtonUi, OnMenuItemClickListener, OnDismissListener, View.OnClickListener { - private CompoundButton mAudioButton; private static final int INVALID_INDEX = -1; + + 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; + } + + + private CompoundButton mAudioButton; private ImageButton mChangeToVoiceButton; private CompoundButton mMuteButton; private CompoundButton mShowDialpadButton; @@ -157,7 +176,6 @@ public class CallButtonFragment int id = view.getId(); Log.d(this, "onClick(View " + view + ", id " + id + ")..."); - boolean isClickHandled = true; switch(id) { case R.id.audioButton: onAudioButtonClicked(); @@ -206,16 +224,13 @@ public class CallButtonFragment onManageVideoCallConferenceClicked(); break; default: - isClickHandled = false; Log.wtf(this, "onClick: unexpected"); - break; + return; } - if (isClickHandled) { - view.performHapticFeedback( - HapticFeedbackConstants.VIRTUAL_KEY, - HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); - } + view.performHapticFeedback( + HapticFeedbackConstants.VIRTUAL_KEY, + HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } public void updateColors() { @@ -355,23 +370,53 @@ public class CallButtonFragment } @Override - public void showAudioButton(boolean show) { - mAudioButton.setVisibility(show ? View.VISIBLE : View.GONE); - } - - @Override - public void showChangeToVoiceButton(boolean show) { - mChangeToVoiceButton.setVisibility(show ? View.VISIBLE : View.GONE); + public void showButton(int buttonId, boolean show) { + final View button = getButtonById(buttonId); + if (button != null) { + button.setVisibility(show ? View.VISIBLE : View.GONE); + } } @Override - public void enableMute(boolean enabled) { - mMuteButton.setEnabled(enabled); + public void enableButton(int buttonId, boolean enable) { + final View button = getButtonById(buttonId); + if (button != null) { + button.setEnabled(enable); + } } - @Override - public void showDialpadButton(boolean show) { - mShowDialpadButton.setVisibility(show ? View.VISIBLE : View.GONE); + private View getButtonById(int id) { + switch (id) { + case BUTTON_AUDIO: + return mAudioButton; + case BUTTON_DOWNGRADE_TO_VOICE: + return mChangeToVoiceButton; + case BUTTON_MUTE: + return mMuteButton; + case BUTTON_DIALPAD: + return mShowDialpadButton; + case BUTTON_HOLD: + return mHoldButton; + case BUTTON_SWAP: + return mSwapButton; + case BUTTON_UPGRADE_TO_VIDEO: + return mChangeToVideoButton; + case BUTTON_SWITCH_CAMERA: + return mSwitchCameraButton; + case BUTTON_ADD_CALL: + return mAddCallButton; + case BUTTON_MERGE: + return mMergeButton; + case BUTTON_PAUSE_VIDEO: + return mPauseVideoButton; + case BUTTON_MANAGE_VIDEO_CONFERENCE: + return mManageVideoCallConferenceButton; + case BUTTON_OVERFLOW: + return mOverflowButton; + default: + Log.w(this, "Invalid button id"); + return null; + } } @Override @@ -382,75 +427,15 @@ public class CallButtonFragment } @Override - public void showHoldButton(boolean show) { - mHoldButton.setVisibility(show ? View.VISIBLE : View.GONE); - } - - @Override - public void enableHold(boolean enabled) { - mHoldButton.setEnabled(enabled); - } - - @Override - public void showSwapButton(boolean show) { - mSwapButton.setVisibility(show ? View.VISIBLE : View.GONE); - } - - @Override - public void showChangeToVideoButton(boolean show) { - mChangeToVideoButton.setVisibility(show ? View.VISIBLE : View.GONE); - } - - @Override - public void enableChangeToVideoButton(boolean enable) { - mChangeToVideoButton.setEnabled(enable); - } - - @Override - public void showSwitchCameraButton(boolean show) { - mSwitchCameraButton.setVisibility(show ? View.VISIBLE : View.GONE); - } - - @Override - public void setSwitchCameraButton(boolean isBackFacingCamera) { + public void setCameraSwitched(boolean isBackFacingCamera) { mSwitchCameraButton.setSelected(isBackFacingCamera); } @Override - public void showAddCallButton(boolean show) { - Log.d(this, "show Add call button: " + show); - mAddCallButton.setVisibility(show ? View.VISIBLE : View.GONE); - } - - public void showManageConferenceVideoCallButton(boolean show) { - mManageVideoCallConferenceButton.setVisibility(show ? View.VISIBLE : View.GONE); - } - - @Override - public void showMergeButton(boolean show) { - mMergeButton.setVisibility(show ? View.VISIBLE : View.GONE); - - // If the merge button was disabled, re-enable it when hiding it. - if (!show) { - mMergeButton.setEnabled(true); - } - } - - @Override - public void showPauseVideoButton(boolean show) { - mPauseVideoButton.setVisibility(show ? View.VISIBLE : View.GONE); - } - - @Override - public void setPauseVideoButton(boolean isPaused) { + public void setVideoPaused(boolean isPaused) { mPauseVideoButton.setSelected(isPaused); } - @Override - public void showOverflowButton(boolean show) { - mOverflowButton.setVisibility(show ? View.VISIBLE : View.GONE); - } - /**The function is called when Modify Call button gets pressed. The function creates and * displays modify call options. */ @@ -526,7 +511,7 @@ public class CallButtonFragment @Override public void configureOverflowMenu(boolean showMergeMenuOption, boolean showAddMenuOption, - boolean showHoldMenuOption, boolean showSwapMenuOption, + boolean showHoldMenuOption, boolean showSwapMenuOption, boolean showManageConferenceVideoCallOption) { if (mOverflowPopup == null) { final ContextThemeWrapper contextWrapper = new ContextThemeWrapper(getActivity(), diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java index 4e840be9f..0faebfd29 100644 --- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java +++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java @@ -16,6 +16,8 @@ package com.android.incallui; +import static com.android.incallui.CallButtonFragment.Buttons.*; + import android.app.AlertDialog; import android.content.Context; import android.os.Bundle; @@ -321,7 +323,7 @@ public class CallButtonPresenter extends Presenter Date: Mon, 13 Apr 2015 13:56:27 -0700 Subject: Hide incoming video until call is connected. Changing the VideoCallPresenter so that the incoming video surface is hidden until the call becomes active. This way the remote party's profile picture is shown until the call is connected. Bug: 19820114 Bug: 20153678 Change-Id: Ifb1eeab2dc92ccd54c070248bd4efb44a113fed3 --- .../com/android/incallui/VideoCallPresenter.java | 39 ++++++++++++++-------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java index 8ee30f2b3..1d8945f31 100644 --- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java +++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java @@ -337,11 +337,11 @@ public class VideoCallPresenter extends Presenter Date: Fri, 10 Apr 2015 17:52:04 -0700 Subject: 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 --- InCallUI/res/layout/call_button_fragment.xml | 12 +- InCallUI/res/menu/incall_overflow_menu.xml | 36 ----- InCallUI/res/values/strings.xml | 25 +-- .../com/android/incallui/CallButtonFragment.java | 178 +++++++++++---------- .../com/android/incallui/CallButtonPresenter.java | 166 +++++-------------- 5 files changed, 153 insertions(+), 264 deletions(-) delete mode 100644 InCallUI/res/menu/incall_overflow_menu.xml 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 @@ + android:contentDescription="@string/audio_mode_speaker" + android:visibility="gone" /> + android:contentDescription="@string/onscreenMuteText" + android:visibility="gone" /> @@ -91,7 +93,8 @@ + android:contentDescription="@string/onscreenShowDialpadText" + android:visibility="gone" /> @@ -102,7 +105,8 @@ + android:contentDescription="@string/onscreenHoldText_unselected" + android:visibility="gone" /> - - - - - - - - - - - - - - - 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 --> Use keyboard to dial - - Hold call - - Resume call - - Add call - - Merge calls - - Swap calls - - Manage Conference - - - Hold + + Hold Call + + Resume Call - End + End Call Dialpad @@ -456,7 +447,7 @@ Emergency number - + Call substate - \u000a 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, @@ -362,19 +376,9 @@ public class CallButtonFragment mManageVideoCallConferenceButton.setEnabled(isEnabled); } - @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 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 Date: Tue, 31 Mar 2015 09:55:54 -0700 Subject: Video calling landscape changes to match specs * Call card has 4dp corners, and is 90% visible * Margins for call card * Call buttons are center aligned with end call button * Remote surface is always center aligned, tapping call card slides it in and out * Status bar is black Bug: 19668216 Change-Id: Ifea27faa5f8ff32f6be13e777ca70aa4d0c7727e --- .../drawable-land/rounded_call_card_background.xml | 23 ++++++++++++ InCallUI/res/layout-land/call_card_fragment.xml | 19 +++++----- InCallUI/res/values-land/colors.xml | 21 +++++++++++ InCallUI/res/values-land/dimens.xml | 5 +++ InCallUI/res/values/colors.xml | 2 ++ InCallUI/res/values/dimens.xml | 5 ++- .../src/com/android/incallui/CallCardFragment.java | 26 ++++++-------- .../src/com/android/incallui/InCallPresenter.java | 11 ++++-- .../com/android/incallui/VideoCallFragment.java | 42 ++++------------------ 9 files changed, 92 insertions(+), 62 deletions(-) create mode 100644 InCallUI/res/drawable-land/rounded_call_card_background.xml create mode 100644 InCallUI/res/values-land/colors.xml diff --git a/InCallUI/res/drawable-land/rounded_call_card_background.xml b/InCallUI/res/drawable-land/rounded_call_card_background.xml new file mode 100644 index 000000000..f41ecda79 --- /dev/null +++ b/InCallUI/res/drawable-land/rounded_call_card_background.xml @@ -0,0 +1,23 @@ + + + + + + + + \ No newline at end of file diff --git a/InCallUI/res/layout-land/call_card_fragment.xml b/InCallUI/res/layout-land/call_card_fragment.xml index fb880e311..edce7b233 100644 --- a/InCallUI/res/layout-land/call_card_fragment.xml +++ b/InCallUI/res/layout-land/call_card_fragment.xml @@ -28,22 +28,25 @@ android:layout_height="match_parent" android:orientation="vertical" android:elevation="@dimen/primary_call_elevation" - android:background="@color/incall_call_banner_background_color" + android:background="@drawable/rounded_call_card_background" android:paddingTop="@dimen/call_banner_primary_call_container_top_padding" android:clipChildren="false" - android:clipToPadding="false" > + android:clipToPadding="false" + android:alpha="0.9" + android:layout_margin="10dp"> - - + + + + + + #000000 + diff --git a/InCallUI/res/values-land/dimens.xml b/InCallUI/res/values-land/dimens.xml index d992ccdea..59a5a9a87 100644 --- a/InCallUI/res/values-land/dimens.xml +++ b/InCallUI/res/values-land/dimens.xml @@ -16,6 +16,11 @@ --> + + true 40dp + + 30dp diff --git a/InCallUI/res/values/colors.xml b/InCallUI/res/values/colors.xml index afc557bc1..cac382deb 100644 --- a/InCallUI/res/values/colors.xml +++ b/InCallUI/res/values/colors.xml @@ -59,6 +59,8 @@ @color/dialer_theme_color + + @color/dialer_theme_color #33999999 diff --git a/InCallUI/res/values/dimens.xml b/InCallUI/res/values/dimens.xml index 43307e8db..0739234f2 100644 --- a/InCallUI/res/values/dimens.xml +++ b/InCallUI/res/values/dimens.xml @@ -16,6 +16,9 @@ --> + + false +