From a9d4e6bb1a043ba60f42c2191055d9d7f92c49c5 Mon Sep 17 00:00:00 2001 From: lynxnb Date: Sun, 9 Jan 2022 17:20:02 +0100 Subject: [PATCH] Add screen orientation setting --- app/src/main/AndroidManifest.xml | 6 ++---- app/src/main/java/emu/skyline/EmulationActivity.kt | 2 +- app/src/main/java/emu/skyline/utils/Settings.kt | 3 +++ app/src/main/res/values/array.xml | 10 ++++++++++ app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/preferences.xml | 7 +++++++ 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 91271ee6..a8e776e4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -52,7 +52,7 @@ + android:launchMode="singleTask"> diff --git a/app/src/main/java/emu/skyline/EmulationActivity.kt b/app/src/main/java/emu/skyline/EmulationActivity.kt index 4a74732f..4d3af6c9 100644 --- a/app/src/main/java/emu/skyline/EmulationActivity.kt +++ b/app/src/main/java/emu/skyline/EmulationActivity.kt @@ -225,7 +225,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo @SuppressLint("SetTextI18n", "ClickableViewAccessibility") override fun onCreate(savedInstanceState : Bundle?) { super.onCreate(savedInstanceState) - + requestedOrientation = settings.orientation setContentView(binding.root) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { diff --git a/app/src/main/java/emu/skyline/utils/Settings.kt b/app/src/main/java/emu/skyline/utils/Settings.kt index d1a0de53..9dccfa96 100644 --- a/app/src/main/java/emu/skyline/utils/Settings.kt +++ b/app/src/main/java/emu/skyline/utils/Settings.kt @@ -6,6 +6,7 @@ package emu.skyline.utils import android.content.Context +import android.content.pm.ActivityInfo import dagger.hilt.android.qualifiers.ApplicationContext import javax.inject.Inject import javax.inject.Singleton @@ -41,4 +42,6 @@ class Settings @Inject constructor(@ApplicationContext private val context : Con var aspectRatio by sharedPreferences(context, 0) var systemLanguage by sharedPreferences(context, 1) + + var orientation by sharedPreferences(context, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) } diff --git a/app/src/main/res/values/array.xml b/app/src/main/res/values/array.xml index a17d9179..10f3fbf3 100644 --- a/app/src/main/res/values/array.xml +++ b/app/src/main/res/values/array.xml @@ -79,4 +79,14 @@ 21:9 (Ultrawide Mods) Device Aspect Ratio (Stretch to fit) + + Auto + Landscape + Landscape (reverse) + + + 6 + 0 + 8 + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e5bda038..858dd21f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -52,6 +52,7 @@ Failed to import keys Display + Screen orientation Force Triple Buffering Utilize at least three swapchain buffers (Higher FPS but more input lag) Utilize at least two swapchain buffers (Lower FPS but less input lag) diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 1128be35..cc45c9e0 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -84,6 +84,13 @@ +