summaryrefslogtreecommitdiffstats
path: root/src/android
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2023-06-16 20:45:32 +0200
committerGitHub <noreply@github.com>2023-06-16 20:45:32 +0200
commit4112031c81a7bd3d80c541a85e8e7dc717820aeb (patch)
tree22feb8b7a4e18e7b3e2672f58a714d00307b850b /src/android
parentMerge pull request #10739 from zeltermann/sdl-cpuinfo (diff)
parentandroid: Fix aspect ratio when rotating screen (diff)
downloadyuzu-4112031c81a7bd3d80c541a85e8e7dc717820aeb.tar
yuzu-4112031c81a7bd3d80c541a85e8e7dc717820aeb.tar.gz
yuzu-4112031c81a7bd3d80c541a85e8e7dc717820aeb.tar.bz2
yuzu-4112031c81a7bd3d80c541a85e8e7dc717820aeb.tar.lz
yuzu-4112031c81a7bd3d80c541a85e8e7dc717820aeb.tar.xz
yuzu-4112031c81a7bd3d80c541a85e8e7dc717820aeb.tar.zst
yuzu-4112031c81a7bd3d80c541a85e8e7dc717820aeb.zip
Diffstat (limited to 'src/android')
-rw-r--r--src/android/app/src/main/AndroidManifest.xml1
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt47
2 files changed, 20 insertions, 28 deletions
diff --git a/src/android/app/src/main/AndroidManifest.xml b/src/android/app/src/main/AndroidManifest.xml
index a6f87fc2e..e31ad69e2 100644
--- a/src/android/app/src/main/AndroidManifest.xml
+++ b/src/android/app/src/main/AndroidManifest.xml
@@ -53,6 +53,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<activity
android:name="org.yuzu.yuzu_emu.activities.EmulationActivity"
android:theme="@style/Theme.Yuzu.Main"
+ android:screenOrientation="userLandscape"
android:supportsPictureInPicture="true"
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|uiMode"
android:exported="true">
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt
index 42e2e5b75..4643418c1 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt
@@ -85,20 +85,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
onReturnFromSettings = context.activityResultRegistry.register(
"SettingsResult",
ActivityResultContracts.StartActivityForResult()
- ) {
- binding.surfaceEmulation.setAspectRatio(
- when (IntSetting.RENDERER_ASPECT_RATIO.int) {
- 0 -> Rational(16, 9)
- 1 -> Rational(4, 3)
- 2 -> Rational(21, 9)
- 3 -> Rational(16, 10)
- 4 -> null // Stretch
- else -> Rational(16, 9)
- }
- )
- emulationActivity?.buildPictureInPictureParams()
- updateScreenLayout()
- }
+ ) { updateScreenLayout() }
} else {
throw IllegalStateException("EmulationFragment must have EmulationActivity parent")
}
@@ -242,17 +229,6 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
DirectoryInitialization.start(requireContext())
}
- binding.surfaceEmulation.setAspectRatio(
- when (IntSetting.RENDERER_ASPECT_RATIO.int) {
- 0 -> Rational(16, 9)
- 1 -> Rational(4, 3)
- 2 -> Rational(21, 9)
- 3 -> Rational(16, 10)
- 4 -> null // Stretch
- else -> Rational(16, 9)
- }
- )
-
updateScreenLayout()
emulationState.run(emulationActivity!!.isActivityRecreated)
@@ -315,7 +291,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
}
@SuppressLint("SourceLockedOrientationActivity")
- private fun updateScreenLayout() {
+ private fun updateOrientation() {
emulationActivity?.let {
it.requestedOrientation = when (IntSetting.RENDERER_SCREEN_LAYOUT.int) {
Settings.LayoutOption_MobileLandscape ->
@@ -326,7 +302,21 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
else -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
}
}
- onConfigurationChanged(resources.configuration)
+ }
+
+ private fun updateScreenLayout() {
+ binding.surfaceEmulation.setAspectRatio(
+ when (IntSetting.RENDERER_ASPECT_RATIO.int) {
+ 0 -> Rational(16, 9)
+ 1 -> Rational(4, 3)
+ 2 -> Rational(21, 9)
+ 3 -> Rational(16, 10)
+ 4 -> null // Stretch
+ else -> Rational(16, 9)
+ }
+ )
+ emulationActivity?.buildPictureInPictureParams()
+ updateOrientation()
}
private fun updateFoldableLayout(
@@ -359,7 +349,8 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
binding.overlayContainer.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
binding.inGameMenu.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
isInFoldableLayout = false
- updateScreenLayout()
+ updateOrientation()
+ onConfigurationChanged(resources.configuration)
}
binding.emulationContainer.requestLayout()
binding.inputContainer.requestLayout()