From 88716f756dcb21d9cf16f51c900783c747aaa7f1 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Sun, 4 Oct 2026 22:32:19 -0400 Subject: [PATCH] l10n: move ui, files, input, store and frontend UI text into string resources (#212) --- .../launcher/files/CollapsibleRail.kt | 5 +- .../launcher/files/FileManagerItems.kt | 36 +-- .../launcher/files/FileManagerModel.kt | 10 +- .../launcher/files/FileManagerScreen.kt | 179 ++++++------ .../com/droiddeck/launcher/files/FileOps.kt | 8 +- .../launcher/files/FilePickerActivity.kt | 3 +- .../launcher/files/FilePropertiesDialog.kt | 32 ++- .../droiddeck/launcher/files/StorageRoots.kt | 17 +- .../launcher/frontend/GameFileSync.kt | 11 +- .../droiddeck/launcher/frontend/Library.kt | 4 +- .../input/ControllerEditorActivity.kt | 10 +- .../launcher/input/ControllerPrefs.kt | 33 +-- .../launcher/input/SecondScreenMode.kt | 12 +- .../droiddeck/launcher/store/FlathubApi.kt | 12 +- .../droiddeck/launcher/store/StoreState.kt | 11 +- .../launcher/ui/ControllerSettings.kt | 7 +- .../droiddeck/launcher/ui/FrontEndContent.kt | 16 +- .../droiddeck/launcher/ui/FrontEndSetup.kt | 4 +- .../launcher/ui/ModeSettingsDialog.kt | 10 +- .../com/droiddeck/launcher/ui/PcKeyboard.kt | 26 +- .../launcher/ui/SecondScreenPresentation.kt | 18 +- .../droiddeck/launcher/ui/SessionOverlay.kt | 2 +- .../com/droiddeck/launcher/ui/StorePage.kt | 6 +- .../java/com/droiddeck/launcher/ui/Theme.kt | 12 +- app/src/main/res/values/strings_g2.xml | 272 ++++++++++++++++++ 25 files changed, 533 insertions(+), 223 deletions(-) create mode 100644 app/src/main/res/values/strings_g2.xml diff --git a/app/src/main/java/com/droiddeck/launcher/files/CollapsibleRail.kt b/app/src/main/java/com/droiddeck/launcher/files/CollapsibleRail.kt index bd180835f..30ae1537b 100644 --- a/app/src/main/java/com/droiddeck/launcher/files/CollapsibleRail.kt +++ b/app/src/main/java/com/droiddeck/launcher/files/CollapsibleRail.kt @@ -56,6 +56,8 @@ data class RailItem( val selected: Boolean, /** >0 shows a small accent count badge on the item's icon (expanded and collapsed). */ val badge: Int = 0, + /** The under-icon label when the rail is collapsed, for names too long to fit; null derives one. */ + val shortLabel: String? = null, // onClick stays LAST so existing call sites can pass it as a trailing lambda; badge is an // optional named param before it (default 0). val onClick: () -> Unit, @@ -73,7 +75,6 @@ private fun collapsedLabel(label: String): String { when (label) { "ENVIROMENT" -> return "ENVIRON" // the app's existing (mis)spelling, kept uppercase "WIN COMPONENTS" -> return "WIN COMP" - "Downloads" -> return "Downlds" } if (label.contains(' ')) return label // multi-word → wraps to 2 lines return if (label.length > 9) label.take(8) + "…" else label @@ -317,7 +318,7 @@ fun CollapsibleRail( RailItemIcon(item, iconTint) Spacer(Modifier.height(2.dp)) Text( - collapsedLabel(item.label), + item.shortLabel ?: collapsedLabel(item.label), color = labelColor, fontSize = 7.5.sp, lineHeight = 8.5.sp, diff --git a/app/src/main/java/com/droiddeck/launcher/files/FileManagerItems.kt b/app/src/main/java/com/droiddeck/launcher/files/FileManagerItems.kt index 054430090..caf3b5a71 100644 --- a/app/src/main/java/com/droiddeck/launcher/files/FileManagerItems.kt +++ b/app/src/main/java/com/droiddeck/launcher/files/FileManagerItems.kt @@ -61,6 +61,7 @@ import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.graphics.vector.rememberVectorPainter import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource import coil.compose.AsyncImage import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight @@ -107,7 +108,7 @@ private fun FileContextMenuItems( ) { val isDir = file.isDirectory DropdownMenuItem( - text = { Text("Select") }, + text = { Text(stringResource(R.string.fm_select)) }, leadingIcon = { Icon(Icons.Filled.Checklist, null, tint = MaterialTheme.colorScheme.primary) }, onClick = { onDismissMenu(); onSelect() }, ) @@ -115,7 +116,7 @@ private fun FileContextMenuItems( // Properties: basic info + Read-only / Hidden toggles, for ANY file or folder (handy for config // files like .txt/.cfg/.ini). Kept near the top since it's a common reason to open this menu. DropdownMenuItem( - text = { Text("Properties") }, + text = { Text(stringResource(R.string.fm_properties)) }, leadingIcon = { Icon(Icons.Filled.Info, null, tint = MaterialTheme.colorScheme.primary) }, onClick = { onDismissMenu(); onProperties() }, ) @@ -123,7 +124,7 @@ private fun FileContextMenuItems( // Favorites are directories - only folders get the pin toggle. if (isDir) { DropdownMenuItem( - text = { Text(if (isFavorite) "Remove from Favorites" else "Add to Favorites") }, + text = { Text(if (isFavorite) stringResource(R.string.fm_favorite_remove) else stringResource(R.string.fm_favorite_add)) }, leadingIcon = { Icon( if (isFavorite) Icons.Filled.Star else Icons.Filled.StarBorder, @@ -136,25 +137,25 @@ private fun FileContextMenuItems( MenuItemDivider() } DropdownMenuItem( - text = { Text("Rename") }, + text = { Text(stringResource(R.string.fm_rename)) }, leadingIcon = { Icon(Icons.Filled.Edit, null, tint = MaterialTheme.colorScheme.primary) }, onClick = { onDismissMenu(); onRename() }, ) MenuItemDivider() DropdownMenuItem( - text = { Text("Copy") }, + text = { Text(stringResource(R.string.fm_copy)) }, leadingIcon = { Icon(Icons.Filled.FileCopy, null, tint = MaterialTheme.colorScheme.primary) }, onClick = { onDismissMenu(); onCopy() }, ) MenuItemDivider() DropdownMenuItem( - text = { Text("Cut") }, + text = { Text(stringResource(R.string.fm_cut)) }, leadingIcon = { Icon(Icons.Filled.ContentCut, null, tint = MaterialTheme.colorScheme.primary) }, onClick = { onDismissMenu(); onCut() }, ) MenuItemDivider() DropdownMenuItem( - text = { Text("Delete") }, + text = { Text(stringResource(R.string.common_delete)) }, leadingIcon = { Icon(Icons.Filled.Delete, null, tint = MaterialTheme.colorScheme.primary) }, onClick = { onDismissMenu(); onDelete() }, ) @@ -184,6 +185,7 @@ internal fun FileItemRow( onProperties: () -> Unit = {}, ) { val dateFormat = remember { SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()) } + val context = LocalContext.current val isDir = file.isDirectory val isExe = !isDir && file.name.lowercase().let { it.endsWith(".exe") || it.endsWith(".bat") || it.endsWith(".msi") || it.endsWith(".sh") } // Image files show a real thumbnail instead of the generic file icon (handy when picking a @@ -276,7 +278,7 @@ internal fun FileItemRow( ) Text( text = buildString { - if (!isDir) append(FileOps.formatBytes(file.length())).append(" \u2022 ") + if (!isDir) append(FileOps.formatBytes(context, file.length())).append(" \u2022 ") append(dateFormat.format(Date(file.lastModified()))) }, color = MaterialTheme.colorScheme.onSurfaceVariant, @@ -285,7 +287,7 @@ internal fun FileItemRow( } if (showActions) Box { IconButton(onClick = onMenu) { - Icon(Icons.Filled.MoreVert, "Actions", tint = MaterialTheme.colorScheme.primary, modifier = Modifier.size(20.dp)) + Icon(Icons.Filled.MoreVert, stringResource(R.string.fm_actions), tint = MaterialTheme.colorScheme.primary, modifier = Modifier.size(20.dp)) } DropdownMenu( expanded = menuExpanded, @@ -338,7 +340,7 @@ internal fun FavoritesList( .padding(horizontal = 16.dp, vertical = 8.dp), ) { Text( - text = "Favorites", + text = stringResource(R.string.fm_favorites), color = MaterialTheme.colorScheme.onBackground, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, @@ -351,7 +353,7 @@ internal fun FavoritesList( Icon(Icons.Filled.PushPin, null, tint = MaterialTheme.colorScheme.primary, modifier = Modifier.size(16.dp)) Spacer(Modifier.width(6.dp)) Text( - text = "Pin current folder", + text = stringResource(R.string.fm_pin_current), color = MaterialTheme.colorScheme.primary, fontSize = 13.sp, ) @@ -366,7 +368,7 @@ internal fun FavoritesList( contentAlignment = Alignment.Center, ) { Text( - text = "No favorites yet - pin a folder with its ⋮ menu to jump back here fast.", + text = stringResource(R.string.fm_no_favorites), color = MaterialTheme.colorScheme.onSurfaceVariant, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 32.dp), @@ -431,7 +433,7 @@ private fun FavoriteCard( // Origin line: coloured drive badge + source description. Row(verticalAlignment = Alignment.CenterVertically) { Text( - text = loc.driveLabel, + text = stringResource(loc.driveLabel), color = badgeFg, fontSize = 11.sp, fontWeight = FontWeight.Bold, @@ -443,9 +445,9 @@ private fun FavoriteCard( Spacer(Modifier.width(6.dp)) Text( text = when (loc.storage) { - FavStorage.INTERNAL -> "Internal storage" - FavStorage.SD -> "SD card" - FavStorage.OTHER -> "Storage" + FavStorage.INTERNAL -> stringResource(R.string.games_internal) + FavStorage.SD -> stringResource(R.string.fm_drive_sd) + FavStorage.OTHER -> stringResource(R.string.fm_drive_storage) }, color = MaterialTheme.colorScheme.onSurfaceVariant, fontSize = 12.sp, @@ -464,7 +466,7 @@ private fun FavoriteCard( IconButton(onClick = onUnpin) { Icon( Icons.Filled.Star, - contentDescription = "Remove from favorites", + contentDescription = stringResource(R.string.fm_unpin_favorite), tint = MaterialTheme.colorScheme.primary, modifier = Modifier.size(22.dp), ) diff --git a/app/src/main/java/com/droiddeck/launcher/files/FileManagerModel.kt b/app/src/main/java/com/droiddeck/launcher/files/FileManagerModel.kt index b1705146f..741211e13 100644 --- a/app/src/main/java/com/droiddeck/launcher/files/FileManagerModel.kt +++ b/app/src/main/java/com/droiddeck/launcher/files/FileManagerModel.kt @@ -8,6 +8,8 @@ import androidx.compose.material.icons.filled.Image import androidx.compose.runtime.getValue import androidx.compose.runtime.setValue import androidx.compose.ui.text.style.TextOverflow +import androidx.annotation.StringRes +import com.droiddeck.launcher.R import java.io.File // The File Manager's non-UI helpers: sorting, paths, conflict choices and favourite locations. @@ -77,7 +79,7 @@ enum class FavStorage { INTERNAL, SD, OTHER } data class FavLocation( val storage: FavStorage, - val driveLabel: String, // "Internal", "SD card", or "Storage" + @StringRes val driveLabel: Int, // Internal, SD card, or Storage val displayPath: String // the unix absolute path ) @@ -87,15 +89,15 @@ fun describeLocation(file: File): FavLocation { val internal = "/storage/emulated/0" if (abs == internal || abs.startsWith("$internal/")) { - return FavLocation(FavStorage.INTERNAL, "Internal", abs) + return FavLocation(FavStorage.INTERNAL, R.string.fm_drive_internal, abs) } if (abs.startsWith("/storage/")) { val name = abs.removePrefix("/storage/").substringBefore('/') if (name.isNotEmpty() && name != "emulated" && name != "self") { - return FavLocation(FavStorage.SD, "SD card", abs) + return FavLocation(FavStorage.SD, R.string.fm_drive_sd, abs) } } - return FavLocation(FavStorage.OTHER, "Storage", abs) + return FavLocation(FavStorage.OTHER, R.string.fm_drive_storage, abs) } diff --git a/app/src/main/java/com/droiddeck/launcher/files/FileManagerScreen.kt b/app/src/main/java/com/droiddeck/launcher/files/FileManagerScreen.kt index ecae61e2f..be22e7d00 100644 --- a/app/src/main/java/com/droiddeck/launcher/files/FileManagerScreen.kt +++ b/app/src/main/java/com/droiddeck/launcher/files/FileManagerScreen.kt @@ -76,6 +76,9 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.pluralStringResource +import androidx.compose.ui.res.stringResource +import com.droiddeck.launcher.R import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleEventObserver @@ -261,11 +264,11 @@ fun FileManagerScreen( fun performDelete(file: File) { scope.launch { isOperationRunning = true - operationLabel = "Deleting..." + operationLabel = context.getString(R.string.fm_op_deleting) val ok = withContext(Dispatchers.IO) { FileOps.delete(file) } isOperationRunning = false loadDirectory(currentDir, resetScroll = false) - if (!ok) Toast.makeText(context, "Delete failed", Toast.LENGTH_SHORT).show() + if (!ok) Toast.makeText(context, R.string.fm_delete_failed, Toast.LENGTH_SHORT).show() } } @@ -288,7 +291,7 @@ fun FileManagerScreen( operationJob = scope.launch { operationProgress = 0f operationDeterminate = true - operationLabel = if (cut) "Moving..." else "Copying..." + operationLabel = context.getString(if (cut) R.string.fm_op_moving else R.string.fm_op_copying) isOperationRunning = true var applyToAll: ConflictChoice? = null @@ -324,10 +327,10 @@ fun FileManagerScreen( } // Progress is per item; with a batch the label carries the overall position. - operationLabel = buildString { - append(if (cut) "Moving" else "Copying") - if (sources.size > 1) append(" ${done + 1}/${sources.size}") - append(" - ").append(src.name) + operationLabel = if (sources.size > 1) { + context.getString(if (cut) R.string.fm_op_moving_batch else R.string.fm_op_copying_batch, done + 1, sources.size, src.name) + } else { + context.getString(if (cut) R.string.fm_op_moving_item else R.string.fm_op_copying_item, src.name) } var lastPct = -1 val onProgress = FileOps.ProgressCallback { copied, total -> @@ -355,9 +358,9 @@ fun FileManagerScreen( loadDirectory(currentDir, resetScroll = false) val message = when { - failed > 0 -> "$done done, $failed failed" - skipped > 0 -> "$done done, $skipped skipped" - sources.size > 1 -> "$done items ${if (cut) "moved" else "copied"}" + failed > 0 -> context.getString(R.string.fm_paste_failed, done, failed) + skipped > 0 -> context.getString(R.string.fm_paste_skipped, done, skipped) + sources.size > 1 -> context.resources.getQuantityString(if (cut) R.plurals.fm_paste_moved else R.plurals.fm_paste_copied, done, done) else -> null } if (message != null) Toast.makeText(context, message, Toast.LENGTH_SHORT).show() @@ -367,32 +370,32 @@ fun FileManagerScreen( fun performRename(file: File, newName: String) { val target = File(file.parentFile, newName) if (target.exists()) { - Toast.makeText(context, "\"$newName\" already exists", Toast.LENGTH_SHORT).show() + Toast.makeText(context, context.getString(R.string.fm_already_exists, newName), Toast.LENGTH_SHORT).show() return } scope.launch { isOperationRunning = true - operationLabel = "Renaming..." + operationLabel = context.getString(R.string.fm_op_renaming) val ok = withContext(Dispatchers.IO) { file.renameTo(target) } isOperationRunning = false loadDirectory(currentDir, resetScroll = false) - if (!ok) Toast.makeText(context, "Rename failed", Toast.LENGTH_SHORT).show() + if (!ok) Toast.makeText(context, R.string.fm_rename_failed, Toast.LENGTH_SHORT).show() } } fun createFolder(parent: File, name: String) { val target = File(parent, name) if (target.exists()) { - Toast.makeText(context, "\"$name\" already exists", Toast.LENGTH_SHORT).show() + Toast.makeText(context, context.getString(R.string.fm_already_exists, name), Toast.LENGTH_SHORT).show() return } scope.launch { isOperationRunning = true - operationLabel = "Creating folder..." + operationLabel = context.getString(R.string.fm_op_creating_folder) val ok = withContext(Dispatchers.IO) { target.mkdirs() } isOperationRunning = false loadDirectory(currentDir, resetScroll = false) - if (!ok) Toast.makeText(context, "Could not create folder", Toast.LENGTH_SHORT).show() + if (!ok) Toast.makeText(context, R.string.fm_create_folder_failed, Toast.LENGTH_SHORT).show() } } @@ -416,12 +419,12 @@ fun FileManagerScreen( var folderName by remember { mutableStateOf("") } OutlinedAlertDialog( onDismissRequest = { showNewFolderDialog = false }, - title = { Text("New Folder") }, + title = { Text(stringResource(R.string.fm_new_folder)) }, text = { OutlinedTextField( value = folderName, onValueChange = { folderName = it }, - label = { Text("Folder name") }, + label = { Text(stringResource(R.string.fm_folder_name)) }, singleLine = true, ) }, @@ -429,9 +432,9 @@ fun FileManagerScreen( TextButton(onClick = { showNewFolderDialog = false if (folderName.isNotBlank()) createFolder(currentDir, folderName) - }) { Text("Create") } + }) { Text(stringResource(R.string.fm_create)) } }, - dismissButton = { TextButton(onClick = { showNewFolderDialog = false }) { Text("Cancel") } }, + dismissButton = { TextButton(onClick = { showNewFolderDialog = false }) { Text(stringResource(R.string.common_cancel)) } }, ) } @@ -439,12 +442,12 @@ fun FileManagerScreen( var newName by remember(renameTarget) { mutableStateOf(renameTarget?.name ?: "") } OutlinedAlertDialog( onDismissRequest = { renameTarget = null }, - title = { Text("Rename") }, + title = { Text(stringResource(R.string.fm_rename)) }, text = { OutlinedTextField( value = newName, onValueChange = { newName = it }, - label = { Text("New name") }, + label = { Text(stringResource(R.string.fm_new_name)) }, singleLine = true, ) }, @@ -453,9 +456,9 @@ fun FileManagerScreen( val file = renameTarget renameTarget = null if (file != null && newName.isNotBlank()) performRename(file, newName) - }) { Text("Rename") } + }) { Text(stringResource(R.string.fm_rename)) } }, - dismissButton = { TextButton(onClick = { renameTarget = null }) { Text("Cancel") } }, + dismissButton = { TextButton(onClick = { renameTarget = null }) { Text(stringResource(R.string.common_cancel)) } }, ) } @@ -473,15 +476,15 @@ fun FileManagerScreen( val file = selectedEntry ?: return OutlinedAlertDialog( onDismissRequest = { selectedEntry = null }, - title = { Text("Delete?") }, - text = { Text("Delete \"${file.name}\" permanently?") }, + title = { Text(stringResource(R.string.fm_delete_title)) }, + text = { Text(stringResource(R.string.fm_delete_text, file.name)) }, confirmButton = { TextButton(onClick = { selectedEntry = null performDelete(file) - }) { Text("Delete") } + }) { Text(stringResource(R.string.common_delete)) } }, - dismissButton = { TextButton(onClick = { selectedEntry = null }) { Text("Cancel") } }, + dismissButton = { TextButton(onClick = { selectedEntry = null }) { Text(stringResource(R.string.common_cancel)) } }, ) } @@ -489,10 +492,10 @@ fun FileManagerScreen( val victims = pendingBulkDelete OutlinedAlertDialog( onDismissRequest = { pendingBulkDelete = emptyList() }, - title = { Text("Delete ${victims.size} item${if (victims.size == 1) "" else "s"}?") }, + title = { Text(pluralStringResource(R.plurals.fm_delete_items_title, victims.size, victims.size)) }, text = { Column { - Text("This can't be undone.") + Text(stringResource(R.string.fm_cannot_undo)) Spacer(Modifier.height(6.dp)) // Name a few so an accidental Select-All is obvious before it's too late. victims.take(5).forEach { @@ -500,7 +503,7 @@ fun FileManagerScreen( } if (victims.size > 5) { Text( - "…and ${victims.size - 5} more", + pluralStringResource(R.plurals.fm_and_more, victims.size - 5, victims.size - 5), color = MaterialTheme.colorScheme.onSurfaceVariant, fontSize = 12.sp, ) @@ -516,19 +519,19 @@ fun FileManagerScreen( isOperationRunning = true var failed = 0 victims.forEachIndexed { i, f -> - operationLabel = "Deleting ${i + 1}/${victims.size} - ${f.name}" + operationLabel = context.getString(R.string.fm_op_deleting_batch, i + 1, victims.size, f.name) if (!withContext(Dispatchers.IO) { FileOps.delete(f) }) failed++ } isOperationRunning = false operationJob = null loadDirectory(currentDir, resetScroll = false) if (failed > 0) { - Toast.makeText(context, "$failed couldn't be deleted", Toast.LENGTH_SHORT).show() + Toast.makeText(context, context.resources.getQuantityString(R.plurals.fm_delete_some_failed, failed, failed), Toast.LENGTH_SHORT).show() } } - }) { Text("Delete", color = MaterialTheme.colorScheme.error) } + }) { Text(stringResource(R.string.common_delete), color = MaterialTheme.colorScheme.error) } }, - dismissButton = { TextButton(onClick = { pendingBulkDelete = emptyList() }) { Text("Cancel") } }, + dismissButton = { TextButton(onClick = { pendingBulkDelete = emptyList() }) { Text(stringResource(R.string.common_cancel)) } }, ) } @@ -537,12 +540,12 @@ fun FileManagerScreen( val isDir = conflict.isDirectory OutlinedAlertDialog( onDismissRequest = { pendingConflict = null }, - title = { Text("\"${conflict.name}\" already exists") }, + title = { Text(stringResource(R.string.fm_already_exists, conflict.name)) }, text = { Column { Text( - if (isDir) "Merge adds and replaces files inside the existing folder." - else "Overwrite replaces the existing file.", + if (isDir) stringResource(R.string.fm_conflict_merge_hint) + else stringResource(R.string.fm_conflict_overwrite_hint), color = MaterialTheme.colorScheme.onSurfaceVariant, fontSize = 12.sp, ) @@ -553,15 +556,15 @@ fun FileManagerScreen( checked = conflictApplyToAll, onCheckedChange = { conflictApplyToAll = it }, ) - Text("Apply to all conflicts", fontSize = 12.sp) + Text(stringResource(R.string.fm_conflict_apply_all), fontSize = 12.sp) } } Spacer(Modifier.height(4.dp)) listOf( (if (isDir) ConflictChoice.MERGE else ConflictChoice.OVERWRITE) to - (if (isDir) "Merge" else "Overwrite"), - ConflictChoice.KEEP_BOTH to "Keep both", - ConflictChoice.SKIP to "Skip", + (if (isDir) stringResource(R.string.fm_conflict_merge) else stringResource(R.string.fm_conflict_overwrite)), + ConflictChoice.KEEP_BOTH to stringResource(R.string.fm_conflict_keep_both), + ConflictChoice.SKIP to stringResource(R.string.fm_conflict_skip), ).forEach { (choice, label) -> TextButton( modifier = Modifier.fillMaxWidth(), @@ -573,7 +576,7 @@ fun FileManagerScreen( confirmButton = {}, dismissButton = { TextButton(onClick = { conflictChoice = ConflictChoice.SKIP; pendingConflict = null }) { - Text("Cancel") + Text(stringResource(R.string.common_cancel)) } }, ) @@ -603,7 +606,7 @@ fun FileManagerScreen( ) { Icon(Icons.Filled.Folder, null, modifier = Modifier.size(18.dp)) Spacer(Modifier.width(8.dp)) - Text("Select this folder") + Text(stringResource(R.string.fm_select_this_folder)) } } // ── Path bar ── @@ -619,10 +622,10 @@ fun FileManagerScreen( // Don't climb above the current drive's root. if (currentDir != currentRoot && parent != null && parent.exists()) loadDirectory(parent) }, enabled = currentDir != currentRoot) { - Icon(Icons.Filled.ArrowBack, "Back", tint = MaterialTheme.colorScheme.primary) + Icon(Icons.Filled.ArrowBack, stringResource(R.string.fm_back), tint = MaterialTheme.colorScheme.primary) } - val currentDriveLabel = describeLocation(currentDir).driveLabel + val currentDriveLabel = stringResource(describeLocation(currentDir).driveLabel) // Dim the drive chip while the Favorites list is open (it's not the active context). val driveChipAlpha = if (showFavorites) 0.45f else 1f Box { @@ -666,7 +669,7 @@ fun FileManagerScreen( } else { Toast.makeText( context, - "${drive.label} is mounted but not readable right now", + context.getString(R.string.fm_drive_not_readable, drive.label), Toast.LENGTH_SHORT, ).show() } @@ -680,7 +683,7 @@ fun FileManagerScreen( if (showFavorites) { Text( - text = "Favorites", + text = stringResource(R.string.fm_favorites), color = MaterialTheme.colorScheme.primary, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, @@ -718,7 +721,7 @@ fun FileManagerScreen( ) { Icon(Icons.Filled.CreateNewFolder, null, tint = MaterialTheme.colorScheme.primary, modifier = Modifier.size(16.dp)) Spacer(Modifier.width(5.dp)) - Text("New Folder", color = MaterialTheme.colorScheme.onBackground, fontSize = 12.sp) + Text(stringResource(R.string.fm_new_folder), color = MaterialTheme.colorScheme.onBackground, fontSize = 12.sp) } } IconButton(onClick = { @@ -727,19 +730,19 @@ fun FileManagerScreen( }) { Icon( if (gridView) Icons.Filled.ViewList else Icons.Filled.GridView, - if (gridView) "List view" else "Grid view", + if (gridView) stringResource(R.string.fm_list_view) else stringResource(R.string.fm_grid_view), tint = MaterialTheme.colorScheme.onSurfaceVariant, ) } IconButton(onClick = { showSearch = !showSearch; if (!showSearch) searchQuery = "" }) { - Icon(Icons.Filled.Search, "Search", tint = MaterialTheme.colorScheme.onSurfaceVariant) + Icon(Icons.Filled.Search, stringResource(R.string.fm_search), tint = MaterialTheme.colorScheme.onSurfaceVariant) } Box { IconButton(onClick = { showSortMenu = true }) { - Icon(Icons.Filled.Sort, "Sort", tint = MaterialTheme.colorScheme.onSurfaceVariant) + Icon(Icons.Filled.Sort, stringResource(R.string.fm_sort), tint = MaterialTheme.colorScheme.onSurfaceVariant) } DropdownMenu(expanded = showSortMenu, onDismissRequest = { showSortMenu = false }) { - listOf("name" to "Name", "date" to "Date modified", "size" to "Size") + listOf("name" to stringResource(R.string.fm_sort_name), "date" to stringResource(R.string.fm_sort_date), "size" to stringResource(R.string.fm_prop_size)) .forEach { (key, label) -> DropdownMenuItem( text = { @@ -758,7 +761,7 @@ fun FileManagerScreen( } HorizontalDivider(color = MaterialTheme.colorScheme.outline) DropdownMenuItem( - text = { Text(if (compactRows) "Comfortable rows" else "Compact rows") }, + text = { Text(if (compactRows) stringResource(R.string.fm_rows_comfortable) else stringResource(R.string.fm_rows_compact)) }, onClick = { compactRows = !compactRows browsePrefs.edit().putBoolean("fmCompactRows", compactRows).apply() @@ -766,7 +769,7 @@ fun FileManagerScreen( }, ) DropdownMenuItem( - text = { Text(if (showHidden) "Hide hidden files" else "Show hidden files") }, + text = { Text(if (showHidden) stringResource(R.string.fm_hide_hidden) else stringResource(R.string.fm_show_hidden)) }, onClick = { showHidden = !showHidden browsePrefs.edit().putBoolean("fmShowHidden", showHidden).apply() @@ -781,9 +784,9 @@ fun FileManagerScreen( // Star toggle: open/close the dedicated Favorites list. IconButton(onClick = { showFavorites = !showFavorites }) { if (showFavorites) { - Icon(Icons.Filled.Star, "Hide favorites", tint = MaterialTheme.colorScheme.primary) + Icon(Icons.Filled.Star, stringResource(R.string.fm_hide_favorites), tint = MaterialTheme.colorScheme.primary) } else { - Icon(Icons.Filled.StarBorder, "Show favorites", tint = MaterialTheme.colorScheme.onSurfaceVariant) + Icon(Icons.Filled.StarBorder, stringResource(R.string.fm_show_favorites), tint = MaterialTheme.colorScheme.onSurfaceVariant) } } } @@ -794,7 +797,7 @@ fun FileManagerScreen( value = searchQuery, onValueChange = { searchQuery = it }, singleLine = true, - placeholder = { Text("Filter this folder", fontSize = 13.sp) }, + placeholder = { Text(stringResource(R.string.fm_filter_folder), fontSize = 13.sp) }, modifier = Modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 4.dp), ) } @@ -821,7 +824,7 @@ fun FileManagerScreen( ) if (freeSpace > 0) { Text( - "${FileOps.formatBytes(freeSpace)} free", + stringResource(R.string.fm_free_space, FileOps.formatBytes(context, freeSpace)), color = MaterialTheme.colorScheme.onSurfaceVariant, fontSize = 12.sp, maxLines = 1, @@ -842,7 +845,7 @@ fun FileManagerScreen( .padding(horizontal = 12.dp, vertical = 6.dp), ) { Text( - "${selectedPaths.size} selected", + stringResource(R.string.fm_selected_count, selectedPaths.size), color = MaterialTheme.colorScheme.onBackground, fontSize = 13.sp, modifier = Modifier.weight(1f), @@ -855,7 +858,7 @@ fun FileManagerScreen( else entries.map { it.absolutePath }.toSet() }, contentPadding = selBarPadding, - ) { Text(if (selectedPaths.size == entries.size) "None" else "All", fontSize = 12.sp) } + ) { Text(if (selectedPaths.size == entries.size) stringResource(R.string.fm_select_none) else stringResource(R.string.fm_select_all), fontSize = 12.sp) } Spacer(Modifier.width(4.dp)) OutlinedButton( enabled = selectedPaths.isNotEmpty(), @@ -866,7 +869,7 @@ fun FileManagerScreen( selectedPaths = emptySet() }, contentPadding = selBarPadding, - ) { Text("Copy", fontSize = 12.sp) } + ) { Text(stringResource(R.string.fm_copy), fontSize = 12.sp) } Spacer(Modifier.width(4.dp)) OutlinedButton( enabled = selectedPaths.isNotEmpty(), @@ -877,19 +880,19 @@ fun FileManagerScreen( selectedPaths = emptySet() }, contentPadding = selBarPadding, - ) { Text("Cut", fontSize = 12.sp) } + ) { Text(stringResource(R.string.fm_cut), fontSize = 12.sp) } Spacer(Modifier.width(4.dp)) OutlinedButton( enabled = selectedPaths.isNotEmpty(), onClick = { pendingBulkDelete = entries.filter { it.absolutePath in selectedPaths } }, contentPadding = selBarPadding, border = BorderStroke(1.dp, MaterialTheme.colorScheme.error), - ) { Text("Delete", color = MaterialTheme.colorScheme.error, fontSize = 12.sp) } + ) { Text(stringResource(R.string.common_delete), color = MaterialTheme.colorScheme.error, fontSize = 12.sp) } Spacer(Modifier.width(4.dp)) OutlinedButton( onClick = { selectionMode = false; selectedPaths = emptySet() }, contentPadding = selBarPadding, - ) { Text("Done", fontSize = 12.sp) } + ) { Text(stringResource(R.string.fm_done), fontSize = 12.sp) } } } @@ -903,16 +906,16 @@ fun FileManagerScreen( .clickable { performPaste() } .padding(horizontal = 16.dp, vertical = 8.dp), ) { - Icon(Icons.Filled.ContentPaste, "Paste", tint = MaterialTheme.colorScheme.primary, modifier = Modifier.size(18.dp)) + Icon(Icons.Filled.ContentPaste, stringResource(R.string.fm_paste), tint = MaterialTheme.colorScheme.primary, modifier = Modifier.size(18.dp)) Spacer(Modifier.width(8.dp)) val what = if (clipboardFiles.size == 1) clipboardFiles.first().name - else "${clipboardFiles.size} items" + else pluralStringResource(R.plurals.fm_items, clipboardFiles.size, clipboardFiles.size) Text( - "Paste $what${if (isCutOperation) " (move)" else ""} here", + if (isCutOperation) stringResource(R.string.fm_paste_move_here, what) else stringResource(R.string.fm_paste_here, what), color = MaterialTheme.colorScheme.onBackground, fontSize = 13.sp, modifier = Modifier.weight(1f), ) TextButton(onClick = { clipboardFiles = emptyList(); isCutOperation = false }) { - Text("Cancel", color = MaterialTheme.colorScheme.onSurfaceVariant, fontSize = 12.sp) + Text(stringResource(R.string.common_cancel), color = MaterialTheme.colorScheme.onSurfaceVariant, fontSize = 12.sp) } } } @@ -944,7 +947,7 @@ fun FileManagerScreen( isOperationRunning = false operationDeterminate = false loadDirectory(currentDir, resetScroll = false) - }) { Text("Cancel", fontSize = 12.sp) } + }) { Text(stringResource(R.string.common_cancel), fontSize = 12.sp) } } } Spacer(Modifier.height(4.dp)) @@ -970,12 +973,12 @@ fun FileManagerScreen( // shown in pick mode (the themed picker keeps its slim layout). Built each recompose (cheap) // so it tracks the current drive/favourites without stale click lambdas. val fmRailState = rememberRailState("filemanager") - fun locItem(label: String, icon: androidx.compose.ui.graphics.vector.ImageVector, dir: File) = - RailItem(label, icon, !showFavorites && currentRoot.absolutePath == dir.absolutePath) { + fun locItem(label: String, icon: androidx.compose.ui.graphics.vector.ImageVector, dir: File, shortLabel: String? = null) = + RailItem(label, icon, !showFavorites && currentRoot.absolutePath == dir.absolutePath, shortLabel = shortLabel) { showFavorites = false; openDrive(dir) } val storageItems = buildList { - add(locItem("Internal", Icons.Filled.Smartphone, File("/storage/emulated/0"))) + add(locItem(stringResource(R.string.fm_drive_internal), Icons.Filled.Smartphone, File("/storage/emulated/0"))) drives.filter { it.removable }.forEach { d -> add(RailItem(d.label, Icons.Filled.SdStorage, !showFavorites && currentRoot.absolutePath == d.dir.absolutePath) { showFavorites = false; if (d.readable) openDrive(d.dir) @@ -983,25 +986,25 @@ fun FileManagerScreen( } } val quickItems = buildList { - File("/storage/emulated/0/Download").takeIf { it.isDirectory }?.let { add(locItem("Downloads", Icons.Filled.Download, it)) } + File("/storage/emulated/0/Download").takeIf { it.isDirectory }?.let { add(locItem(stringResource(R.string.fm_rail_downloads), Icons.Filled.Download, it, stringResource(R.string.fm_rail_downloads_short))) } // The ROMs folder chosen on the main screen: what the session shows as /root/ROMs. SessionPrefs.romsDir(context).takeIf { it.isNotEmpty() }?.let(::File)?.takeIf { it.isDirectory } - ?.let { add(locItem("ROMs", Icons.Filled.SportsEsports, it)) } - File("/storage/emulated/0/Download/DroidDeck").takeIf { it.isDirectory }?.let { add(locItem("Session logs", Icons.Filled.Description, it)) } - File("/storage/emulated/0/Pictures").takeIf { it.isDirectory }?.let { add(locItem("Pictures", Icons.Filled.Image, it)) } + ?.let { add(locItem(stringResource(R.string.fm_rail_roms), Icons.Filled.SportsEsports, it)) } + File("/storage/emulated/0/Download/DroidDeck").takeIf { it.isDirectory }?.let { add(locItem(stringResource(R.string.fm_rail_session_logs), Icons.Filled.Description, it)) } + File("/storage/emulated/0/Pictures").takeIf { it.isDirectory }?.let { add(locItem(stringResource(R.string.fm_rail_pictures), Icons.Filled.Image, it)) } } val favItems = remember(favTick) { FavoritesStore.list(context).map(::File).filter { it.exists() } } .map { d -> RailItem(d.name, Icons.Filled.Star, false) { showFavorites = false; openDrive(d) } } val locationSections = buildList { - add(RailSection("STORAGE", storageItems)) - if (quickItems.isNotEmpty()) add(RailSection("QUICK", quickItems)) - if (favItems.isNotEmpty()) add(RailSection("FAVORITES", favItems)) + add(RailSection(stringResource(R.string.fm_rail_storage), storageItems)) + if (quickItems.isNotEmpty()) add(RailSection(stringResource(R.string.fm_rail_quick), quickItems)) + if (favItems.isNotEmpty()) add(RailSection(stringResource(R.string.fm_rail_favorites), favItems)) } Row(modifier = Modifier.weight(1f).fillMaxWidth()) { // The slim picker keeps its layout: no rail. if (!pickMode) { - CollapsibleRail(state = fmRailState, title = "Files", sections = locationSections, outlinedItems = true) + CollapsibleRail(state = fmRailState, title = stringResource(R.string.fm_rail_title), sections = locationSections, outlinedItems = true) } Box(modifier = Modifier.weight(1f).fillMaxSize()) { // ── Favorites list OR file list ── @@ -1012,7 +1015,7 @@ fun FileManagerScreen( onPinCurrent = { FavoritesStore.add(context, currentDir.absolutePath) favTick++ - Toast.makeText(context, "Added \"${currentDir.name}\" to Favorites", Toast.LENGTH_SHORT).show() + Toast.makeText(context, context.getString(R.string.fm_favorite_added, currentDir.name), Toast.LENGTH_SHORT).show() }, onJump = { dir -> showFavorites = false @@ -1021,7 +1024,7 @@ fun FileManagerScreen( onUnpin = { dir -> FavoritesStore.remove(context, dir.absolutePath) favTick++ - Toast.makeText(context, "Removed \"${dir.name}\" from Favorites", Toast.LENGTH_SHORT).show() + Toast.makeText(context, context.getString(R.string.fm_favorite_removed, dir.name), Toast.LENGTH_SHORT).show() }, modifier = Modifier.fillMaxSize(), ) @@ -1095,8 +1098,8 @@ fun FileManagerScreen( showMenuFor = null Toast.makeText( context, - if (nowFav) "Added \"${file.name}\" to Favorites" - else "Removed \"${file.name}\" from Favorites", + if (nowFav) context.getString(R.string.fm_favorite_added, file.name) + else context.getString(R.string.fm_favorite_removed, file.name), Toast.LENGTH_SHORT, ).show() }, @@ -1112,7 +1115,7 @@ fun FileManagerScreen( modifier = Modifier.fillParentMaxSize(), contentAlignment = Alignment.Center, ) { - Text("Empty directory", color = MaterialTheme.colorScheme.onSurfaceVariant) + Text(stringResource(R.string.fm_empty_directory), color = MaterialTheme.colorScheme.onSurfaceVariant) } } } else { @@ -1173,8 +1176,8 @@ fun FileManagerScreen( showMenuFor = null Toast.makeText( context, - if (nowFav) "Added \"${file.name}\" to Favorites" - else "Removed \"${file.name}\" from Favorites", + if (nowFav) context.getString(R.string.fm_favorite_added, file.name) + else context.getString(R.string.fm_favorite_removed, file.name), Toast.LENGTH_SHORT, ).show() }, diff --git a/app/src/main/java/com/droiddeck/launcher/files/FileOps.kt b/app/src/main/java/com/droiddeck/launcher/files/FileOps.kt index e57e219da..e363a3acc 100644 --- a/app/src/main/java/com/droiddeck/launcher/files/FileOps.kt +++ b/app/src/main/java/com/droiddeck/launcher/files/FileOps.kt @@ -1,6 +1,8 @@ package com.droiddeck.launcher.files +import android.content.Context import android.util.Log +import com.droiddeck.launcher.R import java.io.File import java.io.FileInputStream import java.io.FileOutputStream @@ -19,9 +21,9 @@ object FileOps { /** Byte-accurate copy progress (copied/total bytes), reported as the copy proceeds. */ fun interface ProgressCallback { fun onProgress(copiedBytes: Long, totalBytes: Long) } - fun formatBytes(bytes: Long): String { - if (bytes <= 0) return "0 bytes" - val units = arrayOf("bytes", "KB", "MB", "GB", "TB") + fun formatBytes(context: Context, bytes: Long): String { + if (bytes <= 0) return context.getString(R.string.fm_size_zero) + val units = arrayOf(context.getString(R.string.fm_unit_bytes), "KB", "MB", "GB", "TB") val group = (Math.log10(bytes.toDouble()) / Math.log10(1024.0)).toInt().coerceIn(0, units.lastIndex) return String.format(Locale.ENGLISH, "%.2f", bytes / Math.pow(1024.0, group.toDouble())) + " " + units[group] } diff --git a/app/src/main/java/com/droiddeck/launcher/files/FilePickerActivity.kt b/app/src/main/java/com/droiddeck/launcher/files/FilePickerActivity.kt index cf8b0770d..a36c6cc13 100644 --- a/app/src/main/java/com/droiddeck/launcher/files/FilePickerActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/files/FilePickerActivity.kt @@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.systemBarsPadding import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.ui.Modifier +import com.droiddeck.launcher.R import com.droiddeck.launcher.ui.DroidDeckTheme import java.io.File @@ -55,7 +56,7 @@ class FilePickerActivity : ComponentActivity() { pickDirMode = pickDir, pickExtensions = extensions, initialDir = initialDir, - pickerTitle = title ?: if (pickDir) "Choose a folder" else "Choose a file", + pickerTitle = title ?: getString(if (pickDir) R.string.fm_choose_folder else R.string.fm_choose_file), onPick = { file -> setResult(Activity.RESULT_OK, Intent().putExtra(EXTRA_SELECTED_FILE, file.absolutePath)) finish() diff --git a/app/src/main/java/com/droiddeck/launcher/files/FilePropertiesDialog.kt b/app/src/main/java/com/droiddeck/launcher/files/FilePropertiesDialog.kt index 8c302b853..fff674dc9 100644 --- a/app/src/main/java/com/droiddeck/launcher/files/FilePropertiesDialog.kt +++ b/app/src/main/java/com/droiddeck/launcher/files/FilePropertiesDialog.kt @@ -25,6 +25,8 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource +import com.droiddeck.launcher.R import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp @@ -66,7 +68,7 @@ internal fun FilePropertiesDialog( OutlinedAlertDialog( onDismissRequest = onDismiss, - title = { Text("Properties") }, + title = { Text(stringResource(R.string.fm_properties)) }, text = { Column(modifier = Modifier.verticalScroll(rememberScrollState())) { // ── Basic info ── @@ -79,14 +81,14 @@ internal fun FilePropertiesDialog( overflow = TextOverflow.Ellipsis, ) Spacer(Modifier.height(6.dp)) - PropertyLine("Location", file.parent ?: "-") + PropertyLine(stringResource(R.string.fm_prop_location), file.parent ?: "-") PropertyLine( - "Type", - if (file.isDirectory) "Folder" - else file.extension.uppercase().let { if (it.isBlank()) "File" else "$it file" }, + stringResource(R.string.fm_prop_type), + if (file.isDirectory) stringResource(R.string.fm_type_folder) + else file.extension.uppercase().let { if (it.isBlank()) stringResource(R.string.fm_type_file) else stringResource(R.string.fm_type_ext_file, it) }, ) - if (!file.isDirectory) PropertyLine("Size", FileOps.formatBytes(file.length())) - PropertyLine("Modified", dateFormat.format(Date(file.lastModified()))) + if (!file.isDirectory) PropertyLine(stringResource(R.string.fm_prop_size), FileOps.formatBytes(context, file.length())) + PropertyLine(stringResource(R.string.fm_prop_modified), dateFormat.format(Date(file.lastModified()))) Spacer(Modifier.height(10.dp)) HorizontalDivider(color = MaterialTheme.colorScheme.outline) @@ -95,8 +97,8 @@ internal fun FilePropertiesDialog( val state = attrs // ── Read-only ── checked when the owner can't write (Wine's FILE_ATTRIBUTE_READONLY). AttributeToggleRow( - label = "Read-only", - description = "Stops games (and Wine) from overwriting or deleting this file.", + label = stringResource(R.string.fm_read_only), + description = stringResource(R.string.fm_read_only_hint), checked = state?.readOnly == true, enabled = state != null && !busy, onToggle = { want -> @@ -108,7 +110,7 @@ internal fun FilePropertiesDialog( attrs = attrs?.copy(readOnly = want) onChanged() } else { - Toast.makeText(context, "Couldn't change Read-only", Toast.LENGTH_SHORT).show() + Toast.makeText(context, R.string.fm_read_only_failed, Toast.LENGTH_SHORT).show() } } }, @@ -117,10 +119,10 @@ internal fun FilePropertiesDialog( // ── Hidden ── Wine's DOS hidden bit in the user.DOSATTRIB xattr. val hiddenSupported = state?.hiddenSupported == true AttributeToggleRow( - label = "Hidden", + label = stringResource(R.string.fm_hidden), description = if (state != null && !hiddenSupported) - "This storage can't store the hidden flag." - else "Marks the file hidden in Windows (Wine's hidden attribute).", + stringResource(R.string.fm_hidden_unsupported) + else stringResource(R.string.fm_hidden_hint), checked = state?.hidden == true, enabled = state != null && hiddenSupported && !busy, onToggle = { want -> @@ -134,14 +136,14 @@ internal fun FilePropertiesDialog( } else { // The write failed after all - disable the toggle rather than lie. attrs = attrs?.copy(hiddenSupported = false) - Toast.makeText(context, "Couldn't change Hidden on this storage", Toast.LENGTH_SHORT).show() + Toast.makeText(context, R.string.fm_hidden_failed, Toast.LENGTH_SHORT).show() } } }, ) } }, - confirmButton = { TextButton(onClick = onDismiss) { Text("Done") } }, + confirmButton = { TextButton(onClick = onDismiss) { Text(stringResource(R.string.fm_done)) } }, ) } diff --git a/app/src/main/java/com/droiddeck/launcher/files/StorageRoots.kt b/app/src/main/java/com/droiddeck/launcher/files/StorageRoots.kt index 942c65368..a53e792ce 100644 --- a/app/src/main/java/com/droiddeck/launcher/files/StorageRoots.kt +++ b/app/src/main/java/com/droiddeck/launcher/files/StorageRoots.kt @@ -5,6 +5,7 @@ import android.os.Build import android.os.Environment import android.os.storage.StorageManager import android.os.storage.StorageVolume +import com.droiddeck.launcher.R import java.io.File /** @@ -63,7 +64,7 @@ object StorageRoots { // Internal storage is never removable and never absent; seed it first so it heads the menu. volumeOf(PRIMARY_KEY).apply { - label = "Internal" + label = context.getString(R.string.fm_drive_internal) removable = false candidates += File(INTERNAL_PATH) } @@ -109,13 +110,13 @@ object StorageRoots { entry.seeds += dir } - val roots = volumes.values.map { it.toRoot() } + val roots = volumes.values.map { it.toRoot(context) } val internal = roots.filter { !it.removable } val removable = roots.filter { it.removable }.sortedBy { it.label } return disambiguate(internal + removable) } - private fun Volume.toRoot(): StorageRoot { + private fun Volume.toRoot(context: Context): StorageRoot { // Prefer a path we can actually list; a readable child beats an unreadable root. val dir = candidates.firstOrNull(::canBrowse) ?: candidates.firstNotNullOfOrNull { root -> seeds.firstNotNullOfOrNull { deepestReadable(root, it) } } @@ -125,14 +126,14 @@ object StorageRoots { ?: File("/storage/$key") return StorageRoot( - label = label ?: defaultLabel(), + label = label ?: defaultLabel(context), dir = dir, removable = removable, readable = canBrowse(dir), ) } - private fun Volume.defaultLabel(): String = if (removable) "SD card" else key + private fun Volume.defaultLabel(context: Context): String = if (removable) context.getString(R.string.fm_drive_sd) else key /** Appends the volume id to any label used by more than one volume, so entries stay tellable apart. */ private fun disambiguate(roots: List): List { @@ -183,12 +184,12 @@ object StorageRoots { * name like "android", which tells the user nothing about which card they are looking at. */ private fun labelFor(context: Context, volume: StorageVolume, uuid: String?): String { - if (volume.isPrimary) return "Internal" - if (volume.isRemovable) return "SD card" + if (volume.isPrimary) return context.getString(R.string.fm_drive_internal) + if (volume.isRemovable) return context.getString(R.string.fm_drive_sd) val description = volume.getDescription(context)?.trim() return description?.takeIf { it.isNotBlank() && !it.equals("android", ignoreCase = true) } ?: uuid - ?: "Storage" + ?: context.getString(R.string.fm_drive_storage) } private fun isEmulated(dir: File): Boolean = dir.absolutePath.startsWith(EMULATED_PREFIX) 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 b98444923..f7faf7587 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/GameFileSync.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/GameFileSync.kt @@ -2,6 +2,7 @@ package com.droiddeck.launcher.frontend import android.content.Context import android.util.Log +import com.droiddeck.launcher.R import com.droiddeck.launcher.runtime.LinuxRuntime import com.droiddeck.launcher.session.GameStorage import com.droiddeck.launcher.session.SessionPrefs @@ -37,17 +38,17 @@ object GameFileSync { } @Synchronized private fun sync(context: Context, folder: File) { - check(LinuxRuntime.isInstalled(context)) { "Install the runtime first" } + check(LinuxRuntime.isInstalled(context)) { context.getString(R.string.game_sync_err_runtime) } // A disconnected library must not be interpreted as a mass uninstall. - check(File(LinuxRuntime.rootDir(context), "root/.local/share/Steam/steamapps").isDirectory) { "Steam library is unavailable" } + check(File(LinuxRuntime.rootDir(context), "root/.local/share/Steam/steamapps").isDirectory) { context.getString(R.string.game_sync_err_steam_library) } val storage = GameStorage.effective(context) val storageSetting = SessionPrefs.gameStorage(context) val previousStorage = prefs(context).getString("storagePath", null) if (storageSetting.isEmpty() && prefs(context).getString("storageSetting", null) == storageSetting && previousStorage != null) { - check(File(previousStorage).isDirectory) { "Previous SD library is unavailable" } + check(File(previousStorage).isDirectory) { context.getString(R.string.game_sync_err_previous_sd) } } - storage?.let { check(File(it.path).listFiles() != null) { "Game storage is unavailable" } } - SessionPrefs.addedGamesDirs(context).forEach { check(File(it).listFiles() != null) { "Added games folder is unavailable" } } + 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)) prefs(context).edit().putString("storageSetting", storageSetting).putString("storagePath", storage?.path).apply() } diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt b/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt index 9ccc0ff3b..68ac5a7f0 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt @@ -33,6 +33,8 @@ object Library { class Rom(val name: String, val hostPath: File, val guestPath: String, val emulatorId: String, val art: File? = null) class Emulator(val id: String, val name: String, val system: String, val program: String, val installed: Boolean, val games: List) { + /** The shown name of [system] when it is words rather than a platform name, else 0. */ + val systemRes: Int get() = if (id == "retroarch") R.string.content_system_many else 0 /** The emulator's own icon, bundled (the runtime keeps them as theme SVGs the app cannot draw). */ val iconRes: Int get() = when (id) { "rpcs3" -> R.drawable.emu_rpcs3; "armsx2" -> R.drawable.emu_pcsx2; "dolphin" -> R.drawable.emu_dolphin @@ -109,7 +111,7 @@ object Library { for ((library, label) in libraries) { val steamapps = File(library, "steamapps") val manifests = steamapps.listFiles { f -> f.isFile && f.name.startsWith("appmanifest_") && f.name.endsWith(".acf") } - if (strictRead && steamapps.isDirectory) check(manifests != null) { "Steam manifests are unavailable" } + if (strictRead && steamapps.isDirectory) check(manifests != null) { context.getString(R.string.game_sync_err_manifests) } manifests?.sortedBy { it.name }?.forEach { manifest -> val appId = manifest.name.removePrefix("appmanifest_").removeSuffix(".acf").toIntOrNull() ?: return@forEach if (appId in NOT_GAMES || out.containsKey(appId)) return@forEach diff --git a/app/src/main/java/com/droiddeck/launcher/input/ControllerEditorActivity.kt b/app/src/main/java/com/droiddeck/launcher/input/ControllerEditorActivity.kt index 8b49a4a73..7b5e502f1 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/ControllerEditorActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/ControllerEditorActivity.kt @@ -24,6 +24,8 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import androidx.compose.ui.res.stringResource +import com.droiddeck.launcher.R import com.droiddeck.launcher.ui.DroidDeckTheme import com.droiddeck.launcher.ui.onSignal import com.droiddeck.launcher.ui.LocalPalette @@ -53,10 +55,10 @@ class ControllerEditorActivity : ComponentActivity() { .background(MaterialTheme.colorScheme.surface.copy(alpha = 0.9f), RoundedCornerShape(50)) .padding(start = 14.dp, end = 5.dp, top = 5.dp, bottom = 5.dp), ) { - Text("Drag to move", fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(end = 4.dp)) - EditorButton("Reset", false) { controls.resetLayout() } - EditorButton("Cancel", false) { finish() } - EditorButton("Save", true) { + Text(stringResource(R.string.ctrl_editor_drag), fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(end = 4.dp)) + EditorButton(stringResource(R.string.ctrl_reset), false) { controls.resetLayout() } + EditorButton(stringResource(R.string.common_cancel), false) { finish() } + EditorButton(stringResource(R.string.ctrl_editor_save), true) { controls.saveLayout() finish() } diff --git a/app/src/main/java/com/droiddeck/launcher/input/ControllerPrefs.kt b/app/src/main/java/com/droiddeck/launcher/input/ControllerPrefs.kt index a5a130429..8ba190493 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/ControllerPrefs.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/ControllerPrefs.kt @@ -1,20 +1,21 @@ package com.droiddeck.launcher.input import android.content.Context +import com.droiddeck.launcher.R object ControllerPrefs { const val STEAM_BLUE = 0xFF1A9FFF.toInt() const val OFF = "off" val tints = listOf( - STEAM_BLUE to "Steam blue", - 0xFF66C0F4.toInt() to "Sky", - 0xFFE8EEF4.toInt() to "White", - 0xFFC77DFF.toInt() to "Violet", - 0xFF3DDC84.toInt() to "Green", - 0xFFFFA726.toInt() to "Amber", - 0xFFFF5252.toInt() to "Red", - 0xFFFF6FB5.toInt() to "Pink", + STEAM_BLUE to R.string.ctrl_tint_steam_blue, + 0xFF66C0F4.toInt() to R.string.ctrl_tint_sky, + 0xFFE8EEF4.toInt() to R.string.ctrl_tint_white, + 0xFFC77DFF.toInt() to R.string.ctrl_tint_violet, + 0xFF3DDC84.toInt() to R.string.ctrl_tint_green, + 0xFFFFA726.toInt() to R.string.ctrl_tint_amber, + 0xFFFF5252.toInt() to R.string.ctrl_tint_red, + 0xFFFF6FB5.toInt() to R.string.ctrl_tint_pink, ) val opacities = listOf(40, 60, 80, 100) @@ -22,17 +23,17 @@ object ControllerPrefs { val sizes = listOf(80, 90, 100, 110, 125) val mappable = listOf( - "a" to "A button", "b" to "B button", "x" to "X button", "y" to "Y button", - "lb" to "Left bumper", "rb" to "Right bumper", "lt" to "Left trigger", "rt" to "Right trigger", - "select" to "View button", "start" to "Menu button", + "a" to R.string.ctrl_button_a, "b" to R.string.ctrl_button_b, "x" to R.string.ctrl_button_x, "y" to R.string.ctrl_button_y, + "lb" to R.string.ctrl_button_lb, "rb" to R.string.ctrl_button_rb, "lt" to R.string.ctrl_button_lt, "rt" to R.string.ctrl_button_rt, + "select" to R.string.ctrl_button_view, "start" to R.string.ctrl_button_menu, ) val targets = listOf( - "a" to "A", "b" to "B", "x" to "X", "y" to "Y", - "lb" to "LB", "rb" to "RB", "lt" to "LT", "rt" to "RT", - "l3" to "L3", "r3" to "R3", "select" to "View", "start" to "Menu", "guide" to "Steam", - "up" to "D-pad up", "down" to "D-pad down", "left" to "D-pad left", "right" to "D-pad right", - OFF to "Hidden", + "a" to R.string.ctrl_target_a, "b" to R.string.ctrl_target_b, "x" to R.string.ctrl_target_x, "y" to R.string.ctrl_target_y, + "lb" to R.string.ctrl_target_lb, "rb" to R.string.ctrl_target_rb, "lt" to R.string.ctrl_target_lt, "rt" to R.string.ctrl_target_rt, + "l3" to R.string.ctrl_target_l3, "r3" to R.string.ctrl_target_r3, "select" to R.string.ctrl_target_view, "start" to R.string.ctrl_target_menu, "guide" to R.string.ctrl_target_steam, + "up" to R.string.ctrl_target_up, "down" to R.string.ctrl_target_down, "left" to R.string.ctrl_target_left, "right" to R.string.ctrl_target_right, + OFF to R.string.ctrl_target_hidden, ) class Settings( diff --git a/app/src/main/java/com/droiddeck/launcher/input/SecondScreenMode.kt b/app/src/main/java/com/droiddeck/launcher/input/SecondScreenMode.kt index 4b08a6d21..de5f70d94 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/SecondScreenMode.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/SecondScreenMode.kt @@ -2,14 +2,16 @@ package com.droiddeck.launcher.input import android.hardware.display.DisplayManager import android.view.Display +import androidx.annotation.StringRes +import com.droiddeck.launcher.R /** The control surface shown on a secondary Android display during a Linux session. */ -enum class SecondScreenMode(val id: String, val label: String) { - NONE("none", "None"), - KEYBOARD_TRACKPAD("keyboard-trackpad", "Keyboard + trackpad"), - TERMINAL("terminal", "Terminal"), +enum class SecondScreenMode(val id: String, @StringRes val label: Int) { + NONE("none", R.string.second_mode_none), + KEYBOARD_TRACKPAD("keyboard-trackpad", R.string.second_mode_keyboard_trackpad), + TERMINAL("terminal", R.string.second_mode_terminal), /** The Steam Deck controller's back grips and trackpads; offered while the pad is one. */ - DECK_CONTROLS("deck-controls", "Deck grips + trackpads"), + DECK_CONTROLS("deck-controls", R.string.second_mode_deck_controls), } data class SecondScreenDisplay(val id: Int, val label: String) diff --git a/app/src/main/java/com/droiddeck/launcher/store/FlathubApi.kt b/app/src/main/java/com/droiddeck/launcher/store/FlathubApi.kt index 536e2aa9e..a26c4d4a4 100644 --- a/app/src/main/java/com/droiddeck/launcher/store/FlathubApi.kt +++ b/app/src/main/java/com/droiddeck/launcher/store/FlathubApi.kt @@ -1,6 +1,8 @@ package com.droiddeck.launcher.store import android.util.Log +import androidx.annotation.StringRes +import com.droiddeck.launcher.R import org.json.JSONArray import org.json.JSONObject import java.net.HttpURLConnection @@ -32,13 +34,13 @@ object FlathubApi { ) /** A category as Flathub's search filters it, with the name shown for it. */ - class Category(val id: String, val label: String) + class Category(val id: String, @StringRes val label: Int) val categories = listOf( - Category("Game", "Games"), Category("AudioVideo", "Audio & Video"), Category("Graphics", "Graphics"), - Category("Network", "Internet"), Category("Office", "Office"), Category("Development", "Developer"), - Category("Education", "Education"), Category("Science", "Science"), Category("System", "System"), - Category("Utility", "Utilities"), + Category("Game", R.string.store_cat_games), Category("AudioVideo", R.string.store_cat_audio_video), Category("Graphics", R.string.store_cat_graphics), + Category("Network", R.string.store_cat_internet), Category("Office", R.string.store_cat_office), Category("Development", R.string.store_cat_developer), + Category("Education", R.string.store_cat_education), Category("Science", R.string.store_cat_science), Category("System", R.string.store_cat_system), + Category("Utility", R.string.store_cat_utilities), ) /** Front-page collections: popular, trending, recently-updated, recently-added. */ diff --git a/app/src/main/java/com/droiddeck/launcher/store/StoreState.kt b/app/src/main/java/com/droiddeck/launcher/store/StoreState.kt index 1564194df..b2c35911a 100644 --- a/app/src/main/java/com/droiddeck/launcher/store/StoreState.kt +++ b/app/src/main/java/com/droiddeck/launcher/store/StoreState.kt @@ -8,6 +8,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateMapOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue +import com.droiddeck.launcher.R import com.droiddeck.launcher.runtime.FlatpakManager /** @@ -49,7 +50,7 @@ object StoreState { private set private var searchSeq = 0 - val SECTIONS = listOf("popular" to "Popular", "trending" to "Trending", "recently-added" to "New", "recently-updated" to "Updated") + val SECTIONS = listOf("popular" to R.string.store_section_popular, "trending" to R.string.store_section_trending, "recently-added" to R.string.store_section_new, "recently-updated" to R.string.store_section_updated) fun refresh(context: Context) { val app = context.applicationContext @@ -97,7 +98,7 @@ object StoreState { private fun run(context: Context, what: String, label: String, work: (Context, (String, Int) -> Unit) -> String?) { if (busy != null) return val app = context.applicationContext - busy = what; stage = "Starting…"; percent = -1 + busy = what; stage = app.getString(R.string.store_starting); percent = -1 Thread({ val problem = try { work(app) { s, p -> main.post { stage = s; percent = p } } @@ -109,12 +110,12 @@ object StoreState { main.post { busy = null; stage = null; percent = -1 ready = r; installed = list - if (problem != null) Toast.makeText(app, "$label: $problem", Toast.LENGTH_LONG).show() + if (problem != null) Toast.makeText(app, app.getString(R.string.store_problem, label, problem), Toast.LENGTH_LONG).show() } }, "store-$what").start() } - fun setup(context: Context) = run(context, "setup", "Flatpak setup") { c, p -> FlatpakManager.setup(c, p) } + fun setup(context: Context) = run(context, "setup", context.getString(R.string.store_flatpak_setup)) { c, p -> FlatpakManager.setup(c, p) } fun install(context: Context, id: String, name: String) = run(context, id, name) { c, p -> FlatpakManager.install(c, id, p) } @@ -135,7 +136,7 @@ object StoreState { val u = FlatpakManager.updates(app) main.post { checkingUpdates = false - if (u != null) { updates = u; updatesChecked = true } else Toast.makeText(app, "Could not check Flathub for updates", Toast.LENGTH_SHORT).show() + if (u != null) { updates = u; updatesChecked = true } else Toast.makeText(app, R.string.store_updates_check_failed, Toast.LENGTH_SHORT).show() } }, "store-updates").start() } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ControllerSettings.kt b/app/src/main/java/com/droiddeck/launcher/ui/ControllerSettings.kt index db6f1bbc1..25e6bc4d9 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/ControllerSettings.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/ControllerSettings.kt @@ -49,12 +49,12 @@ fun ColumnScope.ControllerRows(host: MenuHost, oscMode: String, c: ControllerPre val tintOpen = host.open == "controller-tint" SettingsRow(stringResource(R.string.ctrl_color), stringResource(R.string.ctrl_color_hint), highlighted = tintOpen) { Box { - ValueChip(ControllerPrefs.tints.firstOrNull { it.first == c.tint }?.second ?: stringResource(R.string.ctrl_custom), tintOpen) { + ValueChip(ControllerPrefs.tints.firstOrNull { it.first == c.tint }?.second?.let { stringResource(it) } ?: stringResource(R.string.ctrl_custom), tintOpen) { host.open = if (tintOpen) null else "controller-tint" } AnchoredMenu(tintOpen, onDismiss = { if (host.open == "controller-tint") host.open = null }, title = stringResource(R.string.ctrl_color)) { firstItemFocus -> ControllerPrefs.tints.forEachIndexed { index, (color, name) -> - MenuItem(name, checked = c.tint == color, leading = { Swatch(color) }, focusRequester = if (index == 0) firstItemFocus else null) { + MenuItem(stringResource(name), checked = c.tint == color, leading = { Swatch(color) }, focusRequester = if (index == 0) firstItemFocus else null) { a.onTint(color) host.open = null } @@ -90,8 +90,9 @@ fun ControllerMappingPage(mapping: Map, onPick: (String, String) onBack = onBack, ) { SettingsGroup(stringResource(R.string.ctrl_onscreen_buttons)) { + val targets = ControllerPrefs.targets.map { (id, label) -> id to stringResource(label) } for ((id, name) in ControllerPrefs.mappable) { - ChoiceRow(host, "map-$id", name, null, ControllerPrefs.targets, mapping[id] ?: id) { onPick(id, it) } + ChoiceRow(host, "map-$id", stringResource(name), null, targets, mapping[id] ?: id) { onPick(id, it) } } } SettingsGroup(stringResource(R.string.ctrl_defaults)) { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndContent.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndContent.kt index e2b79a198..9454a7c2a 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndContent.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndContent.kt @@ -307,7 +307,7 @@ private fun Content( Column { Text(e.name, fontSize = if (narrow) 22.sp else 26.sp, fontWeight = FontWeight.Bold, color = colors.onBackground) Text( - e.system.replaceFirstChar { it.uppercase() }.let { if (e.installed) it else stringResource(R.string.content_not_installed_suffix, it) }, + systemLabel(e).let { if (e.installed) it else stringResource(R.string.content_not_installed_suffix, it) }, fontSize = 14.sp, color = colors.onSurfaceVariant, ) } @@ -334,7 +334,7 @@ private fun Content( ) } else Rise(5, Modifier.fillMaxWidth()) { - ArtGrid(e.games.mapIndexed { index, g -> Tile(g.name, if (g.art != null) "installed" else g.hostPath.extension.uppercase().ifEmpty { "folder" }, g.art, "rom:${e.id}:$index", e.iconRes) { onSelect("rom:${e.id}:$index") } }, wide = e.games.none { it.art != null }) + ArtGrid(e.games.mapIndexed { index, g -> Tile(g.name, if (g.art != null) stringResource(R.string.content_rom_installed) else g.hostPath.extension.uppercase().ifEmpty { stringResource(R.string.content_rom_folder) }, g.art, "rom:${e.id}:$index", e.iconRes) { onSelect("rom:${e.id}:$index") } }, wide = e.games.none { it.art != null }) } } else { if (pkg != null) Rise(2) { @@ -379,7 +379,7 @@ private fun Content( Rise(0) { Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp)) { BackLink(e.name) { onSelect("emu:${e.id}") } - Eyebrow(stringResource(R.string.content_desktop_system, e.system)) + Eyebrow(stringResource(R.string.content_desktop_system, systemLabel(e))) } } Rise(1) { Title(g.name) } @@ -391,7 +391,7 @@ private fun Content( Actions { Image(painterResource(e.iconRes), null, modifier = Modifier.size(40.dp)) PrimaryButton(stringResource(R.string.content_launch_in, e.name), enabled = !s.busy, main = true) { a.onRom(g) } - if (s.busy) BusyChip(s) else ActionChip(g.hostPath.extension.uppercase().ifEmpty { "folder" }, ok = false) + if (s.busy) BusyChip(s) else ActionChip(g.hostPath.extension.uppercase().ifEmpty { stringResource(R.string.content_rom_folder) }, ok = false) } } if (g.art != null && !narrow) Poster(g.art, g.name, Modifier.width(detailPosterWidth)) @@ -403,7 +403,7 @@ private fun Content( Rise(4, Modifier.fillMaxWidth()) { ArtGrid(others.map { x -> val index = e.games.indexOf(x) - Tile(x.name, if (x.art != null) "installed" else x.hostPath.extension.uppercase().ifEmpty { "folder" }, x.art, "rom:${e.id}:$index", e.iconRes) { onSelect("rom:${e.id}:$index") } + Tile(x.name, if (x.art != null) stringResource(R.string.content_rom_installed) else x.hostPath.extension.uppercase().ifEmpty { stringResource(R.string.content_rom_folder) }, x.art, "rom:${e.id}:$index", e.iconRes) { onSelect("rom:${e.id}:$index") } }, wide = others.none { it.art != null }) } } @@ -658,10 +658,14 @@ private fun UpdateButton(app: UserApps.App, s: FrontEndState) { * contrast - dimming it read as disabled rather than one press from installing. */ @Composable +private fun systemLabel(e: Library.Emulator): String = + if (e.systemRes != 0) stringResource(e.systemRes) else e.system.replaceFirstChar { it.uppercase() } + +@Composable private fun EmulatorTile(e: Library.Emulator, modifier: Modifier, isFirst: Boolean, onClick: () -> Unit) { val colors = MaterialTheme.colorScheme val pal = LocalPalette.current - val system = e.system.replaceFirstChar { it.uppercase() } + val system = systemLabel(e) val detail = if (e.installed && e.id != "retroarch") "$system · " + pluralStringResource(R.plurals.mode_added_count, e.games.size, e.games.size) else system TileFrame("emu:${e.id}", modifier, isFirst, filled = e.installed, onClick = onClick) { Image(painterResource(e.iconRes), contentDescription = null, modifier = Modifier.size(if (e.installed) 44.dp else 36.dp)) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt index 0fa5e6e70..95675cf35 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt @@ -318,10 +318,10 @@ internal fun SetupPanel( LanguageRow(host, s.language, a.onLanguage) SettingsRow(stringResource(R.string.setup_theme), stringResource(R.string.setup_theme_hint)) { Box { - ValueChip(Themes.byId(s.theme).label, host.open == "theme") { host.open = if (host.open == "theme") null else "theme" } + ValueChip(stringResource(Themes.byId(s.theme).label), host.open == "theme") { host.open = if (host.open == "theme") null else "theme" } AnchoredMenu(host.open == "theme", onDismiss = { if (host.open == "theme") host.open = null }, title = stringResource(R.string.setup_theme)) { firstItemFocus -> Themes.all.forEachIndexed { index, theme -> - MenuItem(theme.label, checked = s.theme == theme.id, focusRequester = if (index == 0) firstItemFocus else null) { + MenuItem(stringResource(theme.label), checked = s.theme == theme.id, focusRequester = if (index == 0) firstItemFocus else null) { a.onTheme(theme.id) host.open = null } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt index 36997decf..da74f39ee 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt @@ -205,9 +205,9 @@ fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) { onPick = a.onFpsLimit, ) ChoiceRow( - host, "upscaler", stringResource(R.string.drawer_scaling), "How the picture is resized to the screen; the sharpening modes sharpen where it is enlarged.", + host, "upscaler", stringResource(R.string.drawer_scaling), stringResource(R.string.mode_upscaler_hint), com.droiddeck.launcher.session.SessionPrefs.upscalerChoices, s.upscaler, - note = "The sharpening modes work only when the session is smaller than the screen; Linear, Nearest and Sharpen only work at any size. Costs a little GPU time.", + note = stringResource(R.string.mode_upscaler_note), onPick = a.onUpscaler, ) SliderRow( @@ -335,11 +335,11 @@ fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) { onChange = a.onDeckyEnabled, ) SettingsRow( - "Plugins", - "Install a plugin ZIP for the next Steam session.", + stringResource(R.string.mode_decky_plugins), + stringResource(R.string.mode_decky_plugins_hint), ) { SecondaryButton( - if (s.deckyStage?.startsWith("Downloading plugin binary") == true) "Downloading…" else "Install from ZIP", + if (s.deckyStage?.startsWith("Downloading plugin binary") == true) stringResource(R.string.mode_decky_plugin_downloading) else stringResource(R.string.mode_decky_plugin_install_zip), enabled = s.deckyInstalled != null && s.deckyStage == null && !s.deckySessionRunning, onClick = a.onPickDeckyPluginZip, ) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/PcKeyboard.kt b/app/src/main/java/com/droiddeck/launcher/ui/PcKeyboard.kt index 8bbc4b2d8..e4450662d 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/PcKeyboard.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/PcKeyboard.kt @@ -1,6 +1,7 @@ package com.droiddeck.launcher.ui import com.droiddeck.launcher.R +import androidx.annotation.StringRes import androidx.compose.ui.res.stringResource import android.view.KeyEvent import androidx.compose.animation.animateColorAsState @@ -63,40 +64,42 @@ import androidx.compose.ui.unit.sp * modifier for the next key, a second tap locks it, a third lets it go. A controller moves over the * keys with the d-pad and presses with A. */ -private data class PcKey(val label: String, val code: Int, val weight: Float = 1f, val shifted: String? = null) +private data class PcKey(val label: String, val code: Int, val weight: Float = 1f, val shifted: String? = null, @StringRes val labelRes: Int = 0) private fun k(label: String, code: Int, weight: Float = 1f, shifted: String? = null) = PcKey(label, code, weight, shifted) +private fun k(@StringRes labelRes: Int, code: Int, weight: Float = 1f) = PcKey("", code, weight, null, labelRes) + private val ROWS: List> = listOf( listOf( - k("Esc", 1), k("F1", 59), k("F2", 60), k("F3", 61), k("F4", 62), k("F5", 63), k("F6", 64), + k(R.string.pckb_key_esc, 1), k("F1", 59), k("F2", 60), k("F3", 61), k("F4", 62), k("F5", 63), k("F6", 64), k("F7", 65), k("F8", 66), k("F9", 67), k("F10", 68), k("F11", 87), k("F12", 88), - k("Ins", 110), k("Del", 111), k("Home", 102), k("End", 107), k("PgUp", 104), k("PgDn", 109), + k(R.string.pckb_key_ins, 110), k(R.string.pckb_key_del, 111), k(R.string.pckb_key_home, 102), k(R.string.pckb_key_end, 107), k(R.string.pckb_key_pgup, 104), k(R.string.pckb_key_pgdn, 109), ), listOf( k("`", 41, shifted = "~"), k("1", 2, shifted = "!"), k("2", 3, shifted = "@"), k("3", 4, shifted = "#"), k("4", 5, shifted = "$"), k("5", 6, shifted = "%"), k("6", 7, shifted = "^"), k("7", 8, shifted = "&"), k("8", 9, shifted = "*"), k("9", 10, shifted = "("), k("0", 11, shifted = ")"), k("-", 12, shifted = "_"), - k("=", 13, shifted = "+"), k("⌫ Backspace", 14, 2f), + k("=", 13, shifted = "+"), k(R.string.pckb_key_backspace, 14, 2f), ), listOf( - k("Tab ⇥", 15, 1.5f), k("q", 16), k("w", 17), k("e", 18), k("r", 19), k("t", 20), k("y", 21), + k(R.string.pckb_key_tab, 15, 1.5f), k("q", 16), k("w", 17), k("e", 18), k("r", 19), k("t", 20), k("y", 21), k("u", 22), k("i", 23), k("o", 24), k("p", 25), k("[", 26, shifted = "{"), k("]", 27, shifted = "}"), k("\\", 43, 1.5f, shifted = "|"), ), listOf( - k("Caps", 58, 1.75f), k("a", 30), k("s", 31), k("d", 32), k("f", 33), k("g", 34), k("h", 35), + k(R.string.pckb_key_caps, 58, 1.75f), k("a", 30), k("s", 31), k("d", 32), k("f", 33), k("g", 34), k("h", 35), k("j", 36), k("k", 37), k("l", 38), k(";", 39, shifted = ":"), k("'", 40, shifted = "\""), - k("Enter ⏎", 28, 2.25f), + k(R.string.pckb_key_enter, 28, 2.25f), ), listOf( - k("⇧ Shift", 42, 2.25f), k("z", 44), k("x", 45), k("c", 46), k("v", 47), k("b", 48), k("n", 49), + k(R.string.pckb_key_shift, 42, 2.25f), k("z", 44), k("x", 45), k("c", 46), k("v", 47), k("b", 48), k("n", 49), k("m", 50), k(",", 51, shifted = "<"), k(".", 52, shifted = ">"), k("/", 53, shifted = "?"), - k("⇧ Shift", 54, 1.75f), k("↑", 103), + k(R.string.pckb_key_shift, 54, 1.75f), k("↑", 103), ), listOf( - k("Ctrl", 29, 1.5f), k("Super", 125, 1.25f), k("Alt", 56, 1.25f), k("Space", 57, 6.25f), - k("AltGr", 100, 1.25f), k("Ctrl", 97, 1.25f), k("←", 105), k("↓", 108), k("→", 106), + k(R.string.pckb_key_ctrl, 29, 1.5f), k(R.string.pckb_key_super, 125, 1.25f), k(R.string.pckb_key_alt, 56, 1.25f), k(R.string.pckb_key_space, 57, 6.25f), + k(R.string.pckb_key_altgr, 100, 1.25f), k(R.string.pckb_key_ctrl, 97, 1.25f), k("←", 105), k("↓", 108), k("→", 106), ), ) @@ -171,6 +174,7 @@ fun PcKeyboard( val state = mods[key.code] ?: MOD_OFF val lit = state != MOD_OFF || (key.code == 58 && capsOn) val label = when { + key.labelRes != 0 -> stringResource(key.labelRes) shifted && key.shifted != null -> key.shifted key.label.length == 1 && key.label[0].isLetter() && (shifted xor capsOn) -> key.label.uppercase() else -> key.label diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SecondScreenPresentation.kt b/app/src/main/java/com/droiddeck/launcher/ui/SecondScreenPresentation.kt index 44f56bad8..92cb32117 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SecondScreenPresentation.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SecondScreenPresentation.kt @@ -226,22 +226,24 @@ class SecondScreenPresentation( } keys.addView(button) } - key("Esc", "\u001b") - key("Tab", "\t") - key("Ctrl", "") { button -> + val ctrl = context.getString(R.string.pckb_key_ctrl) + val alt = context.getString(R.string.pckb_key_alt) + key(context.getString(R.string.pckb_key_esc), "\u001b") + key(context.getString(R.string.second_key_tab), "\t") + key(ctrl, "") { button -> ctrlActive = !ctrlActive - button.text = if (ctrlActive) "Ctrl ✓" else "Ctrl" + button.text = if (ctrlActive) context.getString(R.string.second_key_on, ctrl) else ctrl } - key("Alt", "") { button -> + key(alt, "") { button -> altActive = !altActive - button.text = if (altActive) "Alt ✓" else "Alt" + button.text = if (altActive) context.getString(R.string.second_key_on, alt) else alt } key("↑", "\u001b[A") key("↓", "\u001b[B") key("←", "\u001b[D") key("→", "\u001b[C") - key("Ctrl+C", "\u0003") - key("Ctrl+D", "\u0004") + key(context.getString(R.string.second_key_ctrl_c), "\u0003") + key(context.getString(R.string.second_key_ctrl_d), "\u0004") keyStrip.addView(keys) root.addView(keyStrip, LinearLayout.LayoutParams(-1, -2)) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt b/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt index 5d0f851d2..a9fe708f1 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt @@ -427,7 +427,7 @@ fun SessionDrawer(open: Boolean, page: Int, controllerActive: Boolean, onPageCha ChoiceRow(host, "second-screen-mode", stringResource(R.string.drawer_second_screen_shows), null, (listOf(SecondScreenMode.NONE, SecondScreenMode.KEYBOARD_TRACKPAD, SecondScreenMode.TERMINAL) + (if (com.droiddeck.launcher.session.SessionState.deckPad) listOf(SecondScreenMode.DECK_CONTROLS) else emptyList())) - .map { it to it.label }, + .map { it to stringResource(it.label) }, a.secondScreenMode, chipModifier = focus.track(page, "second-screen-mode"), onPick = a.onSecondScreenMode) if (a.secondScreenDisplays.size > 1) ChoiceRow(host, "second-screen-display", stringResource(R.string.drawer_page_display), null, a.secondScreenDisplays.map { it.id to it.label }, a.selectedSecondScreenDisplay, diff --git a/app/src/main/java/com/droiddeck/launcher/ui/StorePage.kt b/app/src/main/java/com/droiddeck/launcher/ui/StorePage.kt index d8ea15892..bf334e2d2 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/StorePage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/StorePage.kt @@ -185,7 +185,7 @@ private fun Discover(onOpen: (String) -> Unit, onCategory: (String) -> Unit) { Rise(3) { SectionTitle(stringResource(R.string.store_categories), null) } Rise(3) { Row(horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(vertical = 4.dp)) { - FlathubApi.categories.forEach { c -> PillButton(c.label, selected = false) { onCategory(c.id) } } + FlathubApi.categories.forEach { c -> PillButton(stringResource(c.label), selected = false) { onCategory(c.id) } } } } if (StoreState.sectionsFailed && StoreState.sections.values.all { it.isEmpty() }) { @@ -195,7 +195,7 @@ private fun Discover(onOpen: (String) -> Unit, onCategory: (String) -> Unit) { } StoreState.SECTIONS.forEachIndexed { i, (key, title) -> val apps = StoreState.sections[key] - Rise(4 + i) { SectionTitle(title, apps?.let { if (it.isEmpty()) null else it.size.toString() } ?: "loading…") } + Rise(4 + i) { SectionTitle(stringResource(title), apps?.let { if (it.isEmpty()) null else it.size.toString() } ?: stringResource(R.string.store_section_loading)) } if (apps != null && apps.isNotEmpty()) Rise(4 + i) { AppGrid(apps.take(12), first = i == 0, onOpen = onOpen) } } } @@ -222,7 +222,7 @@ private fun Search(query: String, category: String?, onQuery: (String) -> Unit, Row(horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(top = 12.dp, bottom = 4.dp)) { PillButton(stringResource(R.string.store_all), selected = category == null) { onCategory(null); StoreState.search(query.trim(), null) } FlathubApi.categories.forEach { c -> - PillButton(c.label, selected = category == c.id) { onCategory(c.id); StoreState.search(query.trim(), c.id) } + PillButton(stringResource(c.label), selected = category == c.id) { onCategory(c.id); StoreState.search(query.trim(), c.id) } } } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/Theme.kt b/app/src/main/java/com/droiddeck/launcher/ui/Theme.kt index 331ad9507..f3e5d9525 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/Theme.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/Theme.kt @@ -1,5 +1,6 @@ package com.droiddeck.launcher.ui +import androidx.annotation.StringRes import androidx.compose.material3.MaterialTheme import androidx.compose.material3.darkColorScheme import androidx.compose.runtime.Composable @@ -8,10 +9,11 @@ import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.luminance import androidx.compose.ui.platform.LocalContext +import com.droiddeck.launcher.R import com.droiddeck.launcher.session.SessionPrefs class Palette( - val id: String, val label: String, val detail: String, + val id: String, @StringRes val label: Int, @StringRes val detail: Int, val background: Color, val surface: Color, val surfaceVariant: Color, val line: Color, val line2: Color, val onBackground: Color, val onSurfaceVariant: Color, val primary: Color, val primary2: Color, val onPrimary: Color, val signal: Color, @@ -26,28 +28,28 @@ object Themes { val all: List = listOf( Palette( - GRAPHITE, "Graphite", "Graphite surfaces, with the logo's own orb blue for everything selected, focused or pressed.", + GRAPHITE, R.string.theme_graphite, R.string.theme_graphite_detail, background = Color(0xFF0A0B0D), surface = Color(0xFF121417), surfaceVariant = Color(0xFF1A1D22), line = Color(0xFF262A31), line2 = Color(0xFF343A43), onBackground = Color(0xFFF2F4F7), onSurfaceVariant = Color(0xFF9AA3AF), primary = Color(0xFF1A9FFF), primary2 = Color(0xFF1487DB), onPrimary = Color(0xFF03111F), signal = Color(0xFF1A9FFF), good = Color(0xFF4CD37F), ), Palette( - PAPER, "Paper on black", "White is the primary, the icon's blue is the signal for rules, rings and dots.", + PAPER, R.string.theme_paper, R.string.theme_paper_detail, background = Color(0xFF000000), surface = Color(0xFF0F0F10), surfaceVariant = Color(0xFF191A1C), line = Color(0xFF262729), line2 = Color(0xFF343638), onBackground = Color(0xFFF9F9F9), onSurfaceVariant = Color(0xFF8E9196), primary = Color(0xFFF9F9F9), primary2 = Color(0xFFD9DADD), onPrimary = Color(0xFF000000), signal = Color(0xFF136CE0), good = Color(0xFF4CD37F), ), Palette( - ICON_BLUE, "Icon blue", "Black ground, white type, the blue for everything selected, focused or pressed.", + ICON_BLUE, R.string.theme_icon_blue, R.string.theme_icon_blue_detail, background = Color(0xFF050608), surface = Color(0xFF0E1116), surfaceVariant = Color(0xFF161B23), line = Color(0xFF1F2630), line2 = Color(0xFF2A3340), onBackground = Color(0xFFF2F4F7), onSurfaceVariant = Color(0xFF8A93A0), primary = Color(0xFF136CE0), primary2 = Color(0xFF0B4FB0), onPrimary = Color(0xFFFFFFFF), signal = Color(0xFF136CE0), good = Color(0xFF4CD37F), ), Palette( - ELECTRIC, "Electric navy", "The blue brighter, on surfaces that lean navy instead of grey.", + ELECTRIC, R.string.theme_electric, R.string.theme_electric_detail, background = Color(0xFF070A10), surface = Color(0xFF0F1522), surfaceVariant = Color(0xFF16203A), line = Color(0xFF1E2A47), line2 = Color(0xFF2A3A5E), onBackground = Color(0xFFEEF3FF), onSurfaceVariant = Color(0xFF8B9AB8), primary = Color(0xFF2E86FF), primary2 = Color(0xFF136CE0), onPrimary = Color(0xFFFFFFFF), signal = Color(0xFF2E86FF), diff --git a/app/src/main/res/values/strings_g2.xml b/app/src/main/res/values/strings_g2.xml new file mode 100644 index 000000000..75177729c --- /dev/null +++ b/app/src/main/res/values/strings_g2.xml @@ -0,0 +1,272 @@ + + + + How the picture is resized to the screen; the sharpening modes sharpen where it is enlarged. + The sharpening modes work only when the session is smaller than the screen; Linear, Nearest and Sharpen only work at any size. Costs a little GPU time. + Plugins + Install a plugin ZIP for the next Steam session. + Downloading… + Install from ZIP + + Games + Audio & Video + Graphics + Internet + Office + Developer + Education + Science + System + Utilities + Popular + Trending + + New + + Updated + loading… + Flatpak setup + + %1$s: %2$s + Could not check Flathub for updates + + + installed + + folder + + Graphite + Graphite surfaces, with the logo\'s own orb blue for everything selected, focused or pressed. + Paper on black + White is the primary, the icon\'s blue is the signal for rules, rings and dots. + Icon blue + Black ground, white type, the blue for everything selected, focused or pressed. + Electric navy + The blue brighter, on surfaces that lean navy instead of grey. + + Esc + Ins + Del + Home + End + PgUp + PgDn + ⌫ Backspace + Tab ⇥ + Caps + Enter ⏎ + ⇧ Shift + Ctrl + Super + Alt + Space + AltGr + + Tab + + %1$s ✓ + Ctrl+C + Ctrl+D + + Install the runtime first + Steam library is unavailable + Previous SD library is unavailable + Game storage is unavailable + Added games folder is unavailable + Steam manifests are unavailable + + Many systems + + Internal + SD card + Storage + Select + Properties + Add to Favorites + Remove from Favorites + Rename + Copy + Cut + Actions + Favorites + Pin current folder + No favorites yet - pin a folder with its ⋮ menu to jump back here fast. + Remove from favorites + 0 bytes + + bytes + Location + Type + Size + Modified + Folder + File + + %1$s file + Read-only + Stops games (and Wine) from overwriting or deleting this file. + Couldn\'t change Read-only + Hidden + This storage can\'t store the hidden flag. + Marks the file hidden in Windows (Wine\'s hidden attribute). + Couldn\'t change Hidden on this storage + Done + Deleting... + Delete failed + Moving... + Copying... + + Moving - %1$s + Copying - %1$s + + Moving %1$d/%2$d - %3$s + Copying %1$d/%2$d - %3$s + + %1$d done, %2$d failed + + %1$d done, %2$d skipped + + %1$d item moved + %1$d items moved + + + %1$d item copied + %1$d items copied + + + \"%1$s\" already exists + Renaming... + Rename failed + Creating folder... + Could not create folder + New Folder + Folder name + Create + New name + Delete? + + Delete \"%1$s\" permanently? + + Delete %1$d item? + Delete %1$d items? + + This can\'t be undone. + + + …and %1$d more + …and %1$d more + + + Deleting %1$d/%2$d - %3$s + + %1$d couldn\'t be deleted + %1$d couldn\'t be deleted + + Merge adds and replaces files inside the existing folder. + Overwrite replaces the existing file. + Apply to all conflicts + Merge + Overwrite + Keep both + Skip + Select this folder + Back + + %1$s is mounted but not readable right now + List view + Grid view + Search + Sort + Name + Date modified + Comfortable rows + Compact rows + Hide hidden files + Show hidden files + Hide favorites + Show favorites + Filter this folder + + %1$s free + %1$d selected + + None + + All + Paste + + %1$d item + %1$d items + + + Paste %1$s here + + Paste %1$s (move) here + Files + STORAGE + + QUICK + FAVORITES + Downloads + + Downlds + ROMs + Session logs + Pictures + + Added \"%1$s\" to Favorites + + Removed \"%1$s\" from Favorites + Empty directory + Choose a folder + Choose a file + + Steam blue + Sky + White + Violet + Green + Amber + Red + Pink + + A button + B button + X button + Y button + Left bumper + Right bumper + Left trigger + Right trigger + View button + Menu button + + A + B + X + Y + LB + RB + LT + RT + L3 + R3 + Steam + + View + + Menu + D-pad up + D-pad down + D-pad left + D-pad right + + Hidden + Drag to move + Save + + None + Keyboard + trackpad + Terminal + Deck grips + trackpads +