summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2012-05-31 16:08:28 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-05-31 16:08:28 -0700
commit7f811903c59845ae8a3461a94a88b40a2d3114e3 (patch)
tree01b2e39bc3955eefff49620063be35189e7b2f41
parent95584440e5db9bb224ee6424db0f8000d040aab5 (diff)
parent988b6a327efa3838dd043780f401a26a04d7fecc (diff)
downloadandroid_packages_apps_Snap-7f811903c59845ae8a3461a94a88b40a2d3114e3.tar.gz
android_packages_apps_Snap-7f811903c59845ae8a3461a94a88b40a2d3114e3.tar.bz2
android_packages_apps_Snap-7f811903c59845ae8a3461a94a88b40a2d3114e3.zip
am 1eed3b2a: am 6f30a447: Merge "Don\'t allow the orientation to be unlocked if "Rotation Lock" is checked in Settings." into jb-dev
* commit '1eed3b2ac7abb0fc2078605d9341f14f6197dbf5': Don't allow the orientation to be unlocked if "Rotation Lock" is checked in Settings.
-rw-r--r--src/com/android/gallery3d/app/OrientationManager.java14
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) {