From b2c323e3538820dc1da537c7a207ca6c9bd6d92b Mon Sep 17 00:00:00 2001 From: Michael Kolb Date: Mon, 15 Apr 2013 11:35:52 -0700 Subject: Lock camera orientation using FW API Bug: 8617536 Change-Id: Id3a5ae777f6f87d24984cbca48202470651cd71c --- gallerycommon/src/com/android/gallery3d/common/ApiHelper.java | 3 +++ src/com/android/gallery3d/app/OrientationManager.java | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index 864e1305f..f6439f1ad 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -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; diff --git a/src/com/android/gallery3d/app/OrientationManager.java b/src/com/android/gallery3d/app/OrientationManager.java index 0a644ef66..24201ff24 100644 --- a/src/com/android/gallery3d/app/OrientationManager.java +++ b/src/com/android/gallery3d/app/OrientationManager.java @@ -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 -- cgit v1.2.3