From 03812bb3b777c104746d07c55a85be636b398d3a Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Sun, 15 Nov 2026 11:05:39 -0500 Subject: [PATCH] feat(boot-movie): add a Shuffle switch backed by Steam's startup movie shuffle setting (#2462) * feat(boot-movie): add a Shuffle switch backed by Steam's startup movie shuffle setting * test(boot-movie): keep unrelated settings unchanged * fix(boot-movie): keep the Shuffle choice across reset, unreadable configs and running sessions * fix(boot-movie): track the Shuffle baseline per Steam home and only for values staging wrote * fix(boot-movie): adopt a Shuffle change made in the inactive Steam home before staging overwrites it * fix(boot-movie): keep the 60 fps note under the Installed movies row --- .../droiddeck/launcher/session/BootMovie.kt | 31 ++- .../launcher/session/SessionFiles.kt | 256 +++++++++++------- .../launcher/session/SessionPrefs.kt | 7 + .../launcher/session/SettingsReset.kt | 2 +- .../droiddeck/launcher/ui/BootMovieSection.kt | 10 +- app/src/main/res/values-ar/strings.xml | 1 + app/src/main/res/values-b+es+419/strings.xml | 1 + app/src/main/res/values-bg/strings.xml | 1 + app/src/main/res/values-cs/strings.xml | 1 + app/src/main/res/values-da/strings.xml | 1 + app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values-el/strings.xml | 1 + app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values-fi/strings.xml | 1 + app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values-hi/strings.xml | 1 + app/src/main/res/values-hu/strings.xml | 1 + app/src/main/res/values-in/strings.xml | 1 + app/src/main/res/values-it/strings.xml | 1 + app/src/main/res/values-ja/strings.xml | 1 + app/src/main/res/values-ko/strings.xml | 1 + app/src/main/res/values-ms/strings.xml | 1 + app/src/main/res/values-nb/strings.xml | 1 + app/src/main/res/values-nl/strings.xml | 1 + app/src/main/res/values-pl/strings.xml | 1 + app/src/main/res/values-pt-rPT/strings.xml | 1 + app/src/main/res/values-pt/strings.xml | 1 + app/src/main/res/values-ro/strings.xml | 1 + app/src/main/res/values-ru/strings.xml | 1 + app/src/main/res/values-sv/strings.xml | 1 + app/src/main/res/values-th/strings.xml | 1 + app/src/main/res/values-tr/strings.xml | 1 + app/src/main/res/values-uk/strings.xml | 1 + app/src/main/res/values-vi/strings.xml | 1 + app/src/main/res/values-zh-rCN/strings.xml | 1 + app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + .../launcher/session/BootMovieTest.kt | 1 + .../session/StartupMovieConfigTest.kt | 136 ++++++++++ docs/development/boot-movies.md | 4 +- 41 files changed, 372 insertions(+), 108 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/session/BootMovie.kt b/app/src/main/java/com/droiddeck/launcher/session/BootMovie.kt index 148766436c..d4916cc4a6 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/BootMovie.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/BootMovie.kt @@ -150,8 +150,37 @@ object BootMovie { folder.listFiles()?.forEach { if (it.name != keep) it.delete() } } + internal fun syncShuffleFromSteam(context: Context, config: File) = syncShuffleFromSteam(context, listOf(config)) + + // Staging writes Shuffle and its baseline under the same lock, so a poll never reads a half-staged value as Steam's. + internal fun syncShuffleFromSteam(context: Context, configs: List) = synchronized(SessionFiles.STEAM_CONFIG) { + val read = configs.mapNotNull { config -> SessionFiles.startupMovieShuffle(config)?.let { config to it } } + val (known, unseen) = read.partition { (config, _) -> SessionPrefs.bootMovieShuffleSeen(context, config) != null } + var changed = false + known.forEach { (config, steam) -> + if (SessionPrefs.bootMovieShuffleSeen(context, config) != steam) { + SessionPrefs.setBootMovieShuffle(context, steam) + changed = true + } + SessionPrefs.setBootMovieShuffleSeen(context, config, steam) + } + // A config read for the first time only sets the choice when no known config changed, so it cannot undo a change. + unseen.forEach { (config, steam) -> + if (!changed && SessionPrefs.bootMovieShuffle(context) != steam) { + SessionPrefs.setBootMovieShuffle(context, steam) + changed = true + } + SessionPrefs.setBootMovieShuffleSeen(context, config, steam) + } + } + fun syncFromSteam(context: Context): Boolean { - val named = SessionFiles.startupMovieLocalPath(BootMovieLibrary.steamConfig(context)) ?: return false + val active = BootMovieLibrary.steamConfig(context) + syncShuffleFromSteam( + context, + BootMovieLibrary.steamRoots(context).map { File(it, "config/config.vdf") }.filter { it != active } + active, + ) + val named = SessionFiles.startupMovieLocalPath(active) ?: return false val seen = SessionPrefs.bootMovieSteamSeen(context) if (named == seen) return false SessionPrefs.setBootMovieSteamSeen(context, named) diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt index 708e43a16a..ad2cb05f22 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt @@ -14,6 +14,9 @@ import com.droiddeck.launcher.runtime.ProotFastPath import java.io.File object SessionFiles { + // Session start and Flatpak staging can both rewrite Steam's config.vdf; one writer at a time. + internal val STEAM_CONFIG = Any() + private const val TAG = "SessionFiles" private const val NO_PAD_SWITCH = "Download/droiddeck-no-pad" const val DIRECTAUDIO_DIR = "usr/local/lib/directaudio" @@ -357,6 +360,11 @@ object SessionFiles { "staged=$bigPictureMovieInstalled done=$done steam=${home.path} config: $before -> ${startupMoviePath(config)}", ) if (startsSession) { + synchronized(STEAM_CONFIG) { + val shuffle = SessionPrefs.bootMovieShuffle(context) + setStartupMovieShuffle(config, shuffle) + if (startupMovieShuffle(config) == shuffle) SessionPrefs.setBootMovieShuffleSeen(context, config, shuffle) + } disableIdleSleep(home) seedUserDefaults(home) } @@ -369,28 +377,30 @@ object SessionFiles { } internal fun resetMissingStartupMovie(config: File, force: Boolean): Boolean { - if (!config.isFile) return true - val text = runCatching { config.readText() }.getOrElse { - Log.w(TAG, "could not read Steam config to reset the startup movie", it) - return false - } - val movie = activeStartupMovie(text) ?: return true - val block = text.substring(movie.keyStart, movie.close + 1) - val path = scalar(block, "LocalPath").orEmpty() - if (path.isEmpty()) return true - val missing = File(config.parentFile, "uioverrides/movies/" + path.removePrefix(BOOT_MOVIES_DIR)) - val gone = path.startsWith(BOOT_MOVIES_DIR) && !missing.isFile && (force || path == BOOT_MOVIE_PATH) - if (!gone) return false - val newline = if (text.contains("\r\n")) "\r\n" else "\n" - val updated = setScalar(setScalar(block, "MovieID", "0", newline), "LocalPath", "", newline) - val staged = File(config.parentFile, config.name + ".staged") - return try { - staged.writeText(text.replaceRange(movie.keyStart, movie.close + 1, updated)) - (staged.renameTo(config)).also { if (!it) staged.delete() } - } catch (e: Exception) { - staged.delete() - Log.w(TAG, "could not reset Steam startup movie selection", e) - false + synchronized(STEAM_CONFIG) { + if (!config.isFile) return true + val text = runCatching { config.readText() }.getOrElse { + Log.w(TAG, "could not read Steam config to reset the startup movie", it) + return false + } + val movie = activeStartupMovie(text) ?: return true + val block = text.substring(movie.keyStart, movie.close + 1) + val path = scalar(block, "LocalPath").orEmpty() + if (path.isEmpty()) return true + val missing = File(config.parentFile, "uioverrides/movies/" + path.removePrefix(BOOT_MOVIES_DIR)) + val gone = path.startsWith(BOOT_MOVIES_DIR) && !missing.isFile && (force || path == BOOT_MOVIE_PATH) + if (!gone) return false + val newline = if (text.contains("\r\n")) "\r\n" else "\n" + val updated = setScalar(setScalar(block, "MovieID", "0", newline), "LocalPath", "", newline) + val staged = File(config.parentFile, config.name + ".staged") + return try { + staged.writeText(text.replaceRange(movie.keyStart, movie.close + 1, updated)) + (staged.renameTo(config)).also { if (!it) staged.delete() } + } catch (e: Exception) { + staged.delete() + Log.w(TAG, "could not reset Steam startup movie selection", e) + false + } } } @@ -491,6 +501,42 @@ object SessionFiles { return scalar(text.substring(movie.keyStart, movie.close + 1), "LocalPath") } + internal fun startupMovieShuffle(config: File): Boolean? { + val text = runCatching { config.readText() }.getOrNull() ?: return null + val movie = activeStartupMovie(text) ?: return false + return scalar(text.substring(movie.keyStart, movie.close + 1), "Shuffle") == "1" + } + + internal fun withStartupMovieShuffle(text: String, on: Boolean): String { + val newline = if (text.contains("\r\n")) "\r\n" else "\n" + val value = if (on) "1" else "0" + return listOfNotNull(customizationMovie(text), olderMovie(text)).sortedByDescending { it.keyStart }.fold(text) { acc, movie -> + val block = acc.substring(movie.keyStart, movie.close + 1) + if (!on && scalar(block, "Shuffle") == null) acc else acc.replaceRange(movie.keyStart, movie.close + 1, setScalar(block, "Shuffle", value, newline)) + } + } + + internal fun setStartupMovieShuffle(config: File, on: Boolean): Boolean { + synchronized(STEAM_CONFIG) { + if (!config.isFile) return false + val text = runCatching { config.readText() }.getOrElse { + Log.w(TAG, "could not read Steam config to set the startup movie shuffle", it) + return false + } + val updated = withStartupMovieShuffle(text, on) + if (updated == text) return true + val staged = File(config.parentFile, config.name + ".staged") + return try { + staged.writeText(updated) + staged.renameTo(config).also { if (!it) staged.delete() } + } catch (e: Exception) { + staged.delete() + Log.w(TAG, "could not set Steam startup movie shuffle", e) + false + } + } + } + internal fun startupMovieBlock(config: File): String? { val text = runCatching { config.readText() }.getOrNull() ?: return null val parts = listOfNotNull( @@ -513,69 +559,71 @@ object SessionFiles { } internal fun ensureStartupMovieDefault(config: File, force: Boolean = false): Boolean { - val path = BOOT_MOVIE_PATH - val legacyPath = "/uioverrides/movies/droiddeck-startup.webm" - var text = if (config.isFile) runCatching { config.readText() }.getOrElse { - Log.w(TAG, "could not read Steam config for startup movie", it) - return false - } else "" - val newline = if (text.contains("\r\n")) "\r\n" else "\n" - val custom = customizationMovie(text) - val active = custom ?: olderMovie(text) - if (active != null) { - val block = text.substring(active.keyStart, active.close + 1) - val selectedId = scalar(block, "MovieID") - val selectedPath = scalar(block, "LocalPath") - if (selectedPath == path && custom != null) { - Log.i(TAG, "Steam startup movie is set to DroidDeck") - return true - } - val legacyDefault = selectedId == "0" && selectedPath == legacyPath - val hasExplicitSelection = - (!selectedId.isNullOrEmpty() && selectedId != "0") || !selectedPath.isNullOrEmpty() - if (!force && !legacyDefault && hasExplicitSelection && selectedPath != path) { - Log.i(TAG, "Steam startup movie selection preserved") + synchronized(STEAM_CONFIG) { + val path = BOOT_MOVIE_PATH + val legacyPath = "/uioverrides/movies/droiddeck-startup.webm" + var text = if (config.isFile) runCatching { config.readText() }.getOrElse { + Log.w(TAG, "could not read Steam config for startup movie", it) return false - } - } - val targets = listOfNotNull(customizationMovie(text), olderMovie(text)).sortedByDescending { it.keyStart } - for (target in targets) text = pointAt(text, target, path, newline) - if (olderMovie(text) == null) { - val steam = findSteamBlock(text) - if (steam == null) { - if (text.isNotBlank() && customizationMovie(text) == null) { - Log.w(TAG, "Steam config has no Steam settings block; startup movie default not set") + } else "" + val newline = if (text.contains("\r\n")) "\r\n" else "\n" + val custom = customizationMovie(text) + val active = custom ?: olderMovie(text) + if (active != null) { + val block = text.substring(active.keyStart, active.close + 1) + val selectedId = scalar(block, "MovieID") + val selectedPath = scalar(block, "LocalPath") + if (selectedPath == path && custom != null) { + Log.i(TAG, "Steam startup movie is set to DroidDeck") + return true + } + val legacyDefault = selectedId == "0" && selectedPath == legacyPath + val hasExplicitSelection = + (!selectedId.isNullOrEmpty() && selectedId != "0") || !selectedPath.isNullOrEmpty() + if (!force && !legacyDefault && hasExplicitSelection && selectedPath != path) { + Log.i(TAG, "Steam startup movie selection preserved") return false } - if (text.isBlank()) { - text = "\"InstallConfigStore\"${newline}{${newline}\t\"Software\"${newline}\t{${newline}\t\t\"Valve\"${newline}\t\t{${newline}\t\t\t\"Steam\"${newline}\t\t\t{${newline}" - val section = startupMovieSection("\t\t\t\t", path, newline) - text += section + newline + "\t\t\t}" + newline + "\t\t}" + newline + "\t}" + newline + "}" + } + val targets = listOfNotNull(customizationMovie(text), olderMovie(text)).sortedByDescending { it.keyStart } + for (target in targets) text = pointAt(text, target, path, newline) + if (olderMovie(text) == null) { + val steam = findSteamBlock(text) + if (steam == null) { + if (text.isNotBlank() && customizationMovie(text) == null) { + Log.w(TAG, "Steam config has no Steam settings block; startup movie default not set") + return false + } + if (text.isBlank()) { + text = "\"InstallConfigStore\"${newline}{${newline}\t\"Software\"${newline}\t{${newline}\t\t\"Valve\"${newline}\t\t{${newline}\t\t\t\"Steam\"${newline}\t\t\t{${newline}" + val section = startupMovieSection("\t\t\t\t", path, newline) + text += section + newline + "\t\t\t}" + newline + "\t\t}" + newline + "\t}" + newline + "}" + } + } else { + val lineStart = text.lastIndexOf('\n', steam.close).let { if (it < 0) 0 else it + 1 } + val indent = text.substring(lineStart, steam.close).takeWhile { it == '\t' || it == ' ' } + val section = startupMovieSection(indent + "\t", path, newline) + text = text.substring(0, lineStart) + section + newline + indent + text.substring(lineStart) } - } else { - val lineStart = text.lastIndexOf('\n', steam.close).let { if (it < 0) 0 else it + 1 } - val indent = text.substring(lineStart, steam.close).takeWhile { it == '\t' || it == ' ' } - val section = startupMovieSection(indent + "\t", path, newline) - text = text.substring(0, lineStart) + section + newline + indent + text.substring(lineStart) } - } - if (customizationMovie(text) == null) text = withCustomization(text, path, newline) - val staged = File(config.parentFile, config.name + ".staged") - return try { - config.parentFile?.mkdirs() - staged.writeText(text) - if (!staged.renameTo(config)) { + if (customizationMovie(text) == null) text = withCustomization(text, path, newline) + val staged = File(config.parentFile, config.name + ".staged") + return try { + config.parentFile?.mkdirs() + staged.writeText(text) + if (!staged.renameTo(config)) { + staged.delete() + Log.e(TAG, "could not write Steam startup movie selection") + false + } else { + Log.i(TAG, "Steam startup movie default selected") + true + } + } catch (e: Exception) { staged.delete() - Log.e(TAG, "could not write Steam startup movie selection") + Log.w(TAG, "could not write Steam startup movie selection", e) false - } else { - Log.i(TAG, "Steam startup movie default selected") - true } - } catch (e: Exception) { - staged.delete() - Log.w(TAG, "could not write Steam startup movie selection", e) - false } } @@ -661,32 +709,34 @@ object SessionFiles { private val IDLE_SLEEP_TIMERS = listOf("IdleSuspendBatterySeconds", "IdleSuspendACSeconds") internal fun disableIdleSleep(steamHome: File): Boolean { - val config = File(steamHome, "config/config.vdf") - val text = runCatching { config.readText() }.getOrNull() ?: return false - val newline = if (text.contains("\r\n")) "\r\n" else "\n" - val steam = findSteamBlock(text) ?: return false - val system = findObject(text, "system", steam.open + 1, steam.close) - val updated = if (system != null) { - val block = text.substring(system.keyStart, system.close + 1) - text.replaceRange(system.keyStart, system.close + 1, IDLE_SLEEP_TIMERS.fold(block) { acc, key -> setScalar(acc, key, "0", newline) }) - } else { - val lineStart = text.lastIndexOf('\n', steam.close).let { if (it < 0) 0 else it + 1 } - val indent = text.substring(lineStart, steam.close).takeWhile { it == '\t' || it == ' ' } + "\t" - val section = (listOf(indent + "\"system\"", indent + "{") + - IDLE_SLEEP_TIMERS.map { "$indent\t\"$it\"\t\t\"0\"" } + (indent + "}")).joinToString(newline) + newline - text.substring(0, lineStart) + section + text.substring(lineStart) - } - val staged = File(config.parentFile, config.name + ".staged") - return try { - if (updated != text) { - staged.writeText(updated) - if (!staged.renameTo(config)) { staged.delete(); return false } + synchronized(STEAM_CONFIG) { + val config = File(steamHome, "config/config.vdf") + val text = runCatching { config.readText() }.getOrNull() ?: return false + val newline = if (text.contains("\r\n")) "\r\n" else "\n" + val steam = findSteamBlock(text) ?: return false + val system = findObject(text, "system", steam.open + 1, steam.close) + val updated = if (system != null) { + val block = text.substring(system.keyStart, system.close + 1) + text.replaceRange(system.keyStart, system.close + 1, IDLE_SLEEP_TIMERS.fold(block) { acc, key -> setScalar(acc, key, "0", newline) }) + } else { + val lineStart = text.lastIndexOf('\n', steam.close).let { if (it < 0) 0 else it + 1 } + val indent = text.substring(lineStart, steam.close).takeWhile { it == '\t' || it == ' ' } + "\t" + val section = (listOf(indent + "\"system\"", indent + "{") + + IDLE_SLEEP_TIMERS.map { "$indent\t\"$it\"\t\t\"0\"" } + (indent + "}")).joinToString(newline) + newline + text.substring(0, lineStart) + section + text.substring(lineStart) + } + val staged = File(config.parentFile, config.name + ".staged") + return try { + if (updated != text) { + staged.writeText(updated) + if (!staged.renameTo(config)) { staged.delete(); return false } + } + true + } catch (e: Exception) { + staged.delete() + Log.w(TAG, "could not disable Steam's idle sleep", e) + false } - true - } catch (e: Exception) { - staged.delete() - Log.w(TAG, "could not disable Steam's idle sleep", e) - false } } @@ -738,7 +788,7 @@ object SessionFiles { } private fun setScalar(block: String, key: String, value: String, newline: String): String { - val pattern = Regex("(?m)^([\\t ]*\"${Regex.escape(key)}\"[\\t ]+)\"[^\"\\r\\n]*\"([\\t ]*)$") + val pattern = Regex("(?m)^([\\t ]*\"${Regex.escape(key)}\"[\\t ]+)\"[^\"\\r\\n]*\"([\\t ]*(?://[^\\r\\n]*)?)$") val match = pattern.find(block) if (match != null) return block.replaceRange(match.range, match.groupValues[1] + "\"" + value + "\"" + match.groupValues[2]) val close = block.lastIndexOf('}') 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 8fe4461b13..035c237bd0 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt @@ -1229,6 +1229,13 @@ object SessionPrefs { fun setBootMovieApplyNext(context: Context, on: Boolean) { prefs(context).edit().putBoolean("bootMovieApplyNext", on).apply() } fun bootMovieSteamSeen(context: Context): String? = prefs(context).getString("bootMovieSteamSeen", null) fun setBootMovieSteamSeen(context: Context, path: String) { prefs(context).edit().putString("bootMovieSteamSeen", path).apply() } + fun bootMovieShuffle(context: Context): Boolean = prefs(context).getBoolean("bootMovieShuffle", false) + fun setBootMovieShuffle(context: Context, on: Boolean) { prefs(context).edit().putBoolean("bootMovieShuffle", on).apply() } + fun bootMovieShuffleSeen(context: Context, config: java.io.File): Boolean? { + val key = "bootMovieShuffleSeen:${config.path}" + return prefs(context).takeIf { it.contains(key) }?.getBoolean(key, false) + } + fun setBootMovieShuffleSeen(context: Context, config: java.io.File, on: Boolean) { prefs(context).edit().putBoolean("bootMovieShuffleSeen:${config.path}", on).apply() } fun bootMovieCustomName(context: Context): String? = prefs(context).getString("bootMovieCustomName", null) fun setBootMovieCustomName(context: Context, name: String?) { prefs(context).edit().apply { if (name == null) remove("bootMovieCustomName") else putString("bootMovieCustomName", name) }.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 9a12c0159b..cc7779322e 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt @@ -26,7 +26,7 @@ object SettingsReset { "guestHostname", "fexPreset", "forceSsbs", "logs", "gameDebugLogsEnabled", "enhancedDiagnosticsNext", "storageDiagnostics", "buildWatermark", "upscaler", "upscaleSharpness", "screenEffects", "textureAnisotropy", "textureLodBias", "steamDownloadsInBackground", "steam_offline", "bootMovie", "bootMovieSound", "bootMovieVolume", "bootMovieSeconds", "skipBootMovie", - "bootMovieApplyNext", "bootMovieSteamSeen", + "bootMovieApplyNext", "bootMovieSteamSeen", "bootMovieShuffle", "questDefaultsV1", "telemetryAuto", "telemetryOff", "statsStrip", "statsHud", "bottomHud", "bottomStripMetrics", "bottomStripTabs", "statsDash", "statsSpeedUnit", ) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BootMovieSection.kt b/app/src/main/java/com/droiddeck/launcher/ui/BootMovieSection.kt index 9e915031f2..2db14a9d74 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/BootMovieSection.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/BootMovieSection.kt @@ -160,7 +160,7 @@ internal fun BootMovieGroup(s: ModeSettings, a: ModeSettingsActions, host: MenuH TabChip(stringResource(R.string.boot_movie_tab_sound), tab == MovieTab.SOUND, Modifier.weight(1f)) { tab = MovieTab.SOUND } } when (tab) { - MovieTab.INSTALLED -> InstalledTab(a) + MovieTab.INSTALLED -> InstalledTab(a, host) MovieTab.IMPORT -> ImportTab(s, a) MovieTab.REPO -> RepoTab(a) MovieTab.SOUND -> SoundTab(s, a, host) @@ -170,7 +170,7 @@ internal fun BootMovieGroup(s: ModeSettings, a: ModeSettingsActions, host: MenuH } @Composable -private fun InstalledTab(a: ModeSettingsActions) { +private fun InstalledTab(a: ModeSettingsActions, host: MenuHost) { var browsing by remember { mutableStateOf(false) } val snapshot = rememberMovies(0, a.onBootMovieChanged) val current = snapshot?.let { snap -> snap.entries.firstOrNull { it.id == snap.selected }?.title } @@ -183,6 +183,12 @@ private fun InstalledTab(a: ModeSettingsActions) { modifier = Modifier.padding(horizontal = 14.dp).padding(bottom = 12.dp), ) val app = LocalContext.current.applicationContext + var shuffle by remember { mutableStateOf(SessionPrefs.bootMovieShuffle(app)) } + LaunchedEffect(snapshot) { shuffle = SessionPrefs.bootMovieShuffle(app) } + ToggleRow( + host, "boot-movie-shuffle", stringResource(R.string.boot_movie_shuffle), + stringResource(R.string.common_applies_next_session), shuffle, + ) { on -> shuffle = on; SessionPrefs.setBootMovieShuffle(app, on) } val scope = rememberCoroutineScope() var saving by remember { mutableStateOf(false) } val debugging = remember { com.droiddeck.launcher.agent.AgentAccess.commandsEnabled(app) } diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index efacf26d78..26f1db7bb4 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -3563,6 +3563,7 @@ الصوت تخطي مقطع بدء التشغيل استخدم مقطعًا أسود مدته 0.1 ثانية كمقطع بدء تشغيل Steam. يسري في الجلسة التالية. + عشوائي فيديو خاص بك MP4 أو MOV أو MKV أو WebM. تُحوَّل الصيغ الأخرى والملفات الأكبر من %1$d ميغابايت إلى WebM بدقة 720p على الجهاز، حتى %2$d ثانية. استيراد diff --git a/app/src/main/res/values-b+es+419/strings.xml b/app/src/main/res/values-b+es+419/strings.xml index fe1017d0f9..006974f736 100644 --- a/app/src/main/res/values-b+es+419/strings.xml +++ b/app/src/main/res/values-b+es+419/strings.xml @@ -3385,6 +3385,7 @@ Sonido Omitir el video de inicio Usa un clip negro de 0.1 segundos como video de inicio de Steam. Se aplica en la próxima sesión. + Aleatorio Tu propio video MP4, MOV, MKV o WebM. Otros formatos y archivos de más de %1$d MB se convierten a WebM 720p en el dispositivo, hasta %2$d segundos. Importar diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index afd008c20e..8f877c02d1 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -3407,6 +3407,7 @@ Звук Пропусни стартовото видео Използвай 0,1-секунден черен клип като стартовото видео на Steam. Влиза в сила при следващата сесия. + Разбъркване Собствено видео MP4, MOV, MKV или WebM. Други формати и файлове над %1$d MB се конвертират на устройството до WebM 720p, до %2$d секунди. Импортиране diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 0ac15fd477..6c66acabfd 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -3485,6 +3485,7 @@ Zvuk Přeskočit úvodní video Použije se 0,1sekundový černý klip jako úvodní video při spuštění aplikace Steam. Projeví se v příští relaci. + Náhodné pořadí Vlastní video MP4, MOV, MKV nebo WebM. Jiné formáty a soubory nad %1$d MB se v zařízení převedou na WebM 720p, nejvýše %2$d sekund. Importovat diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index eccc9c6b0b..d2f31b011e 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -3407,6 +3407,7 @@ Lyd Spring opstartsfilmen over Brug et sort klip på 0,1 sekund som opstartsfilm i Steam. Gælder fra næste session. + Bland Din egen video MP4, MOV, MKV eller WebM. Andre formater og filer over %1$d MB konverteres til 720p-WebM på enheden, op til %2$d sekunder. Importér diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 9869c65003..47dce20b4a 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -3407,6 +3407,7 @@ Ton Startvideo überspringen Ein schwarzes Video von 0,1 Sekunden als Steam-Startvideo verwenden. Gilt ab der nächsten Sitzung. + Zufallswiedergabe Eigenes Video MP4, MOV, MKV oder WebM. Andere Formate und Dateien über %1$d MB werden auf dem Gerät in 720p-WebM umgewandelt, bis %2$d Sekunden. Importieren diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 54913160a6..5870bfa94c 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -3407,6 +3407,7 @@ Ήχος Παράλειψη ταινίας εκκίνησης Χρησιμοποιεί ένα μαύρο κλιπ 0,1 δευτερολέπτου ως ταινία εκκίνησης του Steam. Εφαρμόζεται στην επόμενη συνεδρία. + Τυχαία σειρά Δικό σας βίντεο MP4, MOV, MKV ή WebM. Άλλες μορφές και αρχεία πάνω από %1$d MB μετατρέπονται στη συσκευή σε WebM 720p, έως %2$d δευτερόλεπτα. Εισαγωγή diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 67fa6e424c..454585bcbb 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -3446,6 +3446,7 @@ Sonido Omitir vídeo de inicio Usa un clip negro de 0,1 segundos como vídeo de inicio de Steam. Se aplicará en la próxima sesión. + Aleatorio Tu propio vídeo MP4, MOV, MKV o WebM. Otros formatos y archivos de más de %1$d MB se convierten a WebM 720p en el dispositivo, hasta %2$d segundos. Importar diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index 2e584762f1..3faed1bd20 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -3407,6 +3407,7 @@ Ääni Ohita käynnistysvideo Käytä 0,1 sekunnin mustaa leikettä Steam-käynnistysvideona. Otetaan käyttöön seuraavassa istunnossa. + Satunnainen Oma video MP4, MOV, MKV tai WebM. Muut muodot ja yli %1$d Mt:n tiedostot muunnetaan laitteella 720p-WebM-muotoon, enintään %2$d sekuntia. Tuo diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 6ab5302ef5..dca037ff9b 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -3445,6 +3445,7 @@ Son Ignorer la vidéo de démarrage Utilise un clip noir de 0,1 seconde comme vidéo de démarrage de Steam. S’applique à la prochaine session. + Aléatoire Votre propre vidéo MP4, MOV, MKV ou WebM. Les autres formats et les fichiers de plus de %1$d Mo sont convertis en WebM 720p sur l\'appareil, jusqu\'à %2$d secondes. Importer diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml index de9884c5d7..9acd2d7783 100644 --- a/app/src/main/res/values-hi/strings.xml +++ b/app/src/main/res/values-hi/strings.xml @@ -3407,6 +3407,7 @@ आवाज़ बूट मूवी छोड़ें Steam की स्टार्टअप मूवी के रूप में 0.1 सेकंड की काली क्लिप इस्तेमाल करें। अगले सत्र से लागू होगा। + शफ़ल अपना वीडियो MP4, MOV, MKV या WebM. दूसरे फ़ॉर्मैट और %1$d MB से बड़ी फ़ाइलें डिवाइस पर 720p WebM में बदली जाती हैं, %2$d सेकंड तक। इंपोर्ट करें diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 69cb0fb2b7..bf6abc003c 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -3407,6 +3407,7 @@ Hang Indítási videó kihagyása Egy 0,1 másodperces fekete klipet használ a Steam indítási videójaként. A következő munkamenetben lép érvénybe. + Véletlen sorrend Saját videó MP4, MOV, MKV vagy WebM. Más formátumokat és a %1$d MB-nál nagyobb fájlokat az eszköz 720p WebM-re alakítja, legfeljebb %2$d másodpercig. Importálás diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index 6a520f1553..bfefdf12c7 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -3378,6 +3378,7 @@ Suara Lewati video pembukaan Gunakan klip hitam berdurasi 0,1 detik sebagai video pembukaan Steam. Berlaku pada sesi berikutnya. + Acak Video sendiri MP4, MOV, MKV, atau WebM. Format lain dan file di atas %1$d MB dikonversi ke WebM 720p di perangkat, hingga %2$d detik. Impor diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index c91ccd8cd6..51a2ae045e 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -3445,6 +3445,7 @@ Audio Salta il video di avvio Usa una clip nera di 0,1 secondi come video di avvio di Steam. Dalla sessione successiva. + Casuale Il tuo video MP4, MOV, MKV o WebM. Altri formati e file oltre %1$d MB vengono convertiti in WebM 720p sul dispositivo, fino a %2$d secondi. Importa diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 421e2dd33a..ace99b72c0 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -3378,6 +3378,7 @@ サウンド 起動ムービーをスキップ 0.1 秒の黒いクリップを Steam の起動ムービーとして使用します。次回セッションから適用されます。 + シャッフル 自分のムービー MP4、MOV、MKV、WebM。その他の形式や %1$d MB を超えるファイルは、端末上で 720p の WebM に変換されます(%2$d 秒まで)。 インポート diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index e3ed581703..11fbb0f3ec 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -3378,6 +3378,7 @@ 소리 시작 동영상 건너뛰기 0.1초짜리 검은 화면 클립을 Steam 시작 동영상으로 사용합니다. 다음 세션부터 적용됩니다. + 셔플 내 동영상 MP4, MOV, MKV 또는 WebM. 다른 형식과 %1$d MB를 넘는 파일은 기기에서 720p WebM으로 변환됩니다(최대 %2$d초). 가져오기 diff --git a/app/src/main/res/values-ms/strings.xml b/app/src/main/res/values-ms/strings.xml index fef782c572..b781198eb9 100644 --- a/app/src/main/res/values-ms/strings.xml +++ b/app/src/main/res/values-ms/strings.xml @@ -3378,6 +3378,7 @@ Bunyi Langkau filem permulaan Gunakan klip hitam 0.1 saat sebagai filem permulaan Steam. Berkuat kuasa pada sesi seterusnya. + Rawak Video anda sendiri MP4, MOV, MKV atau WebM. Format lain dan fail melebihi %1$d MB ditukar kepada WebM 720p pada peranti, sehingga %2$d saat. Import diff --git a/app/src/main/res/values-nb/strings.xml b/app/src/main/res/values-nb/strings.xml index 48ed0b2288..ff8ee92cac 100644 --- a/app/src/main/res/values-nb/strings.xml +++ b/app/src/main/res/values-nb/strings.xml @@ -3407,6 +3407,7 @@ Lyd Hopp over oppstartsfilmen Bruk et svart klipp på 0,1 sekunder som oppstartsfilmen til Steam. Trer i kraft neste økt. + Tilfeldig rekkefølge Din egen video MP4, MOV, MKV eller WebM. Andre formater og filer over %1$d MB konverteres til 720p-WebM på enheten, opptil %2$d sekunder. Importer diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 55ae1e7d32..e95fd9a735 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -3407,6 +3407,7 @@ Geluid Opstartvideo overslaan Gebruik een zwart fragment van 0,1 seconde als opstartvideo van Steam. Wordt toegepast in de volgende sessie. + Willekeurig Eigen video MP4, MOV, MKV of WebM. Andere formaten en bestanden boven %1$d MB worden op het apparaat omgezet naar 720p-WebM, tot %2$d seconden. Importeren diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index a4f57aaace..b5537449ab 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -3485,6 +3485,7 @@ Dźwięk Pomiń film startowy Użyj 0,1-sekundowego czarnego klipu jako filmu startowego Steam. Zacznie obowiązywać w następnej sesji. + Losowo Własny film MP4, MOV, MKV lub WebM. Inne formaty i pliki powyżej %1$d MB są konwertowane na urządzeniu do WebM 720p, do %2$d sekund. Importuj diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 97cffb7dec..b07045dcbd 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -3445,6 +3445,7 @@ Som Ignorar o vídeo de arranque Utilizar um clipe preto de 0,1 segundos como vídeo de arranque do Steam. Aplica-se na próxima sessão. + Aleatório O seu próprio vídeo MP4, MOV, MKV ou WebM. Outros formatos e ficheiros acima de %1$d MB são convertidos para WebM 720p no dispositivo, até %2$d segundos. Importar diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 84db6c1161..988e258cbe 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -3453,6 +3453,7 @@ Som Pular vídeo de inicialização Use um clipe preto de 0,1 segundo como vídeo de inicialização do Steam. Aplica-se na próxima sessão. + Aleatório Seu próprio vídeo MP4, MOV, MKV ou WebM. Outros formatos e arquivos acima de %1$d MB são convertidos para WebM 720p no aparelho, até %2$d segundos. Importar diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index 545eec1d84..032e628dde 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -3446,6 +3446,7 @@ Sunet Omite filmul de pornire Folosește un clip negru de 0,1 secunde ca film de pornire pentru Steam. Se aplică la următoarea sesiune. + Aleatoriu Videoclipul tău MP4, MOV, MKV sau WebM. Alte formate și fișierele de peste %1$d MB sunt convertite pe dispozitiv în WebM 720p, până la %2$d secunde. Importă diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 931b0b4a7d..476efea4e9 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -3485,6 +3485,7 @@ Звук Пропускать стартовое видео Использовать 0,1-секундный чёрный клип в качестве стартового видео Steam. Применится в следующем сеансе. + Случайный порядок Своё видео MP4, MOV, MKV или WebM. Другие форматы и файлы больше %1$d МБ преобразуются на устройстве в WebM 720p, до %2$d секунд. Импорт diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 8292ce86b8..0c9addcde5 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -3407,6 +3407,7 @@ Ljud Hoppa över uppstartsfilmen Använd ett svart klipp på 0,1 sekunder som uppstartsfilm för Steam. Tillämpas nästa session. + Blanda Egen video MP4, MOV, MKV eller WebM. Andra format och filer över %1$d MB konverteras till 720p-WebM på enheten, upp till %2$d sekunder. Importera diff --git a/app/src/main/res/values-th/strings.xml b/app/src/main/res/values-th/strings.xml index 90e8a3dd1f..9c936f699b 100644 --- a/app/src/main/res/values-th/strings.xml +++ b/app/src/main/res/values-th/strings.xml @@ -3378,6 +3378,7 @@ เสียง ข้ามวิดีโอเริ่มต้น ใช้คลิปสีดำความยาว 0.1 วินาทีเป็นวิดีโอเริ่มต้นของ Steam มีผลในเซสชันถัดไป + สุ่ม วิดีโอของคุณเอง MP4, MOV, MKV หรือ WebM รูปแบบอื่นและไฟล์ที่ใหญ่กว่า %1$d MB จะถูกแปลงเป็น WebM 720p บนอุปกรณ์ ความยาวไม่เกิน %2$d วินาที นำเข้า diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index e3693cf086..1ba6ea683d 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -3407,6 +3407,7 @@ Ses Açılış videosunu atla Steam\'in açılış videosu olarak 0,1 saniyelik siyah bir klip kullanılır. Sonraki oturumda geçerli olur. + Karıştır Kendi videon MP4, MOV, MKV veya WebM. Diğer biçimler ve %1$d MB üzeri dosyalar cihazda 720p WebM\'e dönüştürülür, en fazla %2$d saniye. İçe aktar diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 574c5efa39..699d176341 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -3485,6 +3485,7 @@ Звук Пропускати відео запуску Використовувати 0,1-секундний чорний кліп як вступне відео Steam. Застосовується з наступного сеансу. + Випадковий порядок Власне відео MP4, MOV, MKV або WebM. Інші формати й файли понад %1$d МБ перетворюються на пристрої на WebM 720p, до %2$d секунд. Імпорт diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index 1dafadd49c..284e5c94a1 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -3378,6 +3378,7 @@ Âm thanh Bỏ qua phim khởi động Dùng đoạn clip đen 0,1 giây làm phim khởi động của Steam. Áp dụng trong phiên chạy tiếp theo. + Ngẫu nhiên Video của bạn MP4, MOV, MKV hoặc WebM. Định dạng khác và tệp trên %1$d MB được chuyển sang WebM 720p ngay trên thiết bị, tối đa %2$d giây. Nhập diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 33cf0f8134..e2f20e1e19 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -3378,6 +3378,7 @@ 声音 跳过启动影片 用一段 0.1 秒的黑色片段作为 Steam 的启动影片。下次会话生效。 + 随机播放 自定义视频 MP4、MOV、MKV 或 WebM。其他格式及超过 %1$d MB 的文件会在设备上转换为 720p WebM,最长 %2$d 秒。 导入 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 74a6608b3a..978f3efc83 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -3375,6 +3375,7 @@ 聲音 跳過啟動影片 以 0.1 秒全黑片段作為 Steam 的啟動影片。下次工作階段生效。 + 隨機播放 自訂影片 MP4、MOV、MKV 或 WebM。其他格式及超過 %1$d MB 的檔案會在裝置上轉換為 720p WebM,最長 %2$d 秒。 匯入 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index f8b1849135..8c733aa7d8 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -3375,6 +3375,7 @@ 聲音 跳過啟動影片 使用 0.1 秒的黑色影片片段作為 Steam 的啟動影片。將於下次工作階段生效。 + 隨機播放 自訂影片 MP4、MOV、MKV 或 WebM。其他格式及超過 %1$d MB 的檔案會在裝置上轉換為 720p WebM,最長 %2$d 秒。 匯入 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 744552732c..dc002069e4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -3621,6 +3621,7 @@ Sound Skip boot movie Use a 0.1-second black clip as Steam’s startup movie. Applies next session. + Shuffle Your own movie MP4, MOV, MKV or WebM. Other formats and files over %1$d MB are converted to 720p WebM on the device, up to %2$d seconds. Import diff --git a/app/src/test/java/com/droiddeck/launcher/session/BootMovieTest.kt b/app/src/test/java/com/droiddeck/launcher/session/BootMovieTest.kt index 5518870e30..4ccff003e1 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/BootMovieTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/BootMovieTest.kt @@ -94,6 +94,7 @@ class BootMovieTest { @Test fun resetCoversTheChoiceButNotTheImportedName() { assertTrue(SettingsReset.isSessionSetting("bootMovie")) assertTrue(SettingsReset.isSessionSetting("bootMovieSound")) + assertTrue(SettingsReset.isSessionSetting("bootMovieShuffle")) assertFalse(SettingsReset.isSessionSetting("bootMovieCustomName")) } } diff --git a/app/src/test/java/com/droiddeck/launcher/session/StartupMovieConfigTest.kt b/app/src/test/java/com/droiddeck/launcher/session/StartupMovieConfigTest.kt index c14fc02310..7c6f57094c 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/StartupMovieConfigTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/StartupMovieConfigTest.kt @@ -63,4 +63,140 @@ class StartupMovieConfigTest { assertTrue(SessionFiles.resetMissingStartupMovie(file, false)) assertNull(SessionFiles.startupMoviePath(file)) } + + @Test fun shuffleIsWrittenIntoBothMovieSectionsAndReadBack() { + val file = config(SessionFiles.BOOT_MOVIE_PATH, "0", SessionFiles.BOOT_MOVIE_PATH) + assertEquals(false, SessionFiles.startupMovieShuffle(file)) + assertTrue(SessionFiles.setStartupMovieShuffle(file, true)) + assertEquals(true, SessionFiles.startupMovieShuffle(file)) + assertEquals(2, Regex("\"Shuffle\"\\s+\"1\"").findAll(file.readText()).count()) + assertEquals(SessionFiles.BOOT_MOVIE_PATH, SessionFiles.startupMoviePath(file)) + } + + @Test fun turningShuffleOffKeepsTheSelectedMovie() { + val file = config(SessionFiles.BOOT_MOVIE_PATH, "0", "/uioverrides/movies/Undertale.webm") + SessionFiles.setStartupMovieShuffle(file, true) + assertTrue(SessionFiles.setStartupMovieShuffle(file, false)) + assertEquals(false, SessionFiles.startupMovieShuffle(file)) + assertEquals("/uioverrides/movies/Undertale.webm", SessionFiles.startupMoviePath(file)) + } + + @Test fun shuffleOffLeavesAConfigWithoutTheKeyUntouched() { + val file = config(SessionFiles.BOOT_MOVIE_PATH, "0", SessionFiles.BOOT_MOVIE_PATH) + val before = file.readText() + assertTrue(SessionFiles.setStartupMovieShuffle(file, false)) + assertEquals(before, file.readText()) + } + + @Test fun shuffleDoesNotChangeOtherProgramSettings() { + val file = config(SessionFiles.BOOT_MOVIE_PATH, "0", SessionFiles.BOOT_MOVIE_PATH) + val text = file.readText().replace( + "\t\t\t}\n\t\t}\n\t}\n", + "\t\t\t}\n\t\t}\n\t\t\"OtherProgram\"\n\t\t{\n\t\t\t\"Shuffle\"\t\t\"0\"\n\t\t}\n\t}\n", + ) + file.writeText(text) + assertTrue(SessionFiles.setStartupMovieShuffle(file, true)) + val updated = file.readText() + assertEquals(2, Regex("\"Shuffle\"\\s+\"1\"").findAll(updated).count()) + assertEquals(1, Regex("\"Shuffle\"\\s+\"0\"").findAll(updated).count()) + } + + @Test fun shuffleIsNotAddedWhenThereIsNoMovieSection() { + val file = folder.newFile().also { it.writeText("\"InstallConfigStore\"\n{\n}\n") } + val before = file.readText() + assertTrue(SessionFiles.setStartupMovieShuffle(file, true)) + assertEquals(before, file.readText()) + assertEquals(false, SessionFiles.startupMovieShuffle(file)) + } + + @Test fun aShuffleChangedInSteamIsTakenOverAndOtherwiseTheChoiceIsKept() { + val app = org.robolectric.RuntimeEnvironment.getApplication() + app.getSharedPreferences("session", android.content.Context.MODE_PRIVATE).edit().clear().commit() + val file = config(SessionFiles.BOOT_MOVIE_PATH, "0", SessionFiles.BOOT_MOVIE_PATH) + BootMovie.syncShuffleFromSteam(app, file) + assertFalse(SessionPrefs.bootMovieShuffle(app)) + SessionPrefs.setBootMovieShuffle(app, true) + BootMovie.syncShuffleFromSteam(app, file) + assertTrue(SessionPrefs.bootMovieShuffle(app)) + SessionFiles.setStartupMovieShuffle(file, true) + BootMovie.syncShuffleFromSteam(app, file) + SessionFiles.setStartupMovieShuffle(file, false) + BootMovie.syncShuffleFromSteam(app, file) + assertFalse(SessionPrefs.bootMovieShuffle(app)) + } + + @Test fun anUnreadableConfigKeepsTheSavedShuffleChoice() { + val app = org.robolectric.RuntimeEnvironment.getApplication() + app.getSharedPreferences("session", android.content.Context.MODE_PRIVATE).edit().clear().commit() + val file = config(SessionFiles.BOOT_MOVIE_PATH, "0", SessionFiles.BOOT_MOVIE_PATH) + SessionPrefs.setBootMovieShuffle(app, true) + SessionPrefs.setBootMovieShuffleSeen(app, file, true) + val missing = File(folder.root, "missing.vdf") + assertNull(SessionFiles.startupMovieShuffle(missing)) + BootMovie.syncShuffleFromSteam(app, missing) + assertTrue(SessionPrefs.bootMovieShuffle(app)) + assertEquals(true, SessionPrefs.bootMovieShuffleSeen(app, file)) + } + + @Test fun resetLeavesShuffleOffEvenWhenSteamStillHasItOn() { + val app = org.robolectric.RuntimeEnvironment.getApplication() + app.getSharedPreferences("session", android.content.Context.MODE_PRIVATE).edit().clear().commit() + val file = config(SessionFiles.BOOT_MOVIE_PATH, "0", SessionFiles.BOOT_MOVIE_PATH) + SessionFiles.setStartupMovieShuffle(file, true) + SessionPrefs.setBootMovieShuffle(app, true) + BootMovie.syncShuffleFromSteam(app, file) + assertFalse(SettingsReset.isSessionSetting("bootMovieShuffleSeen:${file.path}")) + app.getSharedPreferences("session", android.content.Context.MODE_PRIVATE).edit().remove("bootMovieShuffle").commit() + BootMovie.syncShuffleFromSteam(app, file) + assertFalse(SessionPrefs.bootMovieShuffle(app)) + } + + @Test fun eachSteamHomeKeepsItsOwnShuffleBaseline() { + val app = org.robolectric.RuntimeEnvironment.getApplication() + app.getSharedPreferences("session", android.content.Context.MODE_PRIVATE).edit().clear().commit() + val arm = config(SessionFiles.BOOT_MOVIE_PATH, "0", SessionFiles.BOOT_MOVIE_PATH) + val x64 = config(SessionFiles.BOOT_MOVIE_PATH, "0", SessionFiles.BOOT_MOVIE_PATH) + BootMovie.syncShuffleFromSteam(app, arm) + BootMovie.syncShuffleFromSteam(app, x64) + SessionFiles.setStartupMovieShuffle(arm, true) + BootMovie.syncShuffleFromSteam(app, arm) + assertTrue(SessionPrefs.bootMovieShuffle(app)) + BootMovie.syncShuffleFromSteam(app, x64) + assertTrue(SessionPrefs.bootMovieShuffle(app)) + } + + @Test fun aShuffleChangedInAnInactiveSteamHomeIsTakenOverBeforeTheActiveHome() { + val app = org.robolectric.RuntimeEnvironment.getApplication() + app.getSharedPreferences("session", android.content.Context.MODE_PRIVATE).edit().clear().commit() + val inactive = config(SessionFiles.BOOT_MOVIE_PATH, "0", SessionFiles.BOOT_MOVIE_PATH) + val active = config(SessionFiles.BOOT_MOVIE_PATH, "0", SessionFiles.BOOT_MOVIE_PATH) + BootMovie.syncShuffleFromSteam(app, listOf(inactive, active)) + SessionFiles.setStartupMovieShuffle(inactive, true) + BootMovie.syncShuffleFromSteam(app, listOf(inactive, active)) + assertTrue(SessionPrefs.bootMovieShuffle(app)) + } + + @Test fun aChangeInAnInactiveHomeIsNotUndoneByAnActiveHomeReadForTheFirstTime() { + val app = org.robolectric.RuntimeEnvironment.getApplication() + app.getSharedPreferences("session", android.content.Context.MODE_PRIVATE).edit().clear().commit() + val inactive = config(SessionFiles.BOOT_MOVIE_PATH, "0", SessionFiles.BOOT_MOVIE_PATH) + val active = File(folder.root, "unreadable.vdf") + BootMovie.syncShuffleFromSteam(app, listOf(inactive, active)) + SessionFiles.setStartupMovieShuffle(inactive, true) + active.writeText(inactive.readText()) + SessionFiles.setStartupMovieShuffle(active, false) + BootMovie.syncShuffleFromSteam(app, listOf(inactive, active)) + assertTrue(SessionPrefs.bootMovieShuffle(app)) + assertEquals(false, SessionPrefs.bootMovieShuffleSeen(app, active)) + } + + @Test fun aShuffleLineWithATrailingCommentIsReplacedNotDuplicated() { + val file = config(SessionFiles.BOOT_MOVIE_PATH, "0", SessionFiles.BOOT_MOVIE_PATH) + file.writeText(file.readText().replace("\t\t\t\"LocalPath\"", "\t\t\t\"Shuffle\"\t\t\"1\" // set in Steam\n\t\t\t\"LocalPath\"")) + assertEquals(true, SessionFiles.startupMovieShuffle(file)) + assertTrue(SessionFiles.setStartupMovieShuffle(file, false)) + assertEquals(false, SessionFiles.startupMovieShuffle(file)) + assertEquals(1, Regex("\"Shuffle\"").findAll(file.readText().substringAfter("Customization")).count()) + assertTrue(file.readText().contains("\"0\" // set in Steam")) + } } diff --git a/docs/development/boot-movies.md b/docs/development/boot-movies.md index 1fa2dd04b3..7cb03ce5bb 100644 --- a/docs/development/boot-movies.md +++ b/docs/development/boot-movies.md @@ -4,7 +4,9 @@ Settings → Boot movie has four tabs. - **Installed**: "Browse" lists every movie Steam can play: DroidDeck's two, plus every `.webm` in Steam's `config/uioverrides/movies` folder (imported, installed from SteamDeckRepo, or put there by Steam). The list is re-read - every two seconds, so a movie picked or removed inside Steam shows up, and a movie picked inside Steam becomes the choice. + every two seconds, so a movie picked or removed inside Steam shows up, and a movie picked inside Steam becomes the choice. The Shuffle switch is Steam's own `Shuffle` setting (`startup_movie_shuffle` in + Steam's client settings, `Shuffle` next to `MovieID` and `LocalPath`): it is written at the next session start, a change made in Steam is + taken over, and with it off the selected movie plays as before. - **Import**: the same importer as before (copy, remux or on-device transcode to VP8/Opus). The result is written into Steam's movies folder, so Steam lists it as well. - **SteamDeckRepo**: browses `https://steamdeckrepo.com/api/posts` (`sort`, `device`, `search`, `page`; 12 posts a page).