From 63ce9a33a06df1ebc5c338afcae625b19bf6c40f Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Mon, 11 May 2015 14:14:59 -0700 Subject: Handle fullscreen mode toggle when tapping contact photo. 1. Moved the fullscreen mode state tracking and logic from VideoCallPresenter to InCallPresenter (since it is more to do with the entire InCall UI rather than just the video presenter). 2. Added click handler for the contact card to toggle fullscreen video mode. Bug: 20912417 Change-Id: If1656365f7fcfcee5a902c7f5d5d2862edee1661 --- .../src/com/android/incallui/CallCardFragment.java | 8 ++- .../com/android/incallui/CallCardPresenter.java | 20 ++++++-- .../src/com/android/incallui/InCallPresenter.java | 52 +++++++++++++++++-- .../com/android/incallui/VideoCallPresenter.java | 60 +++++++--------------- 4 files changed, 87 insertions(+), 53 deletions(-) diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 611a1f4cb..43cec89de 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -23,7 +23,6 @@ import android.animation.LayoutTransition; import android.animation.ObjectAnimator; import android.app.Activity; import android.content.Context; -import android.content.res.Configuration; import android.graphics.Point; import android.graphics.drawable.AnimationDrawable; import android.graphics.drawable.Drawable; @@ -54,7 +53,6 @@ import android.widget.TextView; import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette; import com.android.contacts.common.widget.FloatingActionButtonController; -import com.android.incallui.service.PhoneNumberService; import com.android.phone.common.animation.AnimUtils; import java.util.List; @@ -223,6 +221,12 @@ public class CallCardFragment extends BaseFragment String simNumber = mgr.getLine1Number(mPrimary.getAccountHandle()); if (!showCallbackNumber && PhoneNumberUtils.compare(callbackNumber, simNumber)) { Log.d(this, "Numbers are the same (and callback number is not being forced to show);" + - " not showing the callback number"); + " not showing the callback number"); callbackNumber = null; } @@ -435,6 +435,16 @@ public class CallCardPresenter extends Presenter } } + /** + * Handles click on the contact photo by toggling fullscreen mode if the current call is a video + * call. + */ + public void onContactPhotoClick() { + if (mPrimary != null && mPrimary.isVideoCall(mContext)) { + InCallPresenter.getInstance().toggleFullscreenMode(); + } + } + private void maybeStartSearch(Call call, boolean isPrimary) { // no need to start search for conference calls which show generic info. if (call != null && !call.isConferenceCall()) { @@ -746,17 +756,17 @@ public class CallCardPresenter extends Presenter } /** - * Handles a change to the full screen video state. + * Handles a change to the fullscreen mode of the in-call UI. * - * @param isFullScreenVideo {@code True} if the application is entering full screen video mode. + * @param isFullscreenMode {@code True} if the in-call UI is entering full screen mode. */ @Override - public void onFullScreenVideoStateChanged(boolean isFullScreenVideo) { + public void onFullscreenModeChanged(boolean isFullscreenMode) { final CallCardUi ui = getUi(); if (ui == null) { return; } - ui.setCallCardVisible(!isFullScreenVideo); + ui.setCallCardVisible(!isFullscreenMode); } private boolean isPrimaryCallActive() { diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index 83d5af34e..d48c27e1d 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -98,6 +98,11 @@ public class InCallPresenter implements CallList.Listener { private boolean mAccountSelectionCancelled = false; private InCallCameraManager mInCallCameraManager = null; + /** + * Determines if the InCall UI is in fullscreen mode or not. + */ + private boolean mIsFullScreen = false; + private final android.telecom.Call.Callback mCallback = new android.telecom.Call.Callback() { @Override @@ -780,7 +785,7 @@ public class InCallPresenter implements CallList.Listener { private void notifyVideoPauseController(boolean showing) { Log.d(this, "notifyVideoPauseController: mIsChangingConfigurations=" + - mIsChangingConfigurations); + mIsChangingConfigurations); if (!mIsChangingConfigurations) { VideoPauseController.getInstance().onUiShowing(showing); } @@ -893,14 +898,51 @@ public class InCallPresenter implements CallList.Listener { } } + /** + * Toggles whether the application is in fullscreen mode or not. + * + * @return {@code true} if in-call is now in fullscreen mode. + */ + public boolean toggleFullscreenMode() { + mIsFullScreen = !mIsFullScreen; + Log.v(this, "toggleFullscreenMode = " + mIsFullScreen); + notifyFullscreenModeChange(mIsFullScreen); + return mIsFullScreen; + } + + /** + * Changes the fullscreen mode of the in-call UI. + * + * @param isFullScreen {@code true} if in-call should be in fullscreen mode, {@code false} + * otherwise. + */ + public void setFullScreen(boolean isFullScreen) { + Log.v(this, "setFullScreen = " + isFullScreen); + if (mIsFullScreen == isFullScreen) { + Log.v(this, "setFullScreen ignored as already in that state."); + return; + } + mIsFullScreen = isFullScreen; + notifyFullscreenModeChange(mIsFullScreen); + } + + /** + * @return {@code true} if the in-call ui is currently in fullscreen mode, {@code false} + * otherwise. + */ + public boolean isFullscreen() { + return mIsFullScreen; + } + + /** * Called by the {@link VideoCallPresenter} to inform of a change in full screen video status. * - * @param isFullScreenVideo {@code True} if entering full screen video mode. + * @param isFullscreenMode {@code True} if entering full screen mode. */ - public void setFullScreenVideoState(boolean isFullScreenVideo) { + public void notifyFullscreenModeChange(boolean isFullscreenMode) { for (InCallEventListener listener : mInCallEventListeners) { - listener.onFullScreenVideoStateChanged(isFullScreenVideo); + listener.onFullscreenModeChanged(isFullscreenMode); } } @@ -1564,7 +1606,7 @@ public class InCallPresenter implements CallList.Listener { * In-Call UI. Used as a means of communicating between fragments that make up the UI. */ public interface InCallEventListener { - public void onFullScreenVideoStateChanged(boolean isFullScreenVideo); + public void onFullscreenModeChanged(boolean isFullscreenMode); } public interface InCallUiListener { diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java index dc5e81fb1..e0b6da8ef 100644 --- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java +++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java @@ -28,14 +28,11 @@ import android.provider.ContactsContract; import android.telecom.AudioState; import android.telecom.CameraCapabilities; import android.telecom.Connection; -import android.telecom.Connection.VideoProvider; import android.telecom.InCallService.VideoCall; import android.telecom.VideoProfile; import android.view.Surface; -import android.view.View; import android.widget.ImageView; -import com.android.contacts.common.CallUtil; import com.android.contacts.common.ContactPhotoManager; import com.android.incallui.InCallPresenter.InCallDetailsListener; import com.android.incallui.InCallPresenter.InCallOrientationListener; @@ -71,7 +68,8 @@ import java.util.Objects; public class VideoCallPresenter extends Presenter implements IncomingCallListener, InCallOrientationListener, InCallStateListener, InCallDetailsListener, SurfaceChangeListener, VideoEventListener, - InCallVideoCallCallbackNotifier.SessionModificationListener { + InCallVideoCallCallbackNotifier.SessionModificationListener, + InCallPresenter.InCallEventListener { public static final String TAG = "VideoCallPresenter"; /** @@ -82,7 +80,7 @@ public class VideoCallPresenter extends Presenter