From 11041e950d5296d072fd951b3224c1d9e940e6d0 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Tue, 14 Mar 2023 21:13:13 +0100 Subject: [PATCH] Android: Combine reading cutout setting with updateOrientation --- .../activities/EmulationActivity.kt | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.kt index 47921ce401..66009e7d29 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.kt @@ -109,8 +109,6 @@ class EmulationActivity : AppCompatActivity(), ThemeProvider { settings = Settings() settings.loadSettings() - updateOrientation() - // Set these options now so that the SurfaceView the game renders into is the right size. enableFullscreenImmersive() @@ -203,21 +201,7 @@ class EmulationActivity : AppCompatActivity(), ThemeProvider { super.onResume() - // Only android 9+ support this feature. - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - val attributes = window.attributes - - attributes.layoutInDisplayCutoutMode = - if (BooleanSetting.MAIN_EXPAND_TO_CUTOUT_AREA.boolean) { - WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES - } else { - WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER - } - - window.attributes = attributes - } - - updateOrientation() + updateDisplaySettings() DolphinSensorEventListener.setDeviceRotation(windowManager.defaultDisplay.rotation) } @@ -338,7 +322,20 @@ class EmulationActivity : AppCompatActivity(), ThemeProvider { View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY } - private fun updateOrientation() { + private fun updateDisplaySettings() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + val attributes = window.attributes + + attributes.layoutInDisplayCutoutMode = + if (BooleanSetting.MAIN_EXPAND_TO_CUTOUT_AREA.boolean) { + WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES + } else { + WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER + } + + window.attributes = attributes + } + requestedOrientation = IntSetting.MAIN_EMULATION_ORIENTATION.int }