mirror of
https://git.ryujinx.app/kenji-nx/ryujinx.git
synced 2025-12-15 01:37:03 +00:00
Sensor, portrait, Landscape Settings
This commit is contained in:
parent
d73d82fbc0
commit
316dc3a9b3
3 changed files with 86 additions and 8 deletions
|
|
@ -60,7 +60,7 @@ class MainActivity : BaseActivity() {
|
||||||
mainViewModel?.gameHost?.hideProgressIndicator()
|
mainViewModel?.gameHost?.hideProgressIndicator()
|
||||||
}
|
}
|
||||||
|
|
||||||
// <<< NEW: is called from the Native/Lib page to set the loading progress
|
// <<< is called from the Native/Lib page to set the loading progress
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun updateProgress(info: String, percent: Float) {
|
fun updateProgress(info: String, percent: Float) {
|
||||||
// Route directly via the GameHost – it takes care of the progress states
|
// Route directly via the GameHost – it takes care of the progress states
|
||||||
|
|
@ -143,6 +143,9 @@ class MainActivity : BaseActivity() {
|
||||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
|
|
||||||
|
// --- Apply alignment
|
||||||
|
applyOrientationPreference()
|
||||||
|
|
||||||
WindowInsetsControllerCompat(window, window.decorView).let { controller ->
|
WindowInsetsControllerCompat(window, window.decorView).let { controller ->
|
||||||
controller.hide(WindowInsetsCompat.Type.systemBars())
|
controller.hide(WindowInsetsCompat.Type.systemBars())
|
||||||
controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||||
|
|
@ -215,6 +218,9 @@ class MainActivity : BaseActivity() {
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
// --- Reapply alignment if necessary
|
||||||
|
applyOrientationPreference()
|
||||||
|
|
||||||
handler.postDelayed(delayedHandleIntent, 10)
|
handler.postDelayed(delayedHandleIntent, 10)
|
||||||
isActive = true
|
isActive = true
|
||||||
|
|
||||||
|
|
@ -258,22 +264,21 @@ class MainActivity : BaseActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun applyOrientationPreference() {
|
||||||
|
val pref = QuickSettings(this).orientationPreference
|
||||||
|
requestedOrientation = pref.value
|
||||||
|
}
|
||||||
|
|
||||||
fun shutdownAndRestart() {
|
fun shutdownAndRestart() {
|
||||||
// Create an intent to restart the app
|
|
||||||
val packageManager = packageManager
|
val packageManager = packageManager
|
||||||
val intent = packageManager.getLaunchIntentForPackage(packageName)
|
val intent = packageManager.getLaunchIntentForPackage(packageName)
|
||||||
val componentName = intent?.component
|
val componentName = intent?.component
|
||||||
val restartIntent = Intent.makeRestartActivityTask(componentName)
|
val restartIntent = Intent.makeRestartActivityTask(componentName)
|
||||||
|
|
||||||
// Clean up resources if needed
|
|
||||||
mainViewModel?.let {
|
mainViewModel?.let {
|
||||||
it.performanceManager?.setTurboMode(false)
|
it.performanceManager?.setTurboMode(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the new activity directly
|
|
||||||
startActivity(restartIntent)
|
startActivity(restartIntent)
|
||||||
|
|
||||||
// Force immediate process termination
|
|
||||||
Runtime.getRuntime().exit(0)
|
Runtime.getRuntime().exit(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,25 @@ package org.kenjinx.android.viewmodels
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
|
import android.content.pm.ActivityInfo
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
|
|
||||||
class QuickSettings(val activity: Activity) {
|
class QuickSettings(val activity: Activity) {
|
||||||
|
// --- Alignment
|
||||||
|
enum class OrientationPreference(val value: Int) {
|
||||||
|
Sensor(ActivityInfo.SCREEN_ORIENTATION_SENSOR),
|
||||||
|
SensorLandscape(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE),
|
||||||
|
SensorPortrait(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun fromValue(v: Int): OrientationPreference =
|
||||||
|
entries.firstOrNull { it.value == v } ?: Sensor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var orientationPreference: OrientationPreference
|
||||||
|
|
||||||
var ignoreMissingServices: Boolean
|
var ignoreMissingServices: Boolean
|
||||||
var enablePptc: Boolean
|
var enablePptc: Boolean
|
||||||
var enableLowPowerPptc: Boolean
|
var enableLowPowerPptc: Boolean
|
||||||
|
|
@ -41,6 +56,10 @@ class QuickSettings(val activity: Activity) {
|
||||||
private var sharedPref: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity)
|
private var sharedPref: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
// --- Load alignment (Default: Sensor)
|
||||||
|
val oriValue = sharedPref.getInt("orientationPreference", ActivityInfo.SCREEN_ORIENTATION_SENSOR)
|
||||||
|
orientationPreference = OrientationPreference.fromValue(oriValue)
|
||||||
|
|
||||||
memoryManagerMode = MemoryManagerMode.entries.toTypedArray()[sharedPref.getInt("memoryManagerMode", MemoryManagerMode.HostMappedUnsafe.ordinal)]
|
memoryManagerMode = MemoryManagerMode.entries.toTypedArray()[sharedPref.getInt("memoryManagerMode", MemoryManagerMode.HostMappedUnsafe.ordinal)]
|
||||||
useNce = sharedPref.getBoolean("useNce", false)
|
useNce = sharedPref.getBoolean("useNce", false)
|
||||||
memoryConfiguration = MemoryConfiguration.entries.toTypedArray()[sharedPref.getInt("memoryConfiguration", MemoryConfiguration.MemoryConfiguration4GiB.ordinal)]
|
memoryConfiguration = MemoryConfiguration.entries.toTypedArray()[sharedPref.getInt("memoryConfiguration", MemoryConfiguration.MemoryConfiguration4GiB.ordinal)]
|
||||||
|
|
@ -76,6 +95,8 @@ class QuickSettings(val activity: Activity) {
|
||||||
|
|
||||||
fun save() {
|
fun save() {
|
||||||
sharedPref.edit {
|
sharedPref.edit {
|
||||||
|
// --- Save orientation
|
||||||
|
putInt("orientationPreference", orientationPreference.value)
|
||||||
|
|
||||||
putInt("memoryManagerMode", memoryManagerMode.ordinal)
|
putInt("memoryManagerMode", memoryManagerMode.ordinal)
|
||||||
putBoolean("useNce", useNce)
|
putBoolean("useNce", useNce)
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,10 @@ import org.kenjinx.android.widgets.ExpandableView
|
||||||
import org.kenjinx.android.widgets.SimpleAlertDialog
|
import org.kenjinx.android.widgets.SimpleAlertDialog
|
||||||
import org.kenjinx.android.widgets.SwitchSelector
|
import org.kenjinx.android.widgets.SwitchSelector
|
||||||
|
|
||||||
|
// >>> QuickSettings + OrientationPreference
|
||||||
|
import org.kenjinx.android.viewmodels.QuickSettings
|
||||||
|
import org.kenjinx.android.viewmodels.QuickSettings.OrientationPreference
|
||||||
|
|
||||||
class SettingViews {
|
class SettingViews {
|
||||||
companion object {
|
companion object {
|
||||||
const val EXPANSTION_TRANSITION_DURATION = 450
|
const val EXPANSTION_TRANSITION_DURATION = 450
|
||||||
|
|
@ -131,6 +135,11 @@ class SettingViews {
|
||||||
val enableGraphicsLogs = remember { mutableStateOf(true) }
|
val enableGraphicsLogs = remember { mutableStateOf(true) }
|
||||||
val isNavigating = remember { mutableStateOf(false) }
|
val isNavigating = remember { mutableStateOf(false) }
|
||||||
|
|
||||||
|
// Load orientation from QuickSettings
|
||||||
|
val orientationPref = remember {
|
||||||
|
mutableStateOf(QuickSettings(mainViewModel.activity).orientationPreference)
|
||||||
|
}
|
||||||
|
|
||||||
if (!loaded.value) {
|
if (!loaded.value) {
|
||||||
settingsViewModel.initializeState(
|
settingsViewModel.initializeState(
|
||||||
memoryManagerMode,
|
memoryManagerMode,
|
||||||
|
|
@ -231,6 +240,20 @@ class SettingViews {
|
||||||
) {
|
) {
|
||||||
ExpandableView(onCardArrowClick = { }, title = "User Interface", icon = Icons.Outlined.BarChart ,isFirst = true) {
|
ExpandableView(onCardArrowClick = { }, title = "User Interface", icon = Icons.Outlined.BarChart ,isFirst = true) {
|
||||||
Column(modifier = Modifier.fillMaxWidth()) {
|
Column(modifier = Modifier.fillMaxWidth()) {
|
||||||
|
|
||||||
|
// Screen Orientation
|
||||||
|
OrientationDropdown(
|
||||||
|
selectedOrientation = orientationPref.value,
|
||||||
|
onOrientationSelected = { sel ->
|
||||||
|
orientationPref.value = sel
|
||||||
|
// Save and use immediately
|
||||||
|
val qs = QuickSettings(mainViewModel.activity)
|
||||||
|
qs.orientationPreference = sel
|
||||||
|
qs.save()
|
||||||
|
mainViewModel.activity.requestedOrientation = sel.value
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
isGrid.SwitchSelector("Use Grid")
|
isGrid.SwitchSelector("Use Grid")
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|
@ -1273,6 +1296,35 @@ class SettingViews {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---- Dropdown for orientation ----
|
||||||
|
@Composable
|
||||||
|
fun OrientationDropdown(
|
||||||
|
selectedOrientation: OrientationPreference,
|
||||||
|
onOrientationSelected: (OrientationPreference) -> Unit
|
||||||
|
) {
|
||||||
|
val options = listOf(
|
||||||
|
OrientationPreference.Sensor,
|
||||||
|
OrientationPreference.SensorLandscape,
|
||||||
|
OrientationPreference.SensorPortrait
|
||||||
|
)
|
||||||
|
|
||||||
|
DropdownSelector(
|
||||||
|
label = "Screen Orientation",
|
||||||
|
selectedValue = selectedOrientation,
|
||||||
|
options = options,
|
||||||
|
getDisplayText = { opt ->
|
||||||
|
when (opt) {
|
||||||
|
OrientationPreference.Sensor -> "Sensor"
|
||||||
|
OrientationPreference.SensorLandscape -> "Sensor Landscape"
|
||||||
|
OrientationPreference.SensorPortrait -> "Sensor Portrait"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onOptionSelected = onOrientationSelected
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Existing dropdowns ----
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MemoryModeDropdown(
|
fun MemoryModeDropdown(
|
||||||
selectedMemoryManagerMode: MemoryManagerMode,
|
selectedMemoryManagerMode: MemoryManagerMode,
|
||||||
|
|
@ -1363,7 +1415,7 @@ class SettingViews {
|
||||||
onOptionSelected = onScaleSelected
|
onOptionSelected = onScaleSelected
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AnisotropicFilteringDropdown(
|
fun AnisotropicFilteringDropdown(
|
||||||
selectedAnisotropy: Float,
|
selectedAnisotropy: Float,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue