From 1265952814b4128814e77c3da44b1da4418ada2a Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 6 Sep 2022 21:24:54 -0500 Subject: [PATCH] Allow streaming in any orientation when using a square display --- app/src/main/AndroidManifest.xml | 2 -- app/src/main/java/com/limelight/Game.java | 31 ++++++++++++++++--- .../preferences/PreferenceConfiguration.java | 10 ++++++ 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1694a69f..96feb939 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -124,11 +124,9 @@ android:name="android.support.PARENT_ACTIVITY" android:value="com.limelight.PcView" /> - = Build.VERSION_CODES.JELLY_BEAN_MR2) { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_USER); + } + else { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); + } + } + else { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE); + } + else { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); + } + } + } + @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); + // Set requested orientation for possible new screen size + setPreferredOrientationForCurrentDisplay(); + if (virtualController != null) { // Refresh layout of OSC for possible new screen size virtualController.refreshLayout(); diff --git a/app/src/main/java/com/limelight/preferences/PreferenceConfiguration.java b/app/src/main/java/com/limelight/preferences/PreferenceConfiguration.java index 4a7e4deb..42b76333 100644 --- a/app/src/main/java/com/limelight/preferences/PreferenceConfiguration.java +++ b/app/src/main/java/com/limelight/preferences/PreferenceConfiguration.java @@ -148,6 +148,16 @@ public class PreferenceConfiguration { return true; } + // If we have a screen that has semi-square dimensions, we may want to change our behavior + // to allow any orientation and vertical+horizontal resolutions. + public static boolean isSquarishScreen(int width, int height) { + float longDim = Math.max(width, height); + float shortDim = Math.min(width, height); + + // We just put the arbitrary cutoff for a square-ish screen at 1.3 + return longDim / shortDim < 1.3f; + } + private static String convertFromLegacyResolutionString(String resString) { if (resString.equalsIgnoreCase("360p")) { return RES_360P;