summaryrefslogtreecommitdiff
path: root/InCallUI/src/com
diff options
context:
space:
mode:
authorTyler Gunn <tgunn@google.com>2015-05-04 08:45:38 -0700
committerTyler Gunn <tgunn@google.com>2015-05-06 10:18:34 -0700
commit8e8824b65575c130c531ed889f07488eff05cf1d (patch)
tree961b106faf8ce76bb05d5494e503b38dabbcd59c /InCallUI/src/com
parented8488149b8d842ee86b4c209d0f39d71f004146 (diff)
Auto fullscreen mode when starting a video call.
- Added code to VideoCallPresenter to automatically enter fullscreen mode once a video call starts. Bug: 19850117 Change-Id: I801433243df556c3398ad82a60fc738bdfb35f79
Diffstat (limited to 'InCallUI/src/com')
-rw-r--r--InCallUI/src/com/android/incallui/VideoCallPresenter.java93
1 files changed, 92 insertions, 1 deletions
diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java
index 87843f907..6309acbe7 100644
--- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java
@@ -22,6 +22,8 @@ import android.database.Cursor;
import android.graphics.Point;
import android.net.Uri;
import android.os.AsyncTask;
+import android.os.Handler;
+import android.os.Looper;
import android.provider.ContactsContract;
import android.telecom.AudioState;
import android.telecom.CameraCapabilities;
@@ -75,6 +77,22 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi
public static final boolean DEBUG = false;
/**
+ * Runnable which is posted to schedule automatically entering fullscreen mode.
+ */
+ private Runnable mAutoFullscreenRunnable = new Runnable() {
+ @Override
+ public void run() {
+ if (mAutoFullScreenPending) {
+ Log.v(this, "Automatically entering fullscreen mode.");
+ setFullScreen(true);
+ mAutoFullScreenPending = false;
+ } else {
+ Log.v(this, "Skipping scheduled fullscreen mode.");
+ }
+ }
+ };
+
+ /**
* Determines the device orientation (portrait/lanscape).
*/
public int getDeviceOrientation() {
@@ -174,6 +192,29 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi
private ContactInfoCache.ContactCacheEntry mProfileInfo = null;
/**
+ * UI thread handler used for delayed task execution.
+ */
+ private Handler mHandler;
+
+ /**
+ * Determines whether video calls should automatically enter full screen mode after
+ * {@link #mAutoFullscreenTimeoutMillis} milliseconds.
+ */
+ private boolean mIsAutoFullscreenEnabled = false;
+
+ /**
+ * Determines the number of milliseconds after which a video call will automatically enter
+ * fullscreen mode. Requires {@link #mIsAutoFullscreenEnabled} to be {@code true}.
+ */
+ private int mAutoFullscreenTimeoutMillis = 0;
+
+ /**
+ * Determines if the countdown is currently running to automatically enter full screen video
+ * mode.
+ */
+ private boolean mAutoFullScreenPending = false;
+
+ /**
* Initializes the presenter.
*
* @param context The current context.
@@ -182,6 +223,11 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi
mContext = context;
mMinimumVideoDimension = mContext.getResources().getDimension(
R.dimen.video_preview_small_dimension);
+ mHandler = new Handler(Looper.getMainLooper());
+ mIsAutoFullscreenEnabled = mContext.getResources()
+ .getBoolean(R.bool.video_call_auto_fullscreen);
+ mAutoFullscreenTimeoutMillis = mContext.getResources().getInteger(
+ R.integer.video_call_auto_fullscreen_timeout);
}
/**
@@ -325,6 +371,21 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi
private void toggleFullScreen() {
mIsFullScreen = !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) {
+ mIsFullScreen = isFullScreen;
InCallPresenter.getInstance().setFullScreenVideoState(mIsFullScreen);
}
@@ -622,6 +683,8 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi
updateAudioMode(true);
mIsVideoMode = true;
+
+ maybeAutoEnterFullscreen();
}
//TODO: Move this into Telecom. InCallUI should not be this close to audio functionality.
@@ -981,7 +1044,6 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi
* @param width peer width
* @param height peer height
*/
-
private void setDisplayVideoSize(int width, int height) {
Log.d(this, "setDisplayVideoSize:Received peer width=" + width + " peer height=" + height);
VideoCallUi ui = getUi();
@@ -1003,6 +1065,35 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi
ui.setDisplayVideoSize(size.x, size.y);
}
+ /**
+ * Schedules auto-entering of fullscreen mode.
+ */
+ public void maybeAutoEnterFullscreen() {
+ if (!mIsAutoFullscreenEnabled) {
+ return;
+ }
+
+ if (mAutoFullScreenPending) {
+ Log.v(this, "maybeAutoEnterFullscreen : already pending.");
+ return;
+ }
+ Log.v(this, "maybeAutoEnterFullscreen : scheduled");
+ mAutoFullScreenPending = true;
+ mHandler.postDelayed(mAutoFullscreenRunnable, mAutoFullscreenTimeoutMillis);
+ }
+
+ /**
+ * Cancels pending auto fullscreen mode.
+ */
+ public void cancelAutoFullScreen() {
+ if (!mAutoFullScreenPending) {
+ Log.v(this, "cancelAutoFullScreen : none pending.");
+ return;
+ }
+ Log.v(this, "cancelAutoFullScreen : cancelling pending");
+ mAutoFullScreenPending = false;
+ }
+
private static boolean isAudioRouteEnabled(int audioRoute, int audioRouteMask) {
return ((audioRoute & audioRouteMask) != 0);
}