misc: chore: Android: Tweak setting names, code

This commit is contained in:
KeatonTheBot 2025-05-19 11:46:48 -05:00
parent b22d771cce
commit 78b00e530c
17 changed files with 185 additions and 201 deletions

View file

@ -8,6 +8,7 @@ import android.os.Environment
import android.provider.DocumentsContract
import android.provider.MediaStore
import androidx.compose.runtime.MutableState
import androidx.core.net.toUri
import androidx.documentfile.provider.DocumentFile
import com.anggrayudi.storage.SimpleStorageHelper
import com.anggrayudi.storage.callback.FileCallback

View file

@ -14,6 +14,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.ui.Modifier
import androidx.core.net.toUri
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
@ -27,6 +28,7 @@ import org.kenjinx.android.viewmodels.GameModel
import org.kenjinx.android.views.MainView
import androidx.core.net.toUri
class MainActivity : BaseActivity() {
private var physicalControllerManager: PhysicalControllerManager =
PhysicalControllerManager(this)

View file

@ -6,18 +6,12 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.AlertDialogDefaults
import androidx.compose.material3.BasicAlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable

View file

@ -178,7 +178,7 @@ class DocumentProvider : DocumentsProvider() {
private fun copyDocument(
sourceDocumentId: String, sourceParentDocumentId: String,
targetParentDocumentId: String?
): String? {
): String {
if (!isChildDocument(sourceParentDocumentId, sourceDocumentId))
throw FileNotFoundException("Couldn't copy document '$sourceDocumentId' as its parent is not '$sourceParentDocumentId'")
@ -209,7 +209,7 @@ class DocumentProvider : DocumentsProvider() {
override fun moveDocument(
sourceDocumentId: String, sourceParentDocumentId: String?,
targetParentDocumentId: String?
): String? {
): String {
try {
val newDocumentId = copyDocument(
sourceDocumentId, sourceParentDocumentId!!,
@ -256,7 +256,7 @@ class DocumentProvider : DocumentsProvider() {
return cursor
}
private fun getTypeForFile(file: File): Any? {
private fun getTypeForFile(file: File): Any {
return if (file.isDirectory)
DocumentsContract.Document.MIME_TYPE_DIR
else

View file

@ -3,7 +3,6 @@ package org.kenjinx.android.viewmodels
import android.content.Intent
import android.net.Uri
import android.os.Environment
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.snapshots.SnapshotStateList

View file

@ -2,6 +2,7 @@ package org.kenjinx.android.viewmodels
import android.app.Activity
import android.content.SharedPreferences
import androidx.core.content.edit
import androidx.preference.PreferenceManager
class QuickSettings(val activity: Activity) {
@ -40,10 +41,10 @@ class QuickSettings(val activity: Activity) {
private var sharedPref: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity)
init {
memoryManagerMode = MemoryManagerMode.values()[sharedPref.getInt("memoryManagerMode", MemoryManagerMode.HostMappedUnsafe.ordinal)]
memoryManagerMode = MemoryManagerMode.entries.toTypedArray()[sharedPref.getInt("memoryManagerMode", MemoryManagerMode.HostMappedUnsafe.ordinal)]
useNce = sharedPref.getBoolean("useNce", false)
memoryConfiguration = MemoryConfiguration.values()[sharedPref.getInt("memoryConfiguration", MemoryConfiguration.MemoryConfiguration4GiB.ordinal)]
vSyncMode = VSyncMode.values()[sharedPref.getInt("vSyncMode", VSyncMode.Switch.ordinal)]
memoryConfiguration = MemoryConfiguration.entries.toTypedArray()[sharedPref.getInt("memoryConfiguration", MemoryConfiguration.MemoryConfiguration4GiB.ordinal)]
vSyncMode = VSyncMode.entries.toTypedArray()[sharedPref.getInt("vSyncMode", VSyncMode.Switch.ordinal)]
enableDocked = sharedPref.getBoolean("enableDocked", true)
enablePptc = sharedPref.getBoolean("enablePptc", true)
enableLowPowerPptc = sharedPref.getBoolean("enableLowPowerPptc", false)
@ -74,53 +75,53 @@ class QuickSettings(val activity: Activity) {
}
fun save() {
val editor = sharedPref.edit()
sharedPref.edit {
editor.putInt("memoryManagerMode", memoryManagerMode.ordinal)
editor.putBoolean("useNce", useNce)
editor.putInt("memoryConfiguration", memoryConfiguration.ordinal)
editor.putInt("vSyncMode", vSyncMode.ordinal)
editor.putBoolean("enableDocked", enableDocked)
editor.putBoolean("enablePptc", enablePptc)
editor.putBoolean("enableLowPowerPptc", enableLowPowerPptc)
editor.putBoolean("enableJitCacheEviction", enableJitCacheEviction)
editor.putBoolean("enableFsIntegrityChecks", enableFsIntegrityChecks)
editor.putInt("fsGlobalAccessLogMode", fsGlobalAccessLogMode)
editor.putBoolean("ignoreMissingServices", ignoreMissingServices)
editor.putBoolean("enableShaderCache", enableShaderCache)
editor.putBoolean("enableTextureRecompression", enableTextureRecompression)
editor.putBoolean("enableMacroHLE",enableMacroHLE)
editor.putFloat("resScale", resScale)
editor.putFloat("maxAnisotropy", maxAnisotropy)
editor.putBoolean("useVirtualController", useVirtualController)
editor.putBoolean("isGrid", isGrid)
editor.putBoolean("useSwitchLayout", useSwitchLayout)
editor.putBoolean("enableMotion", enableMotion)
editor.putBoolean("enablePerformanceMode", enablePerformanceMode)
editor.putFloat("controllerStickSensitivity", controllerStickSensitivity)
editor.putBoolean("enableStubLogs", enableStubLogs)
editor.putBoolean("enableInfoLogs", enableInfoLogs)
editor.putBoolean("enableWarningLogs", enableWarningLogs)
editor.putBoolean("enableErrorLogs", enableErrorLogs)
editor.putBoolean("enableGuestLogs", enableGuestLogs)
editor.putBoolean("enableFsAccessLogs", enableFsAccessLogs)
editor.putBoolean("enableTraceLogs", enableTraceLogs)
editor.putBoolean("enableDebugLogs", enableDebugLogs)
editor.putBoolean("enableGraphicsLogs", enableGraphicsLogs)
editor.apply()
putInt("memoryManagerMode", memoryManagerMode.ordinal)
putBoolean("useNce", useNce)
putInt("memoryConfiguration", memoryConfiguration.ordinal)
putInt("vSyncMode", vSyncMode.ordinal)
putBoolean("enableDocked", enableDocked)
putBoolean("enablePptc", enablePptc)
putBoolean("enableLowPowerPptc", enableLowPowerPptc)
putBoolean("enableJitCacheEviction", enableJitCacheEviction)
putBoolean("enableFsIntegrityChecks", enableFsIntegrityChecks)
putInt("fsGlobalAccessLogMode", fsGlobalAccessLogMode)
putBoolean("ignoreMissingServices", ignoreMissingServices)
putBoolean("enableShaderCache", enableShaderCache)
putBoolean("enableTextureRecompression", enableTextureRecompression)
putBoolean("enableMacroHLE", enableMacroHLE)
putFloat("resScale", resScale)
putFloat("maxAnisotropy", maxAnisotropy)
putBoolean("useVirtualController", useVirtualController)
putBoolean("isGrid", isGrid)
putBoolean("useSwitchLayout", useSwitchLayout)
putBoolean("enableMotion", enableMotion)
putBoolean("enablePerformanceMode", enablePerformanceMode)
putFloat("controllerStickSensitivity", controllerStickSensitivity)
putBoolean("enableStubLogs", enableStubLogs)
putBoolean("enableInfoLogs", enableInfoLogs)
putBoolean("enableWarningLogs", enableWarningLogs)
putBoolean("enableErrorLogs", enableErrorLogs)
putBoolean("enableGuestLogs", enableGuestLogs)
putBoolean("enableFsAccessLogs", enableFsAccessLogs)
putBoolean("enableTraceLogs", enableTraceLogs)
putBoolean("enableDebugLogs", enableDebugLogs)
putBoolean("enableGraphicsLogs", enableGraphicsLogs)
}
}
fun overrideSettings(forceNceAndPptc: Boolean?)
{
if(forceNceAndPptc == true)
{
enablePptc = true;
useNce = true;
enablePptc = true
useNce = true
}
else
{
enablePptc = false;
useNce = false;
enablePptc = false
useNce = false
}
}
}

View file

@ -18,6 +18,7 @@ import java.io.BufferedOutputStream
import java.io.File
import java.io.FileOutputStream
import kotlin.concurrent.thread
import androidx.core.content.edit
class SettingsViewModel(val activity: MainActivity) {
var selectedFirmwareVersion: String = ""
@ -31,6 +32,14 @@ class SettingsViewModel(val activity: MainActivity) {
sharedPref = getPreferences()
previousFolderCallback = activity.storageHelper!!.onFolderSelected
previousFileCallback = activity.storageHelper!!.onFileSelected
activity.storageHelper!!.onFolderSelected = { _, folder ->
run {
val p = folder.getAbsolutePath(activity)
sharedPref.edit {
this.putString("gameFolder", p)
}
}
}
}
private fun getPreferences(): SharedPreferences {
@ -70,10 +79,10 @@ class SettingsViewModel(val activity: MainActivity) {
enableDebugLogs: MutableState<Boolean>,
enableGraphicsLogs: MutableState<Boolean>
) {
memoryManagerMode.value = MemoryManagerMode.values()[sharedPref.getInt("memoryManagerMode", MemoryManagerMode.HostMappedUnsafe.ordinal)]
memoryManagerMode.value = MemoryManagerMode.entries.toTypedArray()[sharedPref.getInt("memoryManagerMode", MemoryManagerMode.HostMappedUnsafe.ordinal)]
useNce.value = sharedPref.getBoolean("useNce", false)
memoryConfiguration.value = MemoryConfiguration.values()[sharedPref.getInt("memoryConfiguration", MemoryConfiguration.MemoryConfiguration4GiB.ordinal)]
vSyncMode.value = VSyncMode.values()[sharedPref.getInt("vSyncMode", VSyncMode.Switch.ordinal)]
memoryConfiguration.value = MemoryConfiguration.entries.toTypedArray()[sharedPref.getInt("memoryConfiguration", MemoryConfiguration.MemoryConfiguration4GiB.ordinal)]
vSyncMode.value = VSyncMode.entries.toTypedArray()[sharedPref.getInt("vSyncMode", VSyncMode.Switch.ordinal)]
enableDocked.value = sharedPref.getBoolean("enableDocked", true)
enablePptc.value = sharedPref.getBoolean("enablePptc", true)
enableLowPowerPptc.value = sharedPref.getBoolean("enableLowPowerPptc", false)
@ -136,41 +145,42 @@ class SettingsViewModel(val activity: MainActivity) {
enableDebugLogs: MutableState<Boolean>,
enableGraphicsLogs: MutableState<Boolean>
) {
val editor = sharedPref.edit()
sharedPref.edit {
editor.putInt("memoryManagerMode", memoryManagerMode.value.ordinal)
editor.putBoolean("useNce", useNce.value)
editor.putInt("memoryConfiguration", memoryConfiguration.value.ordinal)
editor.putInt("vSyncMode", vSyncMode.value.ordinal)
editor.putBoolean("enableDocked", enableDocked.value)
editor.putBoolean("enablePptc", enablePptc.value)
editor.putBoolean("enableLowPowerPptc", enableLowPowerPptc.value)
editor.putBoolean("enableJitCacheEviction", enableJitCacheEviction.value)
editor.putBoolean("enableFsIntegrityChecks", enableFsIntegrityChecks.value)
editor.putInt("fsGlobalAccessLogMode", fsGlobalAccessLogMode.value)
editor.putBoolean("ignoreMissingServices", ignoreMissingServices.value)
editor.putBoolean("enableShaderCache", enableShaderCache.value)
editor.putBoolean("enableTextureRecompression", enableTextureRecompression.value)
editor.putBoolean("enableMacroHLE", enableMacroHLE.value)
editor.putFloat("resScale", resScale.value)
editor.putFloat("maxAnisotropy", maxAnisotropy.value)
editor.putBoolean("useVirtualController", useVirtualController.value)
editor.putBoolean("isGrid", isGrid.value)
editor.putBoolean("useSwitchLayout", useSwitchLayout.value)
editor.putBoolean("enableMotion", enableMotion.value)
editor.putBoolean("enablePerformanceMode", enablePerformanceMode.value)
editor.putFloat("controllerStickSensitivity", controllerStickSensitivity.value)
editor.putBoolean("enableStubLogs", enableStubLogs.value)
editor.putBoolean("enableInfoLogs", enableInfoLogs.value)
editor.putBoolean("enableWarningLogs", enableWarningLogs.value)
editor.putBoolean("enableErrorLogs", enableErrorLogs.value)
editor.putBoolean("enableGuestLogs", enableGuestLogs.value)
editor.putBoolean("enableFsAccessLogs", enableFsAccessLogs.value)
editor.putBoolean("enableTraceLogs", enableTraceLogs.value)
editor.putBoolean("enableDebugLogs", enableDebugLogs.value)
editor.putBoolean("enableGraphicsLogs", enableGraphicsLogs.value)
putInt("memoryManagerMode", memoryManagerMode.value.ordinal)
putBoolean("useNce", useNce.value)
putInt("memoryConfiguration", memoryConfiguration.value.ordinal)
putInt("vSyncMode", vSyncMode.value.ordinal)
putBoolean("enableDocked", enableDocked.value)
putBoolean("enablePptc", enablePptc.value)
putBoolean("enableLowPowerPptc", enableLowPowerPptc.value)
putBoolean("enableJitCacheEviction", enableJitCacheEviction.value)
putBoolean("enableFsIntegrityChecks", enableFsIntegrityChecks.value)
putInt("fsGlobalAccessLogMode", fsGlobalAccessLogMode.value)
putBoolean("ignoreMissingServices", ignoreMissingServices.value)
putBoolean("enableShaderCache", enableShaderCache.value)
putBoolean("enableTextureRecompression", enableTextureRecompression.value)
putBoolean("enableMacroHLE", enableMacroHLE.value)
putFloat("resScale", resScale.value)
putFloat("maxAnisotropy", maxAnisotropy.value)
putBoolean("useVirtualController", useVirtualController.value)
putBoolean("isGrid", isGrid.value)
putBoolean("useSwitchLayout", useSwitchLayout.value)
putBoolean("enableMotion", enableMotion.value)
putBoolean("enablePerformanceMode", enablePerformanceMode.value)
putFloat("controllerStickSensitivity", controllerStickSensitivity.value)
putBoolean("enableStubLogs", enableStubLogs.value)
putBoolean("enableInfoLogs", enableInfoLogs.value)
putBoolean("enableWarningLogs", enableWarningLogs.value)
putBoolean("enableErrorLogs", enableErrorLogs.value)
putBoolean("enableGuestLogs", enableGuestLogs.value)
putBoolean("enableFsAccessLogs", enableFsAccessLogs.value)
putBoolean("enableTraceLogs", enableTraceLogs.value)
putBoolean("enableDebugLogs", enableDebugLogs.value)
putBoolean("enableGraphicsLogs", enableGraphicsLogs.value)
editor.apply()
}
activity.storageHelper!!.onFolderSelected = previousFolderCallback
KenjinxNative.loggingSetEnabled(LogLevel.Info, enableInfoLogs.value)
KenjinxNative.loggingSetEnabled(LogLevel.Stub, enableStubLogs.value)

View file

@ -7,6 +7,7 @@ import androidx.compose.runtime.MutableState
import androidx.compose.runtime.snapshots.SnapshotStateList
import androidx.compose.ui.text.intl.Locale
import androidx.compose.ui.text.toLowerCase
import androidx.core.net.toUri
import com.anggrayudi.storage.SimpleStorageHelper
import com.anggrayudi.storage.file.extension
import com.google.gson.Gson
@ -39,7 +40,7 @@ class TitleUpdateViewModel(val titleId: String) {
pathsState?.clear()
pathsState?.addAll(updatesData.paths)
Uri.parse(str)?.let { uri ->
str.toUri().let { uri ->
try {
storageHelper.storage.context.contentResolver.releasePersistableUriPermission(
uri,

View file

@ -27,7 +27,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.snapshots.SnapshotStateList
import androidx.compose.ui.Alignment
@ -73,7 +72,7 @@ class DlcViews {
}
Spacer(modifier = Modifier.height(8.dp))
Column {
Text(text = "DLC for ${name}", textAlign = TextAlign.Center)
Text(text = "DLC for $name", textAlign = TextAlign.Center)
Box(
modifier = Modifier
.padding(8.dp)

View file

@ -7,20 +7,15 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.material3.Card
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
@ -310,10 +305,10 @@ class GameViews {
CompositionLocalProvider(LocalTextStyle provides TextStyle(fontSize = 10.sp)) {
Column {
var gameTimeVal = 0.0
if (!gameTime.value.isInfinite())
gameTimeVal = gameTime.value
Text(text = "${String.format("%.3f", fifo.value)} %")
Text(text = "${String.format("%.3f", gameFps.value)} FPS")
if (!gameTime.doubleValue.isInfinite())
gameTimeVal = gameTime.doubleValue
Text(text = "${String.format("%.3f", fifo.doubleValue)} %")
Text(text = "${String.format("%.3f", gameFps.doubleValue)} FPS")
Text(text = "${String.format("%.3f", gameTimeVal)} ms")
Box(modifier = Modifier.width(96.dp)) {
Column {
@ -335,12 +330,12 @@ class GameViews {
Row {
Text(modifier = Modifier.padding(2.dp), text = "Used")
Spacer(Modifier.weight(1f))
Text(text = "${usedMem.value} MB")
Text(text = "${usedMem.intValue} MB")
}
Row {
Text(modifier = Modifier.padding(2.dp), text = "Total")
Spacer(Modifier.weight(1f))
Text(text = "${totalMem.value} MB")
Text(text = "${totalMem.intValue} MB")
}
}
}

View file

@ -46,6 +46,8 @@ import androidx.compose.material3.Slider
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
@ -95,13 +97,13 @@ class SettingViews {
val enableLowPowerPptc = remember { mutableStateOf(false) }
val enableJitCacheEviction = remember { mutableStateOf(false) }
var enableFsIntegrityChecks = remember { mutableStateOf(false) }
var fsGlobalAccessLogMode = remember { mutableStateOf(0) }
var fsGlobalAccessLogMode = remember { mutableIntStateOf(0) }
val ignoreMissingServices = remember { mutableStateOf(false) }
val enableShaderCache = remember { mutableStateOf(false) }
val enableTextureRecompression = remember { mutableStateOf(false) }
val enableMacroHLE = remember { mutableStateOf(false) }
val resScale = remember { mutableStateOf(1f) }
val maxAnisotropy = remember { mutableStateOf(0f) }
val resScale = remember { mutableFloatStateOf(1f) }
val maxAnisotropy = remember { mutableFloatStateOf(0f) }
val useVirtualController = remember { mutableStateOf(true) }
val showKeyDialog = remember { mutableStateOf(false) }
val keyInstallState = remember { mutableStateOf(KeyInstallState.File) }
@ -117,7 +119,7 @@ class SettingViews {
val useSwitchLayout = remember { mutableStateOf(true) }
val enableMotion = remember { mutableStateOf(true) }
val enablePerformanceMode = remember { mutableStateOf(true) }
val controllerStickSensitivity = remember { mutableStateOf(1.0f) }
val controllerStickSensitivity = remember { mutableFloatStateOf(1.0f) }
val enableStubLogs = remember { mutableStateOf(true) }
val enableInfoLogs = remember { mutableStateOf(true) }
val enableWarningLogs = remember { mutableStateOf(true) }
@ -578,7 +580,6 @@ class SettingViews {
}
}
}
else -> {}
}
}
}
@ -803,7 +804,6 @@ class SettingViews {
}
}
}
else -> {}
}
}
}
@ -1116,8 +1116,8 @@ class SettingViews {
text = "Controller Stick Sensitivity",
modifier = Modifier.align(Alignment.CenterVertically)
)
Slider(modifier = Modifier.width(250.dp), value = controllerStickSensitivity.value, onValueChange = {
controllerStickSensitivity.value = it
Slider(modifier = Modifier.width(250.dp), value = controllerStickSensitivity.floatValue, onValueChange = {
controllerStickSensitivity.floatValue = it
}, valueRange = 0.1f..2f,
steps = 20,
interactionSource = interactionSource,
@ -1127,7 +1127,7 @@ class SettingViews {
PlainTooltip(modifier = Modifier
.sizeIn(45.dp, 25.dp)
.wrapContentWidth()) {
Text("%.2f".format(controllerStickSensitivity.value))
Text("%.2f".format(controllerStickSensitivity.floatValue))
}
},
interactionSource = interactionSource
@ -1169,12 +1169,12 @@ class SettingViews {
enablePerformanceMode.SwitchSelector(label = "Performance Mode")
}
}
ExpandableView(onCardArrowClick = { }, title = "Cpu", icon = Icons.Outlined.Memory) {
ExpandableView(onCardArrowClick = { }, title = "CPU", icon = Icons.Outlined.Memory) {
Column(modifier = Modifier.fillMaxWidth()) {
useNce.SwitchSelector(label = "Enable NCE (Native Code Execution)")
enablePptc.SwitchSelector(label = "Enable PPTC (Profiled Persistent Translation Cache)")
enableLowPowerPptc.SwitchSelector(label = "Enable Low-Power PPTC")
enableJitCacheEviction.SwitchSelector(label = "Enable Jit Cache Eviction")
useNce.SwitchSelector(label = "NCE (Native Code Execution)")
enablePptc.SwitchSelector(label = "PPTC (Profiled Persistent Translation Cache)")
enableLowPowerPptc.SwitchSelector(label = "Low-Power PPTC")
enableJitCacheEviction.SwitchSelector(label = "Jit Cache Eviction")
MemoryModeDropdown(
selectedMemoryManagerMode = memoryManagerMode.value,
onModeSelected = { mode ->
@ -1185,19 +1185,19 @@ class SettingViews {
}
ExpandableView(onCardArrowClick = { }, title = "Graphics", icon = Icons.Outlined.Panorama) {
Column(modifier = Modifier.fillMaxWidth()) {
enableShaderCache.SwitchSelector(label = "Enable Shader Cache")
enableTextureRecompression.SwitchSelector(label = "Enable Texture Recompression")
enableMacroHLE.SwitchSelector(label = "Enable Macro HLE")
enableShaderCache.SwitchSelector(label = "Shader Cache")
enableTextureRecompression.SwitchSelector(label = "Texture Recompression")
enableMacroHLE.SwitchSelector(label = "Macro HLE")
ResolutionScaleDropdown(
selectedScale = resScale.value,
selectedScale = resScale.floatValue,
onScaleSelected = { scale ->
resScale.value = scale
resScale.floatValue = scale
}
)
AnisotropicFilteringDropdown(
selectedAnisotropy = maxAnisotropy.value,
selectedAnisotropy = maxAnisotropy.floatValue,
onAnisotropySelected = { anisotropy ->
maxAnisotropy.value = anisotropy
maxAnisotropy.floatValue = anisotropy
}
)
@ -1234,19 +1234,19 @@ class SettingViews {
ExpandableView(onCardArrowClick = { }, title = "Logging", icon = Icons.Outlined.FileOpen) {
Column(modifier = Modifier.fillMaxWidth()) {
enableStubLogs.SwitchSelector(label = "Enable Stub Logs")
enableInfoLogs.SwitchSelector(label = "Enable Info Logs")
enableWarningLogs.SwitchSelector(label = "Enable Warning Logs")
enableErrorLogs.SwitchSelector(label = "Enable Error Logs")
enableGuestLogs.SwitchSelector(label = "Enable Guest Logs")
enableTraceLogs.SwitchSelector(label = "Enable Trace Logs")
enableFsAccessLogs.SwitchSelector(label = "Enable Fs Access Logs")
enableDebugLogs.SwitchSelector(label = "Enable Debug Logs")
enableGraphicsLogs.SwitchSelector(label = "Enable Graphics Logs")
enableStubLogs.SwitchSelector(label = "Stub Logs")
enableInfoLogs.SwitchSelector(label = "Info Logs")
enableWarningLogs.SwitchSelector(label = "Warning Logs")
enableErrorLogs.SwitchSelector(label = "Error Logs")
enableGuestLogs.SwitchSelector(label = "Guest Logs")
enableTraceLogs.SwitchSelector(label = "Trace Logs")
enableFsAccessLogs.SwitchSelector(label = "Fs Access Logs")
enableDebugLogs.SwitchSelector(label = "Debug Logs")
enableGraphicsLogs.SwitchSelector(label = "Graphics Logs")
FsGlobalAccessLogModeDropdown(
selectedFsGlobalAccess = fsGlobalAccessLogMode.value,
selectedFsGlobalAccess = fsGlobalAccessLogMode.intValue,
onFsGlobalAccessSelected = { fsGlobalAccess ->
fsGlobalAccessLogMode.value = fsGlobalAccess
fsGlobalAccessLogMode.intValue = fsGlobalAccess
}
)
@ -1276,10 +1276,9 @@ class SettingViews {
@Composable
fun MemoryModeDropdown(
selectedMemoryManagerMode: MemoryManagerMode,
onModeSelected: (MemoryManagerMode) -> Unit,
modifier: Modifier = Modifier
onModeSelected: (MemoryManagerMode) -> Unit
) {
val modes = MemoryManagerMode.values()
val modes = MemoryManagerMode.entries.toTypedArray()
DropdownSelector(
label = "Memory Manager Mode",
@ -1292,18 +1291,16 @@ class SettingViews {
MemoryManagerMode.HostMappedUnsafe -> "Host Unchecked (fastest, unsafe)"
}
},
onOptionSelected = onModeSelected,
modifier = modifier
onOptionSelected = onModeSelected
)
}
@Composable
fun VSyncDropdown(
selectedVSyncMode: VSyncMode,
onModeSelected: (VSyncMode) -> Unit,
modifier: Modifier = Modifier
onModeSelected: (VSyncMode) -> Unit
) {
val modes = VSyncMode.values()
val modes = VSyncMode.entries.toTypedArray()
DropdownSelector(
label = "VSync",
@ -1315,42 +1312,38 @@ class SettingViews {
VSyncMode.Unbounded -> "Unbounded"
}
},
onOptionSelected = onModeSelected,
modifier = modifier
onOptionSelected = onModeSelected
)
}
@Composable
fun MemoryDropdown(
selectedMemoryConfiguration: MemoryConfiguration,
onConfigurationSelected: (MemoryConfiguration) -> Unit,
modifier: Modifier = Modifier
onConfigurationSelected: (MemoryConfiguration) -> Unit
) {
val modes = MemoryConfiguration.values()
val modes = MemoryConfiguration.entries.toTypedArray()
DropdownSelector(
label = "Dram Size",
label = "DRAM Size",
selectedValue = selectedMemoryConfiguration,
options = modes.toList(),
getDisplayText = { configuration ->
when(configuration) {
MemoryConfiguration.MemoryConfiguration4GiB -> "4GB"
MemoryConfiguration.MemoryConfiguration6GiB -> "6GB"
MemoryConfiguration.MemoryConfiguration8GiB -> "8GB"
MemoryConfiguration.MemoryConfiguration10GiB -> "10GB"
MemoryConfiguration.MemoryConfiguration12GiB -> "12GB"
MemoryConfiguration.MemoryConfiguration4GiB -> "4GiB"
MemoryConfiguration.MemoryConfiguration6GiB -> "6GiB"
MemoryConfiguration.MemoryConfiguration8GiB -> "8GiB"
MemoryConfiguration.MemoryConfiguration10GiB -> "10GiB"
MemoryConfiguration.MemoryConfiguration12GiB -> "12GiB"
}
},
onOptionSelected = onConfigurationSelected,
modifier = modifier
onOptionSelected = onConfigurationSelected
)
}
@Composable
fun ResolutionScaleDropdown(
selectedScale: Float,
onScaleSelected: (Float) -> Unit,
modifier: Modifier = Modifier
onScaleSelected: (Float) -> Unit
) {
val scaleOptions = listOf(
0.5f to "0.5x (360p/540p)",
@ -1367,16 +1360,14 @@ class SettingViews {
getDisplayText = { scale ->
scaleOptions.find { it.first == scale }?.second ?: "${scale}x"
},
onOptionSelected = onScaleSelected,
modifier = modifier
onOptionSelected = onScaleSelected
)
}
@Composable
fun AnisotropicFilteringDropdown(
selectedAnisotropy: Float,
onAnisotropySelected: (Float) -> Unit,
modifier: Modifier = Modifier
onAnisotropySelected: (Float) -> Unit
) {
val anisotropyOptions = listOf(
0.0f to "0x",
@ -1393,16 +1384,14 @@ class SettingViews {
getDisplayText = { anisotropy ->
anisotropyOptions.find { it.first == anisotropy }?.second ?: "${anisotropy}x"
},
onOptionSelected = onAnisotropySelected,
modifier = modifier
onOptionSelected = onAnisotropySelected
)
}
@Composable
fun FsGlobalAccessLogModeDropdown(
selectedFsGlobalAccess: Int,
onFsGlobalAccessSelected: (Int) -> Unit,
modifier: Modifier = Modifier
onFsGlobalAccessSelected: (Int) -> Unit
) {
val fsGlobalAccessOptions = listOf(
0 to "0",
@ -1418,8 +1407,7 @@ class SettingViews {
getDisplayText = { fsGlobalAccess ->
fsGlobalAccessOptions.find { it.first == fsGlobalAccess }?.second ?: "${fsGlobalAccess}x"
},
onOptionSelected = onFsGlobalAccessSelected,
modifier = modifier
onOptionSelected = onFsGlobalAccessSelected
)
}
}

View file

@ -26,8 +26,8 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
@ -44,7 +44,7 @@ class TitleUpdateViews {
fun Main(titleId: String, name: String, openDialog: MutableState<Boolean>, canClose: MutableState<Boolean>) {
val viewModel = TitleUpdateViewModel(titleId)
var selectedIndex by remember { mutableStateOf(0) }
var selectedIndex by remember { mutableIntStateOf(0) }
viewModel.data?.apply {
selectedIndex = paths.indexOf(this.selected) + 1
}
@ -85,7 +85,7 @@ class TitleUpdateViews {
}
Spacer(modifier = Modifier.height(8.dp))
Column {
Text(text = "Updates for ${name}", textAlign = TextAlign.Center)
Text(text = "Updates for $name", textAlign = TextAlign.Center)
Box(
modifier = Modifier
.padding(8.dp)

View file

@ -51,7 +51,7 @@ class UserViews {
val isNavigating = remember { mutableStateOf(false) }
fun refresh() {
viewModel?.userViewModel?.refreshUsers()
viewModel.userViewModel.refreshUsers()
reload.value = true
}
LaunchedEffect(reload.value) {
@ -98,7 +98,7 @@ class UserViews {
.padding(4.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
if (viewModel.userViewModel.openedUser.id?.isNotEmpty() == true) {
if (viewModel.userViewModel.openedUser.id.isNotEmpty()) {
val openUser = viewModel.userViewModel.openedUser
Image(
bitmap = BitmapFactory.decodeByteArray(
@ -143,7 +143,7 @@ class UserViews {
.height(104.dp)
.fillMaxSize()
) {
if (viewModel.userViewModel.userList.isNotEmpty() == true) {
if (viewModel.userViewModel.userList.isNotEmpty()) {
items(viewModel.userViewModel.userList) { user ->
Box(
contentAlignment = Alignment.Center

View file

@ -20,10 +20,10 @@ import androidx.compose.ui.unit.dp
@Composable
fun ActionButton(
modifier: Modifier = Modifier,
onClick: () -> Unit,
text: String,
icon: ImageVector? = null,
modifier: Modifier = Modifier,
isFullWidth: Boolean = false,
) {
val buttonModifier = if (isFullWidth) {

View file

@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.KeyboardArrowDown
import androidx.compose.material3.Button
@ -28,8 +27,7 @@ fun <T> DropdownSelector(
selectedValue: T,
options: List<T>,
getDisplayText: (T) -> String,
onOptionSelected: (T) -> Unit,
modifier: Modifier = Modifier
onOptionSelected: (T) -> Unit
) {
val expanded = remember { mutableStateOf(false) }

View file

@ -4,8 +4,8 @@ import android.annotation.SuppressLint
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.MutableTransitionState
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.rememberTransition
import androidx.compose.animation.core.tween
import androidx.compose.animation.core.updateTransition
import androidx.compose.animation.expandVertically
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
@ -50,7 +50,7 @@ fun ExpandableView(
targetState = !mutableExpanded.value
}
}
val transition = updateTransition(transitionState, label = "transition")
val transition = rememberTransition(transitionState, label = "transition")
val arrowRotationDegree = transition.animateFloat(
transitionSpec = {
tween(durationMillis = EXPANSTION_TRANSITION_DURATION)
@ -90,14 +90,16 @@ fun ExpandableView(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Start
) {
if (icon != null) {
Icon(
imageVector = icon,
contentDescription = null,
modifier = Modifier.size(16.dp)
)
androidx.compose.foundation.layout.Spacer(modifier = Modifier.padding(end = 8.dp))
}
androidx.compose.foundation.layout.Spacer(
modifier = Modifier.padding(
end = 8.dp
)
)
Text(
text = title,
@ -129,12 +131,14 @@ fun ExpandableView(
animationSpec = tween(EXPANSTION_TRANSITION_DURATION)
)
) {
Column(modifier = Modifier.padding(
Column(
modifier = Modifier.padding(
start = 8.dp,
end = 8.dp,
top = 0.dp,
bottom = 8.dp
)) {
)
) {
content()
}
}

View file

@ -1,22 +1,17 @@
package org.kenjinx.android.widgets
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
/**
* A reusable switch component with consistent styling across the app.
@ -32,8 +27,7 @@ import androidx.compose.ui.unit.sp
fun SwitchSelector(
label: String,
checked: Boolean,
onCheckedChange: (Boolean) -> Unit,
modifier: Modifier = Modifier
onCheckedChange: (Boolean) -> Unit
) {
Row(
modifier = Modifier
@ -56,13 +50,11 @@ fun SwitchSelector(
@Composable
fun MutableState<Boolean>.SwitchSelector(
label: String,
modifier: Modifier = Modifier
label: String
) {
SwitchSelector(
label = label,
checked = this.value,
onCheckedChange = { this.value = it },
modifier = modifier
onCheckedChange = { this.value = it }
)
}