diff options
Diffstat (limited to 'InCallUI')
13 files changed, 99 insertions, 218 deletions
diff --git a/InCallUI/res/layout/call_card_fragment.xml b/InCallUI/res/layout/call_card_fragment.xml index 09e148512..03bbe87b8 100644 --- a/InCallUI/res/layout/call_card_fragment.xml +++ b/InCallUI/res/layout/call_card_fragment.xml @@ -44,21 +44,22 @@ android:layout_height="wrap_content" android:layout_gravity="center_horizontal" /> - <!-- Secondary "Call info" block, for the background ("on hold") call. --> - <include layout="@layout/secondary_call_info" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_gravity="bottom" /> - </LinearLayout> <!-- Placeholder for the dialpad which is replaced with the dialpad fragment when shown. --> <FrameLayout android:id="@+id/answer_and_dialpad_container" android:layout_width="match_parent" - android:elevation="7dp" + android:elevation="@dimen/dialpad_elevation" android:layout_height="match_parent" /> + <!-- Secondary "Call info" block, for the background ("on hold") call. --> + <include layout="@layout/secondary_call_info" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:elevation="4dp" + android:layout_alignParentBottom="true" /> + <FrameLayout android:id="@+id/floating_end_call_action_button_container" android:layout_width="@dimen/end_call_floating_action_button_diameter" @@ -77,6 +78,33 @@ </FrameLayout> + <!-- Progress spinner, useful for indicating pending operations such as upgrade to video. --> + <FrameLayout + android:id="@+id/progressSpinner" + android:background="#63000000" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_centerHorizontal="true" + android:layout_centerVertical="true" + android:visibility="gone" > + + <ProgressBar + android:id="@+id/progress_bar" + style="@android:style/Widget.Material.ProgressBar" + android:layout_gravity="center" + android:layout_width="48dp" + android:layout_height="48dp" + android:indeterminate="true" /> + + </FrameLayout> + + <fragment android:name="com.android.incallui.VideoCallFragment" + android:layout_alignParentStart="true" + android:layout_gravity="start|center_vertical" + android:id="@+id/videoCallFragment" + android:layout_width="match_parent" + android:layout_height="match_parent" /> + <FrameLayout android:layout_height="match_parent" android:layout_width="0dp" @@ -125,33 +153,6 @@ android:layout_height="wrap_content" android:layout_alignTop="@id/photoLarge" /> - <!-- Progress spinner, useful for indicating pending operations such as upgrade to video. --> - <FrameLayout - android:id="@+id/progressSpinner" - android:background="#63000000" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_centerHorizontal="true" - android:layout_centerVertical="true" - android:visibility="gone" > - - <ProgressBar - android:id="@+id/progress_bar" - style="@android:style/Widget.Material.ProgressBar" - android:layout_gravity="center" - android:layout_width="48dp" - android:layout_height="48dp" - android:indeterminate="true" /> - - </FrameLayout> - - <fragment android:name="com.android.incallui.VideoCallFragment" - android:layout_alignParentStart="true" - android:layout_gravity="start|center_vertical" - android:id="@+id/videoCallFragment" - android:layout_width="match_parent" - android:layout_height="match_parent" /> - </FrameLayout> </RelativeLayout> diff --git a/InCallUI/res/layout/video_call_views.xml b/InCallUI/res/layout/video_call_views.xml index b0c6ce2ad..d514f6df1 100644 --- a/InCallUI/res/layout/video_call_views.xml +++ b/InCallUI/res/layout/video_call_views.xml @@ -29,7 +29,7 @@ <FrameLayout android:id="@+id/previewVideoContainer" android:layout_width="70dp" - android:layout_height="120dp" + android:layout_height="0dp" android:layout_gravity="bottom|right" android:layout_margin="@dimen/video_preview_margin" > diff --git a/InCallUI/res/values-h600dp/dimens.xml b/InCallUI/res/values-h600dp/dimens.xml index 12f48d9b5..dda755a3e 100644 --- a/InCallUI/res/values-h600dp/dimens.xml +++ b/InCallUI/res/values-h600dp/dimens.xml @@ -16,9 +16,16 @@ --> <resources> + <!-- Whether or not this layout displays a large photo. --> + <bool name="has_large_photo">true</bool> + <dimen name="call_banner_height">90dp</dimen> <dimen name="end_call_button_margin_bottom">15dp</dimen> <dimen name="floating_action_button_vertical_offset">-24dp</dimen> + + <dimen name="dialpad_elevation">2dp</dimen> + + <dimen name="video_preview_margin">20dp</dimen> </resources> diff --git a/InCallUI/res/values-w600dp-land/dimens.xml b/InCallUI/res/values-w600dp-land/dimens.xml index 59a5a9a87..112ec5f09 100644 --- a/InCallUI/res/values-w600dp-land/dimens.xml +++ b/InCallUI/res/values-w600dp-land/dimens.xml @@ -16,11 +16,20 @@ --> <resources> + <!-- Whether or not this layout displays a large photo. --> + <bool name="has_large_photo">true</bool> + <!-- Whether or not the landscape mode layout is currently being used --> <bool name="is_layout_landscape">true</bool> + <!-- Height and width of the in-call buttons. --> <dimen name="in_call_button_dimension">40dp</dimen> + <!-- Margin underneath the call buttons. This is used only in landscape mode and is sized so that the call buttons are center aligned with the end call button. --> <dimen name="call_buttons_bottom_margin">30dp</dimen> + + <dimen name="dialpad_elevation">2dp</dimen> + + <dimen name="video_preview_margin">20dp</dimen> </resources> diff --git a/InCallUI/res/values/dimens.xml b/InCallUI/res/values/dimens.xml index d6c47a2c7..59da7860a 100644 --- a/InCallUI/res/values/dimens.xml +++ b/InCallUI/res/values/dimens.xml @@ -16,6 +16,9 @@ --> <resources> + <!-- Whether or not this layout displays a large photo. --> + <bool name="has_large_photo">false</bool> + <!-- Whether or not the landscape mode layout is currently being used --> <bool name="is_layout_landscape">false</bool> @@ -57,7 +60,7 @@ <!-- Height and width of the in-call buttons. --> <dimen name="in_call_button_dimension">48dp</dimen> - <dimen name="primary_call_elevation">5dp</dimen> + <dimen name="primary_call_elevation">0dp</dimen> <dimen name="dialpad_elevation">2dp</dimen> <!-- The InCallUI dialpad will sometimes want digits sizes that are different from dialer. @@ -114,7 +117,7 @@ width of the preview. When in landscape, this is the height. --> <dimen name="video_preview_small_dimension">90dp</dimen> - <dimen name="video_preview_margin">20dp</dimen> + <dimen name="video_preview_margin">0dp</dimen> <dimen name="end_call_floating_action_button_diameter">72dp</dimen> <dimen name="end_call_floating_action_button_small_diameter">56dp</dimen> diff --git a/InCallUI/src/com/android/incallui/AnswerPresenter.java b/InCallUI/src/com/android/incallui/AnswerPresenter.java index 6e1fb3cfb..2bd3629e7 100644 --- a/InCallUI/src/com/android/incallui/AnswerPresenter.java +++ b/InCallUI/src/com/android/incallui/AnswerPresenter.java @@ -77,7 +77,7 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi> showAnswerUi(false); Log.d(this, "declining upgrade request id: "); CallList.getInstance().removeCallUpdateListener(mCallId, this); - InCallPresenter.getInstance().declineUpgradeRequest(getUi().getContext()); + InCallPresenter.getInstance().declineUpgradeRequest(); } if (!call.getId().equals(mCallId)) { // A new call is coming in. diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 1a9f283b1..ad7269059 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -115,6 +115,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr private int mFabNormalDiameter; private int mFabSmallDiameter; private boolean mIsLandscape; + private boolean mHasLargePhoto; private boolean mIsDialpadShowing; // Primary caller info @@ -1333,7 +1334,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr int offsetY = 0; if (!mIsDialpadShowing) { offsetY = mFloatingActionButtonVerticalOffset; - if (mSecondaryCallInfo.isShown()) { + if (mSecondaryCallInfo.isShown() && mHasLargePhoto) { offsetY -= mSecondaryCallInfo.getHeight(); } } @@ -1363,6 +1364,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr } mIsLandscape = getResources().getBoolean(R.bool.is_layout_landscape); + mHasLargePhoto = getResources().getBoolean(R.bool.has_large_photo); final ViewGroup parent = ((ViewGroup) mPrimaryCallCardContainer.getParent()); final ViewTreeObserver observer = parent.getViewTreeObserver(); diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index 7749118de..2acdc470f 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -278,7 +278,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> mPrimary.getState() == Call.State.INCOMING); updatePrimaryDisplayInfo(); maybeStartSearch(mPrimary, true); - mPrimary.setSessionModificationState(Call.SessionModificationState.NO_REQUEST); + maybeClearSessionModificationState(mPrimary); } if (previousPrimary != null && mPrimary == null) { @@ -298,7 +298,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> mSecondary.getState() == Call.State.INCOMING); updateSecondaryDisplayInfo(); maybeStartSearch(mSecondary, false); - mSecondary.setSessionModificationState(Call.SessionModificationState.NO_REQUEST); + maybeClearSessionModificationState(mSecondary); } // Start/stop timers. @@ -563,6 +563,13 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> } } + private void maybeClearSessionModificationState(Call call) { + if (call.getSessionModificationState() != + Call.SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST) { + call.setSessionModificationState(Call.SessionModificationState.NO_REQUEST); + } + } + /** * Starts a query for more contact data for the save primary and secondary calls. */ diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index f50da8dbd..c51a561bf 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -78,7 +78,8 @@ import java.util.concurrent.atomic.AtomicBoolean; * TODO: This class has become more of a state machine at this point. Consider renaming. */ public class InCallPresenter implements CallList.Listener, - CircularRevealFragment.OnCircularRevealCompleteListener { + CircularRevealFragment.OnCircularRevealCompleteListener, + InCallVideoCallCallbackNotifier.SessionModificationListener { private static final String EXTRA_FIRST_TIME_SHOWN = "com.android.incallui.intent.extra.FIRST_TIME_SHOWN"; @@ -387,6 +388,7 @@ public class InCallPresenter implements CallList.Listener, mCallList.addListener(this); VideoPauseController.getInstance().setUp(this); + InCallVideoCallCallbackNotifier.getInstance().addSessionModificationListener(this); mFilteredQueryHandler = new FilteredNumberAsyncQueryHandler(context.getContentResolver()); mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); @@ -413,6 +415,7 @@ public class InCallPresenter implements CallList.Listener, mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); VideoPauseController.getInstance().tearDown(); + InCallVideoCallCallbackNotifier.getInstance().removeSessionModificationListener(this); } private void attemptFinishActivity() { @@ -726,6 +729,17 @@ public class InCallPresenter implements CallList.Listener, } } + @Override + public void onUpgradeToVideoRequest(Call call, int videoState) { + Log.d(this, "onUpgradeToVideoRequest call = " + call + " video state = " + videoState); + + if (call == null) { + return; + } + + call.setRequestedVideoState(videoState); + } + /** * Given the call list, return the state in which the in-call screen should be. */ @@ -980,6 +994,14 @@ public class InCallPresenter implements CallList.Listener, } } + /*package*/ + void declineUpgradeRequest() { + // Pass mContext if InCallActivity is destroyed. + // Ex: When user pressed back key while in active call and + // then modify request is received followed by MT call. + declineUpgradeRequest(mInCallActivity != null ? mInCallActivity : mContext); + } + /** * Returns true if the incall app is the foreground application. */ diff --git a/InCallUI/src/com/android/incallui/InCallVideoCallCallback.java b/InCallUI/src/com/android/incallui/InCallVideoCallCallback.java index 76f8c09fc..99e6d5129 100644 --- a/InCallUI/src/com/android/incallui/InCallVideoCallCallback.java +++ b/InCallUI/src/com/android/incallui/InCallVideoCallCallback.java @@ -55,10 +55,8 @@ public class InCallVideoCallCallback extends VideoCall.Callback { boolean wasVideoCall = VideoUtils.isVideoCall(previousVideoState); boolean isVideoCall = VideoUtils.isVideoCall(newVideoState); - // Check for upgrades to video and downgrades to audio. - if (wasVideoCall && !isVideoCall) { - InCallVideoCallCallbackNotifier.getInstance().downgradeToAudio(mCall); - } else if (previousVideoState != newVideoState) { + // Check for upgrades to video. + if (!wasVideoCall && isVideoCall && previousVideoState != newVideoState) { InCallVideoCallCallbackNotifier.getInstance().upgradeToVideoRequest(mCall, newVideoState); } @@ -93,21 +91,8 @@ public class InCallVideoCallCallback extends VideoCall.Callback { Call.SessionModificationState.REQUEST_FAILED); } } - InCallVideoCallCallbackNotifier.getInstance().upgradeToVideoFail(status, mCall); - } else if (requestedProfile != null && responseProfile != null) { - boolean modifySucceeded = requestedProfile.getVideoState() == - responseProfile.getVideoState(); - boolean isVideoCall = VideoUtils.isVideoCall(responseProfile.getVideoState()); - if (modifySucceeded && isVideoCall) { - InCallVideoCallCallbackNotifier.getInstance().upgradeToVideoSuccess(mCall); - } else if (!modifySucceeded && isVideoCall) { - InCallVideoCallCallbackNotifier.getInstance().upgradeToVideoFail(status, mCall); - } else if (modifySucceeded && !isVideoCall) { - InCallVideoCallCallbackNotifier.getInstance().downgradeToAudio(mCall); - } - } else { - Log.d(this, "onSessionModifyResponseReceived request and response Profiles are null"); } + // Finally clear the outstanding request. mCall.setSessionModificationState(Call.SessionModificationState.NO_REQUEST); } diff --git a/InCallUI/src/com/android/incallui/InCallVideoCallCallbackNotifier.java b/InCallUI/src/com/android/incallui/InCallVideoCallCallbackNotifier.java index dfb645bfc..bb7529205 100644 --- a/InCallUI/src/com/android/incallui/InCallVideoCallCallbackNotifier.java +++ b/InCallUI/src/com/android/incallui/InCallVideoCallCallbackNotifier.java @@ -135,39 +135,6 @@ public class InCallVideoCallCallbackNotifier { } /** - * Inform listeners of a successful response to a video request for a call. - * - * @param call The call. - */ - public void upgradeToVideoSuccess(Call call) { - for (SessionModificationListener listener : mSessionModificationListeners) { - listener.onUpgradeToVideoSuccess(call); - } - } - - /** - * Inform listeners of an unsuccessful response to a video request for a call. - * - * @param call The call. - */ - public void upgradeToVideoFail(int status, Call call) { - for (SessionModificationListener listener : mSessionModificationListeners) { - listener.onUpgradeToVideoFail(status, call); - } - } - - /** - * Inform listeners of a downgrade to audio. - * - * @param call The call. - */ - public void downgradeToAudio(Call call) { - for (SessionModificationListener listener : mSessionModificationListeners) { - listener.onDowngradeToAudio(call); - } - } - - /** * Inform listeners of a call session event. * * @param event The call session event. @@ -240,41 +207,16 @@ public class InCallVideoCallCallbackNotifier { } /** - * Listener interface for any class that wants to be notified of upgrade to video and downgrade - * to audio session modification requests. + * Listener interface for any class that wants to be notified of upgrade to video request. */ public interface SessionModificationListener { /** * Called when a peer request is received to upgrade an audio-only call to a video call. * * @param call The call the request was received for. - * @param videoState The video state that the request wants to upgrade to. + * @param videoState The requested video state. */ public void onUpgradeToVideoRequest(Call call, int videoState); - - /** - * Called when a request to a peer to upgrade an audio-only call to a video call is - * successful. - * - * @param call The call the request was successful for. - */ - public void onUpgradeToVideoSuccess(Call call); - - /** - * Called when a request to a peer to upgrade an audio-only call to a video call is - * NOT successful. This can be if the peer chooses rejects the the video call, or if the - * peer does not support video calling, or if there is some error in sending the request. - * - * @param call The call the request was successful for. - */ - public void onUpgradeToVideoFail(int status, Call call); - - /** - * Called when a call has been downgraded to audio-only. - * - * @param call The call which was downgraded to audio-only. - */ - public void onDowngradeToAudio(Call call); } /** diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java index ebdf82048..2b6bc09a2 100644 --- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java +++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java @@ -68,7 +68,6 @@ import java.util.Objects; public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi> implements IncomingCallListener, InCallOrientationListener, InCallStateListener, InCallDetailsListener, SurfaceChangeListener, VideoEventListener, - InCallVideoCallCallbackNotifier.SessionModificationListener, InCallPresenter.InCallEventListener { public static final String TAG = "VideoCallPresenter"; @@ -241,7 +240,6 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi // Register for surface and video events from {@link InCallVideoCallListener}s. InCallVideoCallCallbackNotifier.getInstance().addSurfaceChangeListener(this); InCallVideoCallCallbackNotifier.getInstance().addVideoEventListener(this); - InCallVideoCallCallbackNotifier.getInstance().addSessionModificationListener(this); mCurrentVideoState = VideoProfile.STATE_AUDIO_ONLY; mCurrentCallState = Call.State.INVALID; } @@ -268,7 +266,6 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi InCallVideoCallCallbackNotifier.getInstance().removeSurfaceChangeListener(this); InCallVideoCallCallbackNotifier.getInstance().removeVideoEventListener(this); - InCallVideoCallCallbackNotifier.getInstance().removeSessionModificationListener(this); } /** @@ -992,57 +989,6 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi } /** - * Handles an incoming upgrade to video request. - * - * @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) { - Log.d(this, "onUpgradeToVideoRequest call = " + call + " new video state = " + videoState); - if (mPrimaryCall == null || !Call.areSame(mPrimaryCall, call)) { - Log.w(this, "UpgradeToVideoRequest received for non-primary call"); - } - - if (call == null) { - return; - } - - call.setRequestedVideoState(videoState); - } - - @Override - public void onUpgradeToVideoSuccess(Call call) { - Log.d(this, "onUpgradeToVideoSuccess call=" + call); - if (mPrimaryCall == null || !Call.areSame(mPrimaryCall, call)) { - Log.w(this, "UpgradeToVideoSuccess received for non-primary call"); - } - - if (call == null) { - return; - } - } - - @Override - public void onUpgradeToVideoFail(int status, Call call) { - Log.d(this, "onUpgradeToVideoFail call=" + call); - if (mPrimaryCall == null || !Call.areSame(mPrimaryCall, call)) { - Log.w(this, "UpgradeToVideoFail received for non-primary call"); - } - - if (call == null) { - return; - } - } - - @Override - public void onDowngradeToAudio(Call call) { - call.setSessionModificationState(Call.SessionModificationState.NO_REQUEST); - // exit video mode - exitVideoMode(); - } - - /** * Sets the preview surface size based on the current device orientation. * See: {@link InCallOrientationEventListener#SCREEN_ORIENTATION_0}, * {@link InCallOrientationEventListener#SCREEN_ORIENTATION_90}, diff --git a/InCallUI/src/com/android/incallui/VideoPauseController.java b/InCallUI/src/com/android/incallui/VideoPauseController.java index 070448ee9..a529d20d3 100644 --- a/InCallUI/src/com/android/incallui/VideoPauseController.java +++ b/InCallUI/src/com/android/incallui/VideoPauseController.java @@ -27,8 +27,7 @@ import com.google.common.base.Preconditions; * This class is responsible for generating video pause/resume requests when the InCall UI is sent * to the background and subsequently brought back to the foreground. */ -class VideoPauseController implements InCallStateListener, IncomingCallListener, - SessionModificationListener { +class VideoPauseController implements InCallStateListener, IncomingCallListener { private static final String TAG = "VideoPauseController"; /** @@ -105,7 +104,6 @@ class VideoPauseController implements InCallStateListener, IncomingCallListener, mInCallPresenter = Preconditions.checkNotNull(inCallPresenter); mInCallPresenter.addListener(this); mInCallPresenter.addIncomingCallListener(this); - InCallVideoCallCallbackNotifier.getInstance().addSessionModificationListener(this); } /** @@ -114,7 +112,6 @@ class VideoPauseController implements InCallStateListener, IncomingCallListener, */ public void tearDown() { log("tearDown..."); - InCallVideoCallCallbackNotifier.getInstance().removeSessionModificationListener(this); mInCallPresenter.removeListener(this); mInCallPresenter.removeIncomingCallListener(this); clear(); @@ -260,46 +257,6 @@ class VideoPauseController implements InCallStateListener, IncomingCallListener, } /** - * 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 is brought to the foreground. Sends a session modification request to resume * the outgoing video. */ |