OSDN Git Service

Support REVERSE in lockOrientation
authorJohn Reck <jreck@google.com>
Wed, 10 Oct 2012 16:44:48 +0000 (09:44 -0700)
committerJohn Reck <jreck@google.com>
Wed, 10 Oct 2012 16:44:48 +0000 (09:44 -0700)
 Bug: 7314703

Change-Id: Id459e49496f562e75c1485d9d717daa28020a587

src/com/android/gallery3d/app/OrientationManager.java

index f5cbf06..a8ef99a 100644 (file)
@@ -98,13 +98,19 @@ public class OrientationManager implements OrientationSource {
     public void lockOrientation() {
         if (mOrientationLocked) return;
         mOrientationLocked = true;
+        // Display rotation >= 180 means we need to use the REVERSE landscape/portrait
+        boolean standard = getDisplayRotation() < 180;
         if (mActivity.getResources().getConfiguration().orientation
                 == Configuration.ORIENTATION_LANDSCAPE) {
             Log.d(TAG, "lock orientation to landscape");
-            mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+            mActivity.setRequestedOrientation(standard
+                    ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
+                    : ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
         } else {
             Log.d(TAG, "lock orientation to portrait");
-            mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+            mActivity.setRequestedOrientation(standard
+                    ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
+                    : ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
         }
         updateCompensation();
     }