From aa89c6604af597037c429b231053cdabac5bb850 Mon Sep 17 00:00:00 2001 From: Miku AuahDark Date: Tue, 18 Jun 2024 10:55:02 +0800 Subject: [PATCH] Android: Respect user orientation lock setting for resizable window (SDL2/3). Based on libsdl-org/SDL@3373667. --- .../app/src/main/java/org/libsdl/app/SDLActivity.java | 8 ++++---- .../app/src/main/java/org/libsdl/app/SDLActivity.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libs/SDL2/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/libs/SDL2/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java index a2b5ba87..b3454051 100644 --- a/libs/SDL2/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/libs/SDL2/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -995,8 +995,8 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh /* No valid hint, nothing is explicitly allowed */ if (!is_portrait_allowed && !is_landscape_allowed) { if (resizable) { - /* All orientations are allowed */ - req = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR; + /* All orientations are allowed, respecting user orientation lock setting */ + 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); @@ -1005,8 +1005,8 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh /* At least one orientation is allowed */ 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; + /* hint allows both landscape and portrait, promote to full user */ + req = ActivityInfo.SCREEN_ORIENTATION_FULL_USER; } else { /* Use the only one allowed "orientation" */ req = (is_landscape_allowed ? orientation_landscape : orientation_portrait); diff --git a/libs/SDL3/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/libs/SDL3/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java index 88667079..79b45842 100644 --- a/libs/SDL3/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/libs/SDL3/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -1083,8 +1083,8 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh /* No valid hint, nothing is explicitly allowed */ if (!is_portrait_allowed && !is_landscape_allowed) { if (resizable) { - /* All orientations are allowed */ - req = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR; + /* All orientations are allowed, respecting user orientation lock setting */ + 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); @@ -1093,8 +1093,8 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh /* At least one orientation is allowed */ 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; + /* hint allows both landscape and portrait, promote to full user */ + req = ActivityInfo.SCREEN_ORIENTATION_FULL_USER; } else { /* Use the only one allowed "orientation" */ req = (is_landscape_allowed ? orientation_landscape : orientation_portrait);