From: Holger Schemel Date: Wed, 29 Mar 2023 06:02:33 +0000 (+0200) Subject: added respecting user-configured screen orientation locking on Android X-Git-Tag: 4.3.5.3~13 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=ca793aef40f02d22bf04489584dd7a450fda54bd;p=rocksndiamonds.git added respecting user-configured screen orientation locking on Android On Android, locking the screen orientation to portrait or landscape as configured by the user of the device was completely ignored so far. This change adds respecting this device setting by using the setting "fullUser" for the app's screen orientation activity (always use user defined screen orientation) instead of the previously used setting "fullSensor" (always use sensor-based rotation, regardless of any user-configured locking of screen rotation). The corresponding entry in the Android Manifest file was added only to document this changed behaviour, even though it is in fact ignored, as this activity setting is finally hard-coded in the Java activity code, where it was changed to use the new behaviour. --- diff --git a/build-projects/android/app/src/main/AndroidManifest.xml.tmpl b/build-projects/android/app/src/main/AndroidManifest.xml.tmpl index f264e833..8331804d 100644 --- a/build-projects/android/app/src/main/AndroidManifest.xml.tmpl +++ b/build-projects/android/app/src/main/AndroidManifest.xml.tmpl @@ -47,6 +47,7 @@ android:alwaysRetainTaskState="true" android:launchMode="singleInstance" android:configChanges="keyboardHidden|orientation|screenSize" + android:screenOrientation="fullUser" android:preferMinimalPostProcessing="true" android:exported="true" > diff --git a/build-projects/android/app/src/main/java/org/libsdl/app/SDLActivity.java b/build-projects/android/app/src/main/java/org/libsdl/app/SDLActivity.java index 9144949b..f8b3e1eb 100644 --- a/build-projects/android/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/build-projects/android/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -871,7 +871,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh if (!is_portrait_allowed && !is_landscape_allowed) { if (resizable) { /* All orientations are allowed */ - req = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR; + req = ActivityInfo.SCREEN_ORIENTATION_FULL_USER; } else { /* Fixed window and nothing specified. Get orientation from w/h of created window */ req = (w > h ? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); @@ -881,7 +881,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh if (resizable) { if (is_portrait_allowed && is_landscape_allowed) { /* hint allows both landscape and portrait, promote to full sensor */ - req = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR; + req = ActivityInfo.SCREEN_ORIENTATION_FULL_USER; } else { /* Use the only one allowed "orientation" */ req = (is_landscape_allowed ? orientation_landscape : orientation_portrait);