From 9e0d3a386a48d5f32dacb45bab96f0ea5752be36 Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Mon, 13 Apr 2015 16:24:21 -0700 Subject: Fix orientation of preview surface when device rotated. - Cleaned up some unused methods in InCallActivity. - In onDeviceOrientationChanged, handle orientatoin change by resizing surface. - Fixed setPreviewSize which was not rotating the surface the appropriate way (ensured it was setting a transform on the surface, and also made sure that the correct dimensions were being passed in). Bug: 19850018 Change-Id: Ia9324ce6bad5a797839e69ba20244f2bcc44acb5 --- .../src/com/android/incallui/InCallActivity.java | 15 +++---- .../com/android/incallui/VideoCallFragment.java | 47 +++++++++++++--------- .../com/android/incallui/VideoCallPresenter.java | 43 +++++++++++++++----- 3 files changed, 66 insertions(+), 39 deletions(-) (limited to 'InCallUI/src/com/android/incallui') diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index 873c288a4..601a5155d 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -448,16 +448,11 @@ public class InCallActivity extends Activity { return false; } - @Override - public void onConfigurationChanged(Configuration config) { - InCallPresenter.getInstance().getProximitySensor().onConfigurationChanged(config); - Log.d(this, "onConfigurationChanged "+config.orientation); - - doOrientationChanged(config.orientation); - super.onConfigurationChanged(config); - } - - + /** + * Handles changes in device orientation. + * + * @param orientation The new device orientation. + */ private void doOrientationChanged(int orientation) { Log.d(this, "doOrientationChanged prevOrientation=" + sCurrentOrientation + " newOrientation=" + orientation); diff --git a/InCallUI/src/com/android/incallui/VideoCallFragment.java b/InCallUI/src/com/android/incallui/VideoCallFragment.java index 11b5bc65f..1d711a882 100644 --- a/InCallUI/src/com/android/incallui/VideoCallFragment.java +++ b/InCallUI/src/com/android/incallui/VideoCallFragment.java @@ -19,6 +19,7 @@ package com.android.incallui; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; +import android.graphics.Matrix; import android.graphics.Point; import android.graphics.SurfaceTexture; import android.os.Bundle; @@ -87,11 +88,6 @@ public class VideoCallFragment extends BaseFragment implements +public class VideoCallPresenter extends Presenter implements IncomingCallListener, InCallOrientationListener, InCallStateListener, InCallDetailsListener, SurfaceChangeListener, VideoEventListener, InCallVideoCallListenerNotifier.SessionModificationListener { @@ -165,7 +165,6 @@ public class VideoCallPresenter extends Presenter 0 && height > 0) { aspectRatio = (float) width / (float) height; } - setPreviewSize(mDeviceOrientation, aspectRatio); - // Check if the preview surface is ready yet; if it is, set it on the {@code VideoCall}. - // If it not yet ready, it will be set when when creation completes. - if (ui.isPreviewVideoSurfaceCreated()) { - mPreviewSurfaceState = PreviewSurfaceState.SURFACE_SET; - mVideoCall.setPreviewSurface(ui.getPreviewVideoSurface()); - } + // Resize the textureview housing the preview video and rotate it appropriately based on + // the device orientation + setPreviewSize(mDeviceOrientation, aspectRatio); } /** @@ -889,8 +907,11 @@ public class VideoCallPresenter extends Presenter