From 9013c4c90d6a83a82cdfa5e3e17f1c28f5591c70 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Wed, 29 Apr 2020 15:35:57 +0300 Subject: [PATCH] Disallow SDL orientation changes --- android/app/src/main/java/org/libsdl/app/SDLActivity.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/java/org/libsdl/app/SDLActivity.java b/android/app/src/main/java/org/libsdl/app/SDLActivity.java index 43e4d1a6de66d..6a868699d65e6 100644 --- a/android/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/android/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -40,6 +40,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh public static boolean mIsResumedCalled, mHasFocus; public static final boolean mHasMultiWindow = (Build.VERSION.SDK_INT >= 24); + public static boolean mAllowSDLOrientationChanges = false; // Cursor types private static final int SDL_SYSTEM_CURSOR_NONE = -1; @@ -892,7 +893,9 @@ public void setOrientationBis(int w, int h, boolean resizable, String hint) } Log.v("SDL", "setOrientation() requestedOrientation=" + req + " width=" + w +" height="+ h +" resizable=" + resizable + " hint=" + hint); - mSingleton.setRequestedOrientation(req); + if (mAllowSDLOrientationChanges && req != -1) { + mSingleton.setRequestedOrientation(req); + } } /** @@ -1826,7 +1829,7 @@ public void surfaceChanged(SurfaceHolder holder, // Prevent a screen distortion glitch, // for instance when the device is in Landscape and a Portrait App is resumed. boolean skip = false; - int requestedOrientation = SDLActivity.mSingleton.getRequestedOrientation(); + int requestedOrientation = SDLActivity.mAllowSDLOrientationChanges ? SDLActivity.mSingleton.getRequestedOrientation() : ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE; if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {