Reorganize Launcher, Performance, and Overview settings

This commit is contained in:
Kurt Himebauch committed 2026-12-05 18:32:35 -05:00
1 parent 1596e2966d
commit 0843a58d96
8 files changed
+277 -186

No files matched your search

@@ -1668,7 +1668,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
},
onSaveExport = { sg, layout -> exportSaves(sg.name, layout) { GameSaves.game(this@FrontEndActivity, sg) } },
onPerformance = { refreshCores(); showComponents = false; showMapping = false; showPerformance = true },
performancePanel = { PerformanceHost(embedded = true) },
performancePanel = { memory -> PerformanceHost(embedded = true, memory = memory) },
onRoms = { showRoms = true },
onFiles = { startActivity(Intent(this, com.droiddeck.launcher.files.FileManagerActivity::class.java)) },
onBrowseFiles = { dir ->
@@ -3114,7 +3114,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
}
@Composable
private fun PerformanceHost(embedded: Boolean = false) {
private fun PerformanceHost(embedded: Boolean = false, memory: @Composable () -> Unit = {}) {
if (embedded) androidx.compose.runtime.LaunchedEffect(Unit) { refreshCores() }
PerformancePage(
cores = CpuCores.all.map { c -> CoreRow(c, "cpu$c" + (CpuCores.maxGhz(c)?.let { String.format(java.util.Locale.US, " · %.1f GHz", it) } ?: "")) },
@@ -3155,6 +3155,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
},
onDismiss = { showPerformance = false },
embedded = embedded,
memory = memory,
)
}
@@ -257,7 +257,7 @@ class FrontEndActions(
val onAddonDelete: (com.droiddeck.launcher.runtime.WowAddons.Target, String) -> Unit = { _, _ -> },
val onSaveExport: (Library.SteamGame, com.droiddeck.launcher.session.GameSaves.Layout) -> Unit = { _, _ -> },
val onPerformance: () -> Unit,
val performancePanel: @Composable () -> Unit = {},
val performancePanel: @Composable (memory: @Composable () -> Unit) -> Unit = { memory -> memory() },
val onRoms: () -> Unit,
val onFiles: () -> Unit,
val onBrowseFiles: (File) -> Unit = {},
@@ -436,11 +436,10 @@ internal fun SetupPanel(
}
}
SettingsGroup(stringResource(R.string.setup_runtime)) { runtimeCheck(false) }
SteamIntegrationGroup(s.integration, s.integrationFocus, a.onIntegration, a.onIntegrationAppInfo, a.onIntegrationLocation)
SteamIntegrationGroup(s.integration, s.integrationFocus, a.onIntegration, a.onIntegrationAppInfo, a.onIntegrationLocation, collapsible = true)
}
PERFORMANCE_TAB -> {
a.performancePanel()
MemoryGroup(s, a, host, onPairWirelessDebugging)
a.performancePanel { MemoryGroup(s, a, host, onPairWirelessDebugging) }
}
CONTROLLER_TAB -> {
val controller = s.controller
@@ -522,11 +521,11 @@ internal fun SetupPanel(
}
}
val device: @Composable () -> Unit = {
SettingsGroup(stringResource(R.string.setup_group_device)) {
SettingsGroup(stringResource(R.string.setup_group_home_navigation)) {
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,
s.homeScreenEnabled, sideBySide = true,
) { a.onHomeScreen(it) }
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)
@@ -543,10 +542,35 @@ internal fun SetupPanel(
s.homePage, onPick = a.onHomePage,
)
}
ToggleRow(
host, "page-swipe", stringResource(R.string.setup_page_swipe),
stringResource(R.string.setup_page_swipe_hint), PageSwipe.on, sideBySide = true,
) { on ->
PageSwipe.on = on
com.droiddeck.launcher.core.AppUiPrefs.setPageSwipe(ctx, on)
}
}
SettingsGroup(stringResource(R.string.setup_group_display)) {
var sessionDisplay by rememberSaveable { mutableStateOf(false) }
val jump = SettingsJump.target
val sessionLabels = listOf(
stringResource(R.string.setup_session_orientation),
stringResource(R.string.setup_session_fullscreen),
stringResource(R.string.setup_dual_screen_sessions),
)
LaunchedEffect(jump) {
if (jump != null && jump.label in sessionLabels) sessionDisplay = true
}
ChoiceRow(
host, "launcher-orientation", stringResource(R.string.setup_launcher_orientation), null,
com.droiddeck.launcher.core.AppUiPrefs.orientationOptions.map { (value, label) -> value to stringResource(label) },
s.launcherOrientation, onPick = a.onLauncherOrientation,
s.launcherOrientation, onPick = a.onLauncherOrientation, sideBySide = true,
)
val fullscreenModes = FullscreenMode.entries.map { it to stringResource(it.label) }
ChoiceRow(
host, "launcher-fullscreen", stringResource(R.string.setup_launcher_fullscreen),
stringResource(R.string.setup_fullscreen_on),
fullscreenModes, s.launcherFullscreenMode, onPick = a.onLauncherFullscreenMode, sideBySide = true,
)
s.tpUbwcMode?.let { ubwc ->
ChoiceRow(
@@ -562,74 +586,74 @@ internal fun SetupPanel(
else Note(stringResource(R.string.gpu_ubwc_restart))
}
}
ChoiceRow(
host, "orientation", stringResource(R.string.setup_session_orientation), stringResource(R.string.setup_session_orientation_hint),
SessionPrefs.orientationOptions.map { (value, label) -> value to stringResource(label) },
s.orientation, onPick = { value ->
a.onOrientation(value)
steamOrientation = SessionPrefs.orientation(ctx, "steam")
desktopOrientation = SessionPrefs.orientation(ctx, "desktop")
},
val dualModes = listOf(
com.droiddeck.launcher.input.DualScreen.MODE_AUTO to stringResource(R.string.setup_dual_screen_auto),
com.droiddeck.launcher.input.DualScreen.MODE_ON to stringResource(R.string.setup_dual_screen_on),
com.droiddeck.launcher.input.DualScreen.MODE_OFF to stringResource(R.string.setup_dual_screen_off),
)
ChoiceRow(
host, "orientation-steam", stringResource(R.string.setup_session_orientation) + " (Steam)", stringResource(R.string.setup_session_orientation_hint),
SessionPrefs.orientationOptions.map { (value, label) -> value to stringResource(label) },
steamOrientation, onPick = { value ->
steamOrientation = value
SessionPrefs.setOrientation(ctx, "steam", value)
},
)
ChoiceRow(
host, "orientation-desktop", stringResource(R.string.setup_session_orientation) + " (Desktop)", stringResource(R.string.setup_session_orientation_hint),
SessionPrefs.orientationOptions.map { (value, label) -> value to stringResource(label) },
desktopOrientation, onPick = { value ->
desktopOrientation = value
SessionPrefs.setOrientation(ctx, "desktop", value)
},
)
val fullscreenModes = FullscreenMode.entries.map { it to stringResource(it.label) }
ChoiceRow(
host, "launcher-fullscreen", stringResource(R.string.setup_launcher_fullscreen),
stringResource(R.string.setup_fullscreen_on),
fullscreenModes, s.launcherFullscreenMode, onPick = a.onLauncherFullscreenMode,
)
ChoiceRow(
host, "session-fullscreen", stringResource(R.string.setup_session_fullscreen),
stringResource(R.string.setup_fullscreen_on),
fullscreenModes, s.sessionFullscreenMode, onPick = a.onSessionFullscreenMode,
)
ToggleRow(
host, "page-swipe", stringResource(R.string.setup_page_swipe),
stringResource(R.string.setup_page_swipe_hint), PageSwipe.on,
) { on ->
PageSwipe.on = on
com.droiddeck.launcher.core.AppUiPrefs.setPageSwipe(ctx, on)
}
ToggleRow(
host, "controller-haptics", stringResource(R.string.setup_controller_haptics),
stringResource(R.string.setup_controller_haptics_hint),
s.controllerHaptics,
) { a.onControllerHaptics(it) }
if (s.dualScreenDevice) {
val dualModes = listOf(
com.droiddeck.launcher.input.DualScreen.MODE_AUTO to stringResource(R.string.setup_dual_screen_auto),
com.droiddeck.launcher.input.DualScreen.MODE_ON to stringResource(R.string.setup_dual_screen_on),
com.droiddeck.launcher.input.DualScreen.MODE_OFF to stringResource(R.string.setup_dual_screen_off),
)
ChoiceRow(
host, "dual-screen", stringResource(R.string.setup_dual_screen_launcher), stringResource(R.string.setup_dual_screen_launcher_hint),
dualModes, s.dualScreenMode, onPick = a.onDualScreenMode,
)
}
ActionRow(
stringResource(R.string.setup_session_display), stringResource(R.string.setup_session_display_hint),
stringResource(if (sessionDisplay) R.string.common_close else R.string.setup_expand_open),
onClick = { sessionDisplay = !sessionDisplay }, sideBySide = true,
)
if (sessionDisplay) {
ChoiceRow(
host, "dual-screen-sessions", stringResource(R.string.setup_dual_screen_sessions), stringResource(R.string.setup_dual_screen_sessions_hint),
dualModes.take(2) + (com.droiddeck.launcher.input.DualScreen.MODE_SWAPPED to stringResource(R.string.setup_dual_screen_swapped)) + dualModes.drop(2), s.dualScreenSessions, onPick = a.onDualScreenSessions,
host, "orientation", stringResource(R.string.setup_session_orientation), stringResource(R.string.setup_session_orientation_hint),
SessionPrefs.orientationOptions.map { (value, label) -> value to stringResource(label) },
s.orientation, onPick = { value ->
a.onOrientation(value)
steamOrientation = SessionPrefs.orientation(ctx, "steam")
desktopOrientation = SessionPrefs.orientation(ctx, "desktop")
},
)
if (s.dualScreenSessions != com.droiddeck.launcher.input.DualScreen.MODE_OFF) {
ToggleRow(host, "dual-screen-controls", stringResource(R.string.setup_dual_screen_controls),
stringResource(R.string.setup_dual_screen_controls_hint), s.dualScreenControls) { a.onDualScreenControls(it) }
ChoiceRow(
host, "orientation-steam", stringResource(R.string.setup_session_orientation) + " (Steam)", stringResource(R.string.setup_session_orientation_hint),
SessionPrefs.orientationOptions.map { (value, label) -> value to stringResource(label) },
steamOrientation, onPick = { value ->
steamOrientation = value
SessionPrefs.setOrientation(ctx, "steam", value)
},
)
ChoiceRow(
host, "orientation-desktop", stringResource(R.string.setup_session_orientation) + " (Desktop)", stringResource(R.string.setup_session_orientation_hint),
SessionPrefs.orientationOptions.map { (value, label) -> value to stringResource(label) },
desktopOrientation, onPick = { value ->
desktopOrientation = value
SessionPrefs.setOrientation(ctx, "desktop", value)
},
)
ChoiceRow(
host, "session-fullscreen", stringResource(R.string.setup_session_fullscreen),
stringResource(R.string.setup_fullscreen_on),
fullscreenModes, s.sessionFullscreenMode, onPick = a.onSessionFullscreenMode,
)
if (s.dualScreenDevice) {
ChoiceRow(
host, "dual-screen-sessions", stringResource(R.string.setup_dual_screen_sessions), stringResource(R.string.setup_dual_screen_sessions_hint),
dualModes.take(2) + (com.droiddeck.launcher.input.DualScreen.MODE_SWAPPED to stringResource(R.string.setup_dual_screen_swapped)) + dualModes.drop(2), s.dualScreenSessions, onPick = a.onDualScreenSessions,
)
if (s.dualScreenSessions != com.droiddeck.launcher.input.DualScreen.MODE_OFF) {
ToggleRow(host, "dual-screen-controls", stringResource(R.string.setup_dual_screen_controls),
stringResource(R.string.setup_dual_screen_controls_hint), s.dualScreenControls) { a.onDualScreenControls(it) }
}
}
}
}
SettingsGroup(stringResource(R.string.setup_group_input)) {
ToggleRow(
host, "controller-haptics", stringResource(R.string.setup_controller_haptics),
stringResource(R.string.setup_controller_haptics_hint),
s.controllerHaptics, sideBySide = true,
) { a.onControllerHaptics(it) }
if (s.dualScreenDevice) {
ToggleRow(host, "android-text-field-keyboard", stringResource(R.string.setup_android_text_field_keyboard),
null, s.androidTextFieldKeyboard) { a.onAndroidTextFieldKeyboard(it) }
null, s.androidTextFieldKeyboard, sideBySide = true) { a.onAndroidTextFieldKeyboard(it) }
}
}
}
@@ -679,9 +703,9 @@ internal fun SetupPanel(
}
BoxWithConstraints(Modifier.fillMaxWidth()) {
if (maxWidth >= 840.dp && !LocalNarrowPane.current) Row(horizontalArrangement = Arrangement.spacedBy(16.dp), verticalAlignment = Alignment.Top) {
Column(Modifier.weight(1f)) { look() }
Column(Modifier.weight(1f)) { device(); art(); download() }
} else Column { look(); device(); art(); download() }
Column(Modifier.weight(1f)) { device() }
Column(Modifier.weight(1f)) { look(); art(); download() }
} else Column { device(); look(); art(); download() }
}
}
DEVELOPER_TAB -> {
@@ -806,11 +830,11 @@ internal fun SetupPanel(
@Composable
private fun MemoryGroup(s: FrontEndState, a: FrontEndActions, host: MenuHost, onPairWirelessDebugging: () -> Unit) {
SettingsGroup(stringResource(R.string.setup_group_background_apps)) {
SettingsGroup(stringResource(R.string.setup_group_memory)) {
ToggleRow(
host, "clear-cached-apps", stringResource(R.string.setup_clear_cached),
stringResource(if (s.adbPaired) R.string.setup_clear_cached_hint else R.string.setup_clear_cached_unpaired),
s.clearCachedApps, enabled = s.adbPaired || s.clearCachedApps,
s.clearCachedApps, enabled = s.adbPaired || s.clearCachedApps, sideBySide = true,
) { a.onClearCachedApps(it) }
ChoiceRow(
host, "background-app-limit", stringResource(R.string.setup_bg_limit),
@@ -822,7 +846,7 @@ private fun MemoryGroup(s: FrontEndState, a: FrontEndActions, host: MenuHost, on
0 to stringResource(R.string.setup_bg_limit_0),
),
s.backgroundAppLimit, enabled = s.adbPaired || s.backgroundAppLimit != com.droiddeck.launcher.core.BackgroundAppLimit.OFF,
onPick = a.onBackgroundAppLimit,
onPick = a.onBackgroundAppLimit, sideBySide = true,
)
ChoiceRow(
host, "memory-hud", stringResource(R.string.setup_memory_hud), stringResource(R.string.setup_memory_hud_hint),
@@ -831,7 +855,7 @@ private fun MemoryGroup(s: FrontEndState, a: FrontEndActions, host: MenuHost, on
com.droiddeck.launcher.session.SessionPrefs.MEMORY_HUD_SIMPLE to stringResource(R.string.setup_memory_hud_simple),
com.droiddeck.launcher.session.SessionPrefs.MEMORY_HUD_ADVANCED to stringResource(R.string.setup_memory_hud_advanced),
),
s.memoryHud, onPick = a.onMemoryHud,
s.memoryHud, onPick = a.onMemoryHud, sideBySide = true,
)
if (!s.adbPaired) ActionRow(
stringResource(R.string.setup_adb_pair), stringResource(R.string.setup_adb_pair_hint),
@@ -15,6 +15,8 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -75,133 +77,158 @@ fun PerformancePage(
onGameCore: (Int, Boolean) -> Unit,
onDismiss: () -> Unit,
embedded: Boolean = false,
memory: @Composable () -> Unit = {},
) {
val host = rememberMenuHost()
val colors = MaterialTheme.colorScheme
val coreItems = cores.map { it.core to it.label }
var showCompatibility by rememberSaveable { mutableStateOf(false) }
val jump = SettingsJump.target
val compatibilityLabels = listOf(
R.string.perf_glthread, R.string.perf_zink, R.string.perf_noglerror, R.string.perf_gsrealtime,
R.string.perf_sysmem, R.string.perf_xalia, R.string.perf_esync, R.string.perf_fsync,
R.string.perf_fastsync, R.string.perf_seccomp, R.string.perf_fastpath, R.string.perf_native_userland,
R.string.perf_cursor_composite, R.string.perf_hostname, R.string.perf_desktop_as_user,
).map { stringResource(it) }
LaunchedEffect(jump) {
if (jump != null && jump.label in compatibilityLabels) showCompatibility = true
}
val body: @Composable () -> Unit = {
SettingsGroup(stringResource(R.string.perf_client_cores_group)) {
SettingsGroup(stringResource(R.string.setup_performance_cpu)) {
ToggleRow(
host, "override", stringResource(R.string.perf_override),
stringResource(R.string.perf_override_hint),
clientOverride, onChange = onClientOverride,
clientOverride, sideBySide = true, onChange = onClientOverride,
)
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,
coreItems, clientCores, enabled = clientOverride, sideBySide = true, onToggle = onClientCore,
)
}
SettingsGroup(stringResource(R.string.perf_game_cores_group)) {
MultiRow(
host, "gameCores", stringResource(R.string.perf_game_cores),
stringResource(R.string.perf_game_cores_hint),
coreItems, gameCores, onToggle = onGameCore,
coreItems, gameCores, sideBySide = true, onToggle = onGameCore,
)
}
SettingsGroup(stringResource(R.string.setup_performance_graphics), key = "performance-gpu") {
ToggleRow(
host, "paceCores", stringResource(R.string.perf_pace_cores),
stringResource(R.string.perf_pace_cores_hint),
paceCores, onChange = onPaceCores,
paceCores, sideBySide = true, onChange = onPaceCores,
)
if (GpuClockPin.supported) ToggleRow(
host, "gpuclock", stringResource(R.string.perf_gpuclock), null,
gpuClockPin, sideBySide = true, onChange = onGpuClockPin,
)
}
SettingsGroup(stringResource(R.string.perf_client_ui)) {
ToggleRow(
host, "glthread", stringResource(R.string.perf_glthread),
stringResource(R.string.perf_glthread_hint),
glThread, onChange = onGlThread,
)
ToggleRow(
host, "zink", stringResource(R.string.perf_zink),
stringResource(R.string.perf_zink_hint),
zinkLazy, onChange = onZinkLazy,
)
ToggleRow(
host, "noglerror", stringResource(R.string.perf_noglerror),
stringResource(R.string.perf_noglerror_hint),
noGlError, onChange = onNoGlError,
)
ToggleRow(
host, "gsrealtime", stringResource(R.string.perf_gsrealtime),
stringResource(R.string.perf_gsrealtime_hint),
gamescopeRealtime, onChange = onGamescopeRealtime,
memory()
if (embedded) SettingsGroup(stringResource(R.string.setup_performance_advanced)) {
ActionRow(
stringResource(R.string.setup_performance_compatibility), stringResource(R.string.setup_performance_compatibility_hint),
stringResource(if (showCompatibility) R.string.common_close else R.string.setup_expand_open),
onClick = { showCompatibility = !showCompatibility }, sideBySide = true,
)
}
if (GpuClockPin.supported) GpuClockGroup(host, gpuClockPin, onChange = onGpuClockPin)
SettingsGroup(stringResource(R.string.perf_fixes)) {
ToggleRow(
host, "sysmem", stringResource(R.string.perf_sysmem),
stringResource(R.string.perf_sysmem_hint),
tuSysmem, onChange = onTuSysmem,
)
ToggleRow(
host, "xalia", stringResource(R.string.perf_xalia),
stringResource(R.string.perf_xalia_hint),
noXalia, onChange = onNoXalia,
)
ToggleRow(
host, "syncfallback", stringResource(R.string.perf_esync),
stringResource(R.string.perf_esync_hint),
syncFallback, onChange = onSyncFallback,
)
ToggleRow(
host, "fsyncfirst", stringResource(R.string.perf_fsync),
stringResource(R.string.perf_fsync_hint),
fsyncFirst, onChange = onFsyncFirst,
)
ToggleRow(
host, "fastsync", stringResource(R.string.perf_fastsync),
stringResource(R.string.perf_fastsync_hint),
fastSync, onChange = onFastSync,
)
ToggleRow(
host, "seccomp", stringResource(R.string.perf_seccomp),
stringResource(R.string.perf_seccomp_hint),
prootNoSeccomp, onChange = onProotNoSeccomp,
)
ToggleRow(
host, "fastpath", stringResource(R.string.perf_fastpath),
when {
nativeUserland -> stringResource(R.string.perf_fastpath_needs_proot)
prootNoSeccomp -> stringResource(R.string.perf_fastpath_needs_seccomp)
else -> stringResource(R.string.perf_fastpath_hint)
},
prootFastPath && !prootNoSeccomp && !nativeUserland, enabled = !prootNoSeccomp && !nativeUserland,
onChange = onProotFastPath,
)
ToggleRow(
host, "nativeuserland", stringResource(R.string.perf_native_userland),
stringResource(R.string.perf_native_userland_hint),
nativeUserland, onChange = onNativeUserland,
)
ToggleRow(
host, "cursorcomposite", stringResource(R.string.perf_cursor_composite),
stringResource(R.string.perf_cursor_composite_hint),
cursorComposite, onChange = onCursorComposite,
)
}
SettingsGroup(stringResource(R.string.perf_identity)) {
var draft by remember(guestHostname) { mutableStateOf(guestHostname) }
val valid = SessionPrefs.validGuestHostname(draft) != null
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),
) {
OutlinedTextField(
draft, { v ->
draft = v.take(63)
if (draft.isBlank() || SessionPrefs.validGuestHostname(draft) != null) onGuestHostname(draft)
if (!embedded || showCompatibility) {
SettingsGroup(stringResource(R.string.perf_client_ui)) {
ToggleRow(
host, "glthread", stringResource(R.string.perf_glthread),
stringResource(R.string.perf_glthread_hint),
glThread, onChange = onGlThread,
)
ToggleRow(
host, "zink", stringResource(R.string.perf_zink),
stringResource(R.string.perf_zink_hint),
zinkLazy, onChange = onZinkLazy,
)
ToggleRow(
host, "noglerror", stringResource(R.string.perf_noglerror),
stringResource(R.string.perf_noglerror_hint),
noGlError, onChange = onNoGlError,
)
ToggleRow(
host, "gsrealtime", stringResource(R.string.perf_gsrealtime),
stringResource(R.string.perf_gsrealtime_hint),
gamescopeRealtime, onChange = onGamescopeRealtime,
)
}
SettingsGroup(stringResource(R.string.perf_fixes)) {
ToggleRow(
host, "sysmem", stringResource(R.string.perf_sysmem),
stringResource(R.string.perf_sysmem_hint),
tuSysmem, onChange = onTuSysmem,
)
ToggleRow(
host, "xalia", stringResource(R.string.perf_xalia),
stringResource(R.string.perf_xalia_hint),
noXalia, onChange = onNoXalia,
)
ToggleRow(
host, "syncfallback", stringResource(R.string.perf_esync),
stringResource(R.string.perf_esync_hint),
syncFallback, onChange = onSyncFallback,
)
ToggleRow(
host, "fsyncfirst", stringResource(R.string.perf_fsync),
stringResource(R.string.perf_fsync_hint),
fsyncFirst, onChange = onFsyncFirst,
)
ToggleRow(
host, "fastsync", stringResource(R.string.perf_fastsync),
stringResource(R.string.perf_fastsync_hint),
fastSync, onChange = onFastSync,
)
ToggleRow(
host, "seccomp", stringResource(R.string.perf_seccomp),
stringResource(R.string.perf_seccomp_hint),
prootNoSeccomp, onChange = onProotNoSeccomp,
)
ToggleRow(
host, "fastpath", stringResource(R.string.perf_fastpath),
when {
nativeUserland -> stringResource(R.string.perf_fastpath_needs_proot)
prootNoSeccomp -> stringResource(R.string.perf_fastpath_needs_seccomp)
else -> stringResource(R.string.perf_fastpath_hint)
},
singleLine = true, isError = !valid && draft.isNotBlank(),
placeholder = { Text(SessionPrefs.DEFAULT_GUEST_HOSTNAME) },
modifier = Modifier.width(220.dp).focusGlide(),
prootFastPath && !prootNoSeccomp && !nativeUserland, enabled = !prootNoSeccomp && !nativeUserland,
onChange = onProotFastPath,
)
ToggleRow(
host, "nativeuserland", stringResource(R.string.perf_native_userland),
stringResource(R.string.perf_native_userland_hint),
nativeUserland, onChange = onNativeUserland,
)
ToggleRow(
host, "cursorcomposite", stringResource(R.string.perf_cursor_composite),
stringResource(R.string.perf_cursor_composite_hint),
cursorComposite, onChange = onCursorComposite,
)
}
SettingsGroup(stringResource(R.string.perf_identity)) {
var draft by remember(guestHostname) { mutableStateOf(guestHostname) }
val valid = SessionPrefs.validGuestHostname(draft) != null
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),
) {
OutlinedTextField(
draft, { v ->
draft = v.take(63)
if (draft.isBlank() || SessionPrefs.validGuestHostname(draft) != null) onGuestHostname(draft)
},
singleLine = true, isError = !valid && draft.isNotBlank(),
placeholder = { Text(SessionPrefs.DEFAULT_GUEST_HOSTNAME) },
modifier = Modifier.width(220.dp).focusGlide(),
)
}
ToggleRow(
host, "desktopasuser", stringResource(R.string.perf_desktop_as_user),
stringResource(if (nativeUserland) R.string.perf_desktop_as_user_hint else R.string.perf_desktop_as_user_needs_native),
desktopAsUser && nativeUserland, enabled = nativeUserland,
onChange = onDesktopAsUser,
)
}
ToggleRow(
host, "desktopasuser", stringResource(R.string.perf_desktop_as_user),
stringResource(if (nativeUserland) R.string.perf_desktop_as_user_hint else R.string.perf_desktop_as_user_needs_native),
desktopAsUser && nativeUserland, enabled = nativeUserland,
onChange = onDesktopAsUser,
)
}
if (phantomWarning != null) {
Spacer(Modifier.height(16.dp))
@@ -214,10 +241,7 @@ fun PerformancePage(
}
}
}
if (embedded) Column {
Text(stringResource(R.string.perf_lede), fontSize = 13.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(horizontal = 4.dp, vertical = 6.dp))
body()
} else SettingsPage(
if (embedded) body() else SettingsPage(
host, title = stringResource(R.string.perf_title),
lede = stringResource(R.string.perf_lede),
onBack = onDismiss,
@@ -575,9 +575,10 @@ fun <T> ChoiceRow(
chipModifier: Modifier = Modifier,
hintLines: Int? = null,
stacked: Boolean = false,
sideBySide: Boolean = false,
onPick: (T) -> Unit,
) {
SettingsRow(label, hint, highlighted = host.open == key, hintLines = hintLines, stacked = stacked) {
SettingsRow(label, hint, highlighted = host.open == key, hintLines = hintLines, stacked = stacked, sideBySide = sideBySide) {
ChoiceChip(host, key, label, options, selected, enabled, note, chipModifier, onPick)
}
}
@@ -752,6 +753,7 @@ fun ValueSlider(
fun MultiRow(
host: MenuHost, key: String, label: String, hint: String?,
items: List<Pair<Int, String>>, selected: Set<Int>, enabled: Boolean = true, note: String? = null,
sideBySide: Boolean = false,
onToggle: (Int, Boolean) -> Unit,
) {
val open = host.open == key
@@ -760,7 +762,7 @@ fun MultiRow(
selected.isEmpty() -> stringResource(R.string.widgets_none)
else -> stringResource(R.string.widgets_n_of_m, selected.size, items.size)
}
SettingsRow(label, hint, highlighted = open) {
SettingsRow(label, hint, highlighted = open, sideBySide = sideBySide) {
Box {
ValueChip(summary, open, enabled) { host.open = if (open) null else key }
AnchoredMenu(open, onDismiss = { if (host.open == key) host.open = null }, title = label, note = note) { firstItemFocus ->
@@ -37,6 +37,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
@@ -74,13 +75,24 @@ internal fun SteamIntegrationGroup(
onFeature: (Feature) -> Unit,
onAppInfo: () -> Unit,
onLocation: () -> Unit = {},
collapsible: Boolean = false,
) {
var expanded by rememberSaveable { mutableStateOf(focus != null) }
LaunchedEffect(focus) { if (focus != null) expanded = true }
val count = stringResource(R.string.integration_count, state.enabledCount(), Feature.entries.size)
SettingsGroup(
stringResource(R.string.integration_title),
detail = stringResource(R.string.integration_count, state.enabledCount(), Feature.entries.size),
detail = count.takeUnless { collapsible },
) {
Feature.entries.forEachIndexed { i, feature ->
IntegrationRow(state, feature, focus == feature, i < Feature.entries.lastIndex, onFeature, onAppInfo, onLocation)
if (collapsible) ActionRow(
count, stringResource(R.string.integration_manage_hint),
stringResource(if (expanded) R.string.common_close else R.string.setup_manage),
onClick = { expanded = !expanded }, sideBySide = true,
)
if (!collapsible || expanded) {
Feature.entries.forEachIndexed { i, feature ->
IntegrationRow(state, feature, focus == feature, i < Feature.entries.lastIndex, onFeature, onAppInfo, onLocation)
}
}
}
}
+12
View File
@@ -3338,6 +3338,18 @@
<string name="setup_ready_signed_in">signed in as %1$s</string>
<string name="setup_needs_you">When something needs you</string>
<string name="setup_group_look">Look</string>
<string name="setup_group_home_navigation">Home &amp; navigation</string>
<string name="setup_group_display">Display</string>
<string name="setup_group_input">Input</string>
<string name="setup_session_display">Session display</string>
<string name="setup_session_display_hint">Fullscreen and orientation for Steam and Desktop.</string>
<string name="setup_expand_open">Open</string>
<string name="setup_performance_cpu">CPU</string>
<string name="setup_performance_graphics">Graphics</string>
<string name="setup_performance_advanced">Advanced compatibility</string>
<string name="setup_performance_compatibility">Compatibility settings</string>
<string name="setup_performance_compatibility_hint">Wine synchronization, proot, and graphics workarounds.</string>
<string name="integration_manage_hint">Wi-Fi names, brightness, Home, system keys, and Bluetooth.</string>
<string name="setup_group_device">This device</string>
<string name="setup_group_art">Library art</string>
<string name="setup_group_download">Downloads</string>
@@ -22,6 +22,7 @@ import org.robolectric.annotation.Config
@Config(sdk = [33], qualifiers = "w960dp-h540dp-land")
class SteamIntegrationGroupTest {
@get:Rule val compose = createRobolectricComposeRule()
private val focus = mutableStateOf<Feature?>(null)
private val state = mutableStateOf(SteamIntegration.State())
private val requests = mutableListOf<Feature>()
private var appInfo = 0
@@ -29,12 +30,27 @@ class SteamIntegrationGroupTest {
private fun stateIs(value: String) = SemanticsMatcher.expectValue(SemanticsProperties.StateDescription, value)
private fun show() = compose.setContent {
private fun show(collapsible: Boolean = false) = compose.setContent {
DroidDeckTheme {
SteamIntegrationGroup(state.value, onFeature = { requests.add(it) }, onAppInfo = { appInfo++ }, onLocation = { location++ })
SteamIntegrationGroup(
state.value, focus = focus.value, onFeature = { requests.add(it) },
onAppInfo = { appInfo++ }, onLocation = { location++ }, collapsible = collapsible,
)
}
}
@Test fun overviewIntegrationCanBeManagedOrOpenedByFeature() {
show(collapsible = true)
val wifi = compose.onNodeWithTag("integration-action-wifi")
wifi.assertDoesNotExist()
compose.onNodeWithText("Manage").performClick()
wifi.assertExists()
compose.onNodeWithText("Close").performClick()
wifi.assertDoesNotExist()
compose.runOnIdle { focus.value = Feature.WIFI }
wifi.assertExists()
}
@Test fun everySwitchRequestsOnlyItsOwnFeature() {
state.value = SteamIntegration.State(home = true)
show()