diff options
Diffstat (limited to 'InCallUI/src/com')
3 files changed, 66 insertions, 39 deletions
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; @@ -88,11 +89,6 @@ public class VideoCallFragment extends BaseFragment<VideoCallPresenter, private View mVideoViews; /** - * {@code True} when the entering the activity again after a restart due to orientation change. - */ - private boolean mIsActivityRestart; - - /** * {@code True} when the layout of the activity has been completed. */ private boolean mIsLayoutComplete = false; @@ -385,12 +381,20 @@ public class VideoCallFragment extends BaseFragment<VideoCallPresenter, Log.e(this, "onClick: Presenter is null."); } } + + /** + * Returns the dimensions of the surface. + * + * @return The dimensions of the surface. + */ + public Point getSurfaceDimensions() { + return new Point(mWidth, mHeight); + } }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mIsActivityRestart = sVideoSurfacesInUse; } /** @@ -675,12 +679,6 @@ public class VideoCallFragment extends BaseFragment<VideoCallPresenter, } } - @Override - public boolean isActivityRestart() { - Log.d(this, "isActivityRestart " + mIsActivityRestart); - return mIsActivityRestart; - } - /** * @return {@code True} if the display video surface has been created. */ @@ -741,12 +739,12 @@ public class VideoCallFragment extends BaseFragment<VideoCallPresenter, params.height = height; preview.setLayoutParams(params); - int rotation = InCallPresenter.toRotationAngle(getCurrentRotation()); - int rotationAngle = 360 - rotation; - preview.setRotation(rotationAngle); - Log.d(this, "setPreviewSize: rotation=" + rotation + - " rotationAngle=" + rotationAngle); - + // The width and height are interchanged outside of this method based on the current + // orientation, so we can transform using "width", which will be either the width or + // the height. + Matrix transform = new Matrix(); + transform.setScale(-1, 1, width/2, 0); + preview.setTransform(transform); } } @@ -853,6 +851,19 @@ public class VideoCallFragment extends BaseFragment<VideoCallPresenter, } /** + * Determines the size of the preview surface. + * + * @return {@link Point} specifying the width and height of the preview surface. + */ + @Override + public Point getPreviewSize() { + if (sPreviewSurface == null) { + return null; + } + return sPreviewSurface.getSurfaceDimensions(); + } + + /** * Inflates the {@link ViewStub} containing the incoming and outgoing surfaces, if necessary, * and creates {@link VideoCallSurface} instances to track the surfaces. */ diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java index d49e2cdd9..5bd7fbe6c 100644 --- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java +++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java @@ -65,7 +65,7 @@ import android.os.SystemProperties; * When downgrading to an audio-only video state, the {@code VideoCallPresenter} nulls both * surfaces. */ -public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi> implements +public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi> implements IncomingCallListener, InCallOrientationListener, InCallStateListener, InCallDetailsListener, SurfaceChangeListener, VideoEventListener, InCallVideoCallListenerNotifier.SessionModificationListener { @@ -165,7 +165,6 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi */ private int mCurrentCallSubstate; - /** Handler which resets request state to NO_REQUEST after an interval. */ private Handler mSessionModificationResetHandler; private static final long SESSION_MODIFICATION_RESET_DELAY_MS = 3000; @@ -833,6 +832,29 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi } mPreviewSurfaceState = PreviewSurfaceState.CAPABILITIES_RECEIVED; + changePreviewDimensions(width, height); + + // 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()); + } + } + + /** + * Changes the dimensions of the preview surface. + * + * @param width The new width. + * @param height The new height. + */ + private void changePreviewDimensions(int width, int height) { + VideoCallUi ui = getUi(); + if (ui == null) { + return; + } + + // Resize the surface used to display the preview video ui.setPreviewSurfaceSize(width, height); // Configure the preview surface to the correct aspect ratio. @@ -840,14 +862,10 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi if (width > 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<VideoCallPresenter.VideoCallUi */ @Override public void onDeviceOrientationChanged(int orientation) { - Log.d(this, "onDeviceOrientationChanged: orientation=" + orientation); mDeviceOrientation = orientation; + Point previewDimensions = getUi().getPreviewSize(); + Log.d(this, "onDeviceOrientationChanged: orientation=" + orientation + " size: " + + previewDimensions); + changePreviewDimensions(previewDimensions.x, previewDimensions.y); } @Override @@ -1118,8 +1139,8 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi void setCallDataUsage(Context context, long dataUsage); void displayCallSessionEvent(int event); Point getScreenSize(); + Point getPreviewSize(); void cleanupSurfaces(); - boolean isActivityRestart(); void showCallSubstateChanged(int callSubstate); } } |