From 6b646de9e3a073c9f7852da0bb1a1ae60ef51a7e Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Sun, 4 Oct 2026 22:49:09 -0400 Subject: [PATCH] l10n: localize the remaining UI text (#212) Text that still reached the screen in English because its function had no Context now comes from resources: the child-process limit's titles and instructions, the update blocks and install failures, game save and storage errors, game file export errors, component package errors, the GPU's support line, family and unnamed fallback, and the driver source tags. The setting choice lists and screen effect Looks use their localized labels, the second library menu is built from separate resources instead of splitting a label at its separators, and an account without a name gets whole sentences rather than a stand-in name. The device report keeps its English text. --- .../com/droiddeck/launcher/DriverMenus.kt | 4 +- .../com/droiddeck/launcher/MainActivity.kt | 27 +++---- .../com/droiddeck/launcher/UpdatesMenu.kt | 4 +- .../droiddeck/launcher/core/DeviceSupport.kt | 6 +- .../launcher/core/PhantomProcessLimit.kt | 38 +++++----- .../launcher/frontend/GameFileSync.kt | 2 +- .../droiddeck/launcher/frontend/GameFiles.kt | 39 +++++----- .../com/droiddeck/launcher/gpu/GpuInfo.kt | 8 ++- .../launcher/session/ComponentsManager.kt | 30 ++++---- .../droiddeck/launcher/session/GameSaves.kt | 25 ++++--- .../droiddeck/launcher/session/GameStorage.kt | 17 ++--- .../droiddeck/launcher/session/OfflineMode.kt | 5 +- .../launcher/session/SessionService.kt | 2 +- .../com/droiddeck/launcher/ui/DriverPage.kt | 2 +- .../droiddeck/launcher/ui/FrontEndScreen.kt | 6 +- .../droiddeck/launcher/ui/FrontEndSetup.kt | 22 +++--- .../droiddeck/launcher/ui/GpuDriversPanel.kt | 2 +- .../launcher/ui/ModeSettingsDialog.kt | 48 +++++++++---- .../launcher/ui/PhantomProcessGatePage.kt | 2 +- .../droiddeck/launcher/ui/SessionOverlay.kt | 12 ++-- .../com/droiddeck/launcher/ui/UpdatesPage.kt | 2 +- .../droiddeck/launcher/update/AppUpdates.kt | 24 ++++--- .../launcher/update/SelfInstaller.kt | 13 ++-- app/src/main/res/values/strings.xml | 72 +++++++++++++++++++ .../launcher/frontend/GameFilesTest.kt | 35 ++++----- 25 files changed, 285 insertions(+), 162 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/DriverMenus.kt b/app/src/main/java/com/droiddeck/launcher/DriverMenus.kt index 3fe26735f..ababdc230 100644 --- a/app/src/main/java/com/droiddeck/launcher/DriverMenus.kt +++ b/app/src/main/java/com/droiddeck/launcher/DriverMenus.kt @@ -58,7 +58,7 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl private var autoCheckedThisProcess = false fun state() = GpuDriversState( - gpuName = gpu.name, gpuFamily = gpu.family.label, soc = gpu.soc, supportText = gpu.supportText, + gpuName = gpu.displayName(activity), gpuFamily = gpu.family.label(activity), soc = gpu.soc, supportText = gpu.supportText(activity), supported = gpu.support == GpuInfo.Support.TESTED, unsupported = gpu.support == GpuInfo.Support.UNSUPPORTED, auto = mode == SessionPrefs.GPU_DRIVERS_AUTO, pairs = pairRows, busy = pairBusy, percent = pairPercent, autoStatus = autoStatus, releaseStatus = releaseStatus.ifEmpty { activity.getString(R.string.drivers_not_checked) }, checking = releaseChecking, @@ -155,7 +155,7 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl if (!force && autoCheckedThisProcess) return autoCheckedThisProcess = true if (DriverPairs.recommendedKey(gpu, emptyList()) == null) { - autoStatus = activity.getString(R.string.drivers_none_to_set, gpu.supportText.lowercase()) + autoStatus = activity.getString(R.string.drivers_none_to_set, gpu.supportText(activity).lowercase()) return } releaseChecking = true diff --git a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt b/app/src/main/java/com/droiddeck/launcher/MainActivity.kt index 713e86233..15e3a0ecc 100644 --- a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/MainActivity.kt @@ -261,8 +261,8 @@ class MainActivity : ComponentActivity() { } onSavePicked = { zip -> saveAction(getString(R.string.main_saves_importing, name)) { - val (written, backup) = GameSaves.import(game(), zip) - val kind = GameSaves.layoutOf(zip)?.label ?: "zip" + val (written, backup) = GameSaves.import(this, game(), zip) + val kind = GameSaves.layoutOf(zip)?.label(this) ?: getString(R.string.saves_zip) resources.getQuantityString( if (backup != null) R.plurals.main_saves_imported_backup else R.plurals.main_saves_imported, written, written, kind, name, @@ -276,12 +276,12 @@ class MainActivity : ComponentActivity() { private fun exportSaves(name: String, layout: GameSaves.Layout, game: () -> GameSaves.Game) { onSavePicked = { dir -> saveAction(getString(R.string.main_saves_exporting, name)) { - val (zip, count) = GameSaves.export(game(), layout, dir) - resources.getQuantityString(R.plurals.main_saves_exported, count, count, layout.label, zip.path.removePrefix("/storage/emulated/0/")) + val (zip, count) = GameSaves.export(this, game(), layout, dir) + resources.getQuantityString(R.plurals.main_saves_exported, count, count, layout.label(this), zip.path.removePrefix("/storage/emulated/0/")) } } GameSaves.savesDir().mkdirs() - pickSaveDir.launch(InAppFilePicker.buildDirIntent(this, getString(R.string.main_saves_pick_folder, name, layout.label), GameSaves.savesDir().path)) + pickSaveDir.launch(InAppFilePicker.buildDirIntent(this, getString(R.string.main_saves_pick_folder, name, layout.label(this)), GameSaves.savesDir().path)) } private val pickAddedGamesDir = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { r -> if (r.resultCode == RESULT_OK) InAppFilePicker.pickedPath(r.data)?.let { path -> @@ -333,7 +333,7 @@ class MainActivity : ComponentActivity() { private var renderer by mutableStateOf("vulkan") private var gameStorage by mutableStateOf("") private var storageDiagnostics by mutableStateOf(false) - private var storageOptions by mutableStateOf>>(emptyList()) + private var storageOptions by mutableStateOf>(emptyList()) private val pickGameStorage = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { r -> if (r.resultCode == RESULT_OK) InAppFilePicker.pickedPath(r.data)?.let { path -> setGameStorage(path, GameStorage.labelFor(this, path)) } } @@ -408,7 +408,7 @@ class MainActivity : ComponentActivity() { private fun pickGameExport(game: Library.SteamGame?) { onSavePicked = { folder -> saveAction(getString(R.string.game_frontend_files)) { - if (game != null) com.droiddeck.launcher.frontend.GameFiles.export(folder, game) + if (game != null) com.droiddeck.launcher.frontend.GameFiles.export(this, folder, game) else com.droiddeck.launcher.frontend.GameFileSync.enable(this, folder) ui.post { gameSyncFolder = com.droiddeck.launcher.frontend.GameFileSync.folder(this) } getString(R.string.game_file_exported, folder.path) @@ -724,7 +724,7 @@ class MainActivity : ComponentActivity() { }, onCopyPhantomCommand = { enabled -> (getSystemService(CLIPBOARD_SERVICE) as ClipboardManager).setPrimaryClip( - ClipData.newPlainText("DroidDeck child-process setting", PhantomProcessLimit.adbCommand(enabled)), + ClipData.newPlainText(getString(R.string.main_adb_clip_label), PhantomProcessLimit.adbCommand(enabled)), ) android.widget.Toast.makeText(this, R.string.main_adb_copied, android.widget.Toast.LENGTH_SHORT).show() }, @@ -768,7 +768,7 @@ class MainActivity : ComponentActivity() { showNonAdreno?.let { release -> ConfirmDialog( title = androidx.compose.ui.res.stringResource(R.string.main_non_adreno_title), - text = androidx.compose.ui.res.stringResource(R.string.main_non_adreno_text, com.droiddeck.launcher.core.DeviceSupport.gpuName(), release.size / 1e6), + text = androidx.compose.ui.res.stringResource(R.string.main_non_adreno_text, com.droiddeck.launcher.core.DeviceSupport.gpuName(this@MainActivity), release.size / 1e6), confirm = androidx.compose.ui.res.stringResource(R.string.main_install_anyway), onConfirm = { showNonAdreno = null; install(release) }, onDismiss = { showNonAdreno = null }, @@ -1393,7 +1393,7 @@ class MainActivity : ComponentActivity() { Thread({ drivers.refreshDrivers() val games = scanAddedGames() - val storage = GameStorage.options(this).map { it.label to it.path } + val storage = GameStorage.options(this) val deckyInstalled = if (mode == SessionService.MODE_STEAM) DeckyManager.installed(this) else null val deckySupervisor = mode == SessionService.MODE_STEAM && DeckyManager.supervisorEnabled(this) ui.post { @@ -1412,7 +1412,7 @@ class MainActivity : ComponentActivity() { /** A second Steam library, proven writable first; "" = internal only. */ private fun setGameStorage(path: String, label: String) { if (path.isNotEmpty() && path != SessionPrefs.GAME_STORAGE_OFF) { - val problem = GameStorage.prepare(path) + val problem = GameStorage.prepare(this, path) if (problem != null) { android.widget.Toast.makeText(this, getString(R.string.main_storage_not_usable, problem), android.widget.Toast.LENGTH_LONG).show() return @@ -1525,7 +1525,10 @@ class MainActivity : ComponentActivity() { private fun refreshPhantomStatus() { phantomProcessStatus = PhantomProcessLimit.read(this) phantomWarning = if (PhantomProcessLimit.blocksSteam(phantomProcessStatus)) { - "${PhantomProcessLimit.title(phantomProcessStatus)}. ${PhantomProcessLimit.instructions(phantomProcessStatus)}\n\n${PhantomProcessLimit.adbCommand()}" + getString( + R.string.phantom_warning, PhantomProcessLimit.title(this, phantomProcessStatus), + PhantomProcessLimit.instructions(this, phantomProcessStatus), PhantomProcessLimit.adbCommand(), + ) } else null } diff --git a/app/src/main/java/com/droiddeck/launcher/UpdatesMenu.kt b/app/src/main/java/com/droiddeck/launcher/UpdatesMenu.kt index f0b975fc9..a55ac1930 100644 --- a/app/src/main/java/com/droiddeck/launcher/UpdatesMenu.kt +++ b/app/src/main/java/com/droiddeck/launcher/UpdatesMenu.kt @@ -91,7 +91,7 @@ internal class UpdatesMenu(private val activity: Activity, private val ui: Handl private fun install(r: AppUpdates.Release) { if (stage != null) return val apk = r.apk ?: run { error = activity.getString(R.string.upd_no_download); return } - AppUpdates.installBlock(r)?.let { error = it; return } + AppUpdates.installBlock(r)?.let { error = it.message(activity); return } if (SessionState.running) { error = activity.getString(R.string.upd_stop_first); return } if (!SelfInstaller.canInstall(activity)) { pending = r; askPermission = true; return } error = null @@ -121,7 +121,7 @@ internal class UpdatesMenu(private val activity: Activity, private val ui: Handl PackageInstaller.STATUS_SUCCESS -> stage = null else -> { stage = null - error = SelfInstaller.describeFailure(status, intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE)) + error = SelfInstaller.describeFailure(activity, status, intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE)) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/core/DeviceSupport.kt b/app/src/main/java/com/droiddeck/launcher/core/DeviceSupport.kt index 179628e0a..4170d69f1 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/DeviceSupport.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/DeviceSupport.kt @@ -1,6 +1,8 @@ package com.droiddeck.launcher.core +import android.content.Context import android.os.Build +import com.droiddeck.launcher.R import java.io.File /** @@ -17,8 +19,8 @@ object DeviceSupport { File("/sys/class/kgsl/kgsl-3d0").exists() || File("/vendor/lib64/hw/vulkan.adreno.so").exists() /** The chip as the device names it, for the card that explains the refusal. */ - fun gpuName(): String { + fun gpuName(context: Context): String { val soc = if (Build.VERSION.SDK_INT >= 31) Build.SOC_MODEL.takeIf { it.isNotBlank() && it != Build.UNKNOWN } else null - return soc?.let { "$it (${Build.HARDWARE})" } ?: Build.HARDWARE.ifBlank { "this GPU" } + return soc?.let { "$it (${Build.HARDWARE})" } ?: Build.HARDWARE.ifBlank { context.getString(R.string.gpu_this_gpu) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/core/PhantomProcessLimit.kt b/app/src/main/java/com/droiddeck/launcher/core/PhantomProcessLimit.kt index 4155a29dd..6a39746b7 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/PhantomProcessLimit.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/PhantomProcessLimit.kt @@ -3,6 +3,7 @@ package com.droiddeck.launcher.core import android.content.Context import android.os.Build import android.provider.Settings +import com.droiddeck.launcher.R /** Android's phantom process monitor can kill the many child processes used by a Steam session. */ enum class PhantomProcessStatus { @@ -98,29 +99,30 @@ object PhantomProcessLimit { fun blocksSteam(status: PhantomProcessStatus): Boolean = status != PhantomProcessStatus.NOT_APPLICABLE && status != PhantomProcessStatus.DISABLED - fun title(status: PhantomProcessStatus): String = when (status) { - PhantomProcessStatus.ENABLED -> "Child-process limit is on" - PhantomProcessStatus.UNSET -> "Child-process limit is unset" - PhantomProcessStatus.UNREADABLE -> "Child-process limit could not be checked" - PhantomProcessStatus.DISABLED -> "Child-process limit is off" - PhantomProcessStatus.NOT_APPLICABLE -> "Child-process limit not required" + fun title(context: Context, status: PhantomProcessStatus): String = context.getString(when (status) { + PhantomProcessStatus.ENABLED -> R.string.phantom_title_on + PhantomProcessStatus.UNSET -> R.string.phantom_title_unset + PhantomProcessStatus.UNREADABLE -> R.string.phantom_title_unreadable + PhantomProcessStatus.DISABLED -> R.string.phantom_title_off + PhantomProcessStatus.NOT_APPLICABLE -> R.string.phantom_title_not_required + }) + + fun instructions(context: Context, status: PhantomProcessStatus): String = when (status) { + PhantomProcessStatus.ENABLED, PhantomProcessStatus.UNSET, PhantomProcessStatus.UNREADABLE -> + context.getString(R.string.phantom_instructions_fix, fixSentence(context)) + PhantomProcessStatus.DISABLED -> context.getString(R.string.phantom_instructions_off) + PhantomProcessStatus.NOT_APPLICABLE -> context.getString(R.string.phantom_instructions_not_applicable) } - fun instructions(status: PhantomProcessStatus): String = when (status) { - PhantomProcessStatus.ENABLED, PhantomProcessStatus.UNSET, PhantomProcessStatus.UNREADABLE -> fixSentence() + " If that is not possible, connect this device to a computer with ADB and run the command below. Return here and check again." - PhantomProcessStatus.DISABLED -> "Steam sessions can start." - PhantomProcessStatus.NOT_APPLICABLE -> "This Android version does not use this limit." + fun gateInstructions(context: Context, status: PhantomProcessStatus): String = when (status) { + PhantomProcessStatus.ENABLED, PhantomProcessStatus.UNSET, PhantomProcessStatus.UNREADABLE -> fixSentence(context) + else -> instructions(context, status) } - fun gateInstructions(status: PhantomProcessStatus): String = when (status) { - PhantomProcessStatus.ENABLED, PhantomProcessStatus.UNSET, PhantomProcessStatus.UNREADABLE -> fixSentence() - else -> instructions(status) - } - - fun fixSentence(sdk: Int = Build.VERSION.SDK_INT): String = - if (hasDeveloperToggle(sdk)) "Turn on “Disable child process restrictions” in Developer options, and keep Developer options on afterwards." - else "This Android version has no switch for it. Use Wireless debugging to change it from this device." + fun fixSentence(context: Context, sdk: Int = Build.VERSION.SDK_INT): String = + context.getString(if (hasDeveloperToggle(sdk)) R.string.phantom_fix_toggle else R.string.phantom_fix_no_toggle) + /** English: for the device report. */ fun reportValue(status: PhantomProcessStatus): String = when (status) { PhantomProcessStatus.DISABLED -> "disabled (good - the OS will not kill the session's children)" PhantomProcessStatus.ENABLED -> "ENABLED (the OS may kill the session with no log; turn off Restrict child processes)" diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/GameFileSync.kt b/app/src/main/java/com/droiddeck/launcher/frontend/GameFileSync.kt index f7faf7587..5e79265f5 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/GameFileSync.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/GameFileSync.kt @@ -49,7 +49,7 @@ object GameFileSync { } storage?.let { check(File(it.path).listFiles() != null) { context.getString(R.string.game_sync_err_game_storage) } } SessionPrefs.addedGamesDirs(context).forEach { check(File(it).listFiles() != null) { context.getString(R.string.game_sync_err_added_games) } } - GameFiles.sync(folder, Library.launchableGames(context, strictRead = true)) + GameFiles.sync(context, folder, Library.launchableGames(context, strictRead = true)) prefs(context).edit().putString("storageSetting", storageSetting).putString("storagePath", storage?.path).apply() } } diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/GameFiles.kt b/app/src/main/java/com/droiddeck/launcher/frontend/GameFiles.kt index 58e58cd07..9df408aea 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/GameFiles.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/GameFiles.kt @@ -6,6 +6,7 @@ import android.util.AtomicFile import androidx.core.util.readText import androidx.core.util.writeBytes import androidx.core.util.writeText +import com.droiddeck.launcher.R import org.json.JSONObject import java.io.File import java.io.InputStream @@ -59,18 +60,18 @@ object GameFiles { private fun contents(id: String) = GameLaunchLink.uri(id) + "\n" - @Synchronized fun export(folder: File, game: Library.SteamGame): File { - require(folder.isDirectory) { "Folder is unavailable" } - val target = child(folder, filename(game)) + @Synchronized fun export(context: Context, folder: File, game: Library.SteamGame): File { + require(folder.isDirectory) { context.getString(R.string.gfiles_folder_unavailable) } + val target = child(context, folder, filename(game)) val text = contents(game.gameIdString) - require(!target.exists() || matches(target, text)) { "A different file already uses ${target.name}" } + require(!target.exists() || matches(target, text)) { context.getString(R.string.gfiles_name_taken, target.name) } if (!target.exists()) write(target, text) - exportArt(folder, game) + exportArt(context, folder, game) return target } /** Cocoon matches icons in its data folder's images directory. Never replace custom art. */ - private fun exportArt(folder: File, game: Library.SteamGame) { + private fun exportArt(context: Context, folder: File, game: Library.SteamGame) { val art = listOfNotNull(game.icon, game.art).firstOrNull { it.isFile && it.extension.lowercase() in listOf("jpg", "jpeg", "png", "webp") } ?: return @@ -79,27 +80,27 @@ object GameFiles { .replace(Regex("[^a-zA-Z0-9\\s]"), "").trim() .replace(Regex("\\s+"), "-").lowercase(java.util.Locale.ROOT).take(50).trimEnd('-') if (title.isEmpty()) return - val images = child(folder, "images") - check(images.isDirectory || images.mkdir()) { "Artwork folder is unavailable" } - val target = child(images, "$title-icon.${art.extension.lowercase()}") + val images = child(context, folder, "images") + check(images.isDirectory || images.mkdir()) { context.getString(R.string.gfiles_art_unavailable) } + val target = child(context, images, "$title-icon.${art.extension.lowercase()}") if (!target.exists()) AtomicFile(target).writeBytes(art.readBytes()) } /** Only remove files in our inventory whose content is still exactly what we wrote. */ - @Synchronized fun sync(folder: File, games: List) { - require(folder.isDirectory) { "Folder is unavailable" } - val inventory = child(folder, INVENTORY) + @Synchronized fun sync(context: Context, folder: File, games: List) { + require(folder.isDirectory) { context.getString(R.string.gfiles_folder_unavailable) } + val inventory = child(context, folder, INVENTORY) val previous = if (inventory.exists()) { val record = JSONObject(AtomicFile(inventory).readText()) - require(record.optString("format") == FORMAT) { "Folder has an unrelated sync inventory" } + require(record.optString("format") == FORMAT) { context.getString(R.string.gfiles_unrelated_inventory) } record.getJSONObject("games") } else JSONObject() val next = JSONObject() val exports = games.distinctBy { it.gameId }.map { game -> - val target = child(folder, filename(game)) + val target = child(context, folder, filename(game)) // Keep an edited export without letting it block the rest of the library sync. val file = if (previous.optString(target.name) == game.gameIdString && target.exists() && - !matches(target, contents(game.gameIdString))) target else export(folder, game) + !matches(target, contents(game.gameIdString))) target else export(context, folder, game) next.put(file.name, game.gameIdString) file } @@ -107,22 +108,22 @@ object GameFiles { for (name in previous.keys()) { val id = previous.getString(name) if (!next.has(name) && name.endsWith(".$EXTENSION") && GameLaunchLink.validId(id)) { - val file = child(folder, name) + val file = child(context, folder, name) if (matches(file, contents(id))) { // Android shared storage is often case insensitive. A case-only rename may // still resolve to the live export, which must not be pruned as an old file. val retained = exports.any { java.nio.file.Files.isSameFile(it.toPath(), file.toPath()) } - if (!retained) check(file.delete()) { "Could not remove $name" } + if (!retained) check(file.delete()) { context.getString(R.string.gfiles_remove_failed, name) } } } } if (previous.toString() != next.toString()) write(inventory, JSONObject().put("format", FORMAT).put("games", next).toString()) } - private fun child(folder: File, name: String): File { + private fun child(context: Context, folder: File, name: String): File { require(name.isNotEmpty() && '/' !in name && '\\' !in name && name != "." && name != "..") val file = File(folder, name) - require(file.canonicalFile.parentFile == folder.canonicalFile) { "File leaves the export folder" } + require(file.canonicalFile.parentFile == folder.canonicalFile) { context.getString(R.string.gfiles_outside_folder) } return file } diff --git a/app/src/main/java/com/droiddeck/launcher/gpu/GpuInfo.kt b/app/src/main/java/com/droiddeck/launcher/gpu/GpuInfo.kt index 4f90bdfb4..0f1cab9cb 100644 --- a/app/src/main/java/com/droiddeck/launcher/gpu/GpuInfo.kt +++ b/app/src/main/java/com/droiddeck/launcher/gpu/GpuInfo.kt @@ -63,7 +63,13 @@ data class GpuInfo( Support.UNSUPPORTED -> R.string.gpuinfo_unsupported }) + /** [name] for the screen: the stand-in for a GPU the device does not name is in the app's language. */ + fun displayName(context: Context): String = if (name == UNNAMED) context.getString(R.string.gpu_this_gpu) else name + companion object { + /** [name] when the device names no GPU; English, as the device report shows it. */ + private const val UNNAMED = "this GPU" + fun detect(): GpuInfo { val adreno = File("/sys/class/kgsl/kgsl-3d0").exists() || File("/vendor/lib64/hw/vulkan.adreno.so").exists() val raw = listOf("/sys/class/kgsl/kgsl-3d0/gpu_model", "/sys/class/kgsl/kgsl-3d0/gpu_chipid") @@ -73,7 +79,7 @@ data class GpuInfo( val family = familyOf(adreno, model) val samsung = Build.MANUFACTURER.equals("samsung", ignoreCase = true) return GpuInfo( - name = if (!adreno) Build.HARDWARE.ifBlank { "this GPU" } else if (model > 0) "Adreno $model" else "Adreno", + name = if (!adreno) Build.HARDWARE.ifBlank { UNNAMED } else if (model > 0) "Adreno $model" else "Adreno", model = model, family = family, soc = soc, oneUi8Gen2 = samsung && model == 740, ) diff --git a/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt b/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt index 04cf9e2d1..09d227b94 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt @@ -248,12 +248,13 @@ object ComponentsManager { Regex("\\(([^)]+)\\)").find(text)?.groupValues?.get(1) ?: text.split(Regex("\\s+")).last() }.getOrDefault("") - private fun fexVersion(dir: File): String { + /** The FEX build's version name; [unnamed] when its DLL carries none, "" when there is no FEX. */ + private fun fexVersion(dir: File, unnamed: String = "FEX (build without a version name)"): String { val dll = File(dir, FEX_FILES[0]) if (!dll.isFile) return "" val text = runCatching { String(dll.readBytes(), Charsets.ISO_8859_1) }.getOrDefault("") return Regex("FEX-\\d{4}(?:\\.\\d+)?(?:-\\d+-g[0-9a-f]{6,})?").findAll(text).map { it.value }.maxByOrNull { it.length } - ?: "FEX (build without a version name)" + ?: unnamed } private fun compFiles(dir: File, comp: String): List { @@ -274,23 +275,24 @@ object ComponentsManager { private inline fun readWcp(f: File, block: (TarArchiveInputStream) -> T): T = TarArchiveInputStream(ZstdInputStream(BufferedInputStream(FileInputStream(f), 1 shl 16))).use(block) - private fun readProfile(f: File): JSONObject = readWcp(f) { tar -> + private fun readProfile(context: Context, f: File): JSONObject = readWcp(f) { tar -> while (true) { val e = tar.nextTarEntry ?: break if (!e.isDirectory && normalize(e.name) == "profile.json") return@readWcp JSONObject(tar.readBytes().decodeToString()) } - throw IllegalArgumentException("no profile.json in ${f.name}") + throw IllegalArgumentException(context.getString(R.string.cmgr_no_profile, f.name)) } - private fun packageInfo(f: File): Package { - val prof = readProfile(f) - val comp = TYPES[prof.optString("type")] ?: throw IllegalArgumentException("${f.name} is not a Linux component package (type ${prof.optString("type")})") + private fun packageInfo(context: Context, f: File): Package { + val prof = readProfile(context, f) + val comp = TYPES[prof.optString("type")] + ?: throw IllegalArgumentException(context.getString(R.string.cmgr_not_component_package, f.name, prof.optString("type"))) return Package(f.name, comp, prof.optString("versionName", f.nameWithoutExtension), prof.optString("description"), f.length()) } fun packages(context: Context): List = packagesDir(context).listFiles() ?.filter { it.isFile && it.name.endsWith(".wcp") }?.sortedBy { it.name } - ?.mapNotNull { f -> runCatching { packageInfo(f) }.onFailure { Log.w(TAG, "skipping ${f.name}", it) }.getOrNull() } + ?.mapNotNull { f -> runCatching { packageInfo(context, f) }.onFailure { Log.w(TAG, "skipping ${f.name}", it) }.getOrNull() } ?: emptyList() /** Unpacks a package's files/ into a Proton; for DXVK/VKD3D the component's own DLLs are replaced as a set. */ @@ -363,7 +365,7 @@ object ComponentsManager { return versions.flatMap { v -> COMPONENTS.mapNotNull { comp -> val f = File(v, "$comp.wcp") - if (!f.isFile) null else Original(comp, v.name, runCatching { readProfile(f).optString("description") }.getOrDefault(""), f.length()) + if (!f.isFile) null else Original(comp, v.name, runCatching { readProfile(context, f).optString("description") }.getOrDefault(""), f.length()) } } } @@ -415,7 +417,7 @@ object ComponentsManager { val syncPacks = EsyncPacks.status(root(context)) val views = protons(context).map { p -> val comps = COMPONENTS.associateWith { comp -> - val detected = if (comp == "fex") fexVersion(p.dir) else readVersionFile(File(p.dir, "${COMP_DIR.getValue(comp)}/version")) + val detected = if (comp == "fex") fexVersion(p.dir, context.getString(R.string.cmgr_fex_unnamed)) else readVersionFile(File(p.dir, "${COMP_DIR.getValue(comp)}/version")) val detail = if (comp == "fex") context.getString(if (File(p.dir, FEX_FILES[2]).isFile) R.string.cmgr_fex_linux_helpers else R.string.cmgr_fex_dlls_only) else "" val active = state.sub("active").optJSONObject(p.id)?.optJSONObject(comp) val inUseLabel = when { @@ -518,7 +520,7 @@ object ComponentsManager { fun swap(context: Context, protonId: String, file: String): String = synchronized(lock) { val p = proton(context, protonId) val wcp = File(packagesDir(context), safeName(file)) - val info = packageInfo(wcp) + val info = packageInfo(context, wcp) val state = loadState(context) if (inUse(context, p)) { state.sub("queued").sub(p.id).put(info.comp, JSONObject().put("kind", "package").put("file", wcp.name).put("label", info.version)) @@ -586,7 +588,7 @@ object ComponentsManager { applyOriginal(context, p, comp, v, File(originalsDir(context), "$pid/${safeName(v)}/$comp.wcp"), state) } else { val wcp = File(packagesDir(context), q.optString("file")) - applyPackage(context, p, packageInfo(wcp), wcp, state) + applyPackage(context, p, packageInfo(context, wcp), wcp, state) } done += "${LABEL[comp]} ${q.optString("label")} → ${p.name}" }.onFailure { Log.w(TAG, "queued $comp for ${p.name}", it) } @@ -630,7 +632,7 @@ object ComponentsManager { /** Imports a -linux .wcp from anywhere the app can read (the file picker hands over a copy). */ fun importPackage(context: Context, source: File, name: String): Package = synchronized(lock) { - val info = packageInfo(source) + val info = packageInfo(context, source) val dest = File(packagesDir(context), safeName(name).let { if (it.endsWith(".wcp")) it else "$it.wcp" }) source.copyTo(File(dest.parentFile, dest.name + ".part"), overwrite = true).renameTo(dest) info.copy(file = dest.name) @@ -680,7 +682,7 @@ object ComponentsManager { part.delete() check(Downloader.downloadFile(item.url, part, false) { f -> progress(if (f < 0) -1 else (f * 100).toInt().coerceIn(0, 100)) }) { context.getString(R.string.user_apps_download_failed) } if (!Hashes.sha256(part).equals(item.digest.substringAfter(':'), true)) { part.delete(); error(context.getString(R.string.cmgr_checksum_mismatch)) } - val info = runCatching { packageInfo(part) }.getOrElse { part.delete(); throw it } + val info = runCatching { packageInfo(context, part) }.getOrElse { part.delete(); throw it } synchronized(lock) { part.renameTo(dest) } return info.copy(file = dest.name) } diff --git a/app/src/main/java/com/droiddeck/launcher/session/GameSaves.kt b/app/src/main/java/com/droiddeck/launcher/session/GameSaves.kt index e73668468..8e9fe257d 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/GameSaves.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/GameSaves.kt @@ -1,6 +1,8 @@ package com.droiddeck.launcher.session +import android.content.Context import android.os.Environment +import com.droiddeck.launcher.R import com.droiddeck.launcher.frontend.Library import java.io.BufferedInputStream import java.io.BufferedOutputStream @@ -25,9 +27,12 @@ import java.util.zip.ZipOutputStream * Ported from Bannerlator's GameSaveBackup and SaveLocator. */ object GameSaves { - enum class Layout(val label: String, val rootPrefix: String, val user: String) { - GAMEHUB("GameHub zip", "/drive_c/", "steamuser"), - WINLATOR("Winlator zip", "drive_c/", "xuser"), + enum class Layout(val app: String, val rootPrefix: String, val user: String) { + GAMEHUB("GameHub", "/drive_c/", "steamuser"), + WINLATOR("Winlator", "drive_c/", "xuser"); + + /** "GameHub zip", in the app's language. */ + fun label(context: Context): String = context.getString(R.string.saves_layout_zip, app) } /** A game, its prefix, and the save folders found in it. */ @@ -127,12 +132,12 @@ object GameSaves { * Zips the game's saves into [dir] as "_.zip" in [layout]. The found save folders when * there are any, else the whole steamuser profile minus Temp and crash dumps. Returns the zip. */ - fun export(game: Game, layout: Layout, dir: File): Pair { - val prefix = game.prefix ?: error("${game.game.name} has not been launched yet") + fun export(context: Context, game: Game, layout: Layout, dir: File): Pair { + val prefix = game.prefix ?: error(context.getString(R.string.saves_not_launched, game.game.name)) dir.mkdirs() val out = File(dir, "${safe(game.game.name)}_${stamp()}.zip") val count = zipProfile(profile(prefix), game.saves.map { it.relPath }.ifEmpty { null }, layout, out) - if (count == 0) { out.delete(); error("No save files found for ${game.game.name}") } + if (count == 0) { out.delete(); error(context.getString(R.string.saves_none_found, game.game.name)) } return out to count } @@ -162,11 +167,11 @@ object GameSaves { * profile holds now into Download/DroidDeck/Saves/backups. Entries outside drive_c, launcher * shortcuts and anything escaping drive_c are skipped. Returns (files written, backup or null). */ - fun import(game: Game, zip: File): Pair { - val prefix = game.prefix ?: error("${game.game.name} has not been launched yet") + fun import(context: Context, game: Game, zip: File): Pair { + val prefix = game.prefix ?: error(context.getString(R.string.saves_not_launched, game.game.name)) val driveC = File(prefix, "drive_c") - if (!driveC.isDirectory) error("${game.game.name} has not been launched yet") - if (!looksLikeSaveZip(zip)) error("${zip.name} has no drive_c folder, so it isn't a GameHub or Winlator save zip") + if (!driveC.isDirectory) error(context.getString(R.string.saves_not_launched, game.game.name)) + if (!looksLikeSaveZip(zip)) error(context.getString(R.string.saves_not_save_zip, zip.name)) backupsDir().mkdirs() val backup = File(backupsDir(), "${safe(game.game.name)}_${stamp()}.zip") diff --git a/app/src/main/java/com/droiddeck/launcher/session/GameStorage.kt b/app/src/main/java/com/droiddeck/launcher/session/GameStorage.kt index 1de64dcff..8c072d44d 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/GameStorage.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/GameStorage.kt @@ -18,7 +18,8 @@ import java.io.File * slowly (intro movies, big asset loads); internal stays the default and the dialog says so. */ object GameStorage { - class Option(val label: String, val path: String) + /** A library root: [label] as the menu lists it (a volume with its free space), [name] alone. */ + class Option(val label: String, val path: String, val name: String = label) /** Every removable volume, as its app folder, with the free space it has. */ fun options(context: Context): List