diff options
| author | Doris Liu <tianliu@google.com> | 2013-02-16 01:39:59 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-02-16 01:40:00 +0000 |
| commit | d9de7afa6c343e85b9c2c0221ca280c69a349c5f (patch) | |
| tree | db603a1a743b2f56c118de2b21ba233b61b1901a | |
| parent | c86e1ca339d770b9199cc332a27edcd0f0c42900 (diff) | |
| parent | 9a32480db4e07fe437dd119d6f1d8471382d503f (diff) | |
| download | android_packages_apps_Gallery2-d9de7afa6c343e85b9c2c0221ca280c69a349c5f.tar.gz android_packages_apps_Gallery2-d9de7afa6c343e85b9c2c0221ca280c69a349c5f.tar.bz2 android_packages_apps_Gallery2-d9de7afa6c343e85b9c2c0221ca280c69a349c5f.zip | |
Merge "Make photo orientation consistent with UI" into gb-ub-photos-bryce
| -rw-r--r-- | src/com/android/camera/CameraActivity.java | 18 | ||||
| -rw-r--r-- | src/com/android/camera/PhotoModule.java | 10 |
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); |
