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;
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 {
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