diff options
author | Chih-Chung Chang <chihchung@google.com> | 2012-05-31 10:52:07 -0700 |
---|---|---|
committer | Chih-Chung Chang <chihchung@google.com> | 2012-05-31 11:09:59 -0700 |
commit | 4283ac523be001b6bc2d605d305e34ab9b364d12 (patch) | |
tree | 01b2e39bc3955eefff49620063be35189e7b2f41 /src | |
parent | ae4b345047813f555fd934e7c23f2d935795b21b (diff) | |
download | android_packages_apps_Snap-4283ac523be001b6bc2d605d305e34ab9b364d12.tar.gz android_packages_apps_Snap-4283ac523be001b6bc2d605d305e34ab9b364d12.tar.bz2 android_packages_apps_Snap-4283ac523be001b6bc2d605d305e34ab9b364d12.zip |
Don't allow the orientation to be unlocked if "Rotation Lock" is checked in Settings.
Bug: 6577802
Change-Id: I5c8eefbb154eedcf71e80e082261e38450105892
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/gallery3d/app/OrientationManager.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/com/android/gallery3d/app/OrientationManager.java b/src/com/android/gallery3d/app/OrientationManager.java index a11977526..c3e91fb81 100644 --- a/src/com/android/gallery3d/app/OrientationManager.java +++ b/src/com/android/gallery3d/app/OrientationManager.java @@ -17,9 +17,11 @@ package com.android.gallery3d.app; import android.app.Activity; +import android.content.ContentResolver; import android.content.Context; import android.content.pm.ActivityInfo; import android.content.res.Configuration; +import android.provider.Settings; import android.view.OrientationEventListener; import android.view.Surface; import android.view.ViewConfiguration; @@ -51,6 +53,10 @@ public class OrientationManager implements OrientationSource { // components should be rotated 90 degrees counter-clockwise. private int mOrientationCompensation = 0; + // This is true if "Settings -> Display -> Rotation Lock" is checked. We + // don't allow the orientation to be unlocked if the value is true. + private boolean mRotationLockedSetting = false; + public OrientationManager(Activity activity) { mActivity = activity; mListeners = new ArrayList<Listener>(); @@ -58,6 +64,9 @@ public class OrientationManager implements OrientationSource { } public void resume() { + ContentResolver resolver = mActivity.getContentResolver(); + mRotationLockedSetting = Settings.System.getInt( + resolver, Settings.System.ACCELEROMETER_ROTATION, 0) != 1; mOrientationListener.enable(); } @@ -105,16 +114,13 @@ public class OrientationManager implements OrientationSource { // rotates. public void unlockOrientation() { if (!mOrientationLocked) return; + if (mRotationLockedSetting) return; mOrientationLocked = false; Log.d(TAG, "unlock orientation"); mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); disableCompensation(); } - public boolean isOrientationLocked() { - return mOrientationLocked; - } - // Calculate the compensation value and send it to listeners. private void updateCompensation() { if (mOrientation == OrientationEventListener.ORIENTATION_UNKNOWN) { |