summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/PhotoModule.java
diff options
context:
space:
mode:
authorandralex8 <andralex8@gmail.com>2017-05-28 16:56:39 +0200
committerArne Coucheron <arco68@gmail.com>2018-01-26 01:07:50 +0100
commit1d737fe6463b30ad4108223d5e8a76fc4d723be4 (patch)
tree4887d1138b232a27589f3734a56e6b1edd527e98 /src/com/android/camera/PhotoModule.java
parent338926556da9322fa2d17054f8a9f11c0bd29e7f (diff)
downloadandroid_packages_apps_Snap-1d737fe6463b30ad4108223d5e8a76fc4d723be4.tar.gz
android_packages_apps_Snap-1d737fe6463b30ad4108223d5e8a76fc4d723be4.tar.bz2
android_packages_apps_Snap-1d737fe6463b30ad4108223d5e8a76fc4d723be4.zip
Add orientation correction for landscape devices
Snap does not correctly handle devices with a landscape screen as rotation is 0 when device is in landscape while Snap assume that 0 is portrait. This lead to a rotated gui and a deformed preview. This commit: - Solve the gui rotation for Photo, Video and Panorama modules - Solve the deformed preview for Photo and Video (Panorama preview was ok with gui fix) - Solve the PhotoMenu rotation (all devices, it was also broken on portrait devices) Change-Id: Ic0b95904da6e13946c7e46e2e571b26da498db02
Diffstat (limited to 'src/com/android/camera/PhotoModule.java')
-rw-r--r--src/com/android/camera/PhotoModule.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 665e3db40..24bf3dd73 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -312,6 +312,7 @@ public class PhotoModule
private boolean mMirror;
private boolean mFirstTimeInitialized;
private boolean mIsImageCaptureIntent;
+ private int mOrientationOffset;
private int mCameraState = INIT;
private boolean mSnapshotOnIdle = false;
@@ -583,6 +584,7 @@ public class PhotoModule
public void init(CameraActivity activity, View parent) {
mActivity = activity;
mRootView = parent;
+ mOrientationOffset = CameraUtil.isDefaultToPortrait(mActivity) ? 0 : 90;
mPreferences = ComboPreferences.get(mActivity);
if (mPreferences == null) {
mPreferences = new ComboPreferences(mActivity);
@@ -1856,7 +1858,7 @@ public class PhotoModule
}
// Set rotation and gps data.
- int orientation = mOrientation;
+ int orientation = (mOrientation + mOrientationOffset) % 360;
mJpegRotation = CameraUtil.getJpegRotation(mCameraId, orientation);
String pictureFormat = mParameters.get(KEY_PICTURE_FORMAT);
Location loc = getLocationAccordPictureFormat(pictureFormat);
@@ -2358,6 +2360,7 @@ public class PhotoModule
// the camera then point the camera to floor or sky, we still have
// the correct orientation.
if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN) return;
+ orientation = (orientation - mOrientationOffset + 360) % 360;
int oldOrientation = mOrientation;
mOrientation = CameraUtil.roundOrientation(orientation, mOrientation);
if (oldOrientation != mOrientation) {