From bc23809b1567fef4306147c9a08a379e8fb1445f Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 11 Dec 2012 14:36:07 +0100 Subject: [PATCH] Fix zoom in landscape & improved algorithm --- src/org/linphone/VideoCallFragment.java | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/org/linphone/VideoCallFragment.java b/src/org/linphone/VideoCallFragment.java index 6c7772557..a6dcf2b09 100644 --- a/src/org/linphone/VideoCallFragment.java +++ b/src/org/linphone/VideoCallFragment.java @@ -171,7 +171,11 @@ public class VideoCallFragment extends Fragment implements OnGestureListener, On public boolean onScale(CompatibilityScaleGestureDetector detector) { mZoomFactor *= detector.getScaleFactor(); // Don't let the object get too small or too large. - mZoomFactor = Math.max(0.1f, Math.min(mZoomFactor, ((float) mVideoView.getHeight()) / LinphoneManager.getLc().getPreferredVideoSize().height)); + // Zoom to make the video fill the screen vertically + float portraitZoomFactor = ((float) mVideoView.getHeight()) / (float) ((3 * mVideoView.getWidth()) / 4); + // Zoom to make the video fill the screen horizontally + float landscapeZoomFactor = ((float) mVideoView.getWidth()) / (float) ((3 * mVideoView.getHeight()) / 4); + mZoomFactor = Math.max(0.1f, Math.min(mZoomFactor, Math.max(portraitZoomFactor, landscapeZoomFactor))); LinphoneManager.getLc().getCurrentCall().zoomVideo(mZoomFactor, mZoomCenterX, mZoomCenterY); return true; @@ -187,11 +191,20 @@ public class VideoCallFragment extends Fragment implements OnGestureListener, On } else if(distanceX < 0 && mZoomCenterX > 0) { mZoomCenterX -= 0.01; } + if (distanceY < 0 && mZoomCenterY < 1) { + mZoomCenterY += 0.01; + } else if(distanceY > 0 && mZoomCenterY > 0) { + mZoomCenterY -= 0.01; + } if (mZoomCenterX > 1) mZoomCenterX = 1; if (mZoomCenterX < 0) mZoomCenterX = 0; + if (mZoomCenterY > 1) + mZoomCenterY = 1; + if (mZoomCenterY < 0) + mZoomCenterY = 0; LinphoneManager.getLc().getCurrentCall().zoomVideo(mZoomFactor, mZoomCenterX, mZoomCenterY); return true; @@ -205,8 +218,12 @@ public class VideoCallFragment extends Fragment implements OnGestureListener, On public boolean onDoubleTap(MotionEvent e) { if (LinphoneUtils.isCallEstablished(LinphoneManager.getLc().getCurrentCall())) { if (mZoomFactor == 1.f) { - // Zoom to make the video fill the screen in height - mZoomFactor = ((float) mVideoView.getHeight()) / LinphoneManager.getLc().getPreferredVideoSize().height; + // Zoom to make the video fill the screen vertically + float portraitZoomFactor = ((float) mVideoView.getHeight()) / (float) ((3 * mVideoView.getWidth()) / 4); + // Zoom to make the video fill the screen horizontally + float landscapeZoomFactor = ((float) mVideoView.getWidth()) / (float) ((3 * mVideoView.getHeight()) / 4); + + mZoomFactor = Math.max(portraitZoomFactor, landscapeZoomFactor); } else { resetZoom();