diff options
author | Tyler Gunn <tgunn@google.com> | 2015-05-11 14:14:59 -0700 |
---|---|---|
committer | Tyler Gunn <tgunn@google.com> | 2015-05-11 14:14:59 -0700 |
commit | 63ce9a33a06df1ebc5c338afcae625b19bf6c40f (patch) | |
tree | 8b016b4a83280468153fbcf3cd97026a0b602627 | |
parent | 545b5acda593e85e3afd22fed2de89f0c1ed08b4 (diff) |
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
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<CallCardPresenter, CallCardPr mSecondaryCallInfo = view.findViewById(R.id.secondary_call_info); mSecondaryCallProviderInfo = view.findViewById(R.id.secondary_call_provider_info); mPhoto = (ImageView) view.findViewById(R.id.photo); + mPhoto.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + getPresenter().onContactPhotoClick(); + } + }); mCallStateIcon = (ImageView) view.findViewById(R.id.callStateIcon); mCallStateVideoCallIcon = (ImageView) view.findViewById(R.id.videoCallIcon); mCallStateLabel = (TextView) view.findViewById(R.id.callStateLabel); diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index 9a5f96414..fcbe16794 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -405,7 +405,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> 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<CallCardPresenter.CallCardUi> } } + /** + * 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<CallCardPresenter.CallCardUi> } /** - * 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); } @@ -894,13 +899,50 @@ 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<VideoCallPresenter.VideoCallUi> 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<VideoCallPresenter.VideoCallUi public void run() { if (mAutoFullScreenPending) { Log.v(this, "Automatically entering fullscreen mode."); - setFullScreen(true); + InCallPresenter.getInstance().setFullScreen(true); mAutoFullScreenPending = false; } else { Log.v(this, "Skipping scheduled fullscreen mode."); @@ -168,11 +166,6 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi private int mPreviewSurfaceState = PreviewSurfaceState.NONE; /** - * Determines whether the video surface is in full-screen mode. - */ - private boolean mIsFullScreen = false; - - /** * Saves the audio mode which was selected prior to going into a video call. */ private static int sPrevVideoAudioMode = AudioModeProvider.AUDIO_MODE_INVALID; @@ -367,31 +360,6 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi } } - private void toggleFullScreen() { - mIsFullScreen = !mIsFullScreen; - Log.v(this, "toggleFullScreen = " + mIsFullScreen); - // Ensure we cancel any scheduled auto activation of fullscreen mode as the user's setting - // should override any automatic operation. - cancelAutoFullScreen(); - InCallPresenter.getInstance().setFullScreenVideoState(mIsFullScreen); - } - - /** - * Sets the current full screen mode. - * - * @param isFullScreen {@code true} if full screen mode should be active, {@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; - InCallPresenter.getInstance().setFullScreenVideoState(mIsFullScreen); - } - /** * Handles clicks on the video surfaces by toggling full screen state. * Informs the {@link InCallPresenter} of the change so that it can inform the @@ -400,7 +368,8 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi * @param surfaceId The video surface receiving the click. */ public void onSurfaceClick(int surfaceId) { - toggleFullScreen(); + boolean isFullscreen = InCallPresenter.getInstance().toggleFullscreenMode(); + Log.v(this, "toggleFullScreen = " + isFullscreen); } /** @@ -485,6 +454,16 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi maybeAutoEnterFullscreen(currentCall); } + /** + * Handles a change to the fullscreen mode of the app. + * + * @param isFullscreenMode {@code true} if the app is now fullscreen, {@code false} otherwise. + */ + @Override + public void onFullscreenModeChanged(boolean isFullscreenMode) { + cancelAutoFullScreen(); + } + private void checkForVideoStateChange(Call call) { final boolean isVideoCall = CallUtils.isVideoCall(call); final boolean hasVideoStateChanged = mCurrentVideoState != call.getVideoState(); @@ -773,9 +752,7 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi showVideoUi(VideoProfile.VideoState.AUDIO_ONLY, Call.State.ACTIVE); enableCamera(mVideoCall, false); - - Log.d(this, "exitVideoMode mIsFullScreen: " + mIsFullScreen); - setFullScreen(false); + InCallPresenter.getInstance().setFullScreen(false); mIsVideoMode = false; } @@ -1092,7 +1069,7 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi } if (!CallUtils.isVideoCall(call) || call.getState() == Call.State.INCOMING) { - setFullScreen(false); + InCallPresenter.getInstance().setFullScreen(false); } } @@ -1113,7 +1090,8 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi if (call == null || ( call != null && (call.getState() != Call.State.ACTIVE || - !CallUtils.isVideoCall(call)) || mIsFullScreen)) { + !CallUtils.isVideoCall(call)) || + InCallPresenter.getInstance().isFullscreen())) { // Ensure any previously scheduled attempt to enter fullscreen is cancelled. cancelAutoFullScreen(); return; |