diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index 782904c4e..381f3aabb 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -807,6 +807,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } private var isHomeApp by mutableStateOf(false) private var androidApps by mutableStateOf>(emptyList()) + private var padConnected by mutableStateOf(false) private val deviceListener = object : InputManager.InputDeviceListener { override fun onInputDeviceAdded(deviceId: Int) { @@ -1264,7 +1265,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde ) { headTracker?.recenter() } if (!phonePanel && glasses.present && !drawerOpen && !pcKeyboardOpen && !loading.visible) com.droiddeck.launcher.ui.GlassesCornerButton(glassesSlot, controllerSettings?.tint ?: android.graphics.Color.rgb(90, 160, 255), controllerSettings?.opacity ?: 100) { - drawerPage = com.droiddeck.launcher.ui.SessionDrawerPage.GLASSES + drawerPage = com.droiddeck.launcher.ui.SessionDrawerPage.VR drawerOpen = true } if (!drawerOpen && !pcKeyboardOpen && !loading.visible) { @@ -1451,7 +1452,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } } LaunchedEffect(drawerOpen, achievementsOpen, AgentGuest.focusRevision, StoreAchievements.revision) { - if (!drawerOpen && !achievementsOpen) return@LaunchedEffect + if (!drawerOpen && !achievementsOpen) { + achievementsInFront = null + return@LaunchedEffect + } val found = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) { runCatching { resolveAchievementsInFront() } .onFailure { Log.w(TAG, "achievements in front: ${it.javaClass.simpleName}") }.getOrNull() @@ -1824,7 +1828,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde onRumble = { on -> updateControllerPrefs { ControllerPrefs.setRumble(this@SessionActivity, on) } }, onSteamMenu = if (SessionState.mode == SessionService.MODE_STEAM) ({ sendSteamGuide() }) else null, onQam = if (SessionState.mode == SessionService.MODE_STEAM) ({ triggerSteamQam() }) else null, - onAchievements = achievementsInFront?.let { { drawerOpen = false; achievementsOpen = true } }, + controllerConnected = padConnected, + achievementsGame = achievementsInFront?.game, + achievementsTitle = achievementsInFront?.title, achievementsProgress = achievementsInFront?.progress, padType = if (SessionState.mode == SessionService.MODE_STEAM && SessionState.deckPad) padType else null, onPadType = { id -> @@ -3801,7 +3807,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (fromController && (event.keyCode == KeyEvent.KEYCODE_BUTTON_L1 || event.keyCode == KeyEvent.KEYCODE_BUTTON_R1)) { if (event.action == KeyEvent.ACTION_DOWN && event.repeatCount == 0) { // The bumpers walk the tabs on the strip; a page kept inside More counts as the More tab. - val pages = sessionDrawerPages(glasses.present) + val pages = sessionDrawerPages(achievementsInFront != null) drawerPage = pages.strip().step(pages.tabFor(drawerPage), if (event.keyCode == KeyEvent.KEYCODE_BUTTON_R1) 1 else -1) releaseDrawerDirection() } @@ -4957,6 +4963,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } private fun refreshControls() { + padConnected = controllerConnected() applyUnfoldedControls() updateOnScreenControls() } @@ -6397,6 +6404,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } (getSystemService(INPUT_SERVICE) as? InputManager) ?.registerInputDeviceListener(deviceListener, Handler(Looper.getMainLooper())) + padConnected = controllerConnected() padBridge?.setStickDeadZone(ControllerPrefs.deadZone(this)) refreshSecondScreenDisplays() if (SessionState.guestPid > 1) padBridge?.syncConnectedControllers() diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt index 219b5dc75..05cd8c530 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt @@ -493,6 +493,17 @@ object SessionPrefs { prefs(context).edit().putString("drawerPageHidden", keys.joinToString(",")).apply() } + fun drawerSections(context: Context): Map = + idList(prefs(context).getString("drawerSections", null)).mapNotNull { entry -> + val at = entry.lastIndexOf('=').takeIf { it > 0 } ?: return@mapNotNull null + entry.substring(0, at) to (entry.substring(at + 1) == "1") + }.toMap() + + fun setDrawerSections(context: Context, sections: Map) { + prefs(context).edit().putString("drawerSections", sections.entries.filter { ',' !in it.key } + .joinToString(",") { "${it.key}=${if (it.value) 1 else 0}" }).apply() + } + fun setNavTabHidden(context: Context, keys: Set) { prefs(context).edit().putString("navTabHidden", keys.joinToString(",")).apply() } diff --git a/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt b/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt index dcac4fef8..6cf0bace9 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt @@ -18,7 +18,7 @@ object SettingsReset { "storesInstallLanguage", "hud", "hudDeck", "hudFps", "hudBattery", "hudGraph", "hudColor", "hudOpacity", "__KEEP_droidDeckHud__", "__KEEP_droidDeckHudPos__", "backHold", "dockedMenuController", "backActionsInverted", "backDoubleTapMs", "touch", "pen", "penButton", "osc", "shape", "steamController", "gamepadLeft", "gamepadRight", "pipAutoEnter", "unfoldedControls", "unfoldedControlsWithController", - "stretch16x9", "avoidNotch", "picturePosition", "integerScaling", "railLabels", "developerTools", "navTabOrder", "navTabShelved", "navTabHidden", "drawerPageOrder", "drawerPageHidden", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys", + "stretch16x9", "avoidNotch", "picturePosition", "integerScaling", "railLabels", "developerTools", "navTabOrder", "navTabShelved", "navTabHidden", "drawerPageOrder", "drawerPageHidden", "drawerSections", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys", "gpuDriverMode", "androidDriver", "linuxDriver", "linuxDriver.steam", "linuxDriver.desktop", "tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime", "paceCores", "directAudio", "mic", "wifiDiscovery", "clientCpusOverride", "clientCpus", "gameCpus", diff --git a/app/src/main/java/com/droiddeck/launcher/ui/DrawerSections.kt b/app/src/main/java/com/droiddeck/launcher/ui/DrawerSections.kt new file mode 100644 index 000000000..fd6839d13 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/DrawerSections.kt @@ -0,0 +1,142 @@ +package com.droiddeck.launcher.ui + +import android.content.Context +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.core.animateFloatAsState +import androidx.compose.animation.expandVertically +import androidx.compose.animation.fadeIn +import androidx.compose.animation.fadeOut +import androidx.compose.animation.shrinkVertically +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.ColumnScope +import androidx.compose.foundation.layout.Row +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.shape.RoundedCornerShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.ExpandMore +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.runtime.compositionLocalOf +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateMapOf +import androidx.compose.runtime.remember +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.draw.rotate +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.semantics.contentDescription +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.semantics.stateDescription +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.R +import com.droiddeck.launcher.session.SessionPrefs + +/** + * Inside the session menu every top-level settings group folds to its header and a summary of its values. + * Groups start folded; a group the player opens or folds stays that way across sessions. + */ +internal object DrawerSectionState { + private val chosen = mutableStateMapOf() + + fun load(context: Context) { + if (DevPreview.drawer != null) return + chosen.clear() + chosen.putAll(SessionPrefs.drawerSections(context)) + } + + fun isOpen(key: String) = chosen[key] ?: false + + fun toggle(context: Context, key: String) { + chosen[key] = !isOpen(key) + if (DevPreview.drawer == null) SessionPrefs.setDrawerSections(context, chosen.toMap()) + } +} + +internal class DrawerSections(val context: Context, val track: (String) -> Modifier) + +internal val LocalDrawerSections = compositionLocalOf { null } + +@Composable +internal fun DrawerSection( + sections: DrawerSections, key: String, title: String, summary: String?, tag: String?, + content: @Composable ColumnScope.() -> Unit, +) { + val colors = MaterialTheme.colorScheme + val pal = LocalPalette.current + val open = DrawerSectionState.isOpen(key) + val source = remember { MutableInteractionSource() } + val hot = source.collectIsFocusedAsState().value || source.collectIsHoveredAsState().value + val rotation by animateFloatAsState(if (open) 180f else 0f, Motion.tw(180), label = "sectionArrow") + val state = stringResource(if (open) R.string.widgets_expanded else R.string.widgets_collapsed) + val toggle = { DrawerSectionState.toggle(sections.context, key) } + val shape = RoundedCornerShape(14.dp) + Column( + Modifier.fillMaxWidth().padding(top = 6.dp).clip(shape) + .background(colors.surface).border(1.dp, if (open) pal.line2 else pal.line, shape), + ) { + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(8.dp), + modifier = Modifier.fillMaxWidth().heightIn(min = 48.dp) + .then(sections.track("section-$key")) + .testTag("drawer-section-$key") + .background(if (hot) pal.signal.copy(alpha = 0.12f) else androidx.compose.ui.graphics.Color.Transparent) + .glideBorder(hot, shape, pal.signal) + .hoverable(source) + .clickable(interactionSource = source, indication = LocalIndication.current, role = Role.Button, onClick = toggle) + .controllerConfirm(onClick = toggle) + .semantics { contentDescription = title; stateDescription = state } + .padding(start = 12.dp, end = 8.dp, top = 6.dp, bottom = 6.dp), + ) { + Column(Modifier.weight(1f)) { + Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp)) { + Text(title.uppercase(), fontSize = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.2.sp, + color = if (open) colors.onBackground else colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis, + modifier = Modifier.weight(1f, fill = false)) + if (tag != null) Text( + tag, fontSize = 10.sp, fontWeight = FontWeight.SemiBold, color = pal.signal, maxLines = 1, + modifier = Modifier.clip(RoundedCornerShape(6.dp)).background(pal.signal.copy(alpha = 0.14f)) + .padding(horizontal = 6.dp, vertical = 2.dp), + ) + } + if (!open && !summary.isNullOrEmpty()) Text( + summary, fontSize = 12.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis, + modifier = Modifier.padding(top = 2.dp), + ) + } + Icon(Icons.Outlined.ExpandMore, contentDescription = null, tint = colors.onSurfaceVariant, + modifier = Modifier.size(22.dp).rotate(rotation)) + } + AnimatedVisibility(open, enter = expandVertically(Motion.tw(200)) + fadeIn(Motion.tw(160)), + exit = shrinkVertically(Motion.tw(160)) + fadeOut(Motion.tw(120))) { + Column(Modifier.fillMaxWidth()) { + Box(Modifier.fillMaxWidth().height(1.dp).background(pal.line)) + // Only top-level groups fold; groups and dialogs opened from inside one draw normally. + CompositionLocalProvider(LocalDrawerSections provides null) { content() } + } + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/DroidDeckHudSettings.kt b/app/src/main/java/com/droiddeck/launcher/ui/DroidDeckHudSettings.kt index d14086ffc..22367d720 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/DroidDeckHudSettings.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/DroidDeckHudSettings.kt @@ -26,7 +26,8 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri fun on(key: String) = cfg[key] == "1" fun int(key: String, fallback: Int) = cfg[key]?.toIntOrNull() ?: fallback - SettingsGroup(stringResource(R.string.drawer_hud)) { + SettingsGroup(stringResource(R.string.drawer_hud), key = "performance-hud", + detail = stringResource(if (a.hudOn) R.string.widgets_on else R.string.widgets_off)) { ToggleRow(host, "hud", stringResource(R.string.drawer_hud), null, a.hudOn, chipModifier = track("hud"), onChange = a.onHud) if (a.hudOn) ToggleRow( host, "hud-only-during-game", stringResource(R.string.hud_only_during_game), @@ -62,7 +63,7 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri if (a.dashboardAvailable && a.secondScreenDisplays.isNotEmpty()) BottomStripSettings(host, track) if (!a.hudOn) return - SettingsGroup(stringResource(R.string.hud_group_look)) { + SettingsGroup(stringResource(R.string.hud_group_look), key = "performance-hud-look") { SliderRow(stringResource(R.string.hud_scale), null, int("hudScale", 100), 50..150, step = 5, format = { "$it%" }, modifier = track("hud-scale")) { a.onHudSetting("hudScale", it.toString()) } SliderRow(stringResource(R.string.drawer_hud_opacity), null, int("hudOpacity", 80), 0..100, step = 5, format = { "$it%" }, @@ -85,7 +86,7 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri } var editing by remember { mutableStateOf(false) } - SettingsGroup(stringResource(R.string.hud_group_metrics)) { + SettingsGroup(stringResource(R.string.hud_group_metrics), key = "performance-hud-metrics") { ActionRow(stringResource(R.string.hud_group_metrics), null, stringResource(R.string.common_edit), onClick = { editing = true }, modifier = track("hud-readings")) val rows = DroidDeckHudSize.rowsFor(DroidDeckHudSize.from(cfg["hudSize"]), cfg) @@ -103,7 +104,7 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri ) } - if (on("showTemp") || on("showGpuTemp") || on("showBatteryTemp")) SettingsGroup(stringResource(R.string.hud_group_temps)) { + if (on("showTemp") || on("showGpuTemp") || on("showBatteryTemp")) SettingsGroup(stringResource(R.string.hud_group_temps), key = "performance-hud-temps") { ChoiceRow(host, "hud-temp-unit", stringResource(R.string.hud_temp_unit), null, listOf("c" to "°C", "f" to "°F"), if (cfg["tempUnit"].equals("f", true)) "f" else "c", chipModifier = track("hud-temp-unit")) { a.onHudSetting("tempUnit", it) } @@ -129,7 +130,7 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri } } - SettingsGroup(stringResource(R.string.hud_group_more)) { + SettingsGroup(stringResource(R.string.hud_group_more), key = "performance-hud-more") { ActionRow(stringResource(R.string.hud_export), stringResource(R.string.hud_export_hint), stringResource(R.string.hud_export_button), onClick = a.onHudExport, modifier = track("hud-export")) ActionRow(stringResource(R.string.hud_reset), null, stringResource(R.string.hud_reset_button), @@ -145,7 +146,7 @@ private fun BottomStripSettings(host: MenuHost, track: (String) -> Modifier) { var hudOn by remember { mutableStateOf(SessionPrefs.bottomHud(context)) } var onTabs by remember { mutableStateOf(SessionPrefs.bottomStripOnTabs(context)) } var shown by remember { mutableStateOf(SessionPrefs.bottomStripMetrics(context)) } - SettingsGroup(stringResource(R.string.bottom_hud_group)) { + SettingsGroup(stringResource(R.string.bottom_hud_group), key = "performance-bottom-hud") { ToggleRow(host, "bottom-hud", stringResource(R.string.bottom_hud_group), null, hudOn, chipModifier = track("bottom-hud")) { on -> hudOn = on diff --git a/app/src/main/java/com/droiddeck/launcher/ui/GlassesPanel.kt b/app/src/main/java/com/droiddeck/launcher/ui/GlassesPanel.kt index 877cad924..c7d9f0736 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/GlassesPanel.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/GlassesPanel.kt @@ -88,7 +88,7 @@ internal fun VrControllerGroups(host: MenuHost, track: (String) -> Modifier = { androidx.compose.runtime.LaunchedEffect(Unit) { com.droiddeck.launcher.input.VrControllers.load(context) } val c by com.droiddeck.launcher.input.VrControllers.settings.collectAsState() val emulate = com.droiddeck.launcher.input.VrControllers.Emulate.entries - SettingsGroup(stringResource(R.string.vr_controllers_group)) { + SettingsGroup(stringResource(R.string.vr_controllers_group), key = "vr-controllers") { ChoiceRow(host, "vr-emulate", stringResource(R.string.vr_controllers_emulate), stringResource(R.string.vr_controllers_emulate_hint), emulate.map { it to stringResource(when (it) { com.droiddeck.launcher.input.VrControllers.Emulate.OFF -> R.string.vr_controllers_off @@ -142,13 +142,13 @@ internal fun GlassesGroups( val directView = usesGlasses && picture == GlassesRendering.Picture.STEREO val menuScreen = !inSession && g.usable && s.gameOnGlasses && s.screen3dof if (g.canControl && onRecenter != null && s.headTracking && (virtualScreen || menuScreen || (directView && steamVrRunning))) { - SettingsGroup(stringResource(R.string.glasses_quick_actions), compact = true) { + SettingsGroup(stringResource(R.string.glasses_quick_actions), compact = true, key = "vr-glasses-quick") { ActionRow(stringResource(R.string.glasses_recenter), if (virtualScreen || menuScreen) stringResource(R.string.glasses_recenter_screen_hint) else null, stringResource(R.string.cardboard_recenter_button), onRecenter) } } - if (display) SettingsGroup(g.model) { + if (display) SettingsGroup(g.model, key = "vr-glasses") { if (g.experimental) SettingsRow(stringResource(R.string.glasses_control), stringResource( if (g.supportsDisplayModeControl) R.string.glasses_xreal_experimental else R.string.glasses_pro2_experimental)) {} val status = if (g.hasDisplay) stringResource(R.string.glasses_status, g.width, g.height, kotlin.math.round(g.hz).toInt(), @@ -170,7 +170,7 @@ internal fun GlassesGroups( s.gameOnGlasses, chipModifier = track("glasses-game")) { Glasses.setGameOnGlasses(it) } } if (display && g.canControl && g.supportsDisplayModeControl && (inSession || g.sbs || g.sbsSupport == GlassesState.SBS_FAILS)) { - SettingsGroup(stringResource(R.string.glasses_display_mode)) { + SettingsGroup(stringResource(R.string.glasses_display_mode), key = "vr-glasses-mode") { if (g.sbsSupport == GlassesState.SBS_FAILS && !g.sbs) { ActionRow(stringResource(R.string.glasses_3d), stringResource(R.string.glasses_3d_failed), stringResource(R.string.stores_dl_retry), { Glasses.set3d(true) }) @@ -182,12 +182,12 @@ internal fun GlassesGroups( val profiles = if (inSession) listOf(GlassesDisplayModes.profile(g.sbs, false)) else listOf(GlassesDisplayProfile.TWO_D, GlassesDisplayProfile.THREE_D) for (profile in profiles) SettingsGroup(stringResource(if (profile == GlassesDisplayProfile.TWO_D) - R.string.glasses_output_2d else R.string.glasses_output_3d)) { + R.string.glasses_output_2d else R.string.glasses_output_3d), key = "vr-glasses-output-${profile.name.lowercase()}") { GlassesResolutionRow(host, g, s, profile, track) if ((profile == GlassesDisplayProfile.THREE_D) == g.sbs) GlassesRefreshRow(host, g, s, track) } } - if (display && (g.canControl || g.hasDisplay)) SettingsGroup(stringResource(R.string.glasses_picture_group)) { + if (display && (g.canControl || g.hasDisplay)) SettingsGroup(stringResource(R.string.glasses_picture_group), key = "vr-glasses-picture") { ChoiceRow(host, "glasses-picture", stringResource(R.string.glasses_picture), stringResource(R.string.glasses_picture_hint), listOf( GlassesSettings.PICTURE_AUTO to stringResource(R.string.glasses_picture_auto), @@ -213,7 +213,7 @@ internal fun GlassesGroups( format = { SpatialMeasurements.distance(it / 10f) }, modifier = track("glasses-distance")) { Glasses.setScreenDistanceDm(it) } } } - if (vr && (g.canControl || g.hasDisplay)) SettingsGroup(stringResource(R.string.cardboard_steamvr)) { + if (vr && (g.canControl || g.hasDisplay)) SettingsGroup(stringResource(R.string.cardboard_steamvr), key = "vr-glasses-steamvr") { steamVr() if (g.supportsDisplayModeControl) ToggleRow(host, "glasses-auto3d", stringResource(R.string.glasses_auto3d), stringResource(R.string.glasses_auto3d_hint), s.auto3d, chipModifier = track("glasses-auto3d")) { Glasses.setAuto3d(it) } @@ -226,7 +226,7 @@ internal fun GlassesGroups( format = { "$it°" }, modifier = track("glasses-vr-fov")) { Glasses.setVrFovDeg(it) } } if ((tab == null || tab == GlassesTab.TRACKING) && g.canControl) { - SettingsGroup(stringResource(R.string.glasses_head_tracking)) { + SettingsGroup(stringResource(R.string.glasses_head_tracking), key = "vr-glasses-tracking") { val trackingHint = when { inSession && !usesGlasses -> R.string.glasses_screen_no_output spatialVr -> R.string.glasses_head_tracking_spatial_vr_hint @@ -240,13 +240,13 @@ internal fun GlassesGroups( chipModifier = track("glasses-tracking")) { Glasses.setHeadTracking(it) } } val calibration by Glasses.calibration.collectAsState() - if (calibration.supported) SettingsGroup(stringResource(R.string.glasses_calibration)) { + if (calibration.supported) SettingsGroup(stringResource(R.string.glasses_calibration), key = "vr-glasses-calibration") { GlassesCalibrationControls(calibration, onStart = Glasses::startCalibration, onCancel = Glasses::cancelCalibration, onReset = Glasses::resetCalibration, onDone = { onRecenter?.invoke() }) } } - if ((tab == null || tab == GlassesTab.HARDWARE) && g.canControl && g.hardwareControls) SettingsGroup(stringResource(R.string.glasses_hardware)) { + if ((tab == null || tab == GlassesTab.HARDWARE) && g.canControl && g.hardwareControls) SettingsGroup(stringResource(R.string.glasses_hardware), key = "vr-glasses-hardware") { if (g.brightnessMax > 0) SliderRow(stringResource(R.string.glasses_brightness), null, g.brightness.coerceAtLeast(0), 0..g.brightnessMax, step = 1, modifier = track("glasses-brightness")) { Glasses.setBrightness(it) } if (g.volumeMax > 0) SliderRow(stringResource(R.string.glasses_volume), null, g.volume.coerceAtLeast(0), 0..g.volumeMax, step = 1, @@ -259,7 +259,7 @@ internal fun GlassesGroups( androidx.compose.runtime.LaunchedEffect(Unit) { HandTracking.load(context) } if ((tab == null || tab == GlassesTab.TRACKING) && g.canControl) { if (g.spatialConnected) { - SettingsGroup(stringResource(R.string.glasses_experimental)) { + SettingsGroup(stringResource(R.string.glasses_experimental), key = "vr-glasses-experimental") { val spatial by SpatialTracking.status.collectAsState() ToggleRow(host, "glasses-position", stringResource(R.string.glasses_position), stringResource(R.string.glasses_position_hint), s.positionalTracking, chipModifier = track("glasses-position")) { Glasses.setPositionalTracking(it) } @@ -282,7 +282,7 @@ internal fun GlassesGroups( s.joyConTracking, enabled = s.positionalTracking, chipModifier = track("glasses-joycons")) { Glasses.setJoyConTracking(it) } } } - if (hands.usable) SettingsGroup(stringResource(R.string.phone_camera_tracking_group)) { + if (hands.usable) SettingsGroup(stringResource(R.string.phone_camera_tracking_group), key = "vr-hand-camera") { HandCameraRows(host, track, inSession) } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/PenSettingsGroup.kt b/app/src/main/java/com/droiddeck/launcher/ui/PenSettingsGroup.kt index 646c8cfcc..772c6cc27 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/PenSettingsGroup.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/PenSettingsGroup.kt @@ -11,7 +11,7 @@ internal fun PenSettingsGroup( host: MenuHost, pen: SessionPrefs.Pen, track: (String) -> Modifier = { Modifier }, onPick: (key: String, value: String) -> Unit, ) { - SettingsGroup(stringResource(R.string.mode_pen)) { + SettingsGroup(stringResource(R.string.mode_pen), key = "controller-pen") { ChoiceRow(host, "pen", stringResource(R.string.mode_pen), null, listOf(SessionPrefs.PEN_MOUSE to stringResource(R.string.mode_pen_mouse), SessionPrefs.PEN_TOUCH to stringResource(R.string.mode_pen_touch)), 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 0c3947f98..a2d15a993 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt @@ -218,7 +218,7 @@ fun PerformancePage( @Composable internal fun GpuClockGroup(host: MenuHost, on: Boolean, chipModifier: Modifier = Modifier, onChange: (Boolean) -> Unit) { - SettingsGroup(stringResource(R.string.perf_gpu)) { + SettingsGroup(stringResource(R.string.perf_gpu), key = "performance-gpu") { ToggleRow( host, "gpuclock", stringResource(R.string.perf_gpuclock), null, diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SessionDrawerPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/SessionDrawerPage.kt index b2bc10c8a..ee2a49fa8 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SessionDrawerPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SessionDrawerPage.kt @@ -6,17 +6,18 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import com.droiddeck.launcher.session.SessionPrefs +/** HUD holds the Performance page and GAMES the Game page; the names stay because saved page orders use them. */ internal enum class SessionDrawerPage(val firstControl: String) { - CONTROLLER("input-profile"), - GLASSES("glasses-game"), - DISPLAY("fg"), - HUD("hud"), - EFFECTS("look"), - GAMES("anisotropy"), - AGENT("agent-input"), - SESSION("suspend"), + CONTROLLER("section-controller-input"), + HUD("section-performance-pacing"), + DISPLAY("section-display"), + EFFECTS("section-effects-look"), + GAMES("section-game-profile"), + VR("section-vr-steamvr"), + SESSION("pause"), MORE("more-edit"), - VR("steamvr"), + ACHIEVEMENTS("achievements"), + AGENT("agent-input"), } internal object DrawerPages { @@ -71,16 +72,16 @@ internal object DrawerPages { } internal fun offeredDrawerPages( - hasGlasses: Boolean = false, hasAgent: Boolean = com.droiddeck.launcher.agent.AgentTab.shown, + hasAchievements: Boolean = false, hasAgent: Boolean = com.droiddeck.launcher.agent.AgentTab.shown, ): List = DrawerPages.order.filter { - (hasGlasses || it != SessionDrawerPage.GLASSES) && + (hasAchievements || it != SessionDrawerPage.ACHIEVEMENTS) && (hasAgent || it != SessionDrawerPage.AGENT) } internal fun sessionDrawerPages( - hasGlasses: Boolean = false, hasAgent: Boolean = com.droiddeck.launcher.agent.AgentTab.shown, -): List = offeredDrawerPages(hasGlasses, hasAgent).filter { it !in DrawerPages.hidden } + hasAchievements: Boolean = false, hasAgent: Boolean = com.droiddeck.launcher.agent.AgentTab.shown, +): List = offeredDrawerPages(hasAchievements, hasAgent).filter { it !in DrawerPages.hidden } /** The pages shown as tabs: everything up to and including the More tab. */ internal fun List.strip(): List { 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 ae0059555..148ff609b 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt @@ -37,6 +37,7 @@ import androidx.compose.material.icons.outlined.DesktopWindows import androidx.compose.material.icons.outlined.Keyboard import androidx.compose.material.icons.outlined.AutoFixHigh import androidx.compose.material.icons.outlined.ExpandMore +import androidx.compose.material.icons.outlined.EmojiEvents import androidx.compose.material.icons.outlined.Home import androidx.compose.material.icons.outlined.MoreHoriz import androidx.compose.material.icons.automirrored.outlined.ArrowBack @@ -175,12 +176,12 @@ import java.util.Locale internal val SessionDrawerPage.title: Int get() = when (this) { SessionDrawerPage.CONTROLLER -> R.string.drawer_page_controller - SessionDrawerPage.GLASSES -> R.string.drawer_page_glasses SessionDrawerPage.DISPLAY -> R.string.drawer_page_display - SessionDrawerPage.HUD -> R.string.drawer_hud - SessionDrawerPage.VR -> R.string.vr_title + SessionDrawerPage.HUD -> R.string.drawer_page_performance + SessionDrawerPage.VR -> R.string.drawer_page_vr SessionDrawerPage.EFFECTS -> R.string.drawer_page_effects - SessionDrawerPage.GAMES -> R.string.game_settings_title + SessionDrawerPage.GAMES -> R.string.drawer_page_game + SessionDrawerPage.ACHIEVEMENTS -> R.string.achievements_title SessionDrawerPage.AGENT -> R.string.rail_agent SessionDrawerPage.SESSION -> R.string.mode_session SessionDrawerPage.MORE -> R.string.drawer_page_more @@ -188,12 +189,12 @@ internal val SessionDrawerPage.title: Int get() = when (this) { internal val SessionDrawerPage.icon get() = when (this) { SessionDrawerPage.CONTROLLER -> Icons.Outlined.SportsEsports - SessionDrawerPage.GLASSES -> GlassesIcon SessionDrawerPage.DISPLAY -> Icons.Outlined.DesktopWindows SessionDrawerPage.HUD -> Icons.Outlined.Speed SessionDrawerPage.VR -> VrHeadsetIcon SessionDrawerPage.EFFECTS -> Icons.Outlined.AutoFixHigh SessionDrawerPage.GAMES -> Icons.Outlined.Layers + SessionDrawerPage.ACHIEVEMENTS -> Icons.Outlined.EmojiEvents SessionDrawerPage.AGENT -> Icons.Outlined.Terminal SessionDrawerPage.SESSION -> Icons.Outlined.Settings SessionDrawerPage.MORE -> Icons.Outlined.MoreHoriz @@ -205,9 +206,15 @@ private class DrawerFocus { var focused by mutableStateOf(null) private set + private val sectionOrder = mutableMapOf>() + private fun requester(key: String) = requesters.getOrPut(key) { FocusRequester() } - fun track(page: SessionDrawerPage, key: String): Modifier = Modifier.focusRequester(requester(key)).onFocusChanged { + fun sections(page: SessionDrawerPage): List = sectionOrder[page]?.toList().orEmpty() + + fun track(page: SessionDrawerPage, key: String): Modifier = Modifier.focusRequester(requester(key)).also { + if (key.startsWith("section-")) sectionOrder.getOrPut(page) { LinkedHashSet() }.add(key) + }.onFocusChanged { if (it.isFocused) { last[page] = key focused = key @@ -313,7 +320,9 @@ class DrawerActions( val onWowChat: (String?) -> Unit = {}, val onSteamMenu: (() -> Unit)?, val onQam: (() -> Unit)?, - val onAchievements: (() -> Unit)? = null, + val controllerConnected: Boolean = false, + val achievementsGame: com.droiddeck.launcher.stores.StoreAchievements.Game? = null, + val achievementsTitle: String? = null, val achievementsProgress: Pair? = null, val onOsc: (String) -> Unit, val onEditSteamTouch: (() -> Unit)? = null, @@ -418,7 +427,7 @@ class DrawerActions( @Composable internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, controllerActive: Boolean, onPageChange: (SessionDrawerPage) -> Unit, a: DrawerActions, docked: Boolean = false, backRequest: Int = 0, onLayerChange: (Boolean) -> Unit = {}) { - val pages = sessionDrawerPages(a.glassesPresent) + val pages = sessionDrawerPages(a.achievementsGame != null) val page = requestedPage.takeIf { it in pages } ?: pages.first() var managing by rememberSaveable { mutableStateOf(false) } var releaseSignal by remember { mutableStateOf(0) } @@ -428,11 +437,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont val pal = LocalPalette.current val host = rememberMenuHost() val (glasses, glassesSettings) = rememberGlasses() - val glassesPages = glassesTabs(glasses) + (GlassesTab.CONTROLLERS to stringResource(R.string.vr_controllers_tab)) - var selectedGlassesTab by rememberSaveable { mutableStateOf(GlassesTab.DISPLAY) } - val glassesTab = selectedGlassesTab.takeIf { key -> glassesPages.any { it.first == key } } ?: GlassesTab.DISPLAY - var androidAppsExpanded by rememberSaveable { mutableStateOf(false) } - var advancedEffectsExpanded by rememberSaveable { mutableStateOf(false) } + remember { DrawerSectionState.load(drawerContext) } var appToChooseDisplay by remember { mutableStateOf(null) } var confirmStop by remember { mutableStateOf(false) } var sheetCoords by remember { mutableStateOf(null) } @@ -440,10 +445,6 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont var savedWidth by remember { mutableStateOf(SessionPrefs.drawerWidthDp(widthContext)) } var stopCoords by remember { mutableStateOf(null) } val pageScroll = remember { SessionDrawerPage.entries.associateWith { ScrollState(0) } } - LaunchedEffect(glassesTab) { - if (page == SessionDrawerPage.GLASSES) host.open = null - pageScroll.getValue(SessionDrawerPage.GLASSES).scrollTo(0) - } val veil by animateFloatAsState(if (open) 1f else 0f, Motion.tw(260), label = "veil") val focus = remember { DrawerFocus() } val inputModeManager = LocalInputModeManager.current @@ -492,7 +493,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont if (open && !controllerActive) focusManager.clearFocus(force = true) } var focusedPage by remember { mutableStateOf(page) } - LaunchedEffect(open, page, glassesTab, controllerActive, host.open, appToChooseDisplay, confirmStop) { + LaunchedEffect(open, page, controllerActive, host.open, appToChooseDisplay, confirmStop) { if (!open) { host.open = null confirmStop = false @@ -501,24 +502,19 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont if (host.open != null || appToChooseDisplay != null || confirmStop) return@LaunchedEffect val turned = page != focusedPage focusedPage = page - val first = when { - page == SessionDrawerPage.GLASSES -> "glasses-tab-$glassesTab" - page == SessionDrawerPage.SESSION && a.isHomeApp -> "apps" - else -> page.firstControl - } if (turned) focus.forget(page) - val target = focus.target(page) ?: first + val target = focus.target(page) ?: page.firstControl repeat(24) { androidx.compose.runtime.withFrameNanos { } focus.request(target) if (focus.focused == target) return@LaunchedEffect } focus.forget(page) - focus.request(first) - if (first != page.firstControl) repeat(4) { + // Which sections a page shows depends on the session, so the first one shown takes focus. + for (key in listOf(page.firstControl) + focus.sections(page)) repeat(2) { androidx.compose.runtime.withFrameNanos { } - if (focus.focused == first) return@LaunchedEffect - focus.request(page.firstControl) + focus.request(key) + if (focus.focused == key) return@LaunchedEffect } } } @@ -587,13 +583,6 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont focus.track(page, "screen").testTag("drawer-screen-picker"), ) } else if (roomyHeader) Spacer(Modifier.weight(1f)) - SteamActionPill( - stringResource(if (a.paused) R.string.resume_session else R.string.stores_dl_pause), - if (a.paused) Icons.Outlined.PlayArrow else Icons.Outlined.Pause, focus.track(page, "pause"), - ) { host.open = null; if (a.paused) a.onResume() else a.onPause() } - if (a.pipSupported) SteamActionPill( - stringResource(R.string.pip_title), Icons.Outlined.PictureInPictureAlt, focus.track(page, "pip"), - ) { host.open = null; a.onPip() } val steamActions = a.steam && a.onSteamMenu != null && a.onQam != null val qamInteraction = remember { MutableInteractionSource() } var qamStartedOnPress by remember { mutableStateOf(false) } @@ -626,12 +615,6 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont } StopSessionButton(modifier = focus.track(page, "stop").onGloballyPositioned { stopCoords = it }) { host.open = null; confirmStop = true } } - a.onAchievements?.let { show -> - DrawerAchievementsRow(a.achievementsProgress, Modifier.padding(top = if (short) 6.dp else 10.dp).then(focus.track(page, "achievements"))) { - host.open = null; show() - } - } - Row( verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth().padding(top = 6.dp), @@ -646,14 +629,10 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont } if (insideMore && !managing) DrawerMoreBack(stringResource(page.title), focus.track(page, "more-back")) { host.open = null; onPageChange(SessionDrawerPage.MORE) } if (managing) ManageDrawerPages( - offeredDrawerPages(a.glassesPresent), + offeredDrawerPages(a.achievementsGame != null), Modifier.weight(1f).fillMaxWidth().padding(top = 8.dp, start = 14.dp, end = 14.dp), releaseSignal, ) { managing = false } else { - if (page == SessionDrawerPage.GLASSES) SegmentedTabs( - glassesPages, glassesTab, modifier = Modifier.fillMaxWidth().padding(top = 8.dp), - tabModifier = { key -> focus.track(page, "glasses-tab-$key").testTag("glasses-tab-$key") }, - ) { selectedGlassesTab = it } // The agent's chat scrolls itself and keeps its composer at the bottom, so it takes the height left. if (page == SessionDrawerPage.AGENT) AgentPageWithControls( Modifier.weight(1f).fillMaxWidth().padding(top = 8.dp, start = 14.dp, end = 14.dp), @@ -663,377 +642,24 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont showControlsWithoutKeyboard = true, ) else Column( modifier = Modifier.weight(1f).fillMaxWidth().verticalScroll(pageScroll.getValue(page)), - ) { CompositionLocalProvider(LocalChipMinWidth provides 96.dp, LocalCompactSettings provides true) { + ) { + val track: (String) -> Modifier = { key -> focus.track(page, key) } + val sections = remember(page) { DrawerSections(drawerContext, track) } + CompositionLocalProvider(LocalChipMinWidth provides 96.dp, LocalCompactSettings provides true, LocalDrawerSections provides sections) { when (page) { - SessionDrawerPage.HUD -> DroidDeckHudSettings(host, a) { key -> focus.track(page, key) } - SessionDrawerPage.DISPLAY -> { - SettingsGroup(stringResource(R.string.drawer_page_display)) { - if (a.gameZoomAvailable) SettingsRow( - stringResource(R.string.game_zoom_title), - stringResource(R.string.game_zoom_hint), - ) { - Row( - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(4.dp), - ) { - val zoomOutEnabled = a.gameZoom > 1.0f - val zoomInEnabled = a.gameZoom < 3.0f - val zoomResetEnabled = a.gameZoom > 1.0f - val zoomOut = { a.onGameZoom((a.gameZoom - 0.25f).coerceAtLeast(1.0f)) } - val zoomIn = { a.onGameZoom((a.gameZoom + 0.25f).coerceAtMost(3.0f)) } - val zoomReset = { a.onGameZoom(1.0f) } - - OutlinedButton( - onClick = zoomOut, - enabled = zoomOutEnabled, - modifier = focus.track(page, "game-zoom-out").width(42.dp) - .controllerConfirm(enabled = zoomOutEnabled, onClick = zoomOut), - contentPadding = PaddingValues(horizontal = 4.dp, vertical = 0.dp), - ) { Text("−") } - Text("${(a.gameZoom * 100.0f).toInt()}%", fontSize = 12.sp) - OutlinedButton( - onClick = zoomIn, - enabled = zoomInEnabled, - modifier = focus.track(page, "game-zoom-in").width(42.dp) - .controllerConfirm(enabled = zoomInEnabled, onClick = zoomIn), - contentPadding = PaddingValues(horizontal = 4.dp, vertical = 0.dp), - ) { Text("+") } - OutlinedButton( - onClick = zoomReset, - enabled = zoomResetEnabled, - modifier = focus.track(page, "game-zoom-reset").width(48.dp) - .controllerConfirm(enabled = zoomResetEnabled, onClick = zoomReset), - contentPadding = PaddingValues(horizontal = 2.dp, vertical = 0.dp), - ) { Text("1×") } - } - } - val fgOpen = host.open == "fg" - val offLabel = stringResource(R.string.frame_gen_off) - val fgLabel = FrameGen.label(LocalContext.current, a.frameGen) - SettingsRow( - stringResource(R.string.frame_gen_title), - if (a.frameGenTargetGameId != null) - "${stringResource(R.string.frame_gen_scope_game)} · ${a.frameGenTargetGameName ?: "ID ${a.frameGenTargetGameId}"}" - else stringResource(R.string.frame_gen_scope_global), - highlighted = fgOpen - ) { - Box { - ValueChip(fgLabel, fgOpen, modifier = focus.track(page, "fg")) { host.open = if (fgOpen) null else "fg" } - FrameGenMenu( - host, a.frameGen, a.lossless, a.onFrameGenPick, a.onImportLossless, - gameProfileId = a.frameGenTargetGameId, - hasGameOverride = a.hasGameOverride, - onResetGame = a.onFrameGenReset, - ) - } - } - if (a.direct) SliderRow( - stringResource(R.string.drawer_frame_limit), stringResource(R.string.drawer_frame_limit_note), - a.fpsLimit.takeIf { it > 0 } ?: SessionPrefs.FPS_LIMIT_OFF, - SessionPrefs.FPS_LIMIT_OFF..SessionPrefs.FPS_LIMIT_MAX, step = 5, - format = { if (it <= SessionPrefs.FPS_LIMIT_OFF) offLabel else it.toString() }, - modifier = focus.track(page, "fps-limit"), - onChange = { a.onFpsLimit(if (it <= SessionPrefs.FPS_LIMIT_OFF) 0 else it) }) - if (a.steam && !a.direct && a.onQam != null) SettingsRow( - stringResource(R.string.drawer_frame_limit), stringResource(R.string.drawer_frame_limit_steam_hint), - ) { - DrawerOutlineButton(stringResource(R.string.drawer_open_steam_qam), modifier = focus.track(page, "fps-limit-steam")) { - host.open = null - a.onQam?.invoke() - } - } - } - SettingsGroup(stringResource(R.string.setup_orientation)) { - ChoiceRow(host, "orientation", stringResource(R.string.setup_session_orientation), null, - SessionPrefs.orientationOptions.map { (value, label) -> value to stringResource(label) }, - a.orientation, chipModifier = focus.track(page, "orientation"), onPick = a.onOrientation) - } - SettingsGroup(stringResource(R.string.display_image_scaling)) { - if (a.steam) SettingsRow(stringResource(R.string.display_integer_scaling), null) { - PadTextButton( - onClick = { a.onIntegerScaling(!a.integerScaling) } - ) { - Text(stringResource( - if (a.integerScaling) R.string.display_scaling_integer - else R.string.display_scaling_fit - )) - } - } - ChoiceRow(host, "upscaler", stringResource(R.string.display_filter), null, - SessionPrefs.upscalerChoices(LocalContext.current), a.upscaler, - note = stringResource(R.string.display_filter_note), - chipModifier = focus.track(page, "upscaler"), onPick = a.onUpscaler) - if (SessionPrefs.upscalerHasSharpness(a.upscaler)) SliderRow( - stringResource(R.string.display_sharpness), null, a.upscaleSharpness, 0..100, step = 5, - format = { "$it%" }, modifier = focus.track(page, "upscale-sharpness"), onChange = a.onUpscaleSharpness) - } - SecondScreenGroup(host, a) { key -> focus.track(page, key) } - } - SessionDrawerPage.EFFECTS -> { - ScreenEffectsGroup(host, a, advancedEffectsExpanded, - onAdvancedToggle = { advancedEffectsExpanded = !advancedEffectsExpanded }) { key -> focus.track(page, key) } - } - SessionDrawerPage.VR -> { - SteamVrGroup(a) { key -> focus.track(page, key) } - if (!a.glassesOutput) CardboardGroup(host, a) { key -> focus.track(page, key) } - } - SessionDrawerPage.CONTROLLER -> { - SettingsGroup(stringResource(R.string.drawer_page_controller)) { - InputQuickSettings(host, desktop = a.desktop, onChanged = a.onInputSelection, onEdit = a.onInputSettings) { key -> focus.track(page, key) } - } - SettingsGroup(stringResource(R.string.input_device_settings)) { - a.padType?.let { type -> - ChoiceRow(host, "pad-type", stringResource(R.string.input_virtual_controller), stringResource(R.string.input_virtual_controller_hint), - listOf(SessionPrefs.CONTROLLER_DECK to stringResource(R.string.mode_controller_deck), - SessionPrefs.CONTROLLER_STEAM to stringResource(R.string.mode_controller_steam), - SessionPrefs.CONTROLLER_DS4 to stringResource(R.string.mode_controller_ds4), - SessionPrefs.CONTROLLER_DUALSENSE to stringResource(R.string.mode_controller_dualsense), - SessionPrefs.CONTROLLER_XBOX360 to stringResource(R.string.mode_controller_x360)), - type, chipModifier = focus.track(page, "pad-type"), onPick = a.onPadType) - } - a.controller?.let { c -> - SliderRow(stringResource(R.string.ctrl_size), null, c.size, 80..125, step = 5, - format = { "$it%" }, modifier = focus.track(page, "controller-size"), - onChange = a.onControllerSize) - ToggleRow(host, "rumble", stringResource(R.string.ctrl_rumble), null, c.rumble, - chipModifier = focus.track(page, "rumble"), onChange = a.onRumble) - } - } - SettingsGroup(stringResource(R.string.input_touchscreen)) { - ChoiceRow(host, "touch", stringResource(R.string.input_touchscreen), stringResource(R.string.input_touchscreen_hint), - listOf(SessionPrefs.TOUCH_AUTO to stringResource(R.string.drawer_touch_auto, a.touchAuto), SessionPrefs.TOUCH_PAD to stringResource(R.string.mode_touch_touchpad), SessionPrefs.TOUCH_DIRECT to stringResource(R.string.mode_touch_direct), SessionPrefs.TOUCH_GESTURES to stringResource(R.string.mode_touch_gestures), SessionPrefs.TOUCH_OFF to stringResource(R.string.widgets_off)), - a.touchMode, chipModifier = focus.track(page, "touch"), onPick = a.onTouch) - if (a.touchActive == SessionPrefs.TOUCH_PAD) - RelativeMouseRow(host, a, focus.track(page, "relative-mouse")) - if (a.touchActive == SessionPrefs.TOUCH_DIRECT) - ToggleRow(host, "direct-cursor", stringResource(R.string.input_touch_cursor), - stringResource(R.string.input_touch_cursor_hint), a.directCursor, - chipModifier = focus.track(page, "direct-cursor"), onChange = a.onDirectCursor) - when (a.touchActive) { - SessionPrefs.TOUCH_GESTURES -> ActionRow(stringResource(R.string.gesture_settings), null, - stringResource(R.string.ctrl_edit), a.onGestureSettings, - modifier = focus.track(page, "gesture-settings")) - SessionPrefs.TOUCH_DIRECT -> ChoiceRow(host, "long-press", stringResource(R.string.input_touch_hold), stringResource(R.string.input_touch_hold_hint), - listOf(MOUSE_BEHAVIOR_NONE to stringResource(R.string.gesture_hold_left), - MOUSE_BEHAVIOR_CLICK to stringResource(R.string.gesture_right_click), - MOUSE_BEHAVIOR_HOLD to stringResource(R.string.gesture_hold_right)), - a.directHoldBehavior, chipModifier = focus.track(page, "long-press"), - onPick = a.onDirectHoldBehavior) - } - } - a.pen?.let { PenSettingsGroup(host, it, track = { key -> focus.track(page, key) }, onPick = a.onPen) } - SettingsGroup(stringResource(R.string.input_screen_visibility)) { - ChoiceRow(host, "osc", stringResource(R.string.mode_osc), null, - if (a.steam) listOf(SessionPrefs.OSC_AUTO to stringResource(R.string.common_auto), SessionPrefs.OSC_ALWAYS to stringResource(R.string.common_always), SessionPrefs.OSC_STEAM_TOUCH to stringResource(R.string.osc_steam_touch), SessionPrefs.OSC_STEAM_QAM to stringResource(R.string.mode_osc_qam), SessionPrefs.OSC_NEVER to stringResource(R.string.common_never)) - else listOf(SessionPrefs.OSC_AUTO to stringResource(R.string.common_auto), SessionPrefs.OSC_ALWAYS to stringResource(R.string.common_always), SessionPrefs.OSC_NEVER to stringResource(R.string.common_never)), - if (!a.steam && a.oscMode == SessionPrefs.OSC_STEAM_TOUCH) SessionPrefs.OSC_AUTO else a.oscMode, - chipModifier = focus.track(page, "osc"), onPick = a.onOsc) - a.adaptiveSticks?.let { on -> - ToggleRow(host, "adaptive-sticks", stringResource(R.string.ctrl_adaptive), null, on, - chipModifier = focus.track(page, "adaptive-sticks"), onChange = a.onAdaptiveSticks) - } - if (a.showFloatingSteamControls) { - ToggleRow(host, "rear-buttons", stringResource(R.string.osc_rear_buttons), null, a.oscRearButtons, - chipModifier = focus.track(page, "rear-buttons"), onChange = a.onOscRearButtons) - ToggleRow(host, "trackpads", stringResource(R.string.osc_trackpads), null, a.oscTrackpads, - chipModifier = focus.track(page, "trackpads"), onChange = a.onOscTrackpads) - } - for ((button, shown) in a.quickButtons) { - val key = "quick-${button.name.lowercase()}" - ToggleRow(host, key, stringResource(quickButtonLabel(button)), null, shown, - chipModifier = focus.track(page, key)) { a.onQuickButton(button, it) } - } - a.onEditSteamTouch?.let { edit -> - ActionRow(stringResource(R.string.osc_steam_layout), stringResource(R.string.osc_steam_layout_hint), stringResource(R.string.ctrl_edit), edit) - } - if (a.steam && a.unfoldedControls != null) ToggleRow(host, "unfolded-controls", stringResource(R.string.unfolded_controls), - stringResource(R.string.unfolded_controls_hint), a.unfoldedControls, - chipModifier = focus.track(page, "unfolded-controls"), onChange = a.onUnfoldedControls) - if (a.steam && a.unfoldedControls == true) ToggleRow(host, "unfolded-controls-with-controller", - stringResource(R.string.unfolded_controls_with_controller), - stringResource(R.string.unfolded_controls_with_controller_hint), a.unfoldedControlsWithController, - chipModifier = focus.track(page, "unfolded-controls-with-controller"), - onChange = a.onUnfoldedControlsWithController) - } - SettingsGroup(stringResource(R.string.shortcuts_title)) { - if (a.steam) ToggleRow(host, "back-hold", stringResource(R.string.back_hold), - stringResource(R.string.back_hold_hint), a.backHold, - chipModifier = focus.track(page, "back-hold"), onChange = a.onBackHold) - if (a.steam) ChoiceRow(host, "back-actions", stringResource(R.string.input_back_taps), stringResource(R.string.input_back_taps_hint), - listOf(false to stringResource(SessionPrefs.BACK_MENU_THEN_QAM), true to stringResource(SessionPrefs.BACK_QAM_THEN_MENU)), - a.backActionsInverted, chipModifier = focus.track(page, "back-actions"), onPick = a.onBackActionsInverted) - if (a.steam) ChoiceRow(host, "back-double-tap", stringResource(R.string.back_double_tap_window), null, - SessionPrefs.BACK_DOUBLE_TAP_MS_OPTIONS.map { it to stringResource(R.string.back_tap_ms, it) }, - a.backDoubleTapMs, chipModifier = focus.track(page, "back-double-tap"), onPick = a.onBackDoubleTapMs) - PhysicalShortcutRows(modifierFor = { focus.track(page, "physical-shortcut-${it.name}") }) - if (a.secondScreenDisplays.isNotEmpty()) ToggleRow(host, "docked-menu-controller", stringResource(R.string.drawer_docked_menu_controller), - null, a.dockedMenuController, - chipModifier = focus.track(page, "docked-menu-controller"), onChange = a.onDockedMenuController) - ToggleRow(host, "corner-tap", stringResource(R.string.drawer_corner_tap), - stringResource(R.string.drawer_corner_tap_hint), a.cornerTap, - chipModifier = focus.track(page, "corner-tap"), onChange = a.onCornerTap) - } - SettingsGroup(stringResource(R.string.drawer_latency)) { - ToggleRow(host, "low-latency", stringResource(R.string.drawer_low_latency), - stringResource(R.string.drawer_low_latency_hint), a.lowLatency, - chipModifier = focus.track(page, "low-latency"), onChange = a.onLowLatency) - ToggleRow(host, "evdev-mouse", stringResource(R.string.drawer_evdev_mouse), - null, a.evdevMouse, - chipModifier = focus.track(page, "evdev-mouse"), onChange = a.onEvdevMouse) - if (a.touchActive != SessionPrefs.TOUCH_PAD) - RelativeMouseRow(host, a, focus.track(page, "relative-mouse")) - } - SettingsGroup(stringResource(R.string.drawer_keyboard)) { - Row(horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth().padding(8.dp)) { - DrawerOutlineButton(stringResource(R.string.drawer_pc_keyboard), modifier = Modifier.weight(1f).height(48.dp).then(focus.track(page, "hardware"))) { - host.open = null; a.onHardwareKeyboard() - } - DrawerOutlineButton(stringResource(R.string.drawer_android_keyboard), modifier = Modifier.weight(1f).height(48.dp).then(focus.track(page, "android"))) { - host.open = null; a.onKeyboard() - } - } - if (a.wowChatShown) ChoiceRow( - host, "wow-chat", stringResource(R.string.wow_chat_title), null, - listOf( - null to stringResource(R.string.wow_chat_ask), - SessionPrefs.WOW_CHAT_VOICE to stringResource(R.string.wow_chat_voice), - SessionPrefs.WOW_CHAT_KEYBOARD to stringResource(R.string.pckb_android), - ), - a.wowChat, chipModifier = focus.track(page, "wow-chat"), onPick = a.onWowChat, - ) - val keyboardContext = LocalContext.current - remember { PcKeyboardPrefs.load(keyboardContext) } - SliderRow( - stringResource(R.string.pckb_size), stringResource(R.string.pckb_size_hint), - PcKeyboardPrefs.size, SessionPrefs.PC_KEYBOARD_SIZE_RANGE, step = 1, - format = { "$it%" }, modifier = focus.track(page, "pckb-size"), - onChange = { PcKeyboardPrefs.setSize(keyboardContext, it) }) - SliderRow( - stringResource(R.string.pckb_opacity), stringResource(R.string.pckb_opacity_hint), - PcKeyboardPrefs.opacity, SessionPrefs.PC_KEYBOARD_OPACITY_RANGE, step = 5, - format = { "$it%" }, modifier = focus.track(page, "pckb-opacity"), - onChange = { PcKeyboardPrefs.setOpacity(keyboardContext, it) }) - MultiRow( - host, "pckb-hidden", stringResource(R.string.pckb_hidden_keys), - stringResource(R.string.pckb_hidden_keys_hint), - listOf( - 0 to stringResource(R.string.pckb_group_function), - 1 to stringResource(R.string.pckb_group_nav), - 2 to stringResource(R.string.pckb_group_arrows), - ), - PC_KEY_GROUP_IDS.filterValues { it in PcKeyboardPrefs.hiddenKeys }.keys, - onToggle = { id, on -> PcKeyboardPrefs.toggleHiddenKey(keyboardContext, PC_KEY_GROUP_IDS.getValue(id), on) }) - } - } - SessionDrawerPage.GLASSES -> if (glassesTab == GlassesTab.CONTROLLERS) { - VrControllerGroups(host) { key -> focus.track(page, key) } - } else { - GlassesGroups(host, glasses, glassesSettings, { key -> focus.track(page, key) }, onRecenter = a.onGlassesRecenter, - tab = glassesTab, outputActive = a.glassesOutput, steamVrRunning = a.steamVr == SteamVr.Status.RUNNING, - steamVr = { SteamVrRow(a) }) - } - SessionDrawerPage.GAMES -> { - if (a.steam || a.direct) SelectedGameProfileGroup(host, a) { key -> focus.track(page, key) } - Text(stringResource(R.string.fex_next_launch), fontSize = 12.sp, - color = colors.onSurfaceVariant, modifier = Modifier.padding(horizontal = 14.dp, vertical = 8.dp)) - TextureFilteringGroup(host, a) { key -> focus.track(page, key) } - if (a.steam || a.direct) SettingsGroup(stringResource(R.string.game_settings_title)) { - DrawerFexPresetRow(host, a, focus.track(page, "fex")) - DrawerNoSteamRow(host, a, focus.track(page, "no-steam")) - GameEnvironmentRow( - modifier = focus.track(page, "game-env"), - showHint = false, - initialScope = a.selectedGameProfileId?.toString().orEmpty(), - ) - } - ComponentsDrawerPage(host, a) { key -> focus.track(page, key) } - ComponentDownloadsDrawerGroup( - host = host, - catalog = a.componentCatalog, - catalogAt = a.componentCatalogAt, - checking = a.componentCatalogChecking, - packages = a.components?.packages.orEmpty(), - downloads = a.componentDownloads, - onRefresh = a.onComponentCatalogRefresh, - onDownload = a.onComponentDownload, - track = { key -> focus.track(page, key) }, - ) + SessionDrawerPage.CONTROLLER -> DrawerControllerPage(host, a, a.controllerConnected || controllerActive, track) + SessionDrawerPage.HUD -> DrawerPerformancePage(host, a, track) + SessionDrawerPage.DISPLAY -> DrawerDisplayPage(host, a, track) + SessionDrawerPage.EFFECTS -> ScreenEffectsGroup(host, a, track) + SessionDrawerPage.GAMES -> DrawerGamePage(host, a, track) + SessionDrawerPage.VR -> DrawerVrPage(host, a, glasses, glassesSettings, track) + SessionDrawerPage.SESSION -> DrawerSessionPage(host, a, track) { app -> + host.open = null + if (a.secondScreenDisplays.isEmpty()) a.onLaunchAndroidApp(app, null) else appToChooseDisplay = app } + SessionDrawerPage.MORE -> DrawerMorePage(host, pages.inMore(), a, { host.open = null; onPageChange(it) }, { host.open = null; managing = true }, track) + SessionDrawerPage.ACHIEVEMENTS -> a.achievementsGame?.let { DrawerAchievementsPage(it, a.achievementsTitle, track) } SessionDrawerPage.AGENT -> Unit - SessionDrawerPage.MORE -> DrawerMorePage(host, pages.inMore(), { host.open = null; onPageChange(it) }, { host.open = null; managing = true }) { key -> focus.track(page, key) } - SessionDrawerPage.SESSION -> { - SettingsGroup(stringResource(R.string.drawer_support)) { - SettingsRow(stringResource(R.string.report_problem), stringResource(R.string.report_problem_hint)) { - DrawerOutlineButton(stringResource(R.string.drawer_share_logs), modifier = focus.track(page, "share-logs"), - progress = com.droiddeck.launcher.session.SessionLogShare.progress) { - host.open = null - a.onShareLogs() - } - } - } - if (a.isHomeApp) SettingsGroup(stringResource(R.string.drawer_android_apps)) { - SettingsRow(stringResource(R.string.drawer_launch_app), null) { - DrawerOutlineButton(if (androidAppsExpanded) stringResource(R.string.common_hide) else stringResource(R.string.common_show), modifier = focus.track(page, "apps")) { - androidAppsExpanded = !androidAppsExpanded - } - } - if (androidAppsExpanded) { - if (a.androidApps.isEmpty()) { - Text(stringResource(R.string.drawer_no_apps), fontSize = 12.sp, color = colors.onSurfaceVariant, - modifier = Modifier.padding(horizontal = 14.dp, vertical = 10.dp)) - } else for (app in a.androidApps) { - MenuItem( - app.label, checked = false, - modifier = focus.track(page, "app:${app.packageName}/${app.className}"), - leading = { - app.icon?.let { icon -> - Image(bitmap = icon.asImageBitmap(), contentDescription = null, - modifier = Modifier.size(26.dp).clip(RoundedCornerShape(6.dp))) - } - }, - ) { - host.open = null - if (a.secondScreenDisplays.isEmpty()) a.onLaunchAndroidApp(app, null) - else appToChooseDisplay = app - } - } - } - } - SettingsGroup(stringResource(R.string.drawer_session_behavior)) { - if (a.micAvailable) ToggleRow(host, "microphone", stringResource(R.string.mode_mic), - stringResource(R.string.drawer_mic_hint), a.micEnabled, - chipModifier = focus.track(page, "microphone"), onChange = a.onMicEnabled) - ChoiceRow( - host, "suspend", stringResource(R.string.mode_suspend), - null, - listOf( - SessionPrefs.SUSPEND_AUTO to stringResource(R.string.common_auto), - SessionPrefs.SUSPEND_MANUAL to stringResource(R.string.mode_suspend_manual), - SessionPrefs.SUSPEND_NEVER to stringResource(R.string.common_never), - ) + if (a.steam) listOf( - SessionPrefs.SUSPEND_NATIVE to stringResource(R.string.mode_suspend_native), - ) else emptyList(), - a.suspendPolicy, - note = stringResource(if (a.steam) R.string.mode_suspend_steam_note else R.string.mode_suspend_note), - chipModifier = focus.track(page, "suspend"), - onPick = a.onSuspendPolicy, - ) - if (a.steam && a.suspendPolicy != SessionPrefs.SUSPEND_NEVER) ToggleRow( - host, "background-downloads", stringResource(R.string.mode_background_downloads), - stringResource(R.string.mode_background_downloads_hint), - a.steamDownloadsInBackground, - onChange = a.onSteamDownloadsInBackground, - ) - } - if (a.pipSupported) SettingsGroup(stringResource(R.string.pip_title)) { - ToggleRow(host, "pip-auto", stringResource(R.string.pip_auto), null, - a.pipAutoEnter, onChange = a.onPipAutoEnter) - } - Column(Modifier.fillMaxWidth().padding(top = 12.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) { - if (!a.isHomeApp) DrawerActionButton(stringResource(R.string.drawer_background), Icons.AutoMirrored.Outlined.ExitToApp, - modifier = focus.track(page, "background")) { host.open = null; a.onBackground() } - } - } } } } } @@ -1078,6 +704,377 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont } } +@Composable +private fun DrawerControllerPage(host: MenuHost, a: DrawerActions, padConnected: Boolean, track: (String) -> Modifier) { + val on = stringResource(R.string.widgets_on) + val off = stringResource(R.string.widgets_off) + val padTag = if (padConnected) stringResource(R.string.drawer_tag_controller) else null + val noPadTag = if (padConnected) null else stringResource(R.string.drawer_tag_no_controller) + SettingsGroup(stringResource(R.string.drawer_section_input), key = "controller-input") { + InputQuickSettings(host, desktop = a.desktop, onChanged = a.onInputSelection, onEdit = a.onInputSettings, track = track) + } + val c = a.controller + val padTypes = listOf(SessionPrefs.CONTROLLER_DECK to stringResource(R.string.mode_controller_deck), + SessionPrefs.CONTROLLER_STEAM to stringResource(R.string.mode_controller_steam), + SessionPrefs.CONTROLLER_DS4 to stringResource(R.string.mode_controller_ds4), + SessionPrefs.CONTROLLER_DUALSENSE to stringResource(R.string.mode_controller_dualsense), + SessionPrefs.CONTROLLER_XBOX360 to stringResource(R.string.mode_controller_x360)) + val rumbleLabel = stringResource(R.string.ctrl_rumble) + if (a.padType != null || c != null) SettingsGroup( + stringResource(R.string.input_device_settings), key = "controller-pad", tag = padTag, + detail = summary(a.padType?.let { padTypes.labelOf(it) }, c?.let { "$rumbleLabel ${if (it.rumble) on else off}" }), + ) { + a.padType?.let { type -> + ChoiceRow(host, "pad-type", stringResource(R.string.input_virtual_controller), stringResource(R.string.input_virtual_controller_hint), + padTypes, type, chipModifier = track("pad-type"), onPick = a.onPadType) + } + c?.let { + ToggleRow(host, "rumble", rumbleLabel, null, it.rumble, chipModifier = track("rumble"), onChange = a.onRumble) + } + } + val oscChoices = if (a.steam) listOf(SessionPrefs.OSC_AUTO to stringResource(R.string.common_auto), SessionPrefs.OSC_ALWAYS to stringResource(R.string.common_always), SessionPrefs.OSC_STEAM_TOUCH to stringResource(R.string.osc_steam_touch), SessionPrefs.OSC_STEAM_QAM to stringResource(R.string.mode_osc_qam), SessionPrefs.OSC_NEVER to stringResource(R.string.common_never)) + else listOf(SessionPrefs.OSC_AUTO to stringResource(R.string.common_auto), SessionPrefs.OSC_ALWAYS to stringResource(R.string.common_always), SessionPrefs.OSC_NEVER to stringResource(R.string.common_never)) + val oscValue = if (!a.steam && a.oscMode == SessionPrefs.OSC_STEAM_TOUCH) SessionPrefs.OSC_AUTO else a.oscMode + SettingsGroup(stringResource(R.string.input_screen_visibility), key = "controller-osc", tag = noPadTag, + detail = summary(oscChoices.labelOf(oscValue), c?.let { "${it.size}%" })) { + ChoiceRow(host, "osc", stringResource(R.string.mode_osc), null, oscChoices, oscValue, chipModifier = track("osc"), onPick = a.onOsc) + c?.let { + SliderRow(stringResource(R.string.ctrl_size), null, it.size, 80..125, step = 5, + format = { v -> "$v%" }, modifier = track("controller-size"), onChange = a.onControllerSize) + } + a.adaptiveSticks?.let { adaptive -> + ToggleRow(host, "adaptive-sticks", stringResource(R.string.ctrl_adaptive), null, adaptive, + chipModifier = track("adaptive-sticks"), onChange = a.onAdaptiveSticks) + } + if (a.showFloatingSteamControls) { + ToggleRow(host, "rear-buttons", stringResource(R.string.osc_rear_buttons), null, a.oscRearButtons, + chipModifier = track("rear-buttons"), onChange = a.onOscRearButtons) + ToggleRow(host, "trackpads", stringResource(R.string.osc_trackpads), null, a.oscTrackpads, + chipModifier = track("trackpads"), onChange = a.onOscTrackpads) + } + for ((button, shown) in a.quickButtons) { + val key = "quick-${button.name.lowercase()}" + ToggleRow(host, key, stringResource(quickButtonLabel(button)), null, shown, + chipModifier = track(key)) { a.onQuickButton(button, it) } + } + a.onEditSteamTouch?.let { edit -> + ActionRow(stringResource(R.string.osc_steam_layout), stringResource(R.string.osc_steam_layout_hint), stringResource(R.string.ctrl_edit), edit, + modifier = track("steam-touch-layout")) + } + if (a.steam && a.unfoldedControls != null) ToggleRow(host, "unfolded-controls", stringResource(R.string.unfolded_controls), + stringResource(R.string.unfolded_controls_hint), a.unfoldedControls, + chipModifier = track("unfolded-controls"), onChange = a.onUnfoldedControls) + if (a.steam && a.unfoldedControls == true) ToggleRow(host, "unfolded-controls-with-controller", + stringResource(R.string.unfolded_controls_with_controller), + stringResource(R.string.unfolded_controls_with_controller_hint), a.unfoldedControlsWithController, + chipModifier = track("unfolded-controls-with-controller"), + onChange = a.onUnfoldedControlsWithController) + } + val touchChoices = listOf(SessionPrefs.TOUCH_AUTO to stringResource(R.string.drawer_touch_auto, a.touchAuto), SessionPrefs.TOUCH_PAD to stringResource(R.string.mode_touch_touchpad), SessionPrefs.TOUCH_DIRECT to stringResource(R.string.mode_touch_direct), SessionPrefs.TOUCH_GESTURES to stringResource(R.string.mode_touch_gestures), SessionPrefs.TOUCH_OFF to stringResource(R.string.widgets_off)) + SettingsGroup(stringResource(R.string.input_touchscreen), key = "controller-touch", tag = noPadTag, detail = touchChoices.labelOf(a.touchMode)) { + ChoiceRow(host, "touch", stringResource(R.string.input_touchscreen), stringResource(R.string.input_touchscreen_hint), + touchChoices, a.touchMode, chipModifier = track("touch"), onPick = a.onTouch) + if (a.touchActive == SessionPrefs.TOUCH_PAD) RelativeMouseRow(host, a, track("relative-mouse")) + if (a.touchActive == SessionPrefs.TOUCH_DIRECT) + ToggleRow(host, "direct-cursor", stringResource(R.string.input_touch_cursor), + stringResource(R.string.input_touch_cursor_hint), a.directCursor, + chipModifier = track("direct-cursor"), onChange = a.onDirectCursor) + when (a.touchActive) { + SessionPrefs.TOUCH_GESTURES -> ActionRow(stringResource(R.string.gesture_settings), null, + stringResource(R.string.ctrl_edit), a.onGestureSettings, modifier = track("gesture-settings")) + SessionPrefs.TOUCH_DIRECT -> ChoiceRow(host, "long-press", stringResource(R.string.input_touch_hold), stringResource(R.string.input_touch_hold_hint), + listOf(MOUSE_BEHAVIOR_NONE to stringResource(R.string.gesture_hold_left), + MOUSE_BEHAVIOR_CLICK to stringResource(R.string.gesture_right_click), + MOUSE_BEHAVIOR_HOLD to stringResource(R.string.gesture_hold_right)), + a.directHoldBehavior, chipModifier = track("long-press"), onPick = a.onDirectHoldBehavior) + } + } + a.pen?.let { PenSettingsGroup(host, it, track = track, onPick = a.onPen) } + SettingsGroup(stringResource(R.string.drawer_section_mouse), key = "controller-mouse", + detail = "${stringResource(R.string.drawer_evdev_mouse)} ${if (a.evdevMouse) on else off}") { + ToggleRow(host, "evdev-mouse", stringResource(R.string.drawer_evdev_mouse), null, a.evdevMouse, + chipModifier = track("evdev-mouse"), onChange = a.onEvdevMouse) + if (a.touchActive != SessionPrefs.TOUCH_PAD) RelativeMouseRow(host, a, track("relative-mouse")) + } + val backOrders = listOf(false to stringResource(SessionPrefs.BACK_MENU_THEN_QAM), true to stringResource(SessionPrefs.BACK_QAM_THEN_MENU)) + SettingsGroup(stringResource(R.string.shortcuts_title), key = "controller-shortcuts", + detail = if (a.steam) summary(backOrders.labelOf(a.backActionsInverted), stringResource(R.string.back_tap_ms, a.backDoubleTapMs)) else null) { + if (a.steam) ToggleRow(host, "back-hold", stringResource(R.string.back_hold), + stringResource(R.string.back_hold_hint), a.backHold, + chipModifier = track("back-hold"), onChange = a.onBackHold) + if (a.steam) ChoiceRow(host, "back-actions", stringResource(R.string.input_back_taps), stringResource(R.string.input_back_taps_hint), + backOrders, a.backActionsInverted, chipModifier = track("back-actions"), onPick = a.onBackActionsInverted) + if (a.steam) ChoiceRow(host, "back-double-tap", stringResource(R.string.back_double_tap_window), null, + SessionPrefs.BACK_DOUBLE_TAP_MS_OPTIONS.map { it to stringResource(R.string.back_tap_ms, it) }, + a.backDoubleTapMs, chipModifier = track("back-double-tap"), onPick = a.onBackDoubleTapMs) + PhysicalShortcutRows(modifierFor = { track("physical-shortcut-${it.name}") }) + if (a.secondScreenDisplays.isNotEmpty()) ToggleRow(host, "docked-menu-controller", stringResource(R.string.drawer_docked_menu_controller), + null, a.dockedMenuController, + chipModifier = track("docked-menu-controller"), onChange = a.onDockedMenuController) + ToggleRow(host, "corner-tap", stringResource(R.string.drawer_corner_tap), + stringResource(R.string.drawer_corner_tap_hint), a.cornerTap, + chipModifier = track("corner-tap"), onChange = a.onCornerTap) + } + val keyboardContext = LocalContext.current + remember { PcKeyboardPrefs.load(keyboardContext) } + SettingsGroup(stringResource(R.string.drawer_section_keyboard_layout), key = "controller-keyboard", + detail = summary("${PcKeyboardPrefs.size}%", "${PcKeyboardPrefs.opacity}%")) { + if (a.wowChatShown) ChoiceRow( + host, "wow-chat", stringResource(R.string.wow_chat_title), null, + listOf( + null to stringResource(R.string.wow_chat_ask), + SessionPrefs.WOW_CHAT_VOICE to stringResource(R.string.wow_chat_voice), + SessionPrefs.WOW_CHAT_KEYBOARD to stringResource(R.string.pckb_android), + ), + a.wowChat, chipModifier = track("wow-chat"), onPick = a.onWowChat, + ) + SliderRow( + stringResource(R.string.pckb_size), stringResource(R.string.pckb_size_hint), + PcKeyboardPrefs.size, SessionPrefs.PC_KEYBOARD_SIZE_RANGE, step = 1, + format = { "$it%" }, modifier = track("pckb-size"), + onChange = { PcKeyboardPrefs.setSize(keyboardContext, it) }) + SliderRow( + stringResource(R.string.pckb_opacity), stringResource(R.string.pckb_opacity_hint), + PcKeyboardPrefs.opacity, SessionPrefs.PC_KEYBOARD_OPACITY_RANGE, step = 5, + format = { "$it%" }, modifier = track("pckb-opacity"), + onChange = { PcKeyboardPrefs.setOpacity(keyboardContext, it) }) + MultiRow( + host, "pckb-hidden", stringResource(R.string.pckb_hidden_keys), + stringResource(R.string.pckb_hidden_keys_hint), + listOf( + 0 to stringResource(R.string.pckb_group_function), + 1 to stringResource(R.string.pckb_group_nav), + 2 to stringResource(R.string.pckb_group_arrows), + ), + PC_KEY_GROUP_IDS.filterValues { it in PcKeyboardPrefs.hiddenKeys }.keys, + onToggle = { id, shown -> PcKeyboardPrefs.toggleHiddenKey(keyboardContext, PC_KEY_GROUP_IDS.getValue(id), shown) }) + } + Row(horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth().padding(top = 12.dp)) { + DrawerOutlineButton(stringResource(R.string.drawer_pc_keyboard), modifier = Modifier.weight(1f).height(48.dp).then(track("hardware"))) { + host.open = null; a.onHardwareKeyboard() + } + DrawerOutlineButton(stringResource(R.string.drawer_android_keyboard), modifier = Modifier.weight(1f).height(48.dp).then(track("android"))) { + host.open = null; a.onKeyboard() + } + } +} + +@Composable +private fun DrawerPerformancePage(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) { + val offLabel = stringResource(R.string.frame_gen_off) + val fgLabel = FrameGen.label(LocalContext.current, a.frameGen) + val limit = if (a.direct && a.fpsLimit > 0) "${stringResource(R.string.drawer_frame_limit)} ${a.fpsLimit}" else null + SettingsGroup(stringResource(R.string.drawer_section_pacing), key = "performance-pacing", detail = summary(fgLabel, limit)) { + val fgOpen = host.open == "fg" + SettingsRow( + stringResource(R.string.frame_gen_title), + if (a.frameGenTargetGameId != null) + "${stringResource(R.string.frame_gen_scope_game)} · ${a.frameGenTargetGameName ?: "ID ${a.frameGenTargetGameId}"}" + else stringResource(R.string.frame_gen_scope_global), + highlighted = fgOpen, + ) { + Box { + ValueChip(fgLabel, fgOpen, modifier = track("fg")) { host.open = if (fgOpen) null else "fg" } + FrameGenMenu( + host, a.frameGen, a.lossless, a.onFrameGenPick, a.onImportLossless, + gameProfileId = a.frameGenTargetGameId, + hasGameOverride = a.hasGameOverride, + onResetGame = a.onFrameGenReset, + ) + } + } + if (a.direct) SliderRow( + stringResource(R.string.drawer_frame_limit), stringResource(R.string.drawer_frame_limit_note), + a.fpsLimit.takeIf { it > 0 } ?: SessionPrefs.FPS_LIMIT_OFF, + SessionPrefs.FPS_LIMIT_OFF..SessionPrefs.FPS_LIMIT_MAX, step = 5, + format = { if (it <= SessionPrefs.FPS_LIMIT_OFF) offLabel else it.toString() }, + modifier = track("fps-limit"), + onChange = { a.onFpsLimit(if (it <= SessionPrefs.FPS_LIMIT_OFF) 0 else it) }) + if (a.steam && !a.direct && a.onQam != null) SettingsRow( + stringResource(R.string.drawer_frame_limit), stringResource(R.string.drawer_frame_limit_steam_hint), + ) { + DrawerOutlineButton(stringResource(R.string.drawer_open_steam_qam), modifier = track("fps-limit-steam")) { + host.open = null + a.onQam?.invoke() + } + } + if (a.blackFrameInsertionAvailable) ToggleRow(host, "bfi", stringResource(R.string.drawer_bfi), + stringResource(R.string.drawer_bfi_note), a.blackFrameInsertion, + chipModifier = track("bfi"), onChange = a.onBlackFrameInsertion) + ToggleRow(host, "low-latency", stringResource(R.string.drawer_low_latency), + stringResource(R.string.drawer_low_latency_hint), a.lowLatency, + chipModifier = track("low-latency"), onChange = a.onLowLatency) + } + DroidDeckHudSettings(host, a, track) +} + +@Composable +private fun DrawerDisplayPage(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) { + val orientations = SessionPrefs.orientationOptions.map { (value, label) -> value to stringResource(label) } + SettingsGroup(stringResource(R.string.drawer_page_display), key = "display", + detail = summary(if (a.gameZoomAvailable) "${(a.gameZoom * 100.0f).toInt()}%" else null, orientations.labelOf(a.orientation))) { + if (a.gameZoomAvailable) GameZoomRow(a, track) + ChoiceRow(host, "orientation", stringResource(R.string.setup_session_orientation), null, + orientations, a.orientation, chipModifier = track("orientation"), onPick = a.onOrientation) + } + val filters = SessionPrefs.upscalerChoices(LocalContext.current) + val integer = stringResource(if (a.integerScaling) R.string.display_scaling_integer else R.string.display_scaling_fit) + SettingsGroup(stringResource(R.string.display_image_scaling), key = "display-scaling", + detail = summary(filters.labelOf(a.upscaler), integer.takeIf { a.steam })) { + if (a.steam) SettingsRow(stringResource(R.string.display_integer_scaling), null) { + PadTextButton(onClick = { a.onIntegerScaling(!a.integerScaling) }, modifier = track("integer-scaling")) { Text(integer) } + } + ChoiceRow(host, "upscaler", stringResource(R.string.display_filter), null, filters, a.upscaler, + note = stringResource(R.string.display_filter_note), + chipModifier = track("upscaler"), onPick = a.onUpscaler) + if (SessionPrefs.upscalerHasSharpness(a.upscaler)) SliderRow( + stringResource(R.string.display_sharpness), null, a.upscaleSharpness, 0..100, step = 5, + format = { "$it%" }, modifier = track("upscale-sharpness"), onChange = a.onUpscaleSharpness) + } + SecondScreenGroup(host, a, track) +} + +@Composable +private fun GameZoomRow(a: DrawerActions, track: (String) -> Modifier) { + SettingsRow(stringResource(R.string.game_zoom_title), stringResource(R.string.game_zoom_hint)) { + Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp)) { + val zoomOutEnabled = a.gameZoom > 1.0f + val zoomInEnabled = a.gameZoom < 3.0f + val zoomOut = { a.onGameZoom((a.gameZoom - 0.25f).coerceAtLeast(1.0f)) } + val zoomIn = { a.onGameZoom((a.gameZoom + 0.25f).coerceAtMost(3.0f)) } + val zoomReset = { a.onGameZoom(1.0f) } + OutlinedButton(onClick = zoomOut, enabled = zoomOutEnabled, + modifier = track("game-zoom-out").width(42.dp).controllerConfirm(enabled = zoomOutEnabled, onClick = zoomOut), + contentPadding = PaddingValues(horizontal = 4.dp, vertical = 0.dp)) { Text("−") } + Text("${(a.gameZoom * 100.0f).toInt()}%", fontSize = 12.sp) + OutlinedButton(onClick = zoomIn, enabled = zoomInEnabled, + modifier = track("game-zoom-in").width(42.dp).controllerConfirm(enabled = zoomInEnabled, onClick = zoomIn), + contentPadding = PaddingValues(horizontal = 4.dp, vertical = 0.dp)) { Text("+") } + OutlinedButton(onClick = zoomReset, enabled = zoomOutEnabled, + modifier = track("game-zoom-reset").width(48.dp).controllerConfirm(enabled = zoomOutEnabled, onClick = zoomReset), + contentPadding = PaddingValues(horizontal = 2.dp, vertical = 0.dp)) { Text("1×") } + } + } +} + +@Composable +private fun DrawerGamePage(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) { + val colors = MaterialTheme.colorScheme + if (a.steam || a.direct) SelectedGameProfileGroup(host, a, track) + if (a.steam || a.direct) SettingsGroup(stringResource(R.string.drawer_section_compat), key = "game-compat") { + DrawerFexPresetRow(host, a, track("fex")) + DrawerNoSteamRow(host, a, track("no-steam")) + GameEnvironmentRow( + modifier = track("game-env"), + showHint = false, + initialScope = a.selectedGameProfileId?.toString().orEmpty(), + ) + Text(stringResource(R.string.fex_next_launch), fontSize = 12.sp, + color = colors.onSurfaceVariant, modifier = Modifier.padding(horizontal = 10.dp, vertical = 8.dp)) + } + TextureFilteringGroup(host, a, track) + ComponentsDrawerPage(host, a, track) + ComponentDownloadsDrawerGroup( + host = host, + catalog = a.componentCatalog, + catalogAt = a.componentCatalogAt, + checking = a.componentCatalogChecking, + packages = a.components?.packages.orEmpty(), + downloads = a.componentDownloads, + onRefresh = a.onComponentCatalogRefresh, + onDownload = a.onComponentDownload, + track = track, + ) +} + +@Composable +private fun DrawerVrPage(host: MenuHost, a: DrawerActions, glasses: com.droiddeck.launcher.glasses.GlassesState, + glassesSettings: com.droiddeck.launcher.glasses.GlassesSettings, track: (String) -> Modifier) { + val running = a.steamVr == SteamVr.Status.RUNNING + if (a.glassesPresent) { + GlassesGroups(host, glasses, glassesSettings, track, onRecenter = a.onGlassesRecenter, + outputActive = a.glassesOutput, steamVrRunning = running) + VrControllerGroups(host, track) + } + SteamVrGroup(a, track) + if (!a.glassesOutput) CardboardGroup(host, a, track) +} + +@Composable +private fun DrawerSessionPage(host: MenuHost, a: DrawerActions, track: (String) -> Modifier, onLaunch: (HomeApp.LaunchableApp) -> Unit) { + val colors = MaterialTheme.colorScheme + Column(Modifier.fillMaxWidth().padding(top = 8.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) { + DrawerActionButton(stringResource(if (a.paused) R.string.resume_session else R.string.drawer_pause_game), + if (a.paused) Icons.Outlined.PlayArrow else Icons.Outlined.Pause, modifier = track("pause")) { + host.open = null + if (a.paused) a.onResume() else a.onPause() + } + if (a.pipSupported) DrawerActionButton(stringResource(R.string.pip_title), Icons.Outlined.PictureInPictureAlt, modifier = track("pip")) { + host.open = null + a.onPip() + } + } + val suspendChoices = listOf( + SessionPrefs.SUSPEND_AUTO to stringResource(R.string.common_auto), + SessionPrefs.SUSPEND_MANUAL to stringResource(R.string.mode_suspend_manual), + SessionPrefs.SUSPEND_NEVER to stringResource(R.string.common_never), + ) + if (a.steam) listOf(SessionPrefs.SUSPEND_NATIVE to stringResource(R.string.mode_suspend_native)) else emptyList() + SettingsGroup(stringResource(R.string.drawer_session_behavior), key = "session-behavior", + detail = summary(stringResource(R.string.mode_suspend) + " " + suspendChoices.labelOf(a.suspendPolicy).orEmpty())) { + if (a.micAvailable) ToggleRow(host, "microphone", stringResource(R.string.mode_mic), + stringResource(R.string.drawer_mic_hint), a.micEnabled, + chipModifier = track("microphone"), onChange = a.onMicEnabled) + ChoiceRow( + host, "suspend", stringResource(R.string.mode_suspend), null, suspendChoices, a.suspendPolicy, + note = stringResource(if (a.steam) R.string.mode_suspend_steam_note else R.string.mode_suspend_note), + chipModifier = track("suspend"), onPick = a.onSuspendPolicy, + ) + if (a.steam && a.suspendPolicy != SessionPrefs.SUSPEND_NEVER) ToggleRow( + host, "background-downloads", stringResource(R.string.mode_background_downloads), + stringResource(R.string.mode_background_downloads_hint), a.steamDownloadsInBackground, + chipModifier = track("background-downloads"), onChange = a.onSteamDownloadsInBackground, + ) + if (a.pipSupported) ToggleRow(host, "pip-auto", stringResource(R.string.pip_auto), null, + a.pipAutoEnter, chipModifier = track("pip-auto"), onChange = a.onPipAutoEnter) + } + if (a.isHomeApp) SettingsGroup(stringResource(R.string.drawer_android_apps), key = "session-apps", + detail = a.androidApps.take(3).joinToString(", ") { it.label }) { + if (a.androidApps.isEmpty()) { + Text(stringResource(R.string.drawer_no_apps), fontSize = 12.sp, color = colors.onSurfaceVariant, + modifier = Modifier.padding(horizontal = 14.dp, vertical = 10.dp)) + } else for (app in a.androidApps) { + MenuItem( + app.label, checked = false, + modifier = track("app:${app.packageName}/${app.className}"), + leading = { + app.icon?.let { icon -> + Image(bitmap = icon.asImageBitmap(), contentDescription = null, + modifier = Modifier.size(26.dp).clip(RoundedCornerShape(6.dp))) + } + }, + ) { onLaunch(app) } + } + } + // Players reach for Share logs while something is going wrong, so Support never folds. + CompositionLocalProvider(LocalDrawerSections provides null) { SettingsGroup(stringResource(R.string.drawer_support)) { + SettingsRow(stringResource(R.string.report_problem), stringResource(R.string.report_problem_hint)) { + DrawerOutlineButton(stringResource(R.string.drawer_share_logs), modifier = track("share-logs"), + progress = com.droiddeck.launcher.session.SessionLogShare.progress) { + host.open = null + a.onShareLogs() + } + } + } } + if (!a.isHomeApp) Column(Modifier.fillMaxWidth().padding(top = 12.dp)) { + DrawerActionButton(stringResource(R.string.drawer_background), Icons.AutoMirrored.Outlined.ExitToApp, + modifier = track("background")) { host.open = null; a.onBackground() } + } +} + +private fun List>.labelOf(value: T): String? = firstOrNull { it.first == value }?.second + +private fun summary(vararg parts: String?): String = parts.filterNot { it.isNullOrEmpty() }.joinToString(" · ") + @Composable private fun DrawerActionButton(text: String, icon: androidx.compose.ui.graphics.vector.ImageVector, modifier: Modifier = Modifier, onClick: () -> Unit) { val colors = MaterialTheme.colorScheme @@ -1261,10 +1258,11 @@ private fun DrawerMoreBack(title: String, modifier: Modifier, onBack: () -> Unit /** The pages kept inside More, and the way into arranging which pages sit on the strip and which here. */ @Composable -private fun DrawerMorePage(host: MenuHost, pages: List, onOpen: (SessionDrawerPage) -> Unit, onEdit: () -> Unit, track: (String) -> Modifier) { +private fun DrawerMorePage(host: MenuHost, pages: List, a: DrawerActions, onOpen: (SessionDrawerPage) -> Unit, onEdit: () -> Unit, track: (String) -> Modifier) { val colors = MaterialTheme.colorScheme val pal = LocalPalette.current - SettingsGroup(stringResource(R.string.drawer_page_more)) { + // The list of pages is the page itself, so it never folds. + CompositionLocalProvider(LocalDrawerSections provides null) { SettingsGroup(stringResource(R.string.drawer_page_more)) { if (pages.isEmpty()) Text( stringResource(R.string.drawer_more_empty), fontSize = 13.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(horizontal = 14.dp, vertical = 12.dp), @@ -1288,23 +1286,23 @@ private fun DrawerMorePage(host: MenuHost, pages: List, onOpe ) { Icon(item.icon, null, tint = colors.onSurfaceVariant, modifier = Modifier.size(22.dp)) Text(stringResource(item.title), fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, modifier = Modifier.weight(1f)) + if (item == SessionDrawerPage.ACHIEVEMENTS) a.achievementsProgress?.takeIf { it.second > 0 }?.let { (done, total) -> + Text(stringResource(R.string.achievements_count_short, done, total), fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = pal.signal) + } } } - } + } } Spacer(Modifier.height(10.dp)) DrawerOutlineButton(stringResource(R.string.drawer_manage_pages), modifier = track("more-edit").testTag("drawer-more-edit"), onClick = onEdit) } @Composable -private fun ScreenEffectsGroup( - host: MenuHost, a: DrawerActions, advancedExpanded: Boolean, onAdvancedToggle: () -> Unit, - track: (String) -> Modifier, -) { +private fun ScreenEffectsGroup(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) { val e = a.effects val preset = ScreenEffectLooks.match(e, a.upscaler) - val colors = MaterialTheme.colorScheme - val pal = LocalPalette.current - SettingsGroup(stringResource(R.string.drawer_effects)) { + val lookLabel = preset?.let { stringResource(it.label) } ?: stringResource(R.string.drawer_look_custom) + SettingsGroup(stringResource(R.string.drawer_effects), key = "effects-look", + detail = summary(lookLabel, a.screenEffectsTargets.labelOf(a.screenEffectsTarget))) { ChoiceRow( host, "effects-profile", stringResource(R.string.screen_effects_target), stringResource(R.string.screen_effects_target_hint), a.screenEffectsTargets, @@ -1358,31 +1356,13 @@ private fun ScreenEffectsGroup( if (a.hdrAvailable) ToggleRow(host, "hdr", stringResource(R.string.mode_hdr), null, a.hdr, chipModifier = track("hdr"), onChange = a.onHdr) else ToggleRow(host, "fake-hdr", stringResource(R.string.drawer_fake_hdr), null, e.hdr, chipModifier = track("fake-hdr")) { a.onEffects(e.copy(hdr = it)) } - if (a.blackFrameInsertionAvailable) ToggleRow(host, "bfi", stringResource(R.string.drawer_bfi), - stringResource(R.string.drawer_bfi_note), a.blackFrameInsertion, - chipModifier = track("bfi"), onChange = a.onBlackFrameInsertion) } - val source = remember { MutableInteractionSource() } - val hot = source.collectIsFocusedAsState().value || source.collectIsHoveredAsState().value - val rotation by animateFloatAsState(if (advancedExpanded) 180f else 0f, Motion.tw(180), label = "advancedArrow") - val description = stringResource(if (advancedExpanded) R.string.widgets_expanded else R.string.widgets_collapsed) - val toggle = { host.open = null; onAdvancedToggle() } - Row( - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(10.dp), - modifier = track("effects-advanced").fillMaxWidth().padding(top = 12.dp).heightIn(min = 48.dp) - .glideBorder(hot, RoundedCornerShape(8.dp), pal.signal) - .hoverable(source).clickable(interactionSource = source, indication = LocalIndication.current, role = Role.Button, onClick = toggle) - .controllerConfirm(onClick = toggle).semantics { stateDescription = description }.padding(horizontal = 4.dp), - ) { - Text(stringResource(R.string.drawer_effects_advanced).uppercase(), fontSize = 12.sp, - fontWeight = FontWeight.SemiBold, letterSpacing = 1.5.sp, color = colors.onSurfaceVariant) - Box(Modifier.weight(1f).height(1.dp).background(pal.line)) - Icon(Icons.Outlined.ExpandMore, contentDescription = null, tint = colors.onSurfaceVariant, - modifier = Modifier.size(22.dp).rotate(rotation)) - } - AnimatedVisibility(advancedExpanded) { - Column(Modifier.fillMaxWidth().clip(RoundedCornerShape(14.dp)).background(colors.surface).border(1.dp, pal.line, RoundedCornerShape(14.dp))) { + val tuned = listOfNotNull( + stringResource(R.string.drawer_cas).takeIf { e.cas }, stringResource(R.string.drawer_deband).takeIf { e.deband }, + ) + SettingsGroup(stringResource(R.string.drawer_section_tuning), key = "effects-tune", + tag = if (preset == null) stringResource(R.string.drawer_tag_custom) else null, detail = summary(*tuned.toTypedArray())) { + run { ToggleRow(host, "cas", stringResource(R.string.drawer_cas), null, e.cas, chipModifier = track("cas")) { a.onEffects(e.copy(cas = it)) } if (e.cas) SliderRow(stringResource(R.string.drawer_cas_level), null, e.casLevel, 0..100, step = 5, format = { "$it%" }, modifier = track("cas-level")) { a.onEffects(e.copy(casLevel = it)) } @@ -1404,7 +1384,8 @@ private fun ScreenEffectsGroup( @Composable private fun CardboardGroup(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) { val c = a.cardboard - SettingsGroup(stringResource(R.string.cardboard_title)) { + SettingsGroup(stringResource(R.string.cardboard_title), key = "vr-cardboard", + detail = stringResource(if (c.enabled) R.string.widgets_on else R.string.widgets_off)) { ToggleRow(host, "cardboard", stringResource(R.string.cardboard_mode), stringResource(R.string.cardboard_mode_hint), c.enabled, chipModifier = track("cardboard")) { a.onCardboard(c.copy(enabled = it)) } if (!c.enabled) return@SettingsGroup @@ -1437,7 +1418,8 @@ private fun CardboardGroup(host: MenuHost, a: DrawerActions, track: (String) -> @Composable private fun SteamVrGroup(a: DrawerActions, track: (String) -> Modifier) { - SettingsGroup(stringResource(R.string.steamvr_title)) { + SettingsGroup(stringResource(R.string.steamvr_title), key = "vr-steamvr", + tag = if (a.steamVr == SteamVr.Status.RUNNING) stringResource(R.string.drawer_tag_running) else null) { val vrLabel = stringResource(R.string.cardboard_steamvr) val enterLabel = stringResource(if (a.immersiveSteamVr) R.string.steamvr_enter else R.string.cardboard_steamvr_start) @Composable fun button(label: String, text: String, action: String) { @@ -1563,7 +1545,8 @@ private fun SecondScreenGroup(host: MenuHost, a: DrawerActions, track: (String) val swapsGame = a.gameSwapAvailable || a.gameOnBottom val hasSecondScreen = a.secondScreenDisplays.isNotEmpty() if (!hasSecondScreen && !choosesDisplay && !swapsGame) return - SettingsGroup(stringResource(R.string.drawer_second_screen)) { + SettingsGroup(stringResource(R.string.drawer_second_screen), key = "display-second", + tag = if (hasSecondScreen) stringResource(R.string.drawer_tag_attached) else null) { if (hasSecondScreen) ChoiceRow(host, "dual-screen-mode", stringResource(R.string.setup_dual_screen_sessions), null, listOf( com.droiddeck.launcher.input.DualScreen.MODE_AUTO to stringResource(R.string.setup_dual_screen_auto), @@ -1643,7 +1626,8 @@ private fun TextureFilteringGroup(host: MenuHost, a: DrawerActions, track: (Stri val lodBiasChoices: List> = (if (inherited) listOf(null to stringResource(R.string.comp_game_use_general)) else emptyList()) + SessionPrefs.textureLodBiasChoices(LocalContext.current).map { (value, label) -> value as String? to label } - SettingsGroup(stringResource(R.string.drawer_texture)) { + SettingsGroup(stringResource(R.string.drawer_texture), key = "game-textures", + detail = summary(anisotropyChoices.labelOf(a.textureAnisotropy), lodBiasChoices.labelOf(a.textureLodBias))) { ChoiceRow(host, "anisotropy", stringResource(R.string.drawer_anisotropy), null, anisotropyChoices, a.textureAnisotropy, chipModifier = track("anisotropy"), onPick = a.onTextureAnisotropy) ChoiceRow(host, "texture-sharpness", stringResource(R.string.drawer_texture_sharpness), null, @@ -1660,7 +1644,7 @@ private fun SelectedGameProfileGroup(host: MenuHost, a: DrawerActions, track: (S val options: List> = listOf(null to stringResource(R.string.comp_scope_general)) + a.gameProfiles.map { (id, name) -> Pair(id, name) } val profile = a.selectedGameProfile - SettingsGroup(stringResource(R.string.drawer_selected_profile)) { + SettingsGroup(stringResource(R.string.drawer_selected_profile), key = "game-profile", detail = options.labelOf(a.selectedGameProfileId)) { DrawerStackedChoice( host = host, key = "game-profile", @@ -1799,7 +1783,7 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin val colors = MaterialTheme.colorScheme val snap = a.components if (snap == null) { - SettingsGroup(stringResource(R.string.drawer_page_components)) { + SettingsGroup(stringResource(R.string.drawer_page_components), key = "game-components") { Text(stringResource(R.string.comp_reading), fontSize = 13.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(14.dp)) } return @@ -1809,7 +1793,7 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin } if (a.selectedGameProfileId != null) { if (gameProfile == null) { - SettingsGroup(stringResource(R.string.drawer_page_components)) { + SettingsGroup(stringResource(R.string.drawer_page_components), key = "game-components") { Text( stringResource(R.string.comp_reading), fontSize = 13.sp, @@ -1819,7 +1803,7 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin } return } - SettingsGroup(stringResource(R.string.drawer_page_components)) { + SettingsGroup(stringResource(R.string.drawer_page_components), key = "game-components") { DrawerStackedChoice( host = host, key = "game-cmp-proton", @@ -1872,7 +1856,7 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin } val running = snap.protons.filter { it.inUseByGame } val view = snap.protons.firstOrNull { it.proton.id == a.defaultProtonId } ?: running.firstOrNull() ?: snap.protons.firstOrNull() - SettingsGroup(stringResource(R.string.drawer_running_now)) { + SettingsGroup(stringResource(R.string.drawer_running_now), key = "game-running-now") { val src = remember { MutableInteractionSource() } val hot = src.collectIsFocusedAsState().value val pal = LocalPalette.current @@ -1902,13 +1886,13 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin } } if (view == null) { - SettingsGroup(stringResource(R.string.drawer_page_components)) { + SettingsGroup(stringResource(R.string.drawer_page_components), key = "game-components") { Text(stringResource(R.string.drawer_no_proton), fontSize = 13.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(14.dp)) } return } val p = view.proton - SettingsGroup(stringResource(R.string.drawer_page_components)) { + SettingsGroup(stringResource(R.string.drawer_page_components), key = "game-components") { DrawerStackedChoice( host, "cmp-proton", stringResource(R.string.comp_proton), listOfNotNull( @@ -1965,7 +1949,8 @@ internal fun ComponentDownloadsDrawerGroup( val colors = MaterialTheme.colorScheme val installed = packages.map { it.file }.toSet() val nightlyPicked = remember { mutableStateMapOf() } - SettingsGroup(stringResource(R.string.drawer_component_downloads)) { + SettingsGroup(stringResource(R.string.drawer_component_downloads), key = "game-downloads", + tag = if (downloads.isNotEmpty()) stringResource(R.string.drawer_tag_downloading) else null) { Text(stringResource(R.string.drawer_component_downloads_hint), fontSize = 12.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(horizontal = 14.dp, vertical = 8.dp)) SettingsRow(stringResource(R.string.comp_nightlies_checked, 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 e6bda83fa..66c4769c7 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SettingsWidgets.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SettingsWidgets.kt @@ -443,7 +443,11 @@ fun ValueChip(text: String, open: Boolean, enabled: Boolean = true, modifier: Mo } @Composable -fun SettingsGroup(title: String, compact: Boolean = false, detail: String? = null, content: @Composable ColumnScope.() -> Unit) { +fun SettingsGroup(title: String, compact: Boolean = false, detail: String? = null, key: String? = null, tag: String? = null, content: @Composable ColumnScope.() -> Unit) { + LocalDrawerSections.current?.let { sections -> + DrawerSection(sections, key ?: title, title, detail, tag, content) + return + } val tight = compact || LocalCompactSettings.current val colors = MaterialTheme.colorScheme val pal = LocalPalette.current diff --git a/app/src/main/java/com/droiddeck/launcher/ui/StoreAchievementsUi.kt b/app/src/main/java/com/droiddeck/launcher/ui/StoreAchievementsUi.kt index 2d6e37753..2f7c96293 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/StoreAchievementsUi.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/StoreAchievementsUi.kt @@ -56,6 +56,7 @@ import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.clip import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester +import androidx.compose.ui.focus.onFocusChanged import androidx.compose.ui.graphics.Color import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext @@ -358,6 +359,67 @@ internal fun SessionAchievementsPanel(label: String, state: AchievementsState, t } } +/** The Achievements page of the session menu: the same list as the full panel, inside the menu's own scroll. */ +@Composable +internal fun DrawerAchievementsPage(game: StoreAchievements.Game, title: String?, track: (String) -> Modifier) { + val colors = MaterialTheme.colorScheme + val pal = LocalPalette.current + val label = StoreAchievements.forSource(game.source)?.label.orEmpty() + val state = rememberAchievements(game) ?: AchievementsState.READING + val kinds = remember(state.list) { + val list = state.list.orEmpty() + val split = groups(list) + if (split.size < 2) emptyList() else listOf(R.string.stores_tab_all to list) + split + } + var pick by remember { mutableIntStateOf(0) } + if (pick >= kinds.size) pick = 0 + var noteHadFocus by remember { mutableStateOf(false) } + val firstRow = remember { FocusRequester() } + val loaded = !state.list.isNullOrEmpty() + LaunchedEffect(loaded) { + if (loaded && noteHadFocus) { + noteHadFocus = false + withFrameNanos { } + runCatching { firstRow.requestFocus() } + } + } + Column(Modifier.fillMaxWidth().padding(top = 8.dp, start = 4.dp, end = 4.dp)) { + Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) { + Text(title.orEmpty(), fontSize = 13.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f)) + state.list?.takeIf { it.isNotEmpty() }?.let { list -> + if (state.all) Trophy(18.dp, Modifier.padding(end = 6.dp)) + Text(stringResource(R.string.achievements_count_short, state.done, list.size), fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = pal.signal) + } + } + val list = state.list + if (list.isNullOrEmpty()) { + Text(achievementsNote(state, label).orEmpty(), fontSize = 13.sp, color = colors.onSurfaceVariant, + modifier = Modifier.padding(top = 12.dp).then(track("achievements")) + .onFocusChanged { if (it.isFocused) noteHadFocus = true }.focusable()) + return@Column + } + LinearProgressIndicator( + progress = { state.done / list.size.toFloat() }, color = pal.signal, trackColor = pal.line, + modifier = Modifier.padding(top = 8.dp).fillMaxWidth().height(4.dp).clip(RoundedCornerShape(2.dp)), + ) + if (kinds.isNotEmpty()) TabStrip( + kinds.map { (name, group) -> if (name == R.string.stores_tab_all) stringResource(name) + " · " + group.size else stringResource(name, group.size) }, + pick, { pick = it }, Modifier.padding(top = 10.dp), bumpers = false, compact = true, + ) + val shown = kinds.getOrNull(pick)?.second ?: list + val sections = if (pick == 0) groups(shown).filter { it.second.isNotEmpty() } else listOf(null to shown) + val first = sections.firstOrNull()?.second?.firstOrNull()?.id + Column(Modifier.padding(top = 6.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) { + for ((group, items) in sections) { + if (group != null) AchievementGroupLabel(stringResource(group, items.size)) + for (a in items) androidx.compose.runtime.key(a.id) { + AchievementRow(a, compact = true, if (a.id == first) track("achievements").focusRequester(firstRow) else Modifier) + } + } + } + } +} + @Composable internal fun DrawerAchievementsRow(progress: Pair?, modifier: Modifier = Modifier, onClick: () -> Unit) { val colors = MaterialTheme.colorScheme diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 098129e05..7a308d7c8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -707,7 +707,22 @@ Next page Arrange pages More - Back to %1$s + Performance + Game + VR & glasses + Frame pacing + Mouse + Keyboard layout + Input profile + Compatibility + Fine tuning + controller connected + no controller + running + custom look + attached + downloading + Pause game Back to %1$s Nothing is kept here. Arrange pages and move one below the More row. Reset Done diff --git a/app/src/test/java/com/droiddeck/launcher/ui/DrawerSectionTestSupport.kt b/app/src/test/java/com/droiddeck/launcher/ui/DrawerSectionTestSupport.kt new file mode 100644 index 000000000..e86d0e220 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/ui/DrawerSectionTestSupport.kt @@ -0,0 +1,12 @@ +package com.droiddeck.launcher.ui + +import androidx.compose.ui.test.SemanticsNodeInteractionsProvider +import androidx.compose.ui.test.onNodeWithTag +import androidx.compose.ui.test.performClick +import androidx.compose.ui.test.performScrollTo + +/** Session menu groups start folded; a test opens the one whose rows it checks. */ +internal fun SemanticsNodeInteractionsProvider.openSection(key: String) { + if (DrawerSectionState.isOpen(key)) return + onNodeWithTag("drawer-section-$key").performScrollTo().performClick() +} diff --git a/app/src/test/java/com/droiddeck/launcher/ui/PenSettingsGroupTest.kt b/app/src/test/java/com/droiddeck/launcher/ui/PenSettingsGroupTest.kt index cc416ce52..f791b1af8 100644 --- a/app/src/test/java/com/droiddeck/launcher/ui/PenSettingsGroupTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/ui/PenSettingsGroupTest.kt @@ -31,7 +31,9 @@ class PenSettingsGroupTest { @Test fun theDrawerHasNoPenGroupUntilAPenIsKnown() { compose.setContent { DroidDeckTheme { SessionDrawer(true, SessionDrawerPage.CONTROLLER, false, {}, actions(pen = null)) } } + compose.openSection("controller-touch") compose.onNodeWithTag("setting-touch").assertExists() + compose.onNodeWithTag("drawer-section-controller-pen").assertDoesNotExist() compose.onNodeWithTag("setting-pen").assertDoesNotExist() compose.onNodeWithTag("setting-pen-button").assertDoesNotExist() } @@ -43,6 +45,7 @@ class PenSettingsGroupTest { SessionDrawer(true, SessionDrawerPage.CONTROLLER, false, {}, actions(SessionPrefs.Pen()) { k, v -> picks += k to v }) } } + compose.openSection("controller-pen") compose.onNodeWithTag("setting-pen-button").performScrollTo().performClick() compose.onNodeWithText(context.getString(R.string.gesture_middle_click)).performScrollTo().performClick() compose.onNodeWithTag("setting-pen").performScrollTo().performClick() diff --git a/app/src/test/java/com/droiddeck/launcher/ui/SessionDrawerPageTest.kt b/app/src/test/java/com/droiddeck/launcher/ui/SessionDrawerPageTest.kt index 18911a352..1024f1f83 100644 --- a/app/src/test/java/com/droiddeck/launcher/ui/SessionDrawerPageTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/ui/SessionDrawerPageTest.kt @@ -4,60 +4,51 @@ import org.junit.Assert.* import org.junit.Test class SessionDrawerPageTest { - @Test fun navigationStartsWithControllerAndGoesStraightToDisplay() { + @Test fun navigationRunsControllerPerformanceDisplayEffectsGameVrSession() { val pages = sessionDrawerPages(hasAgent = false) - assertEquals(SessionDrawerPage.CONTROLLER, pages.first()) - assertEquals(SessionDrawerPage.DISPLAY, pages.step(SessionDrawerPage.CONTROLLER, 1)) - assertEquals(SessionDrawerPage.VR, pages.step(SessionDrawerPage.CONTROLLER, -1)) - assertEquals(SessionDrawerPage.HUD, pages.step(SessionDrawerPage.DISPLAY, 1)) - assertEquals(SessionDrawerPage.EFFECTS, pages.step(SessionDrawerPage.HUD, 1)) - assertEquals(SessionDrawerPage.GAMES, pages.step(SessionDrawerPage.EFFECTS, 1)) - assertEquals(SessionDrawerPage.SESSION, pages.step(SessionDrawerPage.GAMES, 1)) + assertEquals( + listOf(SessionDrawerPage.CONTROLLER, SessionDrawerPage.HUD, SessionDrawerPage.DISPLAY, SessionDrawerPage.EFFECTS, + SessionDrawerPage.GAMES, SessionDrawerPage.VR, SessionDrawerPage.SESSION, SessionDrawerPage.MORE), + pages.strip(), + ) + assertEquals(SessionDrawerPage.MORE, pages.step(SessionDrawerPage.CONTROLLER, -1)) } - @Test fun moreKeepsSteamVrByDefaultAndStandsInForThePagesInsideIt() { - val pages = sessionDrawerPages(hasAgent = false) - assertEquals(listOf(SessionDrawerPage.VR), pages.inMore()) - assertEquals(SessionDrawerPage.MORE, pages.strip().last()) - assertFalse(SessionDrawerPage.VR in pages.strip()) - assertEquals(SessionDrawerPage.MORE, pages.tabFor(SessionDrawerPage.VR)) + @Test fun achievementsAndTheAgentStartInsideMore() { + val pages = sessionDrawerPages(hasAchievements = true, hasAgent = true) + assertEquals(listOf(SessionDrawerPage.ACHIEVEMENTS, SessionDrawerPage.AGENT), pages.inMore()) + assertEquals(SessionDrawerPage.MORE, pages.tabFor(SessionDrawerPage.ACHIEVEMENTS)) assertEquals(SessionDrawerPage.GAMES, pages.tabFor(SessionDrawerPage.GAMES)) val strip = pages.strip() - assertEquals(SessionDrawerPage.MORE, strip.step(SessionDrawerPage.SESSION, 1)) - assertEquals(SessionDrawerPage.CONTROLLER, strip.step(SessionDrawerPage.MORE, 1)) - assertEquals(SessionDrawerPage.SESSION, strip.step(pages.tabFor(SessionDrawerPage.VR), -1)) + assertEquals(SessionDrawerPage.CONTROLLER, strip.step(pages.tabFor(SessionDrawerPage.AGENT), 1)) + } + + @Test fun achievementsAreOfferedOnlyForAGameThatHasThem() { + assertFalse(SessionDrawerPage.ACHIEVEMENTS in sessionDrawerPages(hasAchievements = false, hasAgent = false)) + assertFalse(SessionDrawerPage.AGENT in sessionDrawerPages(hasAgent = false)) + assertTrue(sessionDrawerPages(hasAgent = false).inMore().isEmpty()) } @Test fun anOlderSavedOrderKeepsItsPagesAndGetsAMoreTabAfterSession() { - val saved = listOf("CONTROLLER", "DISPLAY", "HUD", "EFFECTS", "VR", "GAMES", "AGENT", "SESSION") + val saved = listOf("CONTROLLER", "GLASSES", "DISPLAY", "HUD", "EFFECTS", "VR", "GAMES", "AGENT", "SESSION") val out = DrawerPages.arrange(saved) + assertEquals(SessionDrawerPage.entries.toSet(), out.toSet()) assertEquals(SessionDrawerPage.MORE, out[out.indexOf(SessionDrawerPage.SESSION) + 1]) - assertTrue(out.indexOf(SessionDrawerPage.VR) < out.indexOf(SessionDrawerPage.EFFECTS) + 2) - assertTrue(out.inMore().isEmpty()) + assertEquals(listOf(SessionDrawerPage.ACHIEVEMENTS), out.inMore()) + assertTrue(SessionDrawerPage.AGENT in out.strip()) } @Test fun sessionCanBeKeptInsideMore() { val saved = listOf("CONTROLLER", "DISPLAY", "HUD", "EFFECTS", "GAMES", "AGENT", "MORE", "SESSION", "VR") val out = DrawerPages.arrange(saved) - assertEquals(listOf(SessionDrawerPage.SESSION, SessionDrawerPage.VR), out.inMore()) + assertEquals(listOf(SessionDrawerPage.ACHIEVEMENTS, SessionDrawerPage.SESSION, SessionDrawerPage.VR), out.inMore()) assertFalse(SessionDrawerPage.SESSION in out.strip()) } @Test fun moreAndSessionCannotBeHidden() { assertFalse(DrawerPages.hideable(SessionDrawerPage.MORE)) - } - - @Test fun glassesAddTheirPageAfterController() { - val pages = sessionDrawerPages(hasGlasses = true, hasAgent = false) - assertEquals(SessionDrawerPage.GLASSES, pages.step(SessionDrawerPage.CONTROLLER, 1)) - assertEquals(sessionDrawerPages(hasAgent = false), pages.filter { it != SessionDrawerPage.GLASSES }) - } - - @Test fun theAgentPageComesBeforeSessionOnlyWhenTheTabIsShown() { - val with = sessionDrawerPages(hasAgent = true) - assertEquals(SessionDrawerPage.AGENT, with.step(SessionDrawerPage.GAMES, 1)) - assertEquals(SessionDrawerPage.SESSION, with.step(SessionDrawerPage.AGENT, 1)) - assertFalse(SessionDrawerPage.AGENT in sessionDrawerPages(hasAgent = false)) + assertFalse(DrawerPages.hideable(SessionDrawerPage.SESSION)) + assertTrue(DrawerPages.hideable(SessionDrawerPage.HUD)) } @Test fun arrangeKeepsSavedOrderAndSlotsNewPagesAfterTheirNeighbour() { @@ -67,9 +58,4 @@ class SessionDrawerPageTest { assertEquals(listOf(SessionDrawerPage.SESSION, SessionDrawerPage.HUD), out.filter { it in setOf(SessionDrawerPage.SESSION, SessionDrawerPage.HUD) }) assertTrue(out.indexOf(SessionDrawerPage.HUD) < out.indexOf(SessionDrawerPage.CONTROLLER)) } - - @Test fun sessionPageCannotBeHidden() { - assertFalse(DrawerPages.hideable(SessionDrawerPage.SESSION)) - assertTrue(DrawerPages.hideable(SessionDrawerPage.HUD)) - } } diff --git a/app/src/test/java/com/droiddeck/launcher/ui/SessionSecondScreenTest.kt b/app/src/test/java/com/droiddeck/launcher/ui/SessionSecondScreenTest.kt index c45b32d23..83c5e1a0d 100644 --- a/app/src/test/java/com/droiddeck/launcher/ui/SessionSecondScreenTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/ui/SessionSecondScreenTest.kt @@ -130,6 +130,8 @@ class SessionSecondScreenTest { actions(true, listOf(SecondScreenDisplay(1, "Bottom screen"), SecondScreenDisplay(2, "Monitor")), gameSwap = true)) } } + compose.onNodeWithText(context.getString(R.string.swap_game_screen)).assertDoesNotExist() + compose.openSection("display-second") compose.onNodeWithText(context.getString(R.string.swap_game_screen)).performScrollTo().assertIsDisplayed() compose.onNodeWithText("Bottom screen").performScrollTo().assertIsDisplayed() } @@ -265,7 +267,7 @@ class SessionSecondScreenTest { state("drawerOpenState").value = true state("drawerControllerActive").value = true state>("secondScreenDisplays").value = listOf(SecondScreenDisplay(1, "Bottom screen")) - for ((button, page) in listOf(KeyEvent.KEYCODE_BUTTON_R1 to SessionDrawerPage.DISPLAY, + for ((button, page) in listOf(KeyEvent.KEYCODE_BUTTON_R1 to SessionDrawerPage.HUD, KeyEvent.KEYCODE_BUTTON_L1 to SessionDrawerPage.CONTROLLER)) { assertTrue(activity.dispatchKeyEvent(KeyEvent(0L, 0L, KeyEvent.ACTION_DOWN, button, 0, 0, device.id, 0, 0, InputDevice.SOURCE_GAMEPAD))) @@ -309,6 +311,7 @@ class SessionSecondScreenTest { actions(true, emptyList(), micAvailable = true, micEnabled = true, onMic = changes::add)) } } + compose.openSection("session-behavior") compose.onNodeWithTag("setting-microphone").assertIsEnabled() .assert(SemanticsMatcher.expectValue(StateDescription, context.getString(R.string.widgets_on))).performClick() assertEquals(listOf(false), changes) @@ -322,6 +325,7 @@ class SessionSecondScreenTest { actions(true, emptyList(), micAvailable = true, onMic = changes::add)) } } + compose.openSection("session-behavior") compose.onNodeWithTag("setting-microphone").assertIsEnabled() .assert(SemanticsMatcher.expectValue(StateDescription, context.getString(R.string.widgets_off))).performClick() assertEquals(listOf(true), changes) @@ -333,6 +337,7 @@ class SessionSecondScreenTest { SessionDrawer(true, SessionDrawerPage.SESSION, false, {}, actions(false, emptyList())) } } + compose.openSection("session-behavior") compose.onNodeWithTag("setting-microphone").assertDoesNotExist() compose.onNodeWithText(context.getString(R.string.mode_mic)).assertDoesNotExist() } @@ -354,6 +359,7 @@ class SessionSecondScreenTest { onInputSelection = { panel.refreshControls() }, onClose = { open.value = false })) } } + compose.openSection("controller-input") compose.onNodeWithTag("setting-input-profile").performScrollTo().performClick() compose.onNodeWithText("Desktop").performScrollTo().performClick() compose.onNodeWithTag("input-profile-expand").performScrollTo().performClick()