diff --git a/app/src/main/java/com/droiddeck/launcher/ComponentsMenu.kt b/app/src/main/java/com/droiddeck/launcher/ComponentsMenu.kt index 5857101ea..dfaa819f7 100644 --- a/app/src/main/java/com/droiddeck/launcher/ComponentsMenu.kt +++ b/app/src/main/java/com/droiddeck/launcher/ComponentsMenu.kt @@ -14,6 +14,7 @@ import com.droiddeck.launcher.session.ProtonDefault */ internal class ComponentsMenu(private val activity: android.app.Activity, private val ui: android.os.Handler) { var compSnapshot by mutableStateOf(null) + var defaultProtonId by mutableStateOf(null) var compCatalog by mutableStateOf>(emptyList()) var compCatalogAt by mutableStateOf(0L) var compProton by mutableStateOf(null) @@ -21,7 +22,6 @@ internal class ComponentsMenu(private val activity: android.app.Activity, privat var compChecking by mutableStateOf(false) var compBusy by mutableStateOf(null) var compDownloads by mutableStateOf>(emptyMap()) - private var shownDefault: String? = null /** Reads the Protons (and on first open saves their originals) off the UI thread; the Nightlies list comes from its cache. */ fun refreshComponents(snapshotFirst: Boolean = false) { @@ -33,11 +33,9 @@ internal class ComponentsMenu(private val activity: android.app.Activity, privat val chosen = snap?.let { s -> runCatching { ProtonDefault.selectedId(activity, s.protons.map { it.proton }) }.getOrNull() } ui.post { compSnapshot = snap ?: ComponentsManager.Snapshot(emptyList(), emptyList()) + defaultProtonId = chosen if (cat != null && cat.fetchedAt > 0) { compCatalog = cat.items; compCatalogAt = cat.fetchedAt } - if (chosen != null && chosen != shownDefault) { - shownDefault = chosen - compProton = chosen - } else if (compProton == null || snap?.protons?.none { it.proton.id == compProton } == true) { + if (compProton == null || snap?.protons?.none { it.proton.id == compProton } == true) { compProton = chosen ?: snap?.protons?.firstOrNull()?.proton?.id } } @@ -46,7 +44,6 @@ internal class ComponentsMenu(private val activity: android.app.Activity, privat fun chooseProton(id: String) { val proton = compSnapshot?.protons?.firstOrNull { it.proton.id == id }?.proton ?: return - compProton = id Thread({ val message = runCatching { when (ProtonDefault.request(activity, proton)) { @@ -55,7 +52,10 @@ internal class ComponentsMenu(private val activity: android.app.Activity, privat ProtonDefault.Outcome.NOT_RUNNABLE -> activity.getString(R.string.comp_default_not_runnable, proton.name) } }.getOrElse { e -> activity.getString(R.string.comp_default_failed, e.message ?: e.javaClass.simpleName) } - ui.post { android.widget.Toast.makeText(activity, message, android.widget.Toast.LENGTH_LONG).show() } + ui.post { + android.widget.Toast.makeText(activity, message, android.widget.Toast.LENGTH_LONG).show() + refreshComponents() + } }, "components-default").start() } diff --git a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt b/app/src/main/java/com/droiddeck/launcher/MainActivity.kt index 0414ba2b0..1ecd27fb5 100644 --- a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/MainActivity.kt @@ -60,6 +60,12 @@ import com.droiddeck.launcher.ui.ControllerMappingPage import com.droiddeck.launcher.input.ControllerPrefs import com.droiddeck.launcher.input.ControllerEditorActivity import com.droiddeck.launcher.ui.FrontEndScreen +import com.droiddeck.launcher.ui.SettingsCategory +import com.droiddeck.launcher.ui.SettingsDestination +import com.droiddeck.launcher.ui.SettingsHistory +import com.droiddeck.launcher.ui.SettingsCategoryPage +import com.droiddeck.launcher.ui.ModeSettingsContent +import com.droiddeck.launcher.ui.MenuHost import com.droiddeck.launcher.ui.FrontEndState import com.droiddeck.launcher.ui.FrontEndActions import com.droiddeck.launcher.frontend.CoverArt @@ -112,11 +118,11 @@ class MainActivity : ComponentActivity() { private var steamDeckMode by mutableStateOf(false) private var mangoapp by mutableStateOf(true) private var steamController by mutableStateOf(SessionPrefs.CONTROLLER_DECK) - private var showProtons by mutableStateOf(false) + private val showProtons get() = settingsHistory.current is SettingsDestination.Protons // Components page: FEX / DXVK / VKD3D-Proton per Proton (ComponentsManager). - private var showComponents by mutableStateOf(false) + private val showComponents get() = settingsHistory.current is SettingsDestination.Components private var focusComponentsContent by mutableStateOf(true) - private var showMapping by mutableStateOf(false) + private val showMapping get() = settingsHistory.current is SettingsDestination.Mapping private var saveBusy: String? = null /** What to do with the zip or folder the file picker hands back after a game page's Manage saves. */ private var onSavePicked: ((File) -> Unit)? = null @@ -130,7 +136,7 @@ class MainActivity : ComponentActivity() { private var desktopInstalled by mutableStateOf(false) private var offlineAccount by mutableStateOf(null) private var offline by mutableStateOf(false) - private var showPerformance by mutableStateOf(false) + private val showPerformance get() = settingsHistory.current is SettingsDestination.Performance private var clientOverride by mutableStateOf(false) private var clientCores by mutableStateOf>(emptySet()) private var gameCores by mutableStateOf>(emptySet()) @@ -303,7 +309,9 @@ class MainActivity : ComponentActivity() { } } // The mode whose settings dialog is open, with what it shows; refreshed by openModeSettings(). - private var settingsMode by mutableStateOf(null) + private var settingsHistory by mutableStateOf(SettingsHistory()) + private val settingsMode get() = (settingsHistory.current as? SettingsDestination.Category)?.mode + private var requestedRailTab by mutableStateOf(null) private var resolutionCap by mutableStateOf(1080) private var customResolution by mutableStateOf?>(null) private var fexPreset by mutableStateOf("") @@ -493,7 +501,7 @@ class MainActivity : ComponentActivity() { com.droiddeck.launcher.ui.FocusGlideHost(androidx.compose.ui.Modifier.fillMaxSize()) { val sm = settingsMode val page: (@Composable () -> Unit)? = when { - sm != null -> { { ModeSettingsHost(sm) } } + sm != null -> null showPerformance -> { { PerformanceHost() } } showProtons -> { { ProtonHost() } } showComponents -> { { ComponentsHost() } } @@ -514,7 +522,12 @@ class MainActivity : ComponentActivity() { steamGames = steamGames, emulators = emulatorList, running = runningLabel, frameGen = FrameGen.mode(this), lossless = lossless, - pageKey = sm?.let { "settings:$it" } ?: if (showPerformance) "performance" else if (showProtons) "protons" else if (showComponents) "components" else if (showMapping) "controller-mapping" else null, + pageKey = settingsHistory.current?.key, + settingsCategory = (settingsHistory.current as? SettingsDestination.Category)?.category, + settingsMode = sm ?: SessionService.MODE_STEAM, + settingsTarget = (settingsHistory.current as? SettingsDestination.Category)?.target + ?: (settingsHistory.current as? SettingsDestination.Performance)?.target, + requestedRailTab = requestedRailTab, theme = theme, isHomeApp = homeAppSelected, homeScreenEnabled = homeScreenEnabled, @@ -609,7 +622,7 @@ class MainActivity : ComponentActivity() { // A game page's Manage saves: the game's Proton and saves are read when the work runs, off the main thread. onSaveImport = { sg -> importSaves(sg.name) { GameSaves.game(sg) } }, onSaveExport = { sg, layout -> exportSaves(sg.name, layout) { GameSaves.game(sg) } }, - onPerformance = { refreshCores(); showProtons = false; showComponents = false; showMapping = false; showPerformance = true }, + onPerformance = { refreshCores(); settingsHistory = settingsHistory.open(SettingsDestination.Performance()) }, onRoms = { showRoms = true }, onFiles = { startActivity(Intent(this, com.droiddeck.launcher.files.FileManagerActivity::class.java)) }, onBrowseFiles = { dir -> @@ -643,7 +656,18 @@ class MainActivity : ComponentActivity() { OfflineMode.setEnabled(this, !OfflineMode.enabled(this)) offline = OfflineMode.enabled(this) }, - onPageBack = { settingsMode = null; showPerformance = false; showProtons = false; showComponents = false; showMapping = false }, + onPageBack = { settingsBack() }, + onCloseSettings = { settingsHistory = SettingsHistory() }, + onSettingsCategory = { category, target -> openSettingsCategory(category, target) }, + onSettingsMode = { mode -> + val destination = settingsHistory.current as? SettingsDestination.Category + if (destination != null) { + refreshModeSettings(mode) + settingsHistory = settingsHistory.replace(destination.copy(mode = mode, target = null)) + } + }, + onOpenUpdates = { settingsHistory = SettingsHistory(); requestedRailTab = "updates" }, + onRailTabHandled = { requestedRailTab = null }, onTheme = { id -> SessionPrefs.setTheme(this, id); theme = id }, onLauncherFullscreen = { on -> SessionPrefs.setLauncherFullscreen(this, on) @@ -730,11 +754,18 @@ class MainActivity : ComponentActivity() { onKeyboardButton = { on -> ControllerPrefs.setKeyboardButton(this, on); refreshController() }, onEditLayout = { startActivity(Intent(this, ControllerEditorActivity::class.java)) }, onResetLayout = { ControllerPrefs.resetAllLayouts(this); refreshController() }, - onMapping = { settingsMode = null; showPerformance = false; showProtons = false; showComponents = false; showMapping = true }, + onMapping = { settingsHistory = settingsHistory.open(SettingsDestination.Mapping) }, onResetAll = { ControllerPrefs.resetAll(this); refreshController() }, ), ), page = page, + settingsContent = { s, a, openDeveloperOptions, requestWirelessAdb -> + s.settingsCategory?.let { category -> + SettingsCategoryPage(s, a, category, s.settingsMode, s.settingsTarget, openDeveloperOptions, requestWirelessAdb) { host -> + ModeSettingsHost(s.settingsMode, category, host) + } + } + }, ) } if (showRoms) RomsDialog( @@ -969,11 +1000,7 @@ class MainActivity : ComponentActivity() { } private fun openProtons() { - settingsMode = null - showPerformance = false - showComponents = false - showMapping = false - showProtons = true + settingsHistory = settingsHistory.open(SettingsDestination.Protons) protons.refreshProtons() } @@ -988,18 +1015,14 @@ class MainActivity : ComponentActivity() { mapping = settings.mapping, onPick = { id, target -> ControllerPrefs.setTarget(this, id, target); refreshController() }, onReset = { ControllerPrefs.resetMapping(this); refreshController() }, - onBack = { showMapping = false }, + onBack = { settingsBack() }, ) } private fun openComponents(focusContent: Boolean = true, tab: String? = null) { focusComponentsContent = focusContent if (tab != null) components.compComp = tab - settingsMode = null - showPerformance = false - showProtons = false - showMapping = false - showComponents = true + settingsHistory = settingsHistory.open(SettingsDestination.Components(tab ?: components.compComp)) components.refreshComponents(snapshotFirst = true) drivers.refreshDrivers() } @@ -1025,8 +1048,15 @@ class MainActivity : ComponentActivity() { busy = if (busy) stage else components.compBusy, downloads = components.compDownloads, requestInitialFocus = focusComponentsContent, - onProton = { components.chooseProton(it) }, - onComp = { components.compComp = it }, + onProton = { components.compProton = it }, + defaultProtonId = components.defaultProtonId, + onDefaultProton = { components.chooseProton(it) }, + onComp = { tab -> + components.compComp = tab + if (settingsHistory.current is SettingsDestination.Components) { + settingsHistory = settingsHistory.replace(SettingsDestination.Components(tab)) + } + }, onSwap = { file -> components.compProton?.let { pid -> components.componentAction("Swapping") { ComponentsManager.swap(this, pid, file) } } }, onRestore = { version -> components.compProton?.let { pid -> components.componentAction("Restoring") { ComponentsManager.restore(this, pid, components.compComp, version) } } }, onCancelQueued = { components.compProton?.let { pid -> components.componentAction("Cancelling") { ComponentsManager.cancelQueued(this, pid, components.compComp); "The waiting swap was cancelled." } } }, @@ -1035,7 +1065,7 @@ class MainActivity : ComponentActivity() { onDownload = { components.downloadComponent(it) }, onRefresh = { components.refreshComponentCatalog() }, onImport = { pickComponent.launch(InAppFilePicker.buildIntent(this, WCP_EXT, "Choose a component package (-linux .wcp)")) }, - onBack = { showComponents = false }, + onBack = { settingsBack() }, gpu = drivers.state(), gpuActions = com.droiddeck.launcher.ui.GpuDriversActions( onAuto = { on -> drivers.setMode(on) }, @@ -1067,7 +1097,7 @@ class MainActivity : ComponentActivity() { onInstall = { id -> protons.installProton(id) }, onCancel = { id -> ProtonExtras.tools.firstOrNull { it.id == id }?.let { ProtonExtras.unqueue(this, it) }; protons.refreshProtons() }, onRemove = { id -> protons.removeProton(id) }, - onBack = { showProtons = false }, + onBack = { settingsBack() }, ) } @@ -1114,8 +1144,8 @@ class MainActivity : ComponentActivity() { } @Composable - private fun ModeSettingsHost(mode: String) { - ModeSettingsPage( + private fun ModeSettingsHost(mode: String, category: SettingsCategory, host: MenuHost) { + ModeSettingsContent( ModeSettings( mode = mode, resolutionCap = resolutionCap, customResolution = customResolution, shapeMode = shapeMode, hdr = hdrOn, hdrReason = hdrReason, fpsLimit = fpsLimit, @@ -1248,8 +1278,13 @@ class MainActivity : ComponentActivity() { onPickDeckyPluginZip = { pickDeckyPluginZip.launch(InAppFilePicker.buildIntent(this, ZIP_EXT, "Choose a Decky plugin ZIP")) }, - onDismiss = { settingsMode = null }, + onDismiss = { settingsBack() }, ), + category = category, + host = host, + ) + if (category == SettingsCategory.DISPLAY) com.droiddeck.launcher.ui.GraphicsSettingsContent( + host, upscaler, { value -> SessionPrefs.setUpscaler(this, value); upscaler = value }, ) } @@ -1278,7 +1313,7 @@ class MainActivity : ComponentActivity() { onGpuClockPin = { on -> SessionPrefs.setGpuClockPin(this, on); gpuClockPin = on }, onProotNoSeccomp = { on -> SessionPrefs.setProotNoSeccomp(this, on); prootNoSeccomp = on }, onProotFastPath = { on -> SessionPrefs.setProotFastPath(this, on); prootFastPath = on }, - onGuestHostname = { name -> SessionPrefs.setGuestHostname(this, name) }, + onGuestHostname = { name -> SessionPrefs.setGuestHostname(this, name); guestHostname = SessionPrefs.guestHostname(this) }, onClientCore = { core, on -> clientCores = if (on) clientCores + core else clientCores - core SessionPrefs.setClientCpus(this, CpuCores.format(clientCores)) @@ -1287,7 +1322,7 @@ class MainActivity : ComponentActivity() { gameCores = if (on) gameCores + core else gameCores - core SessionPrefs.setGameCpus(this, CpuCores.format(gameCores)) }, - onDismiss = { showPerformance = false }, + onDismiss = { settingsBack() }, ) } @@ -1324,11 +1359,42 @@ class MainActivity : ComponentActivity() { private var pipAutoEnter by mutableStateOf(false) private fun openModeSettings(mode: String) { + refreshModeSettings(mode) + settingsHistory = settingsHistory.open(SettingsDestination.Category(SettingsCategory.SESSIONS, mode)) + } + + private fun openSettingsCategory(category: SettingsCategory, target: String?) { + val entry = com.droiddeck.launcher.ui.SettingsCatalog.entries.firstOrNull { it.target == target } + val mode = entry?.mode ?: SessionService.MODE_STEAM + refreshModeSettings(mode) + settingsHistory = settingsHistory.open(SettingsDestination.Category(category, mode, target)) + when { + target == "components" || target == "default-proton" -> openComponents(true, "fex") + target == "gpu-drivers" -> openComponents(true, com.droiddeck.launcher.ui.GPU_TAB) + target == "protons" -> openProtons() + target == "controller-mapping" -> settingsHistory = settingsHistory.open(SettingsDestination.Mapping) + target == "performance" || target?.startsWith("performance:") == true -> { + refreshCores() + settingsHistory = settingsHistory.open(SettingsDestination.Performance(target?.substringAfter("performance:", "")?.ifEmpty { null })) + } + } + } + + private fun settingsBack() { + settingsHistory = settingsHistory.back() + when (val destination = settingsHistory.current) { + is SettingsDestination.Category -> refreshModeSettings(destination.mode) + is SettingsDestination.Components -> { + destination.tab?.let { components.compComp = it } + components.refreshComponents(snapshotFirst = true) + drivers.refreshDrivers() + } + else -> Unit + } + } + + private fun refreshModeSettings(mode: String) { pipAutoEnter = SessionPrefs.pipAutoEnter(this) - showPerformance = false - showProtons = false - showComponents = false - showMapping = false resolutionCap = SessionPrefs.resolutionCap(this, mode) customResolution = SessionPrefs.customResolution(this, mode) fexPreset = SessionPrefs.fexPreset(this) @@ -1360,7 +1426,6 @@ class MainActivity : ComponentActivity() { renderer = SessionPrefs.desktopRenderer(this) gameStorage = SessionPrefs.gameStorage(this) storageDiagnostics = SessionPrefs.storageDiagnosticsEnabled(this) - settingsMode = mode // The page opens at once, on what was last read; the slow part (driver files, a walk of the // added-games folders, the storage volumes) lands while it animates in. Thread({ diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ComponentsPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/ComponentsPage.kt index 47e38d76d..0b1c447b5 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/ComponentsPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/ComponentsPage.kt @@ -108,6 +108,8 @@ fun ComponentsPage( /** The GPU drivers tab ([GPU_TAB]): what it shows and does. */ gpu: GpuDriversState = GpuDriversState(), gpuActions: GpuDriversActions = GpuDriversActions(), + defaultProtonId: String? = null, + onDefaultProton: (String) -> Unit = {}, ) { val colors = MaterialTheme.colorScheme val pal = LocalPalette.current @@ -117,6 +119,7 @@ fun ComponentsPage( var confirmTitle by remember { mutableStateOf("") } var about by remember { mutableStateOf(false) } var protonMenu by remember { mutableStateOf(false) } + var defaultProtonMenu by remember { mutableStateOf(false) } var confirmVerb by remember { mutableStateOf(R.string.comp_swap) } val ctx = LocalContext.current fun ask(title: String, body: String, verb: Int, action: () -> Unit) { confirmTitle = title; confirmVerb = verb; confirm = body to action } @@ -172,32 +175,52 @@ fun ComponentsPage( } if (narrow) Text(nightlies, fontSize = 13.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis) - // ---- which Proton, which component ------------------------------------------------------ + // ---- Steam default Proton and the component editing target ----------------------------- val comps = ComponentsManager.COMPONENTS androidx.compose.foundation.layout.FlowRow( horizontalArrangement = Arrangement.spacedBy(12.dp), verticalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth().padding(top = 12.dp), ) { - if (view != null && !gpuTab) Box { - ValueChip(view.proton.name, protonMenu, modifier = Modifier.widthIn(max = 300.dp).heightIn(min = 44.dp)) { protonMenu = !protonMenu } - AnchoredMenu(protonMenu, onDismiss = { protonMenu = false }, title = stringResource(R.string.comp_proton), - note = stringResource(R.string.comp_proton_note)) { first -> - views.forEachIndexed { i, v -> - val swaps = v.components.values.count { it.activeFile != null } - MenuItem( - v.proton.name, checked = v.proton.id == view.proton.id, - detail = (if (swaps > 0) stringResource(R.string.comp_swapped, v.proton.version, swaps) else stringResource(R.string.comp_all_original, v.proton.version)) - .let { - when (v.sync?.state) { - "pack" -> stringResource(R.string.comp_esync_pack, it) - "wanted" -> stringResource(R.string.comp_esync_wanted, it) - "builtin" -> stringResource(R.string.comp_esync_builtin, it) - else -> it - } - } - .let { if (v.inUseByGame) stringResource(R.string.comp_game_running_suffix, it) else it }, - focusRequester = if (i == 0) first else null, - ) { onProton(v.proton.id); protonMenu = false } + if (view != null && !gpuTab) { + Column { + Text("Default Proton", fontSize = 12.sp, color = colors.onSurfaceVariant) + Box { + val defaultName = views.firstOrNull { it.proton.id == defaultProtonId }?.proton?.name ?: "Choose default" + ValueChip(defaultName, defaultProtonMenu, modifier = Modifier.widthIn(max = 300.dp).heightIn(min = 44.dp)) { defaultProtonMenu = !defaultProtonMenu } + AnchoredMenu(defaultProtonMenu, onDismiss = { defaultProtonMenu = false }, title = "Default Proton", + note = stringResource(R.string.comp_proton_note)) { first -> + views.forEachIndexed { i, v -> + MenuItem(v.proton.name, checked = v.proton.id == defaultProtonId, + focusRequester = if (i == 0) first else null, + ) { onDefaultProton(v.proton.id); defaultProtonMenu = false } + } + } + } + } + Column { + Text("Editing components for", fontSize = 12.sp, color = colors.onSurfaceVariant) + Box { + ValueChip(view.proton.name, protonMenu, modifier = Modifier.widthIn(max = 300.dp).heightIn(min = 44.dp)) { protonMenu = !protonMenu } + AnchoredMenu(protonMenu, onDismiss = { protonMenu = false }, title = "Editing components for", + note = "Component changes apply to this Proton. The default Proton is selected separately above.") { first -> + views.forEachIndexed { i, v -> + val swaps = v.components.values.count { it.activeFile != null } + MenuItem( + v.proton.name, checked = v.proton.id == view.proton.id, + detail = (if (swaps > 0) stringResource(R.string.comp_swapped, v.proton.version, swaps) else stringResource(R.string.comp_all_original, v.proton.version)) + .let { + when (v.sync?.state) { + "pack" -> stringResource(R.string.comp_esync_pack, it) + "wanted" -> stringResource(R.string.comp_esync_wanted, it) + "builtin" -> stringResource(R.string.comp_esync_builtin, it) + else -> it + } + } + .let { if (v.inUseByGame) stringResource(R.string.comp_game_running_suffix, it) else it }, + focusRequester = if (i == 0) first else null, + ) { onProton(v.proton.id); protonMenu = false } + } + } } } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndContent.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndContent.kt index e2b79a198..782ca07fc 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndContent.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndContent.kt @@ -119,6 +119,7 @@ internal fun Pane( val pal = LocalPalette.current // Pages keep drawing while they leave, so one can fold away instead of blinking out. val pages = remember { HashMap Unit>() } + val savedPages = androidx.compose.runtime.saveable.rememberSaveableStateHolder() // Pages opened from a control (the cog), with where that control sat, in this pane's coordinates. val origins = remember { HashMap() } val paneAt = remember { arrayOf(Offset.Zero) } @@ -154,6 +155,7 @@ internal fun Pane( label = "pane", ) { key -> val shown = if (page != null && key == s.pageKey) page else pages[key] + savedPages.SaveableStateProvider(key) { if (shown != null) { DisposableEffect(key) { onDispose { if (key != livePage) { pages.remove(key); origins.remove(key) } } } val from = origins[key] @@ -168,6 +170,7 @@ internal fun Pane( } } else Content(s, if (key == "games") gameShown[0] else key, a, Modifier.fillMaxSize(), onSelect, onAndroidAppClick, onOpenDeveloperOptions, onRequestWirelessAdb) + } } } } @@ -209,10 +212,10 @@ private fun Content( val narrow = LocalNarrowPane.current val padH = if (narrow) 16.dp else 22.dp val padV = if (narrow) 12.dp else 18.dp - // Setup scrolls inside itself, under its tabs. - if (selected == "setup") { + // Settings has its own search and scrolling. + if (selected == "settings") { Column(modifier = modifier.padding(horizontal = padH, vertical = padV)) { - SetupPanel(s, a, onOpenDeveloperOptions, onRequestWirelessAdb) + SettingsHub(s, a) } return } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndRail.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndRail.kt index 34f503311..97522b6d8 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndRail.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndRail.kt @@ -93,14 +93,14 @@ internal fun SideRail( val compact = LocalConfiguration.current.screenHeightDp < 420 // Under 600dp wide (4:3 and square screens) the labels would cost a fifth of the width. val iconOnly = isNarrowScreen() - val setupNeedsAttention = !s.ready || (s.available != null && s.available != s.installed) || + val settingsNeedsAttention = !s.ready || (s.available != null && s.available != s.installed) || PhantomProcessLimit.blocksSteam(s.phantomProcessStatus) Column( horizontalAlignment = Alignment.CenterHorizontally, modifier = modifier.width(if (iconOnly) 64.dp else 92.dp).background(colors.surface).padding(vertical = if (compact) 8.dp else 12.dp), ) { // Every section on screen at once: items shrink (to 44dp, still a touch target) before the rail scrolls. - val count = 6 + (if (s.storeEnabled) 1 else 0) + (if (s.isHomeApp) 1 else 0) + val count = 5 + (if (s.storeEnabled) 1 else 0) + (if (s.isHomeApp) 1 else 0) BoxWithConstraints(Modifier.weight(1f).fillMaxWidth()) { val fit = (maxHeight / count - 4.dp).coerceIn(44.dp, if (iconOnly) 48.dp else if (compact) 52.dp else 60.dp) Column( @@ -113,10 +113,9 @@ internal fun SideRail( RailItem(stringResource(R.string.rail_games), Icons.Outlined.VideoLibrary, "games", selected == "games", compact, iconOnly, fit, onFocus = { onFocusSelect("games") }) { onSelect("games") } RailItem(stringResource(R.string.rail_desktop), Icons.Outlined.DesktopWindows, "desktop", selected == "desktop", compact, iconOnly, fit, onFocus = { onFocusSelect("desktop") }) { onSelect("desktop") } if (s.storeEnabled) RailItem(stringResource(R.string.rail_store), Icons.Outlined.Storefront, "store", selected == "store", compact, iconOnly, fit, onFocus = { onFocusSelect("store") }) { onSelect("store") } - RailItem(stringResource(R.string.rail_components), Icons.Outlined.Layers, "components", selected == "components", compact, iconOnly, fit, onFocus = { onFocusSelect("components") }) { onSelect("components") } // Home mode's extra section goes last, so it shifts nothing above it. if (s.isHomeApp) RailItem(stringResource(R.string.rail_apps), Icons.Outlined.Apps, "android-apps", selected == "android-apps", compact, iconOnly, fit, onFocus = { onFocusSelect("android-apps") }) { onSelect("android-apps") } - RailItem(stringResource(R.string.rail_setup), Icons.Outlined.Tune, "setup", selected == "setup", compact, iconOnly, fit, badge = setupNeedsAttention, onFocus = { onFocusSelect("setup") }) { onSelect("setup") } + RailItem(stringResource(R.string.settings_title), Icons.Outlined.Tune, "settings", selected == "settings", compact, iconOnly, fit, badge = settingsNeedsAttention, onFocus = { onFocusSelect("settings") }) { onSelect("settings") } RailItem(stringResource(R.string.rail_updates), Icons.Outlined.SystemUpdate, "updates", selected == "updates", compact, iconOnly, fit, badge = s.updates.hasUpdate, onFocus = { onFocusSelect("updates") }) { onSelect("updates") } } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt index d8f8b2275..67978afde 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt @@ -100,6 +100,10 @@ class FrontEndState( val shortcutLibraryScanning: Boolean = false, val gameSyncFolder: String? = null, val pageKey: String? = null, + val settingsCategory: SettingsCategory? = null, + val settingsMode: String = "steam", + val settingsTarget: String? = null, + val requestedRailTab: String? = null, val theme: String = Themes.GRAPHITE, val isHomeApp: Boolean = false, val homeScreenEnabled: Boolean = false, @@ -122,7 +126,7 @@ class FrontEndState( val showPhantomGate: Boolean = false, val launcherFullscreen: Boolean = true, val animationsEnabled: Boolean = true, - /** The Flathub Store, a beta the user turns on in Setup. */ + /** The Flathub Store, a beta the user turns on in Settings. */ val storeEnabled: Boolean = false, /** The Updates page: DroidDeck's own builds and the channel followed. */ val updates: UpdatesState = UpdatesState(), @@ -167,6 +171,11 @@ class FrontEndActions( val onClearLogs: () -> Unit = {}, val onOffline: () -> Unit, val onPageBack: () -> Unit = {}, + val onCloseSettings: () -> Unit = {}, + val onSettingsCategory: (SettingsCategory, String?) -> Unit = { _, _ -> }, + val onSettingsMode: (String) -> Unit = {}, + val onOpenUpdates: () -> Unit = {}, + val onRailTabHandled: () -> Unit = {}, val onTheme: (String) -> Unit = {}, val onLauncherFullscreen: (Boolean) -> Unit = {}, val onAnimationsEnabled: (Boolean) -> Unit = {}, @@ -338,14 +347,22 @@ internal suspend fun focusWithinFrames(done: () -> Boolean, target: () -> FocusR } @Composable -fun FrontEndScreen(s: FrontEndState, a: FrontEndActions, page: (@Composable () -> Unit)? = null) { +fun FrontEndScreen( + s: FrontEndState, + a: FrontEndActions, + page: (@Composable () -> Unit)? = null, + settingsContent: (@Composable (FrontEndState, FrontEndActions, () -> Unit, (Boolean) -> Unit) -> Unit)? = null, +) { val frontFocus = remember { FrontFocus() } - CompositionLocalProvider(LocalFrontFocus provides frontFocus) { FrontEndScreenBody(s, a, page, frontFocus) } + CompositionLocalProvider(LocalFrontFocus provides frontFocus) { FrontEndScreenBody(s, a, page, frontFocus, settingsContent) } } @OptIn(ExperimentalComposeUiApi::class) @Composable -private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Composable () -> Unit)?, frontFocus: FrontFocus) { +private fun FrontEndScreenBody( + s: FrontEndState, a: FrontEndActions, externalPage: (@Composable () -> Unit)?, frontFocus: FrontFocus, + settingsContent: (@Composable (FrontEndState, FrontEndActions, () -> Unit, (Boolean) -> Unit) -> Unit)?, +) { var selected by rememberSaveable { mutableStateOf(if (s.shortcutPicker) "games" else "steam") } LaunchedEffect(s.shortcutPicker) { if (s.shortcutPicker) selected = "games" } var showWirelessAdbFix by rememberSaveable { mutableStateOf(false) } @@ -365,6 +382,14 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com wirelessAdbDesiredEnabled = enabled showWirelessAdbFix = true } + val page: (@Composable () -> Unit)? = if (s.settingsCategory != null && settingsContent != null) { + { settingsContent(s, a, requestDeveloperOptions, requestWirelessAdbFix) } + } else externalPage?.let { content -> + { CompositionLocalProvider(LocalSettingsTarget provides s.settingsTarget, LocalSettingsAnchorsEnabled provides true) { content() } } + } + LaunchedEffect(s.requestedRailTab) { + s.requestedRailTab?.let { selected = it; a.onRailTabHandled() } + } LaunchedEffect(s.showPhantomGate, s.phantomProcessStatus) { if (phantomGateVisible) { while (true) { @@ -383,7 +408,7 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com selected = if (selected.startsWith("rom:")) "emu:" + selected.removePrefix("rom:").substringBefore(':') else "desktop" } LaunchedEffect(s.isHomeApp) { if (!s.isHomeApp && selected == "android-apps") selected = "steam" } - // The Store turned off in Setup takes its page with it. + // The Store turned off in Settings takes its page with it. LaunchedEffect(s.storeEnabled) { if (!s.storeEnabled && selected == "store") selected = "steam" } // The last game uninstalled leaves the Games tab on its empty state. LaunchedEffect(s.steamGames.isEmpty()) { @@ -392,23 +417,15 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com remember { Motion.refresh(ctx); true } val railSelection = when { - s.pageKey == "performance" || s.pageKey == "protons" || s.pageKey == "controller-mapping" -> "setup" - s.pageKey?.startsWith("settings:steam") == true -> "steam" - s.pageKey?.startsWith("settings:") == true -> "desktop" + s.pageKey != null -> "settings" selected.startsWith("app:") -> "games" selected.startsWith("emu:") || selected.startsWith("rom:") || selected.startsWith("user:") -> "desktop" - else -> s.pageKey ?: selected + else -> selected } - // Bumped each time a rail item is picked, so a controller moves on into the new page. var railPicks by remember { mutableStateOf(0) } - val showRailPage: (String, Boolean) -> Unit = { key, focusContent -> - // Components is a full page like Protons or Performance, opened over the current rail - // selection rather than replacing it. - if (key == "components") a.onComponents(focusContent) - else { - if (s.pageKey != null) a.onPageBack() - selected = key - } + val showRailPage: (String, Boolean) -> Unit = { key, _ -> + if (s.pageKey != null) a.onCloseSettings() + selected = key } val onRailFocus: (String) -> Unit = { key -> if (key != railSelection) showRailPage(key, false) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt index c404dab6f..5bae78bcf 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt @@ -129,23 +129,134 @@ internal fun SetupPanel( onOpenDeveloperOptions: () -> Unit, onRequestWirelessAdb: (Boolean) -> Unit, ) { + SettingsHub(s, a) +} + +/** Settings owned by Setup's existing state/actions, split into hub categories. */ +@Composable +internal fun SetupContent( + s: FrontEndState, + a: FrontEndActions, + category: SettingsCategory, + host: MenuHost, + onOpenDeveloperOptions: () -> Unit, + onRequestWirelessAdb: (Boolean) -> Unit, +) { + when (category) { + SettingsCategory.GENERAL -> GeneralSettings(s, a, host) + SettingsCategory.DISPLAY -> DisplaySettings(s, a, host) + SettingsCategory.CONTROLS -> ControlsSettings(s, a, host) + SettingsCategory.AUDIO -> Unit + SettingsCategory.LIBRARY -> LibrarySettings(s, a) + SettingsCategory.SESSIONS -> SessionSettings(s, a, host) + SettingsCategory.COMPATIBILITY -> CompatibilitySettings(s, a) + SettingsCategory.SUPPORT -> SupportSettings(s, a, onOpenDeveloperOptions, onRequestWirelessAdb) + } +} + +@Composable +private fun GeneralSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost) { + SettingsGroup(stringResource(R.string.setup_launcher)) { + SettingsAnchor("theme") { SettingsRow(stringResource(R.string.setup_theme), stringResource(R.string.setup_theme_hint)) { + Box { + ValueChip(Themes.byId(s.theme).label, host.open == "theme") { host.open = if (host.open == "theme") null else "theme" } + AnchoredMenu(host.open == "theme", onDismiss = { if (host.open == "theme") host.open = null }, title = stringResource(R.string.setup_theme)) { firstItemFocus -> + Themes.all.forEachIndexed { index, theme -> + MenuItem(theme.label, checked = s.theme == theme.id, focusRequester = if (index == 0) firstItemFocus else null) { + a.onTheme(theme.id) + host.open = null + } + } + } + } + } } + ToggleRow(host, "home-screen", stringResource(R.string.setup_home), + if (s.homeScreenEnabled) stringResource(R.string.setup_home_on) else stringResource(R.string.setup_home_off), + s.homeScreenEnabled) { a.onHomeScreen(it) } + ToggleRow(host, "launcher-fullscreen", stringResource(R.string.setup_fullscreen), + if (s.launcherFullscreen) stringResource(R.string.setup_fullscreen_on) else stringResource(R.string.setup_fullscreen_off), + s.launcherFullscreen) { a.onLauncherFullscreen(it) } + ToggleRow(host, "launcher-animations", stringResource(R.string.setup_animations), null, + s.animationsEnabled, onChange = a.onAnimationsEnabled) + if (s.homeScreenEnabled) SettingsAnchor("default-home") { ActionRow(stringResource(R.string.setup_default_home), + s.defaultHomeLabel ?: stringResource(R.string.setup_choose_home), stringResource(R.string.setup_choose), a.onHomeApp) } + } + SettingsGroup(stringResource(R.string.setup_linux_apps)) { + ToggleRow(host, "store-enabled", stringResource(R.string.setup_store), + if (s.storeEnabled) stringResource(R.string.setup_store_on) else stringResource(R.string.setup_store_off), + s.storeEnabled, onChange = a.onStoreEnabled) + } +} + +@Composable +private fun DisplaySettings(s: FrontEndState, a: FrontEndActions, host: MenuHost) { + SettingsGroup("Display and graphics") { + SettingsAnchor("fg") { SettingsRow(stringResource(R.string.frame_gen_title), stringResource(R.string.frame_gen_hint)) { + Box { + ValueChip(s.frameGenLabel, host.open == "fg") { host.open = if (host.open == "fg") null else "fg" } + FrameGenMenu(s, a, host) + } + } } + } +} + +@Composable +private fun ControlsSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost) { + val controller = s.controller + if (controller != null && a.controller != null) SettingsAnchor("controller-actions") { SettingsGroup(stringResource(R.string.setup_controller)) { + ControllerRows(host, s.oscMode, controller, a.controller) + } + } else Note(stringResource(R.string.setup_controller_unavailable)) + SettingsGroup(stringResource(R.string.setup_session)) { + ChoiceRow(host, "back-actions", stringResource(R.string.mode_back), SessionPrefs.backActionsOrder(s.backActionsInverted), + listOf(false to SessionPrefs.BACK_MENU_THEN_QAM, true to SessionPrefs.BACK_QAM_THEN_MENU), + s.backActionsInverted, onPick = a.onBackActionsInverted) + } +} + +@Composable +private fun LibrarySettings(s: FrontEndState, a: FrontEndActions) { + SettingsGroup("Library and files") { + val roms = s.romsDir ?: stringResource(R.string.setup_tool_roms_hint) + SettingsAnchor("files") { ActionRow(stringResource(R.string.setup_tool_files), stringResource(R.string.setup_tool_files_hint), "Open", a.onFiles) } + SettingsAnchor("roms") { ActionRow(stringResource(R.string.setup_tool_roms), roms, "Open", a.onRoms) } + } +} + +@Composable +private fun SessionSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost) { + SettingsGroup(stringResource(R.string.setup_session)) { + ToggleRow(host, "offline", stringResource(R.string.setup_offline), + s.offlineAccount?.let { stringResource(R.string.setup_signed_in, it) } ?: stringResource(R.string.setup_sign_in_first), + s.offline, enabled = s.offlineAccount != null, onChange = { a.onOffline() }) + } +} + +@Composable +private fun CompatibilitySettings(s: FrontEndState, a: FrontEndActions) { + SettingsGroup("Compatibility tools") { + SettingsAnchor("components") { ActionRow(stringResource(R.string.setup_card_components), stringResource(R.string.setup_card_components_hint), "Open") { a.onComponents(true) } } + SettingsAnchor("protons") { ActionRow(stringResource(R.string.setup_tool_protons), stringResource(R.string.setup_tool_protons_hint), "Open", a.onProtons) } + SettingsAnchor("performance") { ActionRow(stringResource(R.string.setup_tool_performance), stringResource(R.string.setup_tool_performance_hint), "Open", a.onPerformance) } + } +} + +@Composable +private fun SupportSettings( + s: FrontEndState, + a: FrontEndActions, + onOpenDeveloperOptions: () -> Unit, + onRequestWirelessAdb: (Boolean) -> Unit, +) { + val context = LocalContext.current val host = rememberMenuHost() - val ctx = LocalContext.current var processLimitBusy by remember { mutableStateOf(false) } var processLimitMessage by remember { mutableStateOf(null) } - val setProcessLimit: (Boolean) -> Unit = { enabled -> - processLimitBusy = true - processLimitMessage = null - a.onSetPhantomProcessLimit(enabled) { error -> - processLimitBusy = false - if (error == null) { - a.onRefreshPhantomStatus() - } else { - processLimitMessage = ctx.getString(R.string.setup_limit_adb_failed) - onRequestWirelessAdb(enabled) - } - } - } + var showLimitDetails by rememberSaveable { mutableStateOf(false) } + val limitBlocks = PhantomProcessLimit.blocksSteam(s.phantomProcessStatus) + val gpu = remember { com.droiddeck.launcher.gpu.GpuInfo.detect() } + val gpuOk = gpu.support == com.droiddeck.launcher.gpu.GpuInfo.Support.TESTED + val gpuName = remember { DeviceSupport.gpuName() } val runtime = when { s.busy -> stringResource(R.string.common_working) s.removalPending -> stringResource(R.string.setup_retry_removal) @@ -153,231 +264,106 @@ internal fun SetupPanel( s.available != null && s.available != s.installed -> stringResource(R.string.common_update) else -> stringResource(R.string.setup_manage) } - val colors = MaterialTheme.colorScheme - val pal = LocalPalette.current - // Tested hardware passes; an Adreno below it (a 610, say) warns rather than claiming support. - val gpu = remember { com.droiddeck.launcher.gpu.GpuInfo.detect() } - val gpuOk = gpu.support == com.droiddeck.launcher.gpu.GpuInfo.Support.TESTED - val gpuName = remember { DeviceSupport.gpuName() } - val limitBlocks = PhantomProcessLimit.blocksSteam(s.phantomProcessStatus) - val signedIn = s.offlineAccount != null - var showLimitDetails by rememberSaveable { mutableStateOf(false) } - val checks = 4 - val readyCount = listOf(gpuOk, s.ready && !s.busy, !limitBlocks, signedIn).count { it } - // Four tabs instead of one long scroll; LB and RB turn them from anywhere on the page. Build - // and credits are on the Updates page. - val tabs = listOf(stringResource(R.string.setup_tab_overview), stringResource(R.string.setup_tab_controller), stringResource(R.string.setup_tab_session), stringResource(R.string.setup_tab_launcher)) - var tab by rememberSaveable { mutableStateOf(0) } - val tabFocus = remember { List(tabs.size) { FocusRequester() } } - var tabTurned by remember { mutableStateOf(false) } - val pick: (Int) -> Unit = { i -> tab = i; tabTurned = true } - val inputModeManager = LocalInputModeManager.current - // The control a controller was on went with the old tab: it lands on the new tab itself. - LaunchedEffect(tab) { - if (tabTurned && inputModeManager.inputMode == InputMode.Keyboard) { - androidx.compose.runtime.withFrameNanos { } - runCatching { tabFocus[tab].requestFocus() } + val setProcessLimit: (Boolean) -> Unit = { enabled -> + processLimitBusy = true + processLimitMessage = null + a.onSetPhantomProcessLimit(enabled) { error -> + processLimitBusy = false + if (error == null) a.onRefreshPhantomStatus() + else { + processLimitMessage = context.getString(R.string.setup_limit_adb_failed) + onRequestWirelessAdb(enabled) + } } } - Rise(0, Modifier.fillMaxSize()) { - Column( - modifier = Modifier.fillMaxSize().bumpers( - onPrevious = { pick((tab + tabs.size - 1) % tabs.size) }, - onNext = { pick((tab + 1) % tabs.size) }, - ), - ) { - PageHeader(stringResource(R.string.setup_title)) { - Chip(if (readyCount == checks) stringResource(R.string.setup_all_set) else stringResource(R.string.setup_n_ready, readyCount, checks), ok = readyCount == checks) - } - TabStrip(tabs, tab, pick, Modifier.padding(bottom = 4.dp), tabFocus) - Column(modifier = Modifier.weight(1f).fillMaxWidth().verticalScroll(rememberScrollState()).padding(bottom = 24.dp)) { - when (tab) { - 0 -> { - SectionTitle(stringResource(R.string.setup_system_check), null) - // What Steam needs, one row each: green when done, one button when not. The - // process-limit controls only open under their row. - Column(modifier = Modifier.fillMaxWidth().clip(Shape14).background(colors.surface).border(1.dp, pal.line, Shape14)) { - CheckRow( - if (gpuOk) CheckState.OK else CheckState.WARN, - when (gpu.support) { - com.droiddeck.launcher.gpu.GpuInfo.Support.TESTED -> stringResource(R.string.setup_gpu_supported) - com.droiddeck.launcher.gpu.GpuInfo.Support.UNTESTED -> stringResource(R.string.setup_gpu_untested) - else -> stringResource(R.string.setup_gpu_unsupported) - }, - when (gpu.support) { - com.droiddeck.launcher.gpu.GpuInfo.Support.TESTED -> stringResource(R.string.setup_gpu_detail, gpu.name, gpuName) - com.droiddeck.launcher.gpu.GpuInfo.Support.UNTESTED -> stringResource(R.string.setup_gpu_untested_detail, gpu.name, gpu.supportText.replaceFirstChar { it.lowercase() }) - else -> stringResource(R.string.setup_gpu_unsupported_detail, gpuName) - }, - ) - CheckRow( - when { s.busy -> CheckState.BUSY; !s.ready -> CheckState.WARN; else -> CheckState.OK }, - stringResource(R.string.setup_runtime), - when { - s.busy -> null - s.removalPending -> stringResource(R.string.runtime_removal_incomplete) - !s.ready -> stringResource(R.string.setup_runtime_missing) - s.available != null && s.available != s.installed -> stringResource(R.string.setup_runtime_update, s.installed ?: stringResource(R.string.setup_installed)) - else -> stringResource(R.string.setup_runtime_current, s.installed ?: stringResource(R.string.setup_installed)) - }, - divider = !s.busy, - ) { SecondaryButton(runtime, enabled = !s.busy && !s.runtimeActionsBlocked && !s.sessionRunning, compact = true, onClick = a.onRuntime) } - if (s.busy) { - Column(modifier = Modifier.fillMaxWidth().padding(start = 12.dp, end = 12.dp, bottom = 10.dp)) { - Text( - if (s.percent >= 0) stringResource(R.string.setup_runtime_progress, s.stage, s.percent) else s.stage, - fontSize = 13.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(bottom = 5.dp), - ) - if (s.percent >= 0) LinearProgressIndicator(progress = { s.percent / 100f }, modifier = Modifier.fillMaxWidth().height(4.dp)) - else LinearProgressIndicator(modifier = Modifier.fillMaxWidth().height(4.dp)) - } - Box(Modifier.fillMaxWidth().height(1.dp).background(pal.line)) - } - CheckRow( - if (limitBlocks) CheckState.WARN else CheckState.OK, - stringResource(R.string.setup_limit), - when (s.phantomProcessStatus) { - PhantomProcessStatus.ENABLED -> stringResource(R.string.setup_limit_on) - PhantomProcessStatus.UNSET -> stringResource(R.string.setup_limit_unset) - PhantomProcessStatus.UNREADABLE -> stringResource(R.string.setup_limit_unknown) - else -> PhantomProcessLimit.title(s.phantomProcessStatus) - }, - ) { - if (limitBlocks) PrimaryButton(if (showLimitDetails) stringResource(R.string.common_hide) else stringResource(R.string.setup_fix_it), compact = true) { showLimitDetails = !showLimitDetails } - else if (s.phantomProcessStatus != PhantomProcessStatus.NOT_APPLICABLE) { - SecondaryButton(if (showLimitDetails) stringResource(R.string.common_hide) else stringResource(R.string.setup_details), compact = true) { showLimitDetails = !showLimitDetails } - } - } - AnimatedVisibility(showLimitDetails, enter = expandVertically(Motion.sp(1f)) + fadeIn(Motion.sp(1f)), exit = shrinkVertically(Motion.sp(1f)) + fadeOut(Motion.sp(1f))) { - // One sentence and at most three buttons. The computer route and its - // raw command live on the full page Wireless debugging opens. - Column(modifier = Modifier.fillMaxWidth().padding(start = 56.dp, end = 14.dp, top = 4.dp, bottom = 10.dp)) { - Text( - if (limitBlocks) PhantomProcessLimit.gateInstructions(s.phantomProcessStatus) - else PhantomProcessLimit.instructions(s.phantomProcessStatus), - fontSize = 14.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(vertical = 4.dp), - ) - Actions { - if (limitBlocks) { - PrimaryButton(stringResource(R.string.setup_dev_options), compact = true, onClick = onOpenDeveloperOptions) - SecondaryButton(stringResource(R.string.setup_use_wireless), compact = true, enabled = !processLimitBusy) { setProcessLimit(false) } - SecondaryButton(stringResource(R.string.setup_check_again), compact = true, onClick = a.onRefreshPhantomStatus) - } else if (s.phantomProcessStatus == PhantomProcessStatus.DISABLED) { - SecondaryButton(stringResource(R.string.setup_limit_turn_on), compact = true, enabled = !processLimitBusy) { setProcessLimit(true) } - } - } - if (processLimitBusy) LinearProgressIndicator(modifier = Modifier.fillMaxWidth().padding(vertical = 6.dp)) - processLimitMessage?.let { Text(it, fontSize = 14.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(vertical = 4.dp)) } - } - } - CheckRow( - if (signedIn) CheckState.OK else CheckState.WARN, - stringResource(R.string.setup_account), - s.offlineAccount?.let { if (s.offline) stringResource(R.string.setup_signed_in_offline, it) else stringResource(R.string.setup_signed_in, it) } ?: stringResource(R.string.setup_sign_in), - divider = false, - ) - } - SectionTitle(stringResource(R.string.setup_tools), null) - ToolGrid(s, a) - } - 1 -> { - val controller = s.controller - if (controller != null && a.controller != null) SettingsGroup(stringResource(R.string.setup_controller)) { - ControllerRows(host, s.oscMode, controller, a.controller) - } - if (s.controller == null || a.controller == null) Note(stringResource(R.string.setup_controller_unavailable)) - } - 2 -> { - SettingsGroup(stringResource(R.string.setup_session)) { - ChoiceRow( - host, "back-actions", stringResource(R.string.mode_back), SessionPrefs.backActionsOrder(s.backActionsInverted), - listOf( - false to SessionPrefs.BACK_MENU_THEN_QAM, - true to SessionPrefs.BACK_QAM_THEN_MENU, - ), s.backActionsInverted, onPick = a.onBackActionsInverted, - ) - SettingsRow(stringResource(R.string.frame_gen_title), stringResource(R.string.frame_gen_hint)) { - Box { - ValueChip(s.frameGenLabel, host.open == "fg") { host.open = if (host.open == "fg") null else "fg" } - FrameGenMenu(s, a, host) - } - } - ToggleRow(host, "logs", stringResource(R.string.setup_logs), stringResource(R.string.setup_logs_hint), s.logsEnabled) { a.onLogs() } - ActionRow(stringResource(R.string.setup_latest_logs), stringResource(R.string.drawer_logs_hint), stringResource(R.string.drawer_share_logs), a.onShareLogs) - ActionRow(stringResource(R.string.setup_saved_logs), stringResource(R.string.setup_saved_logs_hint, com.droiddeck.launcher.session.SessionPaths.KEEP_SESSIONS), stringResource(R.string.setup_clear_logs), a.onClearLogs) - ToggleRow( - host, "offline", stringResource(R.string.setup_offline), - s.offlineAccount?.let { stringResource(R.string.setup_signed_in, it) } ?: stringResource(R.string.setup_sign_in_first), - s.offline, enabled = s.offlineAccount != null, - ) { a.onOffline() } - } - } - 3 -> { - SettingsGroup(stringResource(R.string.setup_launcher)) { - SettingsRow(stringResource(R.string.setup_theme), stringResource(R.string.setup_theme_hint)) { - Box { - ValueChip(Themes.byId(s.theme).label, host.open == "theme") { host.open = if (host.open == "theme") null else "theme" } - AnchoredMenu(host.open == "theme", onDismiss = { if (host.open == "theme") host.open = null }, title = stringResource(R.string.setup_theme)) { firstItemFocus -> - Themes.all.forEachIndexed { index, theme -> - MenuItem(theme.label, checked = s.theme == theme.id, focusRequester = if (index == 0) firstItemFocus else null) { - a.onTheme(theme.id) - host.open = null - } - } - } - } - } - ToggleRow( - host, "home-screen", stringResource(R.string.setup_home), - if (s.homeScreenEnabled) stringResource(R.string.setup_home_on) else stringResource(R.string.setup_home_off), - s.homeScreenEnabled, - ) { a.onHomeScreen(it) } - ToggleRow( - host, "launcher-fullscreen", stringResource(R.string.setup_fullscreen), - if (s.launcherFullscreen) stringResource(R.string.setup_fullscreen_on) else stringResource(R.string.setup_fullscreen_off), - s.launcherFullscreen, - ) { a.onLauncherFullscreen(it) } - ToggleRow(host, "launcher-animations", stringResource(R.string.setup_animations), null, - s.animationsEnabled, onChange = a.onAnimationsEnabled) - if (s.homeScreenEnabled) { - ActionRow(stringResource(R.string.setup_default_home), s.defaultHomeLabel ?: stringResource(R.string.setup_choose_home), stringResource(R.string.setup_choose), a.onHomeApp) - } - } - SettingsGroup(stringResource(R.string.setup_linux_apps)) { - ToggleRow( - host, "store-enabled", stringResource(R.string.setup_store), - if (s.storeEnabled) stringResource(R.string.setup_store_on) - else stringResource(R.string.setup_store_off), - s.storeEnabled, - ) { a.onStoreEnabled(it) } - } - } + SettingsGroup(stringResource(R.string.setup_system_check)) { + Column(modifier = Modifier.fillMaxWidth().clip(Shape14).background(MaterialTheme.colorScheme.surface) + .border(1.dp, LocalPalette.current.line, Shape14)) { + CheckRow( + if (gpuOk) CheckState.OK else CheckState.WARN, + when (gpu.support) { + com.droiddeck.launcher.gpu.GpuInfo.Support.TESTED -> stringResource(R.string.setup_gpu_supported) + com.droiddeck.launcher.gpu.GpuInfo.Support.UNTESTED -> stringResource(R.string.setup_gpu_untested) + else -> stringResource(R.string.setup_gpu_unsupported) + }, + when (gpu.support) { + com.droiddeck.launcher.gpu.GpuInfo.Support.TESTED -> stringResource(R.string.setup_gpu_detail, gpu.name, gpuName) + com.droiddeck.launcher.gpu.GpuInfo.Support.UNTESTED -> stringResource(R.string.setup_gpu_untested_detail, gpu.name, gpu.supportText.replaceFirstChar { it.lowercase() }) + else -> stringResource(R.string.setup_gpu_unsupported_detail, gpuName) + }, + ) + SettingsAnchor("runtime") { CheckRow( + when { s.busy -> CheckState.BUSY; !s.ready -> CheckState.WARN; else -> CheckState.OK }, + stringResource(R.string.setup_runtime), + when { + s.busy -> null + s.removalPending -> stringResource(R.string.runtime_removal_incomplete) + !s.ready -> stringResource(R.string.setup_runtime_missing) + s.available != null && s.available != s.installed -> stringResource(R.string.setup_runtime_update, s.installed ?: stringResource(R.string.setup_installed)) + else -> stringResource(R.string.setup_runtime_current, s.installed ?: stringResource(R.string.setup_installed)) + }, + divider = !s.busy, + ) { SecondaryButton(runtime, enabled = !s.busy && !s.runtimeActionsBlocked && !s.sessionRunning, compact = true, onClick = a.onRuntime) } } + if (s.busy) { + Column(modifier = Modifier.fillMaxWidth().padding(start = 12.dp, end = 12.dp, bottom = 10.dp)) { + Text(if (s.percent >= 0) stringResource(R.string.setup_runtime_progress, s.stage, s.percent) else s.stage, + fontSize = 13.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(bottom = 5.dp)) + if (s.percent >= 0) LinearProgressIndicator(progress = { s.percent / 100f }, modifier = Modifier.fillMaxWidth().height(4.dp)) + else LinearProgressIndicator(modifier = Modifier.fillMaxWidth().height(4.dp)) } } + SettingsAnchor("phantom-process") { CheckRow( + if (limitBlocks) CheckState.WARN else CheckState.OK, + stringResource(R.string.setup_limit), + when (s.phantomProcessStatus) { + PhantomProcessStatus.ENABLED -> stringResource(R.string.setup_limit_on) + PhantomProcessStatus.UNSET -> stringResource(R.string.setup_limit_unset) + PhantomProcessStatus.UNREADABLE -> stringResource(R.string.setup_limit_unknown) + else -> PhantomProcessLimit.title(s.phantomProcessStatus) + }, + ) { + if (limitBlocks) PrimaryButton(if (showLimitDetails) stringResource(R.string.common_hide) else stringResource(R.string.setup_fix_it), compact = true) { showLimitDetails = !showLimitDetails } + else if (s.phantomProcessStatus != PhantomProcessStatus.NOT_APPLICABLE) SecondaryButton( + if (showLimitDetails) stringResource(R.string.common_hide) else stringResource(R.string.setup_details), compact = true, + ) { showLimitDetails = !showLimitDetails } + } } + AnimatedVisibility(showLimitDetails, enter = expandVertically(Motion.sp(1f)) + fadeIn(Motion.sp(1f)), exit = shrinkVertically(Motion.sp(1f)) + fadeOut(Motion.sp(1f))) { + Column(modifier = Modifier.fillMaxWidth().padding(start = 56.dp, end = 14.dp, top = 4.dp, bottom = 10.dp)) { + Text(if (limitBlocks) PhantomProcessLimit.gateInstructions(s.phantomProcessStatus) else PhantomProcessLimit.instructions(s.phantomProcessStatus), + fontSize = 14.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(vertical = 4.dp)) + Actions { + if (limitBlocks) { + PrimaryButton(stringResource(R.string.setup_dev_options), compact = true, onClick = onOpenDeveloperOptions) + SecondaryButton(stringResource(R.string.setup_use_wireless), compact = true, enabled = !processLimitBusy) { setProcessLimit(false) } + SecondaryButton(stringResource(R.string.setup_check_again), compact = true, onClick = a.onRefreshPhantomStatus) + } else if (s.phantomProcessStatus == PhantomProcessStatus.DISABLED) { + SecondaryButton(stringResource(R.string.setup_limit_turn_on), compact = true, enabled = !processLimitBusy) { setProcessLimit(true) } + } + } + if (processLimitBusy) LinearProgressIndicator(modifier = Modifier.fillMaxWidth().padding(vertical = 6.dp)) + processLimitMessage?.let { Text(it, fontSize = 14.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(vertical = 4.dp)) } + } + } + CheckRow( + if (s.offlineAccount != null) CheckState.OK else CheckState.WARN, + stringResource(R.string.setup_account), + s.offlineAccount?.let { if (s.offline) stringResource(R.string.setup_signed_in_offline, it) else stringResource(R.string.setup_signed_in, it) } + ?: stringResource(R.string.setup_sign_in), + divider = false, + ) } } + SettingsAnchor("session-logs") { SettingsGroup(stringResource(R.string.setup_session)) { + ToggleRow(host, "logs", stringResource(R.string.setup_logs), stringResource(R.string.setup_logs_hint), s.logsEnabled) { a.onLogs() } + SettingsAnchor("latest-logs") { ActionRow(stringResource(R.string.setup_latest_logs), stringResource(R.string.drawer_logs_hint), stringResource(R.string.drawer_share_logs), a.onShareLogs) } + SettingsAnchor("saved-logs") { ActionRow(stringResource(R.string.setup_saved_logs), stringResource(R.string.setup_saved_logs_hint, com.droiddeck.launcher.session.SessionPaths.KEEP_SESSIONS), stringResource(R.string.setup_clear_logs), a.onClearLogs) } + } } + SettingsGroup("More support") { + SettingsAnchor("updates") { ActionRow("DroidDeck updates", "Build information and release channel", "Open", a.onOpenUpdates) } + } } /** The launcher's own tools as cards: four across, two by two on a narrow page. */ -@Composable -private fun ToolGrid(s: FrontEndState, a: FrontEndActions) { - val columns = if (LocalNarrowPane.current) 2 else 4 - val tools = listOf( - ToolSpec(Icons.Outlined.Folder, stringResource(R.string.setup_tool_files), stringResource(R.string.setup_tool_files_hint), a.onFiles), - ToolSpec(Icons.Outlined.Extension, stringResource(R.string.setup_tool_protons), stringResource(R.string.setup_tool_protons_hint), a.onProtons), - ToolSpec(Icons.Outlined.Speed, stringResource(R.string.setup_tool_performance), stringResource(R.string.setup_tool_performance_hint), a.onPerformance), - ToolSpec(Icons.Outlined.VideogameAsset, stringResource(R.string.setup_tool_roms), s.romsDir ?: stringResource(R.string.setup_tool_roms_hint), a.onRoms), - ) - Column(verticalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth()) { - for (row in tools.chunked(columns)) { - Row(horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth().height(IntrinsicSize.Min)) { - for (t in row) ToolCard(t, Modifier.weight(1f).fillMaxHeight()) - repeat(columns - row.size) { Spacer(Modifier.weight(1f)) } - } - } - } -} - private class ToolSpec(val icon: ImageVector, val title: String, val detail: String, val onClick: () -> Unit) @Composable diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndWidgets.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndWidgets.kt index 630fd5de9..4dd3475a1 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndWidgets.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndWidgets.kt @@ -217,7 +217,7 @@ internal fun SecondaryButton(text: String, enabled: Boolean = true, compact: Boo val fill by animateColorAsState(if (hot) pal.signal.copy(alpha = 0.14f) else Color.White.copy(alpha = 0.03f), Motion.tw(250), label = "secFill") Box( contentAlignment = Alignment.Center, - modifier = modifier.paneItem("btn:$text").downToFirstTile().heightIn(min = if (compact) 44.dp else 48.dp).graphicsLayer { scaleX = scale; scaleY = scale }.clip(Shape12).background(fill).glideBorder(hot, Shape12, pal.signal, pal.line2) + modifier = modifier.paneItem(LocalSettingsAnchorId.current?.let { "setting:$it:$text" } ?: "btn:$text").downToFirstTile().heightIn(min = if (compact) 44.dp else 48.dp).graphicsLayer { scaleX = scale; scaleY = scale }.clip(Shape12).background(fill).glideBorder(hot, Shape12, pal.signal, pal.line2) .alpha(if (enabled) 1f else 0.5f) .hoverable(src).clickable(interactionSource = src, indication = LocalIndication.current, enabled = enabled, onClick = onClick) .controllerConfirm(enabled = enabled, onClick = onClick) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/GraphicsSettings.kt b/app/src/main/java/com/droiddeck/launcher/ui/GraphicsSettings.kt new file mode 100644 index 000000000..1f94c4fd4 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/GraphicsSettings.kt @@ -0,0 +1,141 @@ +package com.droiddeck.launcher.ui + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource +import com.droiddeck.launcher.R +import com.droiddeck.launcher.gpu.ScreenEffectLooks +import com.droiddeck.launcher.gpu.ScreenEffects +import com.droiddeck.launcher.session.SessionPrefs +import java.util.Locale +import kotlin.math.roundToInt + +/** Persistent graphics defaults shown in the launcher's settings page. */ +@Composable +fun GraphicsSettingsContent(host: MenuHost, upscaler: Int, onUpscaler: (Int) -> Unit) { + val context = LocalContext.current + var effects by remember(context) { mutableStateOf(SessionPrefs.screenEffects(context)) } + var anisotropy by remember(context) { mutableIntStateOf(SessionPrefs.textureAnisotropy(context)) } + var lodBias by remember(context) { mutableStateOf(SessionPrefs.textureLodBias(context)) } + + SettingsAdvanced("graphics-effects", stringResource(R.string.drawer_effects), targets = EFFECT_SETTING_IDS) { + ScreenEffectsSettings( + host = host, + effects = effects, + upscaler = upscaler, + onEffects = { value -> SessionPrefs.setScreenEffects(context, value); effects = value }, + onUpscaler = onUpscaler, + grouped = false, + ) + } + SettingsAdvanced("graphics-texture", stringResource(R.string.drawer_texture), targets = TEXTURE_SETTING_IDS) { + TextureFilteringSettings( + host = host, + anisotropy = anisotropy, + lodBias = lodBias, + onAnisotropy = { value -> SessionPrefs.setTextureAnisotropy(context, value); anisotropy = value }, + onLodBias = { value -> SessionPrefs.setTextureLodBias(context, value); lodBias = value }, + grouped = false, + ) + } +} + +/** Screen post-processing settings, shared by new sessions and applied live in the session drawer. */ +@Composable +internal fun ScreenEffectsSettings( + host: MenuHost, + effects: ScreenEffects, + upscaler: Int, + onEffects: (ScreenEffects) -> Unit, + onUpscaler: (Int) -> Unit, + grouped: Boolean = true, + track: (String) -> Modifier = { Modifier }, +) { + val look = ScreenEffectLooks.match(effects, upscaler) + val rows: @Composable androidx.compose.foundation.layout.ColumnScope.() -> Unit = { + val looks = ScreenEffectLooks.LOOKS.map { it.name to it.name } + ChoiceRow(host, "effects-look", stringResource(R.string.drawer_look), + look?.desc ?: stringResource(R.string.drawer_effects_hint), + if (look == null) listOf(LOOK_CUSTOM to stringResource(R.string.drawer_look_custom)) + looks else looks, + look?.name ?: LOOK_CUSTOM, chipModifier = track("look"), hintLines = 2) { name -> + ScreenEffectLooks.LOOKS.firstOrNull { it.name == name }?.let { picked -> + picked.scalingMode?.let(onUpscaler) + onEffects(picked.effects) + } + } + ToggleRow(host, "effects-cas", stringResource(R.string.drawer_cas), null, effects.cas, chipModifier = track("cas")) { onEffects(effects.copy(cas = it)) } + SettingsAnchor("effects-cas-level") { + SliderRow(stringResource(R.string.drawer_cas_level), null, effects.casLevel, 0..100, step = 5, enabled = effects.cas, + format = { "$it%" }, modifier = track("cas-level").settingsTarget("effects-cas-level")) { onEffects(effects.copy(casLevel = it)) } + } + ToggleRow(host, "effects-fake-hdr", stringResource(R.string.drawer_fake_hdr), null, effects.hdr, chipModifier = track("fake-hdr")) { onEffects(effects.copy(hdr = it)) } + ToggleRow(host, "effects-deband", stringResource(R.string.drawer_deband), null, effects.deband, chipModifier = track("deband")) { onEffects(effects.copy(deband = it)) } + SettingsAnchor("effects-deband-strength") { + SliderRow(stringResource(R.string.drawer_deband_strength), null, effects.debandStrength, 0..200, step = 5, enabled = effects.deband, + format = { "$it%" }, modifier = track("deband-strength").settingsTarget("effects-deband-strength")) { onEffects(effects.copy(debandStrength = it)) } + } + SettingsAnchor("effects-brightness") { + SliderRow(stringResource(R.string.drawer_brightness), null, effects.brightness, -100..100, step = 2, + format = ::signed, modifier = track("brightness").settingsTarget("effects-brightness")) { onEffects(effects.copy(brightness = it)) } + } + SettingsAnchor("effects-contrast") { + SliderRow(stringResource(R.string.drawer_contrast), null, effects.contrast, -100..100, step = 2, + format = ::signed, modifier = track("contrast").settingsTarget("effects-contrast")) { onEffects(effects.copy(contrast = it)) } + } + SettingsAnchor("effects-gamma") { + SliderRow(stringResource(R.string.drawer_gamma), null, (effects.gamma * 100f).roundToInt(), 50..300, step = 5, + format = { String.format(Locale.US, "%.2f", it / 100f) }, modifier = track("gamma").settingsTarget("effects-gamma")) { onEffects(effects.copy(gamma = it / 100f)) } + } + SettingsAnchor("effects-saturation") { + SliderRow(stringResource(R.string.drawer_saturation), null, effects.saturation, 0..200, step = 5, + format = { "$it%" }, modifier = track("saturation").settingsTarget("effects-saturation")) { onEffects(effects.copy(saturation = it)) } + } + ToggleRow(host, "effects-fxaa", stringResource(R.string.drawer_fxaa), null, effects.fxaa, chipModifier = track("fxaa")) { onEffects(effects.copy(fxaa = it)) } + ToggleRow(host, "effects-toon", stringResource(R.string.drawer_toon), null, effects.toon, chipModifier = track("toon")) { onEffects(effects.copy(toon = it)) } + ToggleRow(host, "effects-crt", stringResource(R.string.drawer_crt), null, effects.crt, chipModifier = track("crt")) { onEffects(effects.copy(crt = it)) } + ToggleRow(host, "effects-ntsc", stringResource(R.string.drawer_ntsc), null, effects.ntsc, chipModifier = track("ntsc")) { onEffects(effects.copy(ntsc = it)) } + } + if (grouped) SettingsGroup(stringResource(R.string.drawer_effects), content = rows) + else androidx.compose.foundation.layout.Column(Modifier.fillMaxWidth(), content = rows) +} + +/** DXVK filtering options saved as shared defaults and consumed by each game's next launch. */ +@Composable +internal fun TextureFilteringSettings( + host: MenuHost, + anisotropy: Int, + lodBias: String, + onAnisotropy: (Int) -> Unit, + onLodBias: (String) -> Unit, + grouped: Boolean = true, + track: (String) -> Modifier = { Modifier }, +) { + val rows: @Composable androidx.compose.foundation.layout.ColumnScope.() -> Unit = { + ChoiceRow(host, "textures-anisotropy", stringResource(R.string.drawer_anisotropy), stringResource(R.string.drawer_texture_hint), + SessionPrefs.textureAnisotropyChoices, anisotropy, chipModifier = track("anisotropy"), onPick = onAnisotropy) + ChoiceRow(host, "textures-sharpness", stringResource(R.string.drawer_texture_sharpness), stringResource(R.string.drawer_texture_hint), + SessionPrefs.textureLodBiasChoices, lodBias, note = stringResource(R.string.drawer_texture_sharpness_note), + chipModifier = track("texture-sharpness"), onPick = onLodBias) + } + if (grouped) SettingsGroup(stringResource(R.string.drawer_texture), content = rows) + else androidx.compose.foundation.layout.Column(Modifier.fillMaxWidth(), content = rows) +} + +private const val LOOK_CUSTOM = "__custom__" + +private val EFFECT_SETTING_IDS = setOf( + "effects-look", "effects-cas", "effects-cas-level", "effects-fake-hdr", "effects-deband", + "effects-deband-strength", "effects-brightness", "effects-contrast", "effects-gamma", + "effects-saturation", "effects-fxaa", "effects-toon", "effects-crt", "effects-ntsc", +) + +private val TEXTURE_SETTING_IDS = setOf("textures-anisotropy", "textures-sharpness") + +private fun signed(value: Int) = if (value > 0) "+$value" else value.toString() diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt index 714b6590e..483d96840 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt @@ -1,7 +1,6 @@ package com.droiddeck.launcher.ui import androidx.compose.ui.res.pluralStringResource -import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.Row @@ -162,8 +161,6 @@ class ModeSettingsActions( fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) { val steam = s.mode == SessionService.MODE_STEAM val host = rememberMenuHost() - var confirmDeckyRemoval by remember { mutableStateOf(false) } - var explainWifiDiscovery by remember { mutableStateOf(false) } val pageScroll = androidx.compose.foundation.rememberScrollState() val firstChip = remember { androidx.compose.ui.focus.FocusRequester() } androidx.compose.runtime.LaunchedEffect(Unit) { @@ -178,6 +175,26 @@ fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) { onBack = a.onDismiss, scroll = pageScroll, ) { + for (category in SettingsCategory.values()) { + ModeSettingsContent(s, a, category, host, firstChip) + } + } +} + +/** Renders only the mode-specific rows for one Settings hub category. */ +@Composable +fun ModeSettingsContent( + s: ModeSettings, + a: ModeSettingsActions, + category: SettingsCategory, + host: MenuHost, + firstChip: androidx.compose.ui.focus.FocusRequester? = null, +) { + val steam = s.mode == SessionService.MODE_STEAM + var confirmDeckyRemoval by remember { mutableStateOf(false) } + var explainWifiDiscovery by remember { mutableStateOf(false) } + when (category) { + SettingsCategory.DISPLAY -> { SettingsGroup(stringResource(R.string.mode_display)) { val default = SessionPrefs.defaultResolutionCap(s.mode) var editCustom by remember { mutableStateOf(false) } @@ -188,12 +205,12 @@ fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) { .map { (cap, label) -> cap to (if (cap == default) stringResource(R.string.mode_res_default, label) else label) } + (CUSTOM to (custom?.let { stringResource(R.string.mode_res_custom_value, it.first, it.second) } ?: stringResource(R.string.mode_res_custom))), if (custom != null) CUSTOM else s.resolutionCap, note = stringResource(R.string.mode_res_note), - chipModifier = androidx.compose.ui.Modifier.focusRequester(firstChip), + chipModifier = firstChip?.let { androidx.compose.ui.Modifier.focusRequester(it) } ?: androidx.compose.ui.Modifier, onPick = { v -> if (v == CUSTOM) editCustom = true else { a.onCustomResolution(null); a.onResolution(v) } }, ) ChoiceRow( host, "shape", stringResource(R.string.mode_ratio), - if (custom != null) stringResource(R.string.mode_ratio_custom) else stringResource(R.string.mode_ratio_auto), + "Shared · " + if (custom != null) stringResource(R.string.mode_ratio_custom) else stringResource(R.string.mode_ratio_auto), com.droiddeck.launcher.session.SessionPrefs.shapeChoices, s.shapeMode, enabled = custom == null, onPick = a.onShape, ) ChoiceRow( @@ -203,15 +220,15 @@ fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) { onPick = a.onFpsLimit, ) ChoiceRow( - host, "upscaler", stringResource(R.string.drawer_scaling), "How the picture is resized to the screen; the sharpening modes sharpen where it is enlarged.", + host, "upscaler", stringResource(R.string.drawer_scaling), "Shared · Applies next session. How the picture is resized to the screen; the sharpening modes sharpen where it is enlarged.", com.droiddeck.launcher.session.SessionPrefs.upscalerChoices, s.upscaler, note = "The sharpening modes work only when the session is smaller than the screen; Linear, Nearest and Sharpen only work at any size. Costs a little GPU time.", onPick = a.onUpscaler, ) - SliderRow( - stringResource(R.string.drawer_scaling_sharpness), null, s.upscaleSharpness, 0..100, step = 5, + SettingsAnchor("upscale-sharpness") { SliderRow( + stringResource(R.string.drawer_scaling_sharpness), "Shared · Applies next session.", s.upscaleSharpness, 0..100, step = 5, enabled = s.upscaler != 0, format = { "$it%" }, onChange = a.onUpscaleSharpness, - ) + ) } if (editCustom) CustomResolutionDialog( initial = custom, onSave = { size -> editCustom = false; a.onCustomResolution(size) }, @@ -226,28 +243,24 @@ fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) { checked = s.hdr && s.hdrReason == null, enabled = s.hdrReason == null, onChange = a.onHdr, ) } - SettingsGroup(stringResource(R.string.mode_drivers)) { - SettingsRow(stringResource(R.string.mode_gpu_drivers), stringResource(R.string.mode_gpu_drivers_hint)) { - ValueChip(s.gpuDrivers, open = false) { a.onGpuDrivers() } - } + if (s.forceFullscreen != null) SettingsGroup(stringResource(R.string.mode_display)) { + ToggleRow(host, "fill", stringResource(R.string.mode_fill), stringResource(R.string.mode_fill_hint), s.forceFullscreen, onChange = a.onForceFullscreen) + if (s.stretch16x9 != null) ToggleRow(host, "stretch169", stringResource(R.string.mode_stretch169), stringResource(R.string.mode_stretch169_hint), s.stretch16x9, onChange = a.onStretch16x9) } + if (steam) SettingsGroup(stringResource(R.string.mode_client)) { + ToggleRow(host, "mangoapp", stringResource(R.string.mode_mangoapp), + if (s.steamDeckMode) stringResource(R.string.mode_mangoapp_hint) else "Enable Steam Deck mode in Sessions to use this overlay. Applies next session.", + s.mangoapp, enabled = s.steamDeckMode, onChange = a.onMangoapp) + } + } + SettingsCategory.CONTROLS -> { SettingsGroup(if (steam) stringResource(R.string.mode_touch_controls) else stringResource(R.string.mode_touch)) { ChoiceRow( - host, "touch", stringResource(R.string.mode_touch), null, + host, "touch", stringResource(R.string.mode_touch), "Shared · Applies next session.", listOf(SessionPrefs.TOUCH_AUTO to stringResource(R.string.common_auto), SessionPrefs.TOUCH_PAD to stringResource(R.string.mode_touch_touchpad), SessionPrefs.TOUCH_DIRECT to stringResource(R.string.mode_touch_direct), SessionPrefs.TOUCH_OFF to stringResource(R.string.widgets_off)), s.touchMode, note = stringResource(R.string.mode_touch_note), onPick = a.onTouch, ) - if (steam && s.oscMode != null) ChoiceRow( - host, "osc", stringResource(R.string.mode_osc), null, - listOf( - SessionPrefs.OSC_AUTO to stringResource(R.string.common_auto), - SessionPrefs.OSC_ALWAYS to stringResource(R.string.common_always), - SessionPrefs.OSC_STEAM_QAM to stringResource(R.string.mode_osc_qam), - SessionPrefs.OSC_NEVER to stringResource(R.string.common_never), - ), s.oscMode, - note = stringResource(R.string.mode_osc_note), onPick = a.onOsc, - ) if (steam && s.steamController != null) ChoiceRow( host, "controller", stringResource(R.string.mode_controller), stringResource(R.string.mode_controller_hint), listOf( @@ -257,14 +270,63 @@ fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) { note = stringResource(R.string.mode_controller_note), onPick = a.onSteamController, ) - if (steam) ChoiceRow( - host, "back-actions", stringResource(R.string.mode_back), SessionPrefs.backActionsOrder(s.backActionsInverted), - listOf( - false to SessionPrefs.BACK_MENU_THEN_QAM, - true to SessionPrefs.BACK_QAM_THEN_MENU, - ), s.backActionsInverted, onPick = a.onBackActionsInverted, - ) } + } + SettingsCategory.AUDIO -> { + if (steam && s.directAudio != null && s.mic != null) SettingsGroup(stringResource(R.string.mode_audio)) { + ToggleRow(host, "da", stringResource(R.string.mode_directaudio), stringResource(R.string.mode_directaudio_hint), s.directAudio, onChange = a.onDirectAudio) + ChoiceRow( + host, "clientAudio", "Steam-menu audio", "Steam menus only. " + stringResource(R.string.mode_client_audio_hint), + listOf("classic" to stringResource(R.string.mode_client_audio_classic), "directaudio" to stringResource(R.string.mode_client_audio_direct)), if (s.clientDirectAudio) "directaudio" else "classic", + onPick = { id -> a.onClientDirectAudio(id == "directaudio") }, + ) + ToggleRow(host, "mic", stringResource(R.string.mode_mic), stringResource(R.string.mode_mic_hint), s.mic, onChange = a.onMic) + } + } + SettingsCategory.LIBRARY -> { + if (steam && s.addedGamesDirs != null) SettingsAnchor("added-games") { SettingsGroup(stringResource(R.string.mode_added_games)) { + for (dir in s.addedGamesDirs) { + val n = s.addedGames.count { it.folderPath.startsWith("$dir/") } + SettingsAnchor("added-games:${dir}") { ActionRow( + dir.substringAfterLast('/').ifEmpty { dir }, dir + " · " + (if (n == 0) stringResource(R.string.mode_added_none) else pluralStringResource(R.plurals.mode_added_count, n, n)) + ". " + stringResource(R.string.added_games_forget_hint), + stringResource(R.string.common_forget), onClick = { a.onForgetAddedGamesDir(dir) }, + ) } + } + SettingsAnchor("added-games-add") { ActionRow( + if (s.addedGamesDirs.isEmpty()) stringResource(R.string.mode_games_folder) else stringResource(R.string.mode_games_folder_another), + stringResource(R.string.added_games_import_hint), stringResource(R.string.common_add_ellipsis), onClick = a.onPickAddedGamesDir, + ) } + ToggleRow(host, "addedArt", stringResource(R.string.mode_added_art), stringResource(R.string.mode_added_art_hint), s.addedGamesArt, onChange = a.onAddedGamesArt) + for (g in s.addedGames) ChoiceRow( + host, "added:" + g.folderPath, g.folderName, if (s.addedGamesDirs.size > 1) stringResource(R.string.mode_added_launches_in, g.exeName, g.folderPath.substringBeforeLast('/').substringAfterLast('/')) else stringResource(R.string.mode_added_launches, g.exeName), + g.candidates + ("__pick__" to stringResource(R.string.mode_added_choose)), g.exePath, + note = stringResource(R.string.mode_added_exe_note), + onPick = { path -> if (path == "__pick__") a.onPickAddedGameExe(g.folderPath) else a.onAddedGameExe(g.folderPath, path) }, + ) + } } + if (steam && s.gameStorage != null) SettingsAnchor("storage") { SettingsGroup(stringResource(R.string.mode_storage)) { + val custom = s.gameStorage.isNotEmpty() && s.gameStorage != "off" && s.storageOptions.none { it.second == s.gameStorage } + val options = buildList { + add("" to (if (s.storageOptions.isEmpty()) stringResource(R.string.mode_storage_auto_none) else stringResource(R.string.mode_storage_auto))) + add("off" to stringResource(R.string.mode_storage_internal)) + for ((label, path) in s.storageOptions) add(path to label) + if (custom) add(s.gameStorage to stringResource(R.string.mode_storage_folder, s.gameStorage)) + } + val open = host.open == "storage" + SettingsAnchor("storage-location") { SettingsRow(stringResource(R.string.mode_second_library), stringResource(R.string.second_library_import_hint), highlighted = open) { + androidx.compose.foundation.layout.Box { + ValueChip(options.firstOrNull { it.first == s.gameStorage }?.second?.substringBefore(" -") ?: "-", open) { host.open = if (open) null else "storage" } + AnchoredMenu(open, onDismiss = { if (host.open == "storage") host.open = null }, title = stringResource(R.string.mode_second_library), note = stringResource(R.string.mode_storage_note)) { firstItemFocus -> + options.forEachIndexed { index, (path, label) -> MenuItem(label, checked = path == s.gameStorage, focusRequester = if (index == 0) firstItemFocus else null) { + a.onGameStorage(path, if (path.isEmpty() || path == "off") "" else label.substringBefore(" ·")); host.open = null + } } + MenuItem(stringResource(R.string.mode_choose_folder), checked = false) { host.open = null; a.onPickGameStorageFolder() } + } + } + } } + } } + } + SettingsCategory.SESSIONS -> { SettingsGroup(stringResource(R.string.mode_session)) { ChoiceRow( host, "suspend", stringResource(R.string.mode_suspend), @@ -290,7 +352,7 @@ fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) { s.runSteamAtStartup, onChange = a.onRunSteamAtStartup, ) } - if (steam) SettingsGroup(stringResource(R.string.mode_decky)) { + if (steam) SettingsAnchor("decky") { SettingsGroup(stringResource(R.string.mode_decky)) { val updateAvailable = s.deckyInstalled != null && s.deckyLatestRelease != null && s.deckyInstalled != s.deckyLatestRelease.tag val status = when { @@ -302,7 +364,7 @@ fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) { updateAvailable -> stringResource(R.string.mode_decky_update, s.deckyLatestRelease.tag) else -> stringResource(R.string.mode_decky_current, s.deckyInstalled) } - SettingsRow(stringResource(R.string.mode_decky_loader), status) { + SettingsAnchor("decky-loader") { SettingsRow(stringResource(R.string.mode_decky_loader), status) { val action = when { s.deckyStage != null -> stringResource(R.string.common_working) s.deckyChecking -> stringResource(R.string.common_checking) @@ -323,7 +385,7 @@ fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) { enabled = s.deckyStage == null && !s.deckySessionRunning, ) { confirmDeckyRemoval = true } } - } + } } if (s.deckyInstalled != null) ToggleRow( host, "decky-enabled", stringResource(R.string.mode_decky), if (s.deckyEnabled) stringResource(R.string.mode_decky_on) @@ -332,7 +394,7 @@ fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) { enabled = !s.deckySessionRunning && s.deckyStage == null, onChange = a.onDeckyEnabled, ) - SettingsRow( + SettingsAnchor("decky-plugins") { SettingsRow( "Plugins", "Install a plugin ZIP for the next Steam session.", ) { @@ -341,25 +403,20 @@ fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) { enabled = s.deckyInstalled != null && s.deckyStage == null && !s.deckySessionRunning, onClick = a.onPickDeckyPluginZip, ) - } + } } if (s.deckyStage != null && s.deckyPercent >= 0) { LinearProgressIndicator( progress = { s.deckyPercent / 100f }, modifier = Modifier.fillMaxWidth().padding(horizontal = 14.dp, vertical = 8.dp), ) } - } + } } if (steam && s.steamChannel != null) SettingsGroup(stringResource(R.string.mode_client)) { ToggleRow( host, "steamdeck", stringResource(R.string.mode_deck_mode), stringResource(R.string.mode_deck_mode_hint), s.steamDeckMode, onChange = a.onSteamDeckMode, ) - if (s.steamDeckMode) ToggleRow( - host, "mangoapp", stringResource(R.string.mode_mangoapp), - stringResource(R.string.mode_mangoapp_hint), - s.mangoapp, onChange = a.onMangoapp, - ) // Deck mode fixes the branch (SessionPrefs.steamChannel); the choice is for Deck mode off. if (s.steamDeckMode) SettingsRow(stringResource(R.string.mode_branch), stringResource(R.string.mode_branch_deck)) {} else ChoiceRow( @@ -375,7 +432,7 @@ fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) { !s.wifiDiscoveryPermission && s.wifiDiscoveryAsked -> stringResource(R.string.mode_wifi_permission_denied) else -> stringResource(R.string.mode_wifi_discovery_hint) } - SettingsRow(stringResource(R.string.mode_wifi_discovery), hint) { + SettingsAnchor("wifi") { SettingsRow(stringResource(R.string.mode_wifi_discovery), hint) { Row(verticalAlignment = androidx.compose.ui.Alignment.CenterVertically, horizontalArrangement = androidx.compose.foundation.layout.Arrangement.spacedBy(8.dp)) { if (s.wifiDiscoveryBlocked || (s.wifiDiscovery && !s.wifiDiscoveryLocation)) { @@ -386,39 +443,25 @@ fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) { if (on) explainWifiDiscovery = true else a.onWifiDiscovery(false) } } - } + } } } - if (steam && s.addedGamesDirs != null) SettingsGroup(stringResource(R.string.mode_added_games)) { - for (dir in s.addedGamesDirs) { - val n = s.addedGames.count { it.folderPath.startsWith("$dir/") } - ActionRow( - dir.substringAfterLast('/').ifEmpty { dir }, dir + " · " + (if (n == 0) stringResource(R.string.mode_added_none) else pluralStringResource(R.plurals.mode_added_count, n, n)) + ". " + stringResource(R.string.added_games_forget_hint), - stringResource(R.string.common_forget), onClick = { a.onForgetAddedGamesDir(dir) }, - ) - } - ActionRow( - if (s.addedGamesDirs.isEmpty()) stringResource(R.string.mode_games_folder) else stringResource(R.string.mode_games_folder_another), - stringResource(R.string.added_games_import_hint), - stringResource(R.string.common_add_ellipsis), onClick = a.onPickAddedGamesDir, - ) - ToggleRow( - host, "addedArt", stringResource(R.string.mode_added_art), - stringResource(R.string.mode_added_art_hint), - s.addedGamesArt, onChange = a.onAddedGamesArt, - ) - for (g in s.addedGames) ChoiceRow( - host, "added:" + g.folderPath, g.folderName, if (s.addedGamesDirs.size > 1) stringResource(R.string.mode_added_launches_in, g.exeName, g.folderPath.substringBeforeLast('/').substringAfterLast('/')) else stringResource(R.string.mode_added_launches, g.exeName), - g.candidates + ("__pick__" to stringResource(R.string.mode_added_choose)), g.exePath, - note = stringResource(R.string.mode_added_exe_note), - onPick = { path -> if (path == "__pick__") a.onPickAddedGameExe(g.folderPath) else a.onAddedGameExe(g.folderPath, path) }, - ) + if (!steam && s.renderer != null) SettingsGroup(stringResource(R.string.mode_renderer)) { + ChoiceRow(host, "renderer", stringResource(R.string.mode_desktop_renderer), stringResource(R.string.mode_renderer_hint), + listOf("vulkan" to stringResource(R.string.mode_renderer_vulkan), "gles2" to stringResource(R.string.mode_renderer_gles2), "pixman" to stringResource(R.string.mode_renderer_pixman)), s.renderer, + note = stringResource(R.string.mode_renderer_note), onPick = a.onRenderer) } - if (steam && s.fexPreset != null) SettingsGroup(stringResource(R.string.game_settings_title)) { - if (s.syncBackend != null) SettingsRow( - stringResource(R.string.sync_backend_title), - stringResource(R.string.sync_backend_hint), - ) { - SegmentedTabs( + } + SettingsCategory.COMPATIBILITY -> { + SettingsGroup(stringResource(R.string.mode_drivers)) { + SettingsAnchor("gpu-drivers") { SettingsRow(stringResource(R.string.mode_gpu_drivers), stringResource(R.string.mode_gpu_drivers_hint)) { + ValueChip(s.gpuDrivers, open = false) { a.onGpuDrivers() } + } } + } + if (steam && s.fexPreset != null) { + SettingsAdvanced("game-settings", stringResource(R.string.game_settings_title), targets = setOf("fex", "syncBackend", "game-env")) { + if (s.syncBackend != null) SettingsAnchor("syncBackend") { SettingsRow( + stringResource(R.string.sync_backend_title), stringResource(R.string.sync_backend_hint), + ) { SegmentedTabs( listOf( SessionPrefs.SYNC_NTSYNC to stringResource(R.string.sync_backend_ntsync), SessionPrefs.SYNC_FSYNC to stringResource(R.string.sync_backend_fsync), @@ -426,78 +469,22 @@ fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) { SessionPrefs.SYNC_WINESERVER to stringResource(R.string.sync_backend_wineserver), ), s.syncBackend, - ) { id -> host.open = null; a.onSyncBackend(id) } + ) { id -> host.open = null; a.onSyncBackend(id) } } } + ChoiceRow( + host, "fex", stringResource(R.string.fex_preset_title), stringResource(R.string.fex_next_launch), + FexPreset.all.map { it.id to stringResource(it.label) }, s.fexPreset, + note = stringResource(FexPreset.byId(s.fexPreset).detail), onPick = a.onFexPreset, + ) + SettingsAnchor("game-env") { GameEnvironmentRow() } } - ChoiceRow( - host, "fex", stringResource(R.string.fex_preset_title), stringResource(R.string.fex_next_launch), - FexPreset.all.map { it.id to stringResource(it.label) }, s.fexPreset, - note = stringResource(FexPreset.byId(s.fexPreset).detail), onPick = a.onFexPreset, - ) - GameEnvironmentRow() - if (s.forceFullscreen != null) ToggleRow( - host, "fill", stringResource(R.string.mode_fill), - stringResource(R.string.mode_fill_hint), - s.forceFullscreen, onChange = a.onForceFullscreen, - ) - if (s.stretch16x9 != null) ToggleRow( - host, "stretch169", stringResource(R.string.mode_stretch169), - stringResource(R.string.mode_stretch169_hint), - s.stretch16x9, onChange = a.onStretch16x9, - ) } - if (steam && s.directAudio != null && s.mic != null) SettingsGroup(stringResource(R.string.mode_audio)) { - ToggleRow(host, "da", stringResource(R.string.mode_directaudio), stringResource(R.string.mode_directaudio_hint), s.directAudio, onChange = a.onDirectAudio) - ChoiceRow( - host, "clientAudio", stringResource(R.string.mode_client_audio), stringResource(R.string.mode_client_audio_hint), - listOf("classic" to stringResource(R.string.mode_client_audio_classic), "directaudio" to stringResource(R.string.mode_client_audio_direct)), if (s.clientDirectAudio) "directaudio" else "classic", - onPick = { id -> a.onClientDirectAudio(id == "directaudio") }, - ) - ToggleRow(host, "mic", stringResource(R.string.mode_mic), stringResource(R.string.mode_mic_hint), s.mic, onChange = a.onMic) - } - if (steam && s.gameStorage != null) SettingsGroup(stringResource(R.string.mode_storage)) { - val custom = s.gameStorage.isNotEmpty() && s.gameStorage != "off" && s.storageOptions.none { it.second == s.gameStorage } - val options = buildList { - add("" to (if (s.storageOptions.isEmpty()) stringResource(R.string.mode_storage_auto_none) else stringResource(R.string.mode_storage_auto))) - add("off" to stringResource(R.string.mode_storage_internal)) - for ((label, path) in s.storageOptions) add(path to label) - if (custom) add(s.gameStorage to stringResource(R.string.mode_storage_folder, s.gameStorage)) - } - val open = host.open == "storage" - SettingsRow( - stringResource(R.string.mode_second_library), - stringResource(R.string.second_library_import_hint), - highlighted = open, - ) { - androidx.compose.foundation.layout.Box { - ValueChip(options.firstOrNull { it.first == s.gameStorage }?.second?.substringBefore(" -") ?: "-", open) { host.open = if (open) null else "storage" } - AnchoredMenu( - open, onDismiss = { if (host.open == "storage") host.open = null }, title = stringResource(R.string.mode_second_library), - note = stringResource(R.string.mode_storage_note), - ) { firstItemFocus -> - options.forEachIndexed { index, (path, label) -> - MenuItem(label, checked = path == s.gameStorage, focusRequester = if (index == 0) firstItemFocus else null) { - a.onGameStorage(path, if (path.isEmpty() || path == "off") "" else label.substringBefore(" ·")) - host.open = null - } - } - MenuItem(stringResource(R.string.mode_choose_folder), checked = false) { host.open = null; a.onPickGameStorageFolder() } - } - } - } - ToggleRow( - host, "storageDiagnostics", stringResource(R.string.mode_storage_diagnostics), - stringResource(R.string.mode_storage_diagnostics_hint), s.storageDiagnostics, - onChange = a.onStorageDiagnostics, - ) - } - if (!steam && s.renderer != null) SettingsGroup(stringResource(R.string.mode_renderer)) { - ChoiceRow( - host, "renderer", stringResource(R.string.mode_desktop_renderer), stringResource(R.string.mode_renderer_hint), - listOf("vulkan" to stringResource(R.string.mode_renderer_vulkan), "gles2" to stringResource(R.string.mode_renderer_gles2), "pixman" to stringResource(R.string.mode_renderer_pixman)), s.renderer, - note = stringResource(R.string.mode_renderer_note), - onPick = a.onRenderer, - ) + } + SettingsCategory.SUPPORT -> { + if (steam && s.gameStorage != null) SettingsAdvanced("storage-diagnostics", stringResource(R.string.mode_storage), targets = setOf("storageDiagnostics")) { + ToggleRow(host, "storageDiagnostics", stringResource(R.string.mode_storage_diagnostics), stringResource(R.string.mode_storage_diagnostics_hint), s.storageDiagnostics, onChange = a.onStorageDiagnostics) } + } + SettingsCategory.GENERAL -> Unit } if (explainWifiDiscovery) AlertDialog( onDismissRequest = { explainWifiDiscovery = false }, diff --git a/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt index b46133463..c9e3b8175 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt @@ -9,7 +9,7 @@ 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.foundation.layout.width +import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField @@ -80,17 +80,17 @@ fun PerformancePage( stringResource(R.string.perf_override_hint), clientOverride, onChange = onClientOverride, ) - MultiRow( + SettingsAnchor("clientCores") { MultiRow( host, "clientCores", stringResource(R.string.perf_client_cores), if (clientOverride) stringResource(R.string.perf_client_cores_on) else stringResource(R.string.perf_client_cores_off), coreItems, clientCores, enabled = clientOverride, onToggle = onClientCore, - ) + ) } } SettingsGroup(stringResource(R.string.perf_game_cores_group)) { - MultiRow( + SettingsAnchor("gameCores") { MultiRow( host, "gameCores", stringResource(R.string.perf_game_cores), stringResource(R.string.perf_game_cores_hint), coreItems, gameCores, onToggle = onGameCore, - ) + ) } } SettingsGroup(stringResource(R.string.perf_client_ui)) { ToggleRow( @@ -162,7 +162,7 @@ fun PerformancePage( SettingsGroup(stringResource(R.string.perf_identity)) { var draft by remember(guestHostname) { mutableStateOf(guestHostname) } val valid = SessionPrefs.validGuestHostname(draft) != null - SettingsRow( + SettingsAnchor("hostname") { SettingsRow( stringResource(R.string.perf_hostname), if (valid || draft.isBlank()) stringResource(R.string.perf_hostname_hint, SessionPrefs.DEFAULT_GUEST_HOSTNAME) else stringResource(R.string.perf_hostname_invalid), @@ -174,9 +174,9 @@ fun PerformancePage( }, singleLine = true, isError = !valid && draft.isNotBlank(), placeholder = { Text(SessionPrefs.DEFAULT_GUEST_HOSTNAME) }, - modifier = Modifier.width(220.dp), + modifier = Modifier.widthIn(max = 220.dp), ) - } + } } } if (phantomWarning != null) { Spacer(Modifier.height(16.dp)) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ProtonPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/ProtonPage.kt index 3515f2180..04058082a 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/ProtonPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/ProtonPage.kt @@ -36,8 +36,8 @@ fun ProtonPage( SettingsPage( host, title = stringResource(R.string.setup_tool_protons), - eyebrow = stringResource(R.string.setup_title), - lede = stringResource(R.string.proton_lede), + eyebrow = stringResource(R.string.settings_title), + lede = "Install ARM64 Proton versions here. Choose the default Proton in Components; set per-game overrides in Steam → Properties → Compatibility.", onBack = onBack, ) { if (!runtimeReady) Text( diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt b/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt index 5d0f851d2..0e83452c2 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt @@ -116,11 +116,10 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.res.stringResource import androidx.compose.ui.platform.LocalContext import com.droiddeck.launcher.R -import com.droiddeck.launcher.core.FexPreset import com.droiddeck.launcher.core.TextureFiltering +import com.droiddeck.launcher.core.FexPreset import com.droiddeck.launcher.gpu.FrameGen import com.droiddeck.launcher.gpu.Lossless -import com.droiddeck.launcher.gpu.ScreenEffectLooks import com.droiddeck.launcher.gpu.ScreenEffects import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.session.ComponentsManager @@ -386,8 +385,9 @@ fun SessionDrawer(open: Boolean, page: Int, controllerActive: Boolean, onPageCha } } DRAWER_PAGE_EFFECTS -> { - ScreenEffectsGroup(host, a) { key -> focus.track(page, key) } - TextureFilteringGroup(host, a) { key -> focus.track(page, key) } + ScreenEffectsSettings(host, a.effects, a.upscaler, a.onEffects, a.onUpscaler) { key -> focus.track(page, key) } + TextureFilteringSettings(host, a.textureAnisotropy, a.textureLodBias, + a.onTextureAnisotropy, a.onTextureLodBias) { key -> focus.track(page, key) } } DRAWER_PAGE_COMPONENTS -> ComponentsDrawerPage(host, a) { key -> focus.track(page, key) } DRAWER_PAGE_CONTROLS -> { @@ -696,61 +696,6 @@ private fun DrawerPageTabs(page: Int, modifier: Modifier = Modifier, compact: Bo /** The Look row's value when the rows below match no Look. */ private const val LOOK_CUSTOM = "custom" -/** - * Screen effects on the Effects page: a Look row that moves every row under it, then the rows - * themselves: switches and sliders the d-pad steps (SliderRow), so a pad drives them. - */ -@Composable -private fun ScreenEffectsGroup(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) { - val e = a.effects - val look = ScreenEffectLooks.match(e, a.upscaler) - SettingsGroup(stringResource(R.string.drawer_effects)) { - val looks = ScreenEffectLooks.LOOKS.map { it.name to it.name } - ChoiceRow(host, "look", stringResource(R.string.drawer_look), - look?.desc ?: stringResource(R.string.drawer_effects_hint), - if (look == null) listOf(LOOK_CUSTOM to stringResource(R.string.drawer_look_custom)) + looks else looks, - look?.name ?: LOOK_CUSTOM, chipModifier = track("look"), hintLines = 2) { name -> - ScreenEffectLooks.LOOKS.firstOrNull { it.name == name }?.let { picked -> - picked.scalingMode?.let(a.onUpscaler) - a.onEffects(picked.effects) - } - } - ToggleRow(host, "cas", stringResource(R.string.drawer_cas), null, e.cas, chipModifier = track("cas")) { a.onEffects(e.copy(cas = it)) } - SliderRow(stringResource(R.string.drawer_cas_level), null, e.casLevel, 0..100, step = 5, enabled = e.cas, - format = { "$it%" }, modifier = track("cas-level")) { a.onEffects(e.copy(casLevel = it)) } - ToggleRow(host, "fake-hdr", stringResource(R.string.drawer_fake_hdr), null, e.hdr, chipModifier = track("fake-hdr")) { a.onEffects(e.copy(hdr = it)) } - ToggleRow(host, "deband", stringResource(R.string.drawer_deband), null, e.deband, chipModifier = track("deband")) { a.onEffects(e.copy(deband = it)) } - SliderRow(stringResource(R.string.drawer_deband_strength), null, e.debandStrength, 0..200, step = 5, enabled = e.deband, - format = { "$it%" }, modifier = track("deband-strength")) { a.onEffects(e.copy(debandStrength = it)) } - SliderRow(stringResource(R.string.drawer_brightness), null, e.brightness, -100..100, step = 2, - format = ::signed, modifier = track("brightness")) { a.onEffects(e.copy(brightness = it)) } - SliderRow(stringResource(R.string.drawer_contrast), null, e.contrast, -100..100, step = 2, - format = ::signed, modifier = track("contrast")) { a.onEffects(e.copy(contrast = it)) } - SliderRow(stringResource(R.string.drawer_gamma), null, (e.gamma * 100f).roundToInt(), 50..300, step = 5, - format = { String.format(Locale.US, "%.2f", it / 100f) }, modifier = track("gamma")) { a.onEffects(e.copy(gamma = it / 100f)) } - SliderRow(stringResource(R.string.drawer_saturation), null, e.saturation, 0..200, step = 5, - format = { "$it%" }, modifier = track("saturation")) { a.onEffects(e.copy(saturation = it)) } - ToggleRow(host, "fxaa", stringResource(R.string.drawer_fxaa), null, e.fxaa, chipModifier = track("fxaa")) { a.onEffects(e.copy(fxaa = it)) } - ToggleRow(host, "toon", stringResource(R.string.drawer_toon), null, e.toon, chipModifier = track("toon")) { a.onEffects(e.copy(toon = it)) } - ToggleRow(host, "crt", stringResource(R.string.drawer_crt), null, e.crt, chipModifier = track("crt")) { a.onEffects(e.copy(crt = it)) } - ToggleRow(host, "ntsc", stringResource(R.string.drawer_ntsc), null, e.ntsc, chipModifier = track("ntsc")) { a.onEffects(e.copy(ntsc = it)) } - } -} - -/** Texture filtering on the Effects page: DXVK options for the next DirectX 9-11 launch. */ -@Composable -private fun TextureFilteringGroup(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) { - SettingsGroup(stringResource(R.string.drawer_texture)) { - ChoiceRow(host, "anisotropy", stringResource(R.string.drawer_anisotropy), stringResource(R.string.drawer_texture_hint), - SessionPrefs.textureAnisotropyChoices, a.textureAnisotropy, chipModifier = track("anisotropy"), onPick = a.onTextureAnisotropy) - ChoiceRow(host, "texture-sharpness", stringResource(R.string.drawer_texture_sharpness), stringResource(R.string.drawer_texture_hint), - SessionPrefs.textureLodBiasChoices, a.textureLodBias, note = stringResource(R.string.drawer_texture_sharpness_note), - chipModifier = track("texture-sharpness"), onPick = a.onTextureLodBias) - } -} - -private fun signed(v: Int) = if (v > 0) "+$v" else "$v" - /** Display, Effects, Controls, Components, Settings. */ const val DRAWER_PAGES = 5 diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SettingsCategoryPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/SettingsCategoryPage.kt new file mode 100644 index 000000000..0f9927b11 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/SettingsCategoryPage.kt @@ -0,0 +1,76 @@ +package com.droiddeck.launcher.ui + +import androidx.activity.compose.BackHandler +import androidx.compose.foundation.focusGroup +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.remember +import androidx.compose.runtime.getValue +import androidx.compose.runtime.setValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.snapshotFlow +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.ui.focus.onFocusChanged +import kotlinx.coroutines.flow.filterNotNull +import androidx.compose.ui.Modifier +import androidx.compose.ui.focus.FocusRequester +import androidx.compose.ui.focus.focusRequester +import androidx.compose.ui.unit.dp + +@Composable +internal fun SettingsCategoryPage( + s: FrontEndState, + a: FrontEndActions, + category: SettingsCategory, + mode: String, + target: String?, + onOpenDeveloperOptions: () -> Unit, + onRequestWirelessAdb: (Boolean) -> Unit, + modeContent: @Composable (MenuHost) -> Unit, +) { + val host = rememberMenuHost() + val entry = remember { FocusRequester() } + val frontFocus = LocalFrontFocus.current + var hasFocus by remember { mutableStateOf(false) } + var lastItem by rememberSaveable { mutableStateOf(null) } + LaunchedEffect(frontFocus) { + snapshotFlow { if (hasFocus) frontFocus?.last else null }.filterNotNull().collect { lastItem = it } + } + val back = { if (host.open != null) host.open = null else a.onPageBack() } + BackHandler(enabled = host.open != null, onBack = back) + LaunchedEffect(category, mode) { + if (target == null) { + focusWithinFrames({ hasFocus }) { + val id = lastItem + if (id != null && (frontFocus?.attached?.get(id) ?: 0) > 0) frontFocus!!.items.getValue(id) + else entry + } + } + } + CompositionLocalProvider(LocalSettingsTarget provides target, LocalSettingsAnchorsEnabled provides true) { + SettingsPage( + host, category.title, back, eyebrow = "Settings", + lede = category.description, + ) { + if (category == SettingsCategory.DISPLAY || category == SettingsCategory.SESSIONS) { + SegmentedTabs( + listOf("steam" to "Steam", "desktop" to "Desktop"), mode, + Modifier.padding(bottom = 10.dp), a.onSettingsMode, + ) + Lede("${if (mode == "steam") "Steam" else "Desktop"} session defaults. Controls marked Shared apply to both modes.") + } else { + Lede("Shared defaults. Steam-only options are labeled where applicable.") + } + Column(Modifier.fillMaxWidth().focusRequester(entry).onFocusChanged { hasFocus = it.hasFocus }.focusGroup()) { + if (category != SettingsCategory.SESSIONS || mode == "steam") { + SetupContent(s, a, category, host, onOpenDeveloperOptions, onRequestWirelessAdb) + } + modeContent(host) + } + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SettingsHub.kt b/app/src/main/java/com/droiddeck/launcher/ui/SettingsHub.kt new file mode 100644 index 000000000..5be0ea91b --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/SettingsHub.kt @@ -0,0 +1,337 @@ +package com.droiddeck.launcher.ui + +import androidx.compose.foundation.LocalIndication +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.hoverable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.interaction.collectIsFocusedAsState +import androidx.compose.foundation.interaction.collectIsHoveredAsState +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +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.height +import androidx.compose.foundation.layout.heightIn +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.text.BasicTextField +import androidx.compose.foundation.verticalScroll +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.DisplaySettings +import androidx.compose.material.icons.outlined.FolderOpen +import androidx.compose.material.icons.outlined.Gamepad +import androidx.compose.material.icons.outlined.GraphicEq +import androidx.compose.material.icons.outlined.HelpOutline +import androidx.compose.material.icons.outlined.Home +import androidx.compose.material.icons.outlined.Settings +import androidx.compose.material.icons.outlined.Speed +import androidx.compose.material.icons.outlined.Search +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.focus.focusRequester +import androidx.compose.ui.focus.onFocusChanged +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.semantics.contentDescription +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.droiddeck.launcher.core.PhantomProcessLimit + +/** The settings taxonomy is shared by the hub, category pages, and the searchable index. */ +enum class SettingsCategory(val title: String, val description: String) { + GENERAL("General", "Launcher appearance and home-screen behavior"), + DISPLAY("Display & graphics", "Resolution, effects, scaling, and frame generation"), + CONTROLS("Controls & input", "Controller layout, touch behavior, and button mapping"), + AUDIO("Audio & microphone", "Session audio and microphone options"), + LIBRARY("Library & storage", "Game folders, storage, ROMs, and file access"), + SESSIONS("Sessions", "Session startup, suspend, and client behavior"), + COMPATIBILITY("Compatibility & performance", "Proton, components, and performance tools"), + SUPPORT("Support & diagnostics", "System checks, logs, runtime, and app updates"), +} + +data class SettingsEntry( + val target: String, + val category: SettingsCategory, + val title: String, + val description: String, + val aliases: List = emptyList(), + /** Null means the target is available regardless of Steam/Desktop mode. */ + val mode: String? = null, +) { + internal fun matches(query: String): Boolean { + val q = query.trim().lowercase() + if (q.isEmpty()) return false + return sequenceOf(title, description, category.title).plus(aliases.asSequence()) + .any { it.lowercase().contains(q) } + } +} + +/** Search data points into the existing settings rows and specialist pages; it stores no values. */ +object SettingsCatalog { + val entries: List = listOf( + SettingsEntry("theme", SettingsCategory.GENERAL, "Theme", "Choose the launcher color theme", listOf("appearance", "colors")), + SettingsEntry("home-screen", SettingsCategory.GENERAL, "Home screen", "Enable DroidDeck as an Android home app", listOf("launcher", "default launcher")), + SettingsEntry("default-home", SettingsCategory.GENERAL, "Default home app", "Choose DroidDeck as the Android home app", listOf("home app", "launcher app")), + SettingsEntry("launcher-fullscreen", SettingsCategory.GENERAL, "Fullscreen", "Show the launcher without Android system bars", listOf("immersive")), + SettingsEntry("launcher-animations", SettingsCategory.GENERAL, "Animations", "Enable or disable launcher motion", listOf("motion")), + SettingsEntry("store-enabled", SettingsCategory.GENERAL, "Linux app store", "Show the Flathub Store in the launcher", listOf("store", "flathub")), + SettingsEntry("res", SettingsCategory.DISPLAY, "Resolution", "Set the next session resolution", listOf("720p", "900p", "1080p", "native"), "steam"), + SettingsEntry("shape", SettingsCategory.DISPLAY, "Aspect ratio", "Choose how the session fits the screen", listOf("shape", "ratio"), "steam"), + SettingsEntry("fps", SettingsCategory.DISPLAY, "Frame-rate limit", "Limit the session frame rate", listOf("fps", "refresh rate"), "steam"), + SettingsEntry("upscaler", SettingsCategory.DISPLAY, "Upscaling", "Choose the session image scaling filter", listOf("sharpness", "scaling"), "steam"), + SettingsEntry("upscale-sharpness", SettingsCategory.DISPLAY, "Upscaling sharpness", "Adjust image sharpening", listOf("sharpening"), "steam"), + SettingsEntry("hdr", SettingsCategory.DISPLAY, "HDR", "Enable HDR output when supported", listOf("high dynamic range"), "steam"), + SettingsEntry("fill", SettingsCategory.DISPLAY, "Fill screen", "Stretch the session to fill the display", listOf("force fullscreen"), "steam"), + SettingsEntry("stretch169", SettingsCategory.DISPLAY, "Stretch to 16:9", "Stretch the session image to a 16:9 shape", listOf("widescreen stretch"), "steam"), + SettingsEntry("gpu-drivers", SettingsCategory.COMPATIBILITY, "GPU drivers", "Manage Android and Linux display drivers", listOf("turnip", "adreno", "vulkan"), "steam"), + SettingsEntry("fg", SettingsCategory.DISPLAY, "Frame generation", "Choose a frame-generation mode or import Lossless Scaling", listOf("lossless scaling", "lsfg")), + SettingsEntry("effects-look", SettingsCategory.DISPLAY, "Screen effects preset", "Choose a preset for image effects", listOf("look", "post-processing")), + SettingsEntry("effects-cas", SettingsCategory.DISPLAY, "Contrast adaptive sharpening", "Enable contrast adaptive sharpening", listOf("cas", "sharpness")), + SettingsEntry("effects-cas-level", SettingsCategory.DISPLAY, "Sharpening strength", "Adjust contrast adaptive sharpening", listOf("cas level")), + SettingsEntry("effects-fake-hdr", SettingsCategory.DISPLAY, "Fake HDR", "Add an HDR-style image effect", listOf("hdr effect")), + SettingsEntry("effects-deband", SettingsCategory.DISPLAY, "Debanding", "Reduce color banding in gradients", listOf("banding")), + SettingsEntry("effects-deband-strength", SettingsCategory.DISPLAY, "Debanding strength", "Adjust color banding reduction", listOf("banding strength")), + SettingsEntry("effects-brightness", SettingsCategory.DISPLAY, "Brightness", "Adjust the session image brightness", listOf("light")), + SettingsEntry("effects-contrast", SettingsCategory.DISPLAY, "Contrast", "Adjust the session image contrast", listOf("image contrast")), + SettingsEntry("effects-gamma", SettingsCategory.DISPLAY, "Gamma", "Adjust the session image gamma", listOf("midtones")), + SettingsEntry("effects-saturation", SettingsCategory.DISPLAY, "Saturation", "Adjust the session image saturation", listOf("color intensity")), + SettingsEntry("effects-fxaa", SettingsCategory.DISPLAY, "FXAA", "Enable fast approximate anti-aliasing", listOf("anti-aliasing")), + SettingsEntry("effects-toon", SettingsCategory.DISPLAY, "Toon effect", "Enable the toon image effect", listOf("cartoon")), + SettingsEntry("effects-crt", SettingsCategory.DISPLAY, "CRT effect", "Enable the CRT image effect", listOf("scanlines")), + SettingsEntry("effects-ntsc", SettingsCategory.DISPLAY, "NTSC effect", "Enable the NTSC image effect", listOf("composite video")), + SettingsEntry("textures-anisotropy", SettingsCategory.DISPLAY, "Texture anisotropy", "Choose texture filtering anisotropy", listOf("anisotropic filtering")), + SettingsEntry("textures-sharpness", SettingsCategory.DISPLAY, "Texture sharpness", "Adjust texture level-of-detail bias", listOf("lod bias", "texture filtering")), + SettingsEntry("touch", SettingsCategory.CONTROLS, "Touch mode", "Choose how touch input behaves in a session", listOf("touchpad", "direct touch"), "steam"), + SettingsEntry("controller-osc", SettingsCategory.CONTROLS, "On-screen controls", "Choose when the touch controls appear", listOf("overlay", "controller overlay"), "steam"), + SettingsEntry("controller", SettingsCategory.CONTROLS, "Controller type", "Choose the controller profile exposed to Steam", listOf("xbox", "steam deck"), "steam"), + SettingsEntry("back-actions", SettingsCategory.CONTROLS, "Back-button actions", "Choose the order of the Steam menu and Quick Access Menu", listOf("b button", "menu button", "qam")), + SettingsEntry("controller-mapping", SettingsCategory.CONTROLS, "Button mapping", "Remap controller buttons", listOf("mapping", "remap")), + SettingsEntry("controller-opacity", SettingsCategory.CONTROLS, "Controller opacity", "Adjust the on-screen controller opacity", listOf("transparency")), + SettingsEntry("controller-size", SettingsCategory.CONTROLS, "Controller size", "Adjust the on-screen controller size", listOf("scale")), + SettingsEntry("controller-stick-click", SettingsCategory.CONTROLS, "Stick click", "Enable stick-click controls", listOf("l3", "r3")), + SettingsEntry("controller-adaptive", SettingsCategory.CONTROLS, "Adaptive sticks", "Adjust stick behavior to the active game", listOf("stick sensitivity")), + SettingsEntry("controller-rumble", SettingsCategory.CONTROLS, "Controller rumble", "Enable controller vibration", listOf("vibration")), + SettingsEntry("controller-steam", SettingsCategory.CONTROLS, "Steam button", "Show the Steam button on the virtual controller", listOf("steam menu")), + SettingsEntry("controller-qam", SettingsCategory.CONTROLS, "Quick Access button", "Show the Quick Access button on the virtual controller", listOf("qam")), + SettingsEntry("controller-keyboard", SettingsCategory.CONTROLS, "On-screen keyboard button", "Show the keyboard button on the virtual controller", listOf("keyboard")), + SettingsEntry("controller-actions", SettingsCategory.CONTROLS, "Controller layout and mapping", "Edit the on-screen layout, remap buttons, or reset controller settings", listOf("color", "opacity", "size", "stick click", "adaptive sticks", "rumble", "steam button", "qam button", "keyboard button", "layout", "mapping", "reset")), + SettingsEntry("da", SettingsCategory.AUDIO, "Direct audio", "Configure direct game audio", listOf("audio output"), "steam"), + SettingsEntry("clientAudio", SettingsCategory.AUDIO, "Steam client audio", "Choose Steam client audio mode", listOf("client audio"), "steam"), + SettingsEntry("mic", SettingsCategory.AUDIO, "Microphone", "Allow session microphone input", listOf("recording", "voice chat"), "steam"), + SettingsEntry("added-games", SettingsCategory.LIBRARY, "Added games", "Manage imported game folders and launch files", listOf("non-steam games", "exe"), "steam"), + SettingsEntry("addedArt", SettingsCategory.LIBRARY, "Added game artwork", "Show artwork for imported games", listOf("game covers", "covers"), "steam"), + SettingsEntry("storage", SettingsCategory.LIBRARY, "Game storage", "Choose where Steam stores games", listOf("second library", "sd card"), "steam"), + SettingsEntry("storage-location", SettingsCategory.LIBRARY, "Second library", "Import or remove a second Steam library", listOf("library location", "sd card folder"), "steam"), + SettingsEntry("added-games-add", SettingsCategory.LIBRARY, "Add a game folder", "Import another folder of games", listOf("add games directory", "import folder"), "steam"), + SettingsEntry("roms", SettingsCategory.LIBRARY, "ROM folders", "Choose the folder scanned for ROMs", listOf("emulator games")), + SettingsEntry("files", SettingsCategory.LIBRARY, "File manager", "Browse files in the Linux runtime", listOf("file browser")), + SettingsEntry("suspend", SettingsCategory.SESSIONS, "Suspend behavior", "Choose how sessions respond to suspend", listOf("sleep", "suspend policy"), "steam"), + SettingsEntry("offline", SettingsCategory.SESSIONS, "Offline mode", "Use the signed-in account in offline mode", listOf("offline account")), + SettingsEntry("pip-auto", SettingsCategory.SESSIONS, "Picture-in-picture", "Automatically enter picture-in-picture", listOf("pip"), "steam"), + SettingsEntry("steam-startup", SettingsCategory.SESSIONS, "Start Steam on launch", "Start Steam automatically with DroidDeck", listOf("autostart"), "steam"), + SettingsEntry("steamdeck", SettingsCategory.SESSIONS, "Steam Deck mode", "Use the Steam Deck client interface", listOf("big picture", "deck mode"), "steam"), + SettingsEntry("mangoapp", SettingsCategory.DISPLAY, "Performance overlay", "Show the MangoHud performance overlay", listOf("mangohud", "mangoapp"), "steam"), + SettingsEntry("channel", SettingsCategory.SESSIONS, "Steam branch", "Choose the Steam client update branch", listOf("beta", "client channel"), "steam"), + SettingsEntry("wifi", SettingsCategory.SESSIONS, "Wi-Fi discovery", "Enable local network discovery for Steam", listOf("network", "remote play"), "steam"), + SettingsEntry("renderer", SettingsCategory.SESSIONS, "Desktop renderer", "Choose the Linux desktop renderer", listOf("desktop graphics"), "desktop"), + SettingsEntry("decky", SettingsCategory.SESSIONS, "Decky Loader", "Install and manage Decky Loader", listOf("decky loader", "plugin loader"), "steam"), + SettingsEntry("decky-enabled", SettingsCategory.SESSIONS, "Enable Decky Loader", "Start or stop Decky Loader with Steam", listOf("decky toggle"), "steam"), + SettingsEntry("decky-loader", SettingsCategory.SESSIONS, "Decky installation", "Install or repair the Decky loader", listOf("decky install", "decky status"), "steam"), + SettingsEntry("decky-plugins", SettingsCategory.SESSIONS, "Decky plugins", "Install a Decky plugin ZIP", listOf("plugin zip"), "steam"), + SettingsEntry("components", SettingsCategory.COMPATIBILITY, "Compatibility components", "Manage FEX, DXVK, and VKD3D-Proton", listOf("dxvk", "vkd3d", "fex", "default proton", "default-proton")), + SettingsEntry("protons", SettingsCategory.COMPATIBILITY, "Proton versions", "Install and manage Proton builds", listOf("wine", "proton-ge", "installed proton")), + SettingsEntry("performance", SettingsCategory.COMPATIBILITY, "Performance", "Tune CPU cores and graphics compatibility options", listOf("cpu", "cores", "zink", "fsync")), + SettingsEntry("performance:override", SettingsCategory.COMPATIBILITY, "Per-app core limits", "Override the Steam client CPU core selection", listOf("client core override", "cpu affinity")), + SettingsEntry("performance:clientCores", SettingsCategory.COMPATIBILITY, "Steam client CPU cores", "Choose CPU cores available to the Steam client", listOf("steam cores", "client affinity")), + SettingsEntry("performance:gameCores", SettingsCategory.COMPATIBILITY, "Game CPU cores", "Choose CPU cores available to games", listOf("game affinity")), + SettingsEntry("performance:glthread", SettingsCategory.COMPATIBILITY, "GL threading", "Change GL threading behavior", listOf("gl thread")), + SettingsEntry("performance:zink", SettingsCategory.COMPATIBILITY, "Zink", "Change Zink lazy pipeline behavior", listOf("lazy pipeline")), + SettingsEntry("performance:noglerror", SettingsCategory.COMPATIBILITY, "Ignore GL errors", "Change OpenGL error handling", listOf("opengl errors")), + SettingsEntry("performance:gsrealtime", SettingsCategory.COMPATIBILITY, "Gamescope real-time priority", "Set Gamescope scheduling priority", listOf("realtime scheduling")), + SettingsEntry("performance:gpuclock", SettingsCategory.COMPATIBILITY, "Pin GPU clock", "Set the GPU clock policy", listOf("gpu clock")), + SettingsEntry("performance:sysmem", SettingsCategory.COMPATIBILITY, "Turnip system memory", "Change Turnip system memory behavior", listOf("tu sysmem")), + SettingsEntry("performance:xalia", SettingsCategory.COMPATIBILITY, "Xalia", "Change Xalia input behavior", listOf("no xalia")), + SettingsEntry("performance:syncfallback", SettingsCategory.COMPATIBILITY, "Esync fallback", "Change synchronization fallback behavior", listOf("esync")), + SettingsEntry("performance:fsyncfirst", SettingsCategory.COMPATIBILITY, "Fsync first", "Try fsync before other synchronization backends", listOf("fsync")), + SettingsEntry("performance:fastsync", SettingsCategory.COMPATIBILITY, "Fast sync", "Enable fast synchronization", listOf("wine sync")), + SettingsEntry("performance:seccomp", SettingsCategory.COMPATIBILITY, "Proot seccomp", "Change the proot seccomp setting", listOf("syscall filtering")), + SettingsEntry("performance:fastpath", SettingsCategory.COMPATIBILITY, "Proot fast path", "Enable the proot fast path", listOf("fast path")), + SettingsEntry("performance:hostname", SettingsCategory.COMPATIBILITY, "Guest hostname", "Set the Linux guest hostname", listOf("computer name")), + SettingsEntry("fex", SettingsCategory.COMPATIBILITY, "FEX preset", "Choose CPU translation settings for games", listOf("translation", "x86"), "steam"), + SettingsEntry("syncBackend", SettingsCategory.COMPATIBILITY, "Synchronization backend", "Choose the game synchronization backend", listOf("ntsync", "fsync", "esync"), "steam"), + SettingsEntry("game-env", SettingsCategory.COMPATIBILITY, "Game environment", "Edit per-game environment options", listOf("environment variables", "launch options"), "steam"), + SettingsEntry("storageDiagnostics", SettingsCategory.SUPPORT, "Storage diagnostics", "Collect diagnostics for game storage", listOf("storage logs"), "steam"), + SettingsEntry("runtime", SettingsCategory.SUPPORT, "Linux runtime", "Install, update, or manage the Linux runtime", listOf("runtime install", "container")), + SettingsEntry("logs", SettingsCategory.SUPPORT, "Session logs", "Enable, share, or clear session logs", listOf("diagnostics", "debug logs")), + SettingsEntry("updates", SettingsCategory.SUPPORT, "DroidDeck updates", "View build information and release channel", listOf("version", "build")), + SettingsEntry("phantom-process", SettingsCategory.SUPPORT, "Child-process limit", "Diagnose Android's process limit that can block Steam", listOf("phantom process", "developer options", "adb")), + ) + + fun search(query: String): List = entries.filter { it.matches(query) } +} + +private data class CategoryCard(val category: SettingsCategory, val icon: ImageVector) + +@Composable +fun SettingsHub(s: FrontEndState, a: FrontEndActions) { + var query by rememberSaveable { mutableStateOf("") } + val frontFocus = LocalFrontFocus.current + DisposableEffect(frontFocus) { + frontFocus?.let { it.primaryAttached++ } + onDispose { frontFocus?.let { it.primaryAttached-- } } + } + val cards = listOf( + CategoryCard(SettingsCategory.GENERAL, Icons.Outlined.Home), + CategoryCard(SettingsCategory.DISPLAY, Icons.Outlined.DisplaySettings), + CategoryCard(SettingsCategory.CONTROLS, Icons.Outlined.Gamepad), + CategoryCard(SettingsCategory.AUDIO, Icons.Outlined.GraphicEq), + CategoryCard(SettingsCategory.LIBRARY, Icons.Outlined.FolderOpen), + CategoryCard(SettingsCategory.SESSIONS, Icons.Outlined.Settings), + CategoryCard(SettingsCategory.COMPATIBILITY, Icons.Outlined.Speed), + CategoryCard(SettingsCategory.SUPPORT, Icons.Outlined.HelpOutline), + ) + Column( + modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(horizontal = 16.dp, vertical = 12.dp), + verticalArrangement = Arrangement.spacedBy(12.dp), + ) { + PageHeader("Settings") + HubSearchField(query = query, onQuery = { query = it }, frontFocus = frontFocus) + if (!s.ready || s.removalPending || PhantomProcessLimit.blocksSteam(s.phantomProcessStatus)) { + val (title, detail, target) = when { + s.removalPending -> Triple("Runtime needs attention", "Runtime removal needs to be completed before using the session.", "runtime") + !s.ready -> Triple("Linux runtime is not ready", "Install or repair the runtime to launch Steam.", "runtime") + else -> Triple("Android process limit may block Steam", "Review the child-process setting and available fixes.", "phantom-process") + } + SettingsAnchor(target) { ActionRow(title, detail, "Review") { a.onSettingsCategory(SettingsCategory.SUPPORT, target) } } + } + if (query.isBlank()) { + val columns = if (LocalNarrowPane.current) 1 else 2 + cards.chunked(columns).forEach { row -> + Row(horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth().heightIn(min = 96.dp)) { + row.forEach { card -> + SettingsCategoryCard(card, Modifier.weight(1f).paneItem("settings-category:${card.category.name}"), onClick = { a.onSettingsCategory(card.category, null) }) + } + repeat(columns - row.size) { Spacer(Modifier.weight(1f)) } + } + } + } else { + val results = SettingsCatalog.search(query) + if (results.isEmpty()) { + Note("No settings found for “${query.trim()}”.") + } else { + results.forEach { entry -> + SettingsSearchResult(entry, Modifier.paneItem("settings-search:${entry.target}")) { a.onSettingsCategory(entry.category, entry.target) } + } + } + } + } +} + +@Composable +private fun HubSearchField(query: String, onQuery: (String) -> Unit, frontFocus: FrontFocus?) { + val colors = MaterialTheme.colorScheme + val pal = LocalPalette.current + val shape = RoundedCornerShape(14.dp) + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(10.dp), + modifier = Modifier.fillMaxWidth().clip(shape).background(colors.surface) + .border(1.dp, pal.line2, shape).padding(horizontal = 14.dp, vertical = 11.dp), + ) { + Icon(Icons.Outlined.Search, contentDescription = null, tint = colors.onSurfaceVariant, modifier = Modifier.size(20.dp)) + BasicTextField( + value = query, + onValueChange = onQuery, + singleLine = true, + textStyle = androidx.compose.ui.text.TextStyle(fontSize = 15.sp, color = colors.onBackground), + cursorBrush = androidx.compose.ui.graphics.SolidColor(pal.signal), + modifier = Modifier.weight(1f) + .then(if (frontFocus == null) Modifier else Modifier.focusRequester(frontFocus.primary).onFocusChanged { if (it.isFocused) frontFocus.last = FrontFocus.PRIMARY }) + .semantics { contentDescription = "Search settings" }, + decorationBox = { inner -> + Box { + if (query.isEmpty()) Text("Search settings", fontSize = 15.sp, color = colors.onSurfaceVariant) + inner() + } + }, + ) + if (query.isNotEmpty()) Text( + "Clear", color = pal.signal, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, + modifier = Modifier.clickable { onQuery("") }.padding(4.dp), + ) + } +} + +@Composable +private fun SettingsCategoryCard(card: CategoryCard, modifier: Modifier, onClick: () -> Unit) { + val colors = MaterialTheme.colorScheme + val pal = LocalPalette.current + val source = remember { MutableInteractionSource() } + val focused = source.collectIsFocusedAsState().value + val hovered = source.collectIsHoveredAsState().value + val shape = RoundedCornerShape(14.dp) + Column( + verticalArrangement = Arrangement.spacedBy(6.dp), + modifier = modifier.fillMaxSize().clip(shape) + .background(if (focused || hovered) pal.signal.copy(alpha = 0.10f) else colors.surface) + .glideBorder(focused, shape, pal.signal, pal.line) + .hoverable(source) + .clickable(interactionSource = source, indication = LocalIndication.current, role = Role.Button, onClick = onClick) + .controllerConfirm(onClick = onClick) + .padding(14.dp), + ) { + Icon(card.icon, contentDescription = null, tint = if (focused || hovered) pal.signal else colors.onSurfaceVariant, modifier = Modifier.size(22.dp)) + Text(card.category.title, fontSize = 16.sp, fontWeight = FontWeight.Bold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis) + Text(card.category.description, fontSize = 13.sp, color = colors.onSurfaceVariant, maxLines = 2, overflow = TextOverflow.Ellipsis) + } +} + +@Composable +private fun SettingsSearchResult(entry: SettingsEntry, modifier: Modifier = Modifier, onClick: () -> Unit) { + val colors = MaterialTheme.colorScheme + val pal = LocalPalette.current + val source = remember { MutableInteractionSource() } + val focused = source.collectIsFocusedAsState().value + val hovered = source.collectIsHoveredAsState().value + val shape = RoundedCornerShape(12.dp) + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = modifier.fillMaxWidth().clip(shape) + .background(if (focused || hovered) pal.signal.copy(alpha = 0.10f) else colors.surface) + .glideBorder(focused, shape, pal.signal, pal.line) + .hoverable(source) + .clickable(interactionSource = source, indication = LocalIndication.current, role = Role.Button, onClick = onClick) + .controllerConfirm(onClick = onClick) + .padding(horizontal = 14.dp, vertical = 11.dp), + ) { + Column(modifier = Modifier.weight(1f)) { + Text(entry.title, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground) + Text(entry.description, fontSize = 13.sp, color = colors.onSurfaceVariant, maxLines = 2, overflow = TextOverflow.Ellipsis) + } + Spacer(Modifier.width(12.dp)) + Text(entry.category.title, fontSize = 12.sp, color = pal.signal, maxLines = 1, overflow = TextOverflow.Ellipsis) + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SettingsNavigation.kt b/app/src/main/java/com/droiddeck/launcher/ui/SettingsNavigation.kt new file mode 100644 index 000000000..1162bd6ef --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/SettingsNavigation.kt @@ -0,0 +1,33 @@ +package com.droiddeck.launcher.ui + +sealed interface SettingsDestination { + val key: String + + data class Category( + val category: SettingsCategory, + val mode: String = "steam", + val target: String? = null, + ) : SettingsDestination { + override val key = "settings:${category.name}:$mode:${target.orEmpty()}" + } + + data class Components(val tab: String? = null) : SettingsDestination { + override val key = "components" + } + + data object Protons : SettingsDestination { override val key = "protons" } + data class Performance(val target: String? = null) : SettingsDestination { override val key = "performance:${target.orEmpty()}" } + data object Mapping : SettingsDestination { override val key = "controller-mapping" } +} + +data class SettingsHistory(val destinations: List = emptyList()) { + val current: SettingsDestination? get() = destinations.lastOrNull() + + fun open(destination: SettingsDestination): SettingsHistory = + if (destination == current) this else copy(destinations = destinations + destination) + + fun replace(destination: SettingsDestination): SettingsHistory = + copy(destinations = destinations.dropLast(1) + destination) + + fun back(): SettingsHistory = copy(destinations = destinations.dropLast(1)) +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SettingsWidgets.kt b/app/src/main/java/com/droiddeck/launcher/ui/SettingsWidgets.kt index dc8a345f1..6cecac5c5 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SettingsWidgets.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SettingsWidgets.kt @@ -10,6 +10,10 @@ import androidx.compose.animation.core.MutableTransitionState import androidx.compose.animation.core.animateFloatAsState import androidx.compose.animation.core.animateDpAsState import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.focusGroup +import androidx.compose.foundation.relocation.BringIntoViewRequester +import androidx.compose.foundation.relocation.bringIntoViewRequester import androidx.compose.foundation.layout.offset import androidx.compose.ui.semantics.role import androidx.compose.ui.semantics.selected @@ -56,10 +60,12 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -95,6 +101,7 @@ import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.LayoutDirection import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.window.Popup import androidx.compose.ui.window.PopupPositionProvider import androidx.compose.ui.window.PopupProperties @@ -202,6 +209,77 @@ private fun BumperKey(label: String, description: String, onClick: () -> Unit) { /** The narrowest a setting's value box gets; the session menu's sheet sets it lower. */ val LocalChipMinWidth = androidx.compose.runtime.compositionLocalOf { 150.dp } +/** Search destination for settings. A target names a [SettingsAnchor] id; null leaves focus alone. */ +val LocalSettingsTarget = staticCompositionLocalOf { null } + +/** Enables anchors only on searchable settings category pages. */ +val LocalSettingsAnchorsEnabled = staticCompositionLocalOf { false } +internal val LocalSettingsAnchorId = staticCompositionLocalOf { null } + +@Composable +internal fun Modifier.settingsTarget(id: String): Modifier = + if (LocalSettingsAnchorsEnabled.current) paneItem("setting:$id") else this + +/** A non-stopping focus group that can reveal itself and request its first actionable child. */ +@Composable +@OptIn(ExperimentalFoundationApi::class) +fun SettingsAnchor(id: String, content: @Composable () -> Unit) { + val target = LocalSettingsTarget.current + val enabled = LocalSettingsAnchorsEnabled.current + if (!enabled) { + content() + return + } + val bringIntoView = remember { BringIntoViewRequester() } + val focusRequester = remember { FocusRequester() } + Column( + modifier = Modifier.fillMaxWidth() + .bringIntoViewRequester(bringIntoView) + .focusRequester(focusRequester) + .focusGroup(), + ) { + CompositionLocalProvider(LocalSettingsAnchorId provides id) { content() } + } + LaunchedEffect(target, id) { + if (target == id) { + androidx.compose.runtime.withFrameNanos { } + runCatching { bringIntoView.bringIntoView() } + androidx.compose.runtime.withFrameNanos { } + runCatching { focusRequester.requestFocus() } + } + } +} + +/** An optional group that starts closed; a settings search opens it so its destination can focus. */ +@Composable +fun SettingsAdvanced( + id: String, + title: String, + targets: Set = emptySet(), + content: @Composable ColumnScope.() -> Unit, +) { + val target = LocalSettingsTarget.current + val expandsForTarget = target == id || target in targets + var expanded by rememberSaveable(id, target) { mutableStateOf(expandsForTarget) } + SettingsAnchor(id) { + SettingsGroup(title) { + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.End, + modifier = Modifier.fillMaxWidth().padding(horizontal = 14.dp, vertical = 5.dp), + ) { + SecondaryButton( + stringResource(if (expanded) R.string.common_hide else R.string.common_show), + compact = true, + modifier = Modifier.settingsTarget(id), + onClick = { expanded = !expanded }, + ) + } + if (expanded) content() + } + } +} + class MenuHost { var open by mutableStateOf(null) } @@ -319,7 +397,9 @@ fun ValueChip(text: String, open: Boolean, enabled: Boolean = true, modifier: Mo val rot by animateFloatAsState(if (open) 180f else 0f, Motion.sp(0.6f), label = "chipCaret") Row( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.SpaceBetween, - modifier = modifier + modifier = modifier.then( + LocalSettingsAnchorId.current?.let { Modifier.settingsTarget(it) } ?: Modifier, + ) .widthIn(min = LocalChipMinWidth.current) .heightIn(min = 44.dp) .clip(RoundedCornerShape(10.dp)) @@ -400,14 +480,19 @@ fun ChoiceRow( onPick: (T) -> Unit, ) { val open = host.open == key - SettingsRow(label, hint, highlighted = open, hintLines = hintLines) { - Box { - ValueChip(options.firstOrNull { it.first == selected }?.second ?: "-", open, enabled, modifier = chipModifier) { host.open = if (open) null else key } - AnchoredMenu(open, onDismiss = { if (host.open == key) host.open = null }, title = label, note = note) { firstItemFocus -> - options.forEachIndexed { index, (value, text) -> - MenuItem(text, checked = value == selected, focusRequester = if (index == 0) firstItemFocus else null) { - onPick(value) - host.open = null + SettingsAnchor(key) { + SettingsRow(label, hint, highlighted = open, hintLines = hintLines) { + Box { + ValueChip( + options.firstOrNull { it.first == selected }?.second ?: "-", open, enabled, + modifier = chipModifier, + ) { host.open = if (open) null else key } + AnchoredMenu(open, onDismiss = { if (host.open == key) host.open = null }, title = label, note = note) { firstItemFocus -> + options.forEachIndexed { index, (value, text) -> + MenuItem(text, checked = value == selected, focusRequester = if (index == 0) firstItemFocus else null) { + onPick(value) + host.open = null + } } } } @@ -416,10 +501,13 @@ fun ChoiceRow( } @Composable -fun ToggleRow(host: MenuHost, key: String, label: String, hint: String?, checked: Boolean, enabled: Boolean = true, chipModifier: Modifier = Modifier, onChange: (Boolean) -> Unit) = - SettingsRow(label, hint) { - ToggleSwitch(checked, enabled, label, chipModifier) { host.open = null; onChange(it) } +fun ToggleRow(host: MenuHost, key: String, label: String, hint: String?, checked: Boolean, enabled: Boolean = true, chipModifier: Modifier = Modifier, onChange: (Boolean) -> Unit) { + SettingsAnchor(key) { + SettingsRow(label, hint) { + ToggleSwitch(checked, enabled, label, chipModifier.settingsTarget(key)) { host.open = null; onChange(it) } + } } +} /** An on/off switch: one tap or one A press flips it, where a menu of On and Off took three. */ @Composable diff --git a/app/src/main/java/com/droiddeck/launcher/ui/WirelessAdbFixPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/WirelessAdbFixPage.kt index f369427a0..d844d1c84 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/WirelessAdbFixPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/WirelessAdbFixPage.kt @@ -178,7 +178,7 @@ fun WirelessAdbFixPage( step == 2 -> stringResource(R.string.wadb_title_done) else -> stringResource(R.string.wadb_title) }, - eyebrow = stringResource(R.string.setup_title), + eyebrow = stringResource(R.string.settings_title), lede = when { compactSplit && step == 0 -> stringResource(R.string.wadb_lede_compact0) compactSplit && step == 1 -> stringResource(R.string.wadb_lede_compact1) diff --git a/app/src/main/res/values/settings.xml b/app/src/main/res/values/settings.xml new file mode 100644 index 000000000..b31f011f9 --- /dev/null +++ b/app/src/main/res/values/settings.xml @@ -0,0 +1,4 @@ + + + Settings + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 11c794fc0..b87eadc5c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -203,7 +203,7 @@ Its folder holds Linux programs, which shared storage cannot run, so it is copied into DroidDeck (%1$s). Add Cancel - Install the Linux runtime from Setup first. + Install the Linux runtime from Settings → Support & diagnostics first. Wait for %1$s to finish. Compatible Builds marked “%1$s” in Steam’s Compatibility menu have DroidDeck’s prefix fixes and start games here. The default is Proton Experimental ARM64 (%1$s), or Proton 11.0 ARM64 (%1$s) once that newer build is installed. Valve’s own Proton entries without the mark cannot start a game on this device. @@ -387,7 +387,7 @@ Applies the next time a game starts Import .zip Reading Protons… - No Proton installed yet. Start Steam once to download its ARM64 Proton, or add GE-Proton or CachyOS from Setup. + No Proton installed yet. Start Steam once to download its ARM64 Proton, or add GE-Proton or CachyOS from Settings → Compatibility & performance → Proton versions. Original · %1$s %1$s · this build %1$s · earlier build @@ -620,7 +620,7 @@ Store Flathub · ARM64 ● Flatpak ready - Install the Linux runtime from Setup first. + Install the Linux runtime from Settings → Support & diagnostics first. Set up Flatpak Adds Flatpak and connects it to Flathub (about 20 MB). The first app also downloads its runtime. Setting up… @@ -840,7 +840,7 @@ Runtime required Loading install details… Install details are unavailable. Try again later. - Install the Linux runtime from Setup first. + Install the Linux runtime from Settings → Support & diagnostics first. Stop the running session to install desktop apps. Installs %1$s into the Linux desktop. %1$s · %2$d%%