OSDN Git Service

am f5d5c639: am 32049103: Merge "Lock camera orientation using FW API" into gb-ub...
authorMichael Kolb <kolby@google.com>
Fri, 19 Apr 2013 17:41:52 +0000 (10:41 -0700)
committerAndroid Git Automerger <android-git-automerger@android.com>
Fri, 19 Apr 2013 17:41:52 +0000 (10:41 -0700)
* commit 'f5d5c63904ee5eb70b2088d0ed27b3bc5fbc5c57':
  Lock camera orientation using FW API

gallerycommon/src/com/android/gallery3d/common/ApiHelper.java
src/com/android/gallery3d/app/OrientationManager.java

index 864e130..f6439f1 100644 (file)
@@ -186,6 +186,9 @@ public class ApiHelper {
     public static final boolean HAS_ROTATION_ANIMATION =
             hasField(WindowManager.LayoutParams.class, "rotationAnimation");
 
+    public static final boolean HAS_ORIENTATION_LOCK =
+            Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR2;
+
     public static final boolean HAS_CANCELLATION_SIGNAL =
             Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN;
 
index 0a644ef..24201ff 100644 (file)
@@ -25,6 +25,7 @@ import android.provider.Settings;
 import android.view.OrientationEventListener;
 import android.view.Surface;
 
+import com.android.gallery3d.common.ApiHelper;
 import com.android.gallery3d.ui.OrientationSource;
 
 public class OrientationManager implements OrientationSource {
@@ -71,7 +72,11 @@ public class OrientationManager implements OrientationSource {
     public void lockOrientation() {
         if (mOrientationLocked) return;
         mOrientationLocked = true;
-        mActivity.setRequestedOrientation(calculateCurrentScreenOrientation());
+        if (ApiHelper.HAS_ORIENTATION_LOCK) {
+            mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
+        } else {
+            mActivity.setRequestedOrientation(calculateCurrentScreenOrientation());
+        }
     }
 
     // Unlock the framework orientation, so it can change when the device