summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoris Liu <tianliu@google.com>2013-02-16 01:39:59 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-02-16 01:40:00 +0000
commitf7159e15dd704e9501a3538cb05498f40a30f042 (patch)
tree889e81cdab28657ba68bbcc258b7ab06cfc9b660
parent26ac2619cc54a743aac488a2b348805c155d1a39 (diff)
parent3cf565c4242a9deab7da5eb84fc302c79d594f11 (diff)
downloadandroid_packages_apps_Snap-f7159e15dd704e9501a3538cb05498f40a30f042.tar.gz
android_packages_apps_Snap-f7159e15dd704e9501a3538cb05498f40a30f042.tar.bz2
android_packages_apps_Snap-f7159e15dd704e9501a3538cb05498f40a30f042.zip
Merge "Make photo orientation consistent with UI" into gb-ub-photos-bryce
-rw-r--r--src/com/android/camera/CameraActivity.java18
-rw-r--r--src/com/android/camera/PhotoModule.java10
2 files changed, 27 insertions, 1 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index e0a2a276c..a207b2b71 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -23,11 +23,14 @@ import android.content.Context;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
+import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.IBinder;
import android.provider.MediaStore;
+import android.provider.Settings;
+import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -58,6 +61,7 @@ public class CameraActivity extends ActivityBase
private Drawable[] mDrawables;
private int mCurrentModuleIndex;
private MotionEvent mDown;
+ private boolean mAutoRotateScreen;
private MyOrientationEventListener mOrientationListener;
// The degrees of the device rotated clockwise from its natural orientation.
@@ -141,6 +145,12 @@ public class CameraActivity extends ActivityBase
super.onDestroy();
}
+ // Return whether the auto-rotate screen in system settings
+ // is turned on.
+ public boolean isAutoRotateScreen() {
+ return mAutoRotateScreen;
+ }
+
private class MyOrientationEventListener
extends OrientationEventListener {
public MyOrientationEventListener(Context context) {
@@ -318,6 +328,14 @@ public class CameraActivity extends ActivityBase
@Override
public void onResume() {
mPaused = false;
+ if (Settings.System.getInt(getContentResolver(),
+ Settings.System.ACCELEROMETER_ROTATION, 0) == 0) {// auto-rotate off
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
+ mAutoRotateScreen = false;
+ } else {
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
+ mAutoRotateScreen = true;
+ }
mOrientationListener.enable();
mCurrentModule.onResumeBeforeSuper();
super.onResume();
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index e52c83c3a..15f40461d 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -1134,7 +1134,15 @@ public class PhotoModule
}
// Set rotation and gps data.
- mJpegRotation = Util.getJpegRotation(mCameraId, mOrientation);
+ int orientation;
+ // We need to be consistent with the framework orientation (i.e. the
+ // orientation of the UI.) when the auto-rotate screen setting is on.
+ if (mActivity.isAutoRotateScreen()) {
+ orientation = (360 - mDisplayRotation) % 360;
+ } else {
+ orientation = mOrientation;
+ }
+ mJpegRotation = Util.getJpegRotation(mCameraId, orientation);
mParameters.setRotation(mJpegRotation);
Location loc = mLocationManager.getCurrentLocation();
Util.setGpsParameters(mParameters, loc);