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 ee5ffd4dfa..1456e562e6 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/ControllerSettings.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/ControllerSettings.kt @@ -1,5 +1,7 @@ package com.droiddeck.launcher.ui +import com.droiddeck.launcher.R +import androidx.compose.ui.res.stringResource import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.layout.Arrangement @@ -36,17 +38,17 @@ private fun Swatch(color: Int) { @Composable fun ColumnScope.ControllerRows(host: MenuHost, oscMode: String, c: ControllerPrefs.Settings, a: ControllerActions) { ChoiceRow( - host, "controller-osc", "On-screen controls", "When the touch pad appears in a session", - listOf(SessionPrefs.OSC_AUTO to "Auto", SessionPrefs.OSC_ALWAYS to "Always", SessionPrefs.OSC_STEAM_QAM to "Steam + QAM", SessionPrefs.OSC_NEVER to "Never"), - oscMode, note = "Auto shows all controls without a controller. Steam + QAM shows only those buttons.", onPick = a.onOsc, + host, "controller-osc", stringResource(R.string.mode_osc), stringResource(R.string.ctrl_osc_hint), + listOf(SessionPrefs.OSC_AUTO to stringResource(R.string.common_auto), SessionPrefs.OSC_ALWAYS to stringResource(R.string.common_always), SessionPrefs.OSC_STEAM_QAM to stringResource(R.string.mode_osc_qam), SessionPrefs.OSC_NEVER to stringResource(R.string.common_never)), + oscMode, note = stringResource(R.string.mode_osc_note), onPick = a.onOsc, ) val tintOpen = host.open == "controller-tint" - SettingsRow("Color", "Tint of the on-screen buttons", highlighted = tintOpen) { + SettingsRow(stringResource(R.string.ctrl_color), stringResource(R.string.ctrl_color_hint), highlighted = tintOpen) { Box { - ValueChip(ControllerPrefs.tints.firstOrNull { it.first == c.tint }?.second ?: "Custom", tintOpen) { + ValueChip(ControllerPrefs.tints.firstOrNull { it.first == c.tint }?.second ?: 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 = "Color") { firstItemFocus -> + 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) { a.onTint(color) @@ -56,36 +58,36 @@ fun ColumnScope.ControllerRows(host: MenuHost, oscMode: String, c: ControllerPre } } } - ChoiceRow(host, "controller-opacity", "Opacity", null, ControllerPrefs.opacities.map { it to "$it%" }, c.opacity, onPick = a.onOpacity) - ChoiceRow(host, "controller-size", "Button size", "100% keeps the standard size", ControllerPrefs.sizes.map { it to "$it%" }, c.size, onPick = a.onSize) - ToggleRow(host, "controller-stick-click", "Stick click", "Double-tap a stick and hold for L3 or R3", c.stickClick, onChange = a.onStickClick) - ToggleRow(host, "controller-adaptive", "Adaptive sticks", "Sticks appear when touched near their saved positions and hide when released", c.adaptiveSticks, onChange = a.onAdaptiveSticks) - SettingsRow("Layout", if (c.customLayout) "Custom positions saved" else "Placed for this screen's size and your grip") { + ChoiceRow(host, "controller-opacity", stringResource(R.string.ctrl_opacity), null, ControllerPrefs.opacities.map { it to stringResource(R.string.ctrl_percent, it) }, c.opacity, onPick = a.onOpacity) + ChoiceRow(host, "controller-size", stringResource(R.string.ctrl_size), stringResource(R.string.ctrl_size_hint), ControllerPrefs.sizes.map { it to stringResource(R.string.ctrl_percent, it) }, c.size, onPick = a.onSize) + ToggleRow(host, "controller-stick-click", stringResource(R.string.ctrl_stick_click), stringResource(R.string.ctrl_stick_click_hint), c.stickClick, onChange = a.onStickClick) + ToggleRow(host, "controller-adaptive", stringResource(R.string.ctrl_adaptive), stringResource(R.string.ctrl_adaptive_hint), c.adaptiveSticks, onChange = a.onAdaptiveSticks) + SettingsRow(stringResource(R.string.ctrl_layout), if (c.customLayout) stringResource(R.string.ctrl_layout_custom) else stringResource(R.string.ctrl_layout_default)) { Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) { - SecondaryButton("Edit") { a.onEditLayout() } - SecondaryButton("Reset", enabled = c.customLayout) { a.onResetLayout() } + SecondaryButton(stringResource(R.string.ctrl_edit)) { a.onEditLayout() } + SecondaryButton(stringResource(R.string.ctrl_reset), enabled = c.customLayout) { a.onResetLayout() } } } val remapped = c.mapping.count { (id, target) -> id != target } - ActionRow("Button mapping", if (remapped == 0) "Every button sends its own input" else "$remapped of ${c.mapping.size} buttons remapped", "Configure", a.onMapping) - ActionRow("Reset controller", "Restore the default color, opacity, size, stick behavior, mapping and layout", "Reset", a.onResetAll) + ActionRow(stringResource(R.string.ctrl_mapping), if (remapped == 0) stringResource(R.string.ctrl_mapping_default) else stringResource(R.string.ctrl_mapping_count, remapped, c.mapping.size), stringResource(R.string.ctrl_configure), a.onMapping) + ActionRow(stringResource(R.string.ctrl_reset_all), stringResource(R.string.ctrl_reset_all_hint), stringResource(R.string.ctrl_reset), a.onResetAll) } @Composable fun ControllerMappingPage(mapping: Map, onPick: (String, String) -> Unit, onReset: () -> Unit, onBack: () -> Unit) { val host = rememberMenuHost() SettingsPage( - host, title = "Button mapping", eyebrow = "Controller", - lede = "Choose what each on-screen button sends to the game. Hidden removes the button.", + host, title = stringResource(R.string.ctrl_mapping), eyebrow = stringResource(R.string.setup_controller), + lede = stringResource(R.string.ctrl_mapping_lede), onBack = onBack, ) { - SettingsGroup("On-screen buttons") { + SettingsGroup(stringResource(R.string.ctrl_onscreen_buttons)) { for ((id, name) in ControllerPrefs.mappable) { ChoiceRow(host, "map-$id", name, null, ControllerPrefs.targets, mapping[id] ?: id) { onPick(id, it) } } } - SettingsGroup("Defaults") { - ActionRow("Reset mapping", "Every button sends its own input again", "Reset", onReset) + SettingsGroup(stringResource(R.string.ctrl_defaults)) { + ActionRow(stringResource(R.string.ctrl_reset_mapping), stringResource(R.string.ctrl_mapping_default), stringResource(R.string.ctrl_reset), onReset) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/PhantomProcessGatePage.kt b/app/src/main/java/com/droiddeck/launcher/ui/PhantomProcessGatePage.kt index cae45fa485..1d20aa6610 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/PhantomProcessGatePage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/PhantomProcessGatePage.kt @@ -1,5 +1,7 @@ package com.droiddeck.launcher.ui +import com.droiddeck.launcher.R +import androidx.compose.ui.res.stringResource import android.content.Context import android.net.ConnectivityManager import android.net.NetworkCapabilities @@ -64,10 +66,9 @@ fun PhantomProcessGatePage( val compact = maxWidth < 620.dp && maxHeight < 500.dp SettingsPage( host = rememberMenuHost(), - title = "One Android setting to change", - eyebrow = "Steam", - lede = if (compact) null else "Android stops apps that start lots of background processes, and Steam starts dozens. " + - "Until this is changed, games close with no error.", + title = stringResource(R.string.gate_title), + eyebrow = stringResource(R.string.gate_eyebrow), + lede = if (compact) null else stringResource(R.string.gate_lede), onBack = onDismiss, scrollContent = true, compactLayout = compact, @@ -123,7 +124,7 @@ private fun FixGroup( onCancel: () -> Unit, ) { val pairing = stage is Stage.Waiting || stage is Stage.CodeNeeded || stage is Stage.Working - SettingsGroup(if (hasToggle) "Developer options" else "Fix it for me", compact = compact) { + SettingsGroup(if (hasToggle) stringResource(R.string.setup_dev_options) else stringResource(R.string.gate_fix_for_me), compact = compact) { Column( modifier = Modifier.fillMaxWidth().padding(if (compact) 10.dp else 14.dp), verticalArrangement = Arrangement.spacedBy(8.dp), @@ -131,14 +132,14 @@ private fun FixGroup( when { pairing -> PairingProgress(stage, onCancel) hasToggle -> { - Body("Turn on “Disable child process restrictions”, then come back. Keep Developer options on afterwards: turning them off turns the switch back off.") - PrimaryButton("Open Developer options", compact = compact, onClick = onOpenDeveloperOptions) + Body(stringResource(R.string.gate_toggle_steps)) + PrimaryButton(stringResource(R.string.gate_open_dev), compact = compact, onClick = onOpenDeveloperOptions) } else -> { - Body("This Android version has no switch for it, so DroidDeck changes it over Wireless debugging on this device. About a minute, no computer needed.") + Body(stringResource(R.string.gate_no_toggle)) (stage as? Stage.Failed)?.let { Body(it.error, error = true) } PrimaryButton( - if (stage is Stage.Failed) "Try again" else "Fix it for me", + if (stage is Stage.Failed) stringResource(R.string.store_try_again) else stringResource(R.string.gate_fix_for_me), compact = compact, enabled = environment.onWifi && environment.notifications, onClick = onFixWithWirelessDebugging, @@ -147,11 +148,11 @@ private fun FixGroup( } if (!hasToggle && !pairing) { if (!environment.onWifi) { - Body("Wireless debugging needs Wi-Fi. Connect to any network first; it doesn't need internet.", warn = true) + Body(stringResource(R.string.gate_needs_wifi), warn = true) } if (!environment.notifications) { - Body("The pairing code is entered in a notification. Allow notifications for DroidDeck, or use Other ways.", warn = true) - SecondaryButton("Allow notifications", compact = compact, onClick = onOpenNotificationSettings) + Body(stringResource(R.string.gate_needs_notifications), warn = true) + SecondaryButton(stringResource(R.string.gate_allow_notifications), compact = compact, onClick = onOpenNotificationSettings) } } } @@ -161,9 +162,9 @@ private fun FixGroup( @Composable private fun PairingProgress(stage: Stage, onCancel: () -> Unit) { val steps = listOf( - "Open Settings → Developer options → Wireless debugging and turn it on", - "Tap “Pair device with pairing code”", - "Type the code into the DroidDeck notification", + stringResource(R.string.gate_step1), + stringResource(R.string.gate_step2), + stringResource(R.string.gate_step3), ) val active = when (stage) { Stage.Waiting -> 1 @@ -184,8 +185,8 @@ private fun PairingProgress(stage: Stage, onCancel: () -> Unit) { CircularProgressIndicator(modifier = Modifier.size(16.dp), strokeWidth = 2.dp) Text( when (stage) { - Stage.Waiting -> "Waiting for the pairing pop-up…" - is Stage.CodeNeeded -> stage.error ?: "Pop-up found. Enter its code in the notification." + Stage.Waiting -> stringResource(R.string.gate_waiting) + is Stage.CodeNeeded -> stage.error ?: stringResource(R.string.gate_code_needed) is Stage.Working -> stage.step else -> "" }, @@ -193,16 +194,16 @@ private fun PairingProgress(stage: Stage, onCancel: () -> Unit) { color = if (stage is Stage.CodeNeeded && stage.error != null) MaterialTheme.colorScheme.error else MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.weight(1f), ) - SecondaryButton("Cancel", compact = true, onClick = onCancel) + SecondaryButton(stringResource(R.string.common_cancel), compact = true, onClick = onCancel) } } @Composable private fun StatusGroup(status: PhantomProcessStatus, compact: Boolean) { - SettingsGroup("Status", compact = compact) { + SettingsGroup(stringResource(R.string.gate_status), compact = compact) { Column(Modifier.fillMaxWidth().padding(if (compact) 10.dp else 14.dp), verticalArrangement = Arrangement.spacedBy(2.dp)) { Text(PhantomProcessLimit.title(status), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onBackground) - Body("Checking every 2 seconds. This page closes when it's off.") + Body(stringResource(R.string.gate_polling)) } } } @@ -217,12 +218,12 @@ private fun OtherWays( onCopyCommand: () -> Unit, ) { var open by rememberSaveable { mutableStateOf(false) } - SettingsGroup("Other ways", compact = compact) { + SettingsGroup(stringResource(R.string.gate_other_ways), compact = compact) { Row( verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth().clickable { open = !open }.padding(horizontal = 14.dp, vertical = 10.dp), ) { - Body(if (hasToggle) "Wireless debugging, manual address, computer ADB" else "Manual address, computer ADB, Developer options", modifier = Modifier.weight(1f)) + Body(if (hasToggle) stringResource(R.string.gate_other_toggle) else stringResource(R.string.gate_other_no_toggle), modifier = Modifier.weight(1f)) Text(if (open) "▴" else "▾", fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant) } if (open) Column( @@ -230,20 +231,20 @@ private fun OtherWays( verticalArrangement = Arrangement.spacedBy(8.dp), ) { if (hasToggle) { - SecondaryButton("Use Wireless debugging instead", compact = true, onClick = onFixWithWirelessDebugging) + SecondaryButton(stringResource(R.string.gate_use_wireless_instead), compact = true, onClick = onFixWithWirelessDebugging) } else { - Body("Some ROMs add the switch anyway. Look for “child process” in Developer options.") - SecondaryButton("Open Developer options", compact = true, onClick = onOpenDeveloperOptions) + Body(stringResource(R.string.gate_some_roms)) + SecondaryButton(stringResource(R.string.gate_open_dev), compact = true, onClick = onOpenDeveloperOptions) } - Body("If the notification doesn't work, enter the pop-up's address and code yourself.") - SecondaryButton("Enter address manually", compact = true, onClick = onEnterAddressManually) - Body("From a computer with ADB:") + Body(stringResource(R.string.gate_manual_hint)) + SecondaryButton(stringResource(R.string.gate_enter_manually), compact = true, onClick = onEnterAddressManually) + Body(stringResource(R.string.gate_from_computer)) Text( PhantomProcessLimit.adbCommand(), style = MaterialTheme.typography.bodySmall.copy(fontFamily = FontFamily.Monospace, fontSize = 11.sp), color = MaterialTheme.colorScheme.onSurfaceVariant, ) - SecondaryButton("Copy command", compact = true, onClick = onCopyCommand) + SecondaryButton(stringResource(R.string.gate_copy_command), compact = true, onClick = onCopyCommand) } } } @@ -271,16 +272,16 @@ fun DeveloperDisplayChoiceDialog( ) { AlertDialog( onDismissRequest = onDismiss, - title = { Text("Open Developer options") }, + title = { Text(stringResource(R.string.gate_open_dev)) }, text = { Column(verticalArrangement = Arrangement.spacedBy(4.dp), modifier = Modifier.fillMaxWidth()) { - Text("Choose which display to open Android Settings on.") - TextButton(modifier = Modifier.fillMaxWidth(), onClick = onMainScreen) { Text("Main screen") } + Text(stringResource(R.string.gate_choose_display)) + TextButton(modifier = Modifier.fillMaxWidth(), onClick = onMainScreen) { Text(stringResource(R.string.gate_main_screen)) } displays.forEach { (id, label) -> TextButton(modifier = Modifier.fillMaxWidth(), onClick = { onSecondaryScreen(id) }) { Text(label) } } } }, - confirmButton = { TextButton(onClick = onDismiss) { Text("Cancel") } }, + confirmButton = { TextButton(onClick = onDismiss) { Text(stringResource(R.string.common_cancel)) } }, ) } 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 7ffaf91db9..d8ea158923 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/StorePage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/StorePage.kt @@ -1,5 +1,7 @@ package com.droiddeck.launcher.ui +import com.droiddeck.launcher.R +import androidx.compose.ui.res.stringResource import androidx.activity.compose.BackHandler import androidx.compose.animation.core.Spring import androidx.compose.animation.core.animateFloatAsState @@ -64,7 +66,7 @@ import com.droiddeck.launcher.store.StoreState // The Store rail section: Flathub's apps for this device's architecture, installed into the // Linux runtime with Flatpak, and the ones already installed. -private val TABS = listOf("Discover", "Search", "Installed") +private val TABS = listOf(R.string.store_tab_discover, R.string.store_tab_search, R.string.store_tab_installed) @Composable internal fun StorePage(s: FrontEndState, a: FrontEndActions, modifier: Modifier) { @@ -112,19 +114,19 @@ internal fun StorePage(s: FrontEndState, a: FrontEndActions, modifier: Modifier) return@Column } Rise(0) { - PageHeader("Store") { - Chip("Flathub · ARM64", ok = false) - if (StoreState.ready) Chip("● Flatpak ready", ok = true) + PageHeader(stringResource(R.string.store_title)) { + Chip(stringResource(R.string.store_chip_flathub), ok = false) + if (StoreState.ready) Chip(stringResource(R.string.store_chip_ready), ok = true) } } if (!s.ready) { - Rise(1) { Note("Install the Linux runtime from Setup first; the store installs apps into it.") } + Rise(1) { Note(stringResource(R.string.store_needs_runtime)) } return@Column } if (!StoreState.ready) Rise(1) { SetupCard() } Rise(2) { TabStrip( - TABS.mapIndexed { i, t -> if (i == 2 && StoreState.installed.isNotEmpty()) "$t · ${StoreState.installed.size}" else t }, + TABS.mapIndexed { i, id -> stringResource(id).let { t -> if (i == 2 && StoreState.installed.isNotEmpty()) stringResource(R.string.store_tab_count, t, StoreState.installed.size) else t } }, tab, { switchTab(it) }, modifier = Modifier.padding(top = 14.dp, bottom = 4.dp), focusRequesters = tabFocus, ) } @@ -148,14 +150,13 @@ private fun SetupCard() { verticalArrangement = Arrangement.spacedBy(12.dp), modifier = Modifier.fillMaxWidth().padding(top = 12.dp).clip(Shape16).background(colors.surface).border(1.dp, pal.line, Shape16).padding(16.dp), ) { - Text("Set up Flatpak", fontSize = 18.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground) + Text(stringResource(R.string.store_setup_title), fontSize = 18.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground) Text( - "Adds Flatpak to the Linux runtime and connects it to Flathub, about 20 MB. Apps then install " + - "with the runtimes they need; the first one is the biggest download.", + stringResource(R.string.store_setup_text), fontSize = 14.sp, color = colors.onSurfaceVariant, ) Actions { - PrimaryButton(if (busy) "Setting up…" else "Set up Flatpak", enabled = StoreState.busy == null, main = true) { StoreState.setup(ctx) } + PrimaryButton(if (busy) stringResource(R.string.store_setting_up) else stringResource(R.string.store_setup_title), enabled = StoreState.busy == null, main = true) { StoreState.setup(ctx) } } } } @@ -166,11 +167,11 @@ private fun BusyBar() { val colors = MaterialTheme.colorScheme val busy = StoreState.busy ?: return val name = StoreState.installed.firstOrNull { it.id == busy }?.name ?: StoreState.details[busy]?.name - ?: when (busy) { "setup" -> "Flatpak"; "update-all" -> "Updates"; else -> busy.substringAfterLast('.') } + ?: when (busy) { "setup" -> stringResource(R.string.store_flatpak); "update-all" -> stringResource(R.string.store_updates); else -> busy.substringAfterLast('.') } Column(modifier = Modifier.fillMaxWidth().padding(top = 10.dp, bottom = 4.dp)) { val stage = StoreState.stage Text( - "$name · " + (if (stage != null && StoreState.percent >= 0) "$stage · ${StoreState.percent}%" else stage ?: "Starting…"), + if (stage != null && StoreState.percent >= 0) stringResource(R.string.store_busy_percent, name, stage, StoreState.percent) else stringResource(R.string.store_busy, name, stage ?: stringResource(R.string.store_starting)), fontSize = 12.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.padding(bottom = 6.dp), ) @@ -181,15 +182,15 @@ private fun BusyBar() { @Composable private fun Discover(onOpen: (String) -> Unit, onCategory: (String) -> Unit) { - Rise(3) { SectionTitle("Categories", null) } + 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) } } } } if (StoreState.sectionsFailed && StoreState.sections.values.all { it.isEmpty() }) { - Rise(4) { Note("Flathub could not be reached. Check the connection and open the Store again.") } - Actions { SecondaryButton("Try again") { StoreState.loadSections(force = true) } } + Rise(4) { Note(stringResource(R.string.store_unreachable)) } + Actions { SecondaryButton(stringResource(R.string.store_try_again)) { StoreState.loadSections(force = true) } } return } StoreState.SECTIONS.forEachIndexed { i, (key, title) -> @@ -211,15 +212,15 @@ private fun Search(query: String, category: String?, onQuery: (String) -> Unit, Rise(3) { Row(verticalAlignment = Alignment.Bottom, horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth().padding(top = 12.dp)) { AdbTextField( - value = query, onValueChange = onQuery, label = "Search Flathub", keyboardType = KeyboardType.Text, - imeAction = ImeAction.Done, placeholder = "Firefox, games, emulators…", modifier = Modifier.weight(1f), onDone = run, + value = query, onValueChange = onQuery, label = stringResource(R.string.store_search_label), keyboardType = KeyboardType.Text, + imeAction = ImeAction.Done, placeholder = stringResource(R.string.store_search_placeholder), modifier = Modifier.weight(1f), onDone = run, ) - PrimaryButton("Search", main = true, onClick = run) + PrimaryButton(stringResource(R.string.store_search), main = true, onClick = run) } } Rise(4) { Row(horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(top = 12.dp, bottom = 4.dp)) { - PillButton("All", selected = category == null) { onCategory(null); StoreState.search(query.trim(), null) } + 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) } } @@ -227,11 +228,11 @@ private fun Search(query: String, category: String?, onQuery: (String) -> Unit, } val results = StoreState.searchResults when { - StoreState.searching -> Rise(5) { SectionTitle("Searching…", null) } - results == null -> Rise(5) { Note("Search Flathub by name, or pick a category. Only apps built for ARM64 are listed.") } - results.isEmpty() -> Rise(5) { Note("Nothing on Flathub for ARM64 matches that.") } + StoreState.searching -> Rise(5) { SectionTitle(stringResource(R.string.store_searching), null) } + results == null -> Rise(5) { Note(stringResource(R.string.store_search_hint)) } + results.isEmpty() -> Rise(5) { Note(stringResource(R.string.store_no_results)) } else -> { - Rise(5) { SectionTitle("Results", results.size.toString()) } + Rise(5) { SectionTitle(stringResource(R.string.store_results), results.size.toString()) } Rise(6) { AppGrid(results, first = true, onOpen = onOpen) } } } @@ -245,19 +246,19 @@ private fun Installed(a: FrontEndActions, onOpen: (String) -> Unit) { val apps = StoreState.installed Rise(3) { Actions { - SecondaryButton(if (StoreState.checkingUpdates) "Checking…" else "Check for updates", enabled = StoreState.ready && !StoreState.checkingUpdates && StoreState.busy == null) { + SecondaryButton(if (StoreState.checkingUpdates) stringResource(R.string.common_checking) else stringResource(R.string.store_check_updates), enabled = StoreState.ready && !StoreState.checkingUpdates && StoreState.busy == null) { StoreState.checkUpdates(ctx) } - if (StoreState.updates.isNotEmpty()) PrimaryButton("Update all (${StoreState.updates.size})", enabled = StoreState.busy == null) { - StoreState.update(ctx, null, "Updates") - } else if (StoreState.updatesChecked && !StoreState.checkingUpdates) ActionChip("● Everything is up to date", ok = true) + if (StoreState.updates.isNotEmpty()) PrimaryButton(stringResource(R.string.store_update_all, StoreState.updates.size), enabled = StoreState.busy == null) { + StoreState.update(ctx, null, ctx.getString(R.string.store_updates)) + } else if (StoreState.updatesChecked && !StoreState.checkingUpdates) ActionChip(stringResource(R.string.store_all_current), ok = true) } } if (apps.isEmpty()) { - Rise(4) { Box(Modifier.padding(top = 12.dp)) { Note(if (StoreState.ready) "No apps yet. Find some under Discover or Search." else "Set up Flatpak to install apps.") } } + Rise(4) { Box(Modifier.padding(top = 12.dp)) { Note(if (StoreState.ready) stringResource(R.string.store_no_apps) else stringResource(R.string.store_setup_first_note)) } } return } - Rise(4) { SectionTitle("Installed", apps.size.toString()) } + Rise(4) { SectionTitle(stringResource(R.string.store_tab_installed), apps.size.toString()) } Column(verticalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth()) { apps.forEachIndexed { i, app -> key(app.id) { @@ -270,13 +271,13 @@ private fun Installed(a: FrontEndActions, onOpen: (String) -> Unit) { Column(modifier = Modifier.weight(1f)) { Text(app.name, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis) Text( - (if (app.id in StoreState.updates) "Update available · " else "") + (app.summary ?: app.id), + (app.summary ?: app.id).let { if (app.id in StoreState.updates) stringResource(R.string.store_update_available_prefix, it) else it }, fontSize = 13.sp, color = if (app.id in StoreState.updates) pal.signal else colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis, ) } - PrimaryButton("Open", compact = true, enabled = !s_busyFor(app.id)) { a.onFlatpakApp(app.id, app.name) } - if (app.id in StoreState.updates) SecondaryButton("Update", compact = true, enabled = StoreState.busy == null) { StoreState.update(ctx, app.id, app.name) } - SecondaryButton("Details", compact = true) { onOpen(app.id) } + PrimaryButton(stringResource(R.string.store_open), compact = true, enabled = !s_busyFor(app.id)) { a.onFlatpakApp(app.id, app.name) } + if (app.id in StoreState.updates) SecondaryButton(stringResource(R.string.common_update), compact = true, enabled = StoreState.busy == null) { StoreState.update(ctx, app.id, app.name) } + SecondaryButton(stringResource(R.string.store_details), compact = true) { onOpen(app.id) } } } } @@ -295,7 +296,7 @@ private fun AppDetail(s: FrontEndState, a: FrontEndActions, id: String, onBack: val d = StoreState.details[id] val local = StoreState.installed.firstOrNull { it.id == id } val name = d?.name ?: local?.name ?: id - Rise(0) { BackLink("Store", onClick = onBack) } + Rise(0) { BackLink(stringResource(R.string.store_title), onClick = onBack) } Rise(1) { Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(16.dp), modifier = Modifier.padding(top = 12.dp, bottom = 8.dp)) { AppIcon(d?.icon ?: local?.icon ?: FlathubApi.iconUrl(id), name, 72) @@ -315,35 +316,35 @@ private fun AppDetail(s: FrontEndState, a: FrontEndActions, id: String, onBack: Rise(2) { Actions { if (installed) { - PrimaryButton("Open", enabled = !busyHere, main = true) { a.onFlatpakApp(id, name) } - if (id in StoreState.updates) SecondaryButton("Update", enabled = StoreState.busy == null) { StoreState.update(ctx, id, name) } - SecondaryButton(if (busyHere) "Working…" else if (confirmRemove) "Press again to remove" else "Remove", enabled = StoreState.busy == null) { + PrimaryButton(stringResource(R.string.store_open), enabled = !busyHere, main = true) { a.onFlatpakApp(id, name) } + if (id in StoreState.updates) SecondaryButton(stringResource(R.string.common_update), enabled = StoreState.busy == null) { StoreState.update(ctx, id, name) } + SecondaryButton(if (busyHere) stringResource(R.string.common_working) else if (confirmRemove) stringResource(R.string.store_press_again) else stringResource(R.string.store_remove), enabled = StoreState.busy == null) { if (confirmRemove) { confirmRemove = false; StoreState.uninstall(ctx, id, name) } else confirmRemove = true } } else { PrimaryButton( - if (busyHere) "Installing…" else "Install", main = true, + if (busyHere) stringResource(R.string.store_installing) else stringResource(R.string.store_install), main = true, enabled = StoreState.ready && StoreState.busy == null && s.ready && (d == null || d.arches.isEmpty() || "aarch64" in d.arches), ) { StoreState.install(ctx, id, name) } - if (!StoreState.ready) ActionChip("Set up Flatpak first", ok = false) + if (!StoreState.ready) ActionChip(stringResource(R.string.store_setup_first), ok = false) } d?.version?.let { ActionChip("v$it", ok = false) } - if (d != null && d.downloadSize > 0) ActionChip("${FileUtils.sizeToString(d.downloadSize)} download", ok = false) - if (installed) ActionChip("● Installed", ok = true) + if (d != null && d.downloadSize > 0) ActionChip(stringResource(R.string.store_download_size, FileUtils.sizeToString(d.downloadSize)), ok = false) + if (installed) ActionChip(stringResource(R.string.store_installed_chip), ok = true) } } if (busyHere) BusyBar() if (d == null) { Rise(3) { Box(Modifier.padding(top = 14.dp)) { - Note(if (StoreState.detailsFailed[id] == true) "Flathub's page for this app could not be loaded." else "Loading from Flathub…") + Note(if (StoreState.detailsFailed[id] == true) stringResource(R.string.store_details_failed) else stringResource(R.string.store_loading)) } } return } - if (d.arches.isNotEmpty() && "aarch64" !in d.arches) Rise(3) { Box(Modifier.padding(top = 12.dp)) { Note("Flathub has no ARM64 build of this app, so it cannot be installed here.") } } + if (d.arches.isNotEmpty() && "aarch64" !in d.arches) Rise(3) { Box(Modifier.padding(top = 12.dp)) { Note(stringResource(R.string.store_no_arm)) } } if (d.screenshots.isNotEmpty()) { - Rise(3) { SectionTitle("Screenshots", null) } + Rise(3) { SectionTitle(stringResource(R.string.store_screenshots), null) } Rise(3) { Row(horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState())) { d.screenshots.take(6).forEach { shot -> @@ -356,18 +357,18 @@ private fun AppDetail(s: FrontEndState, a: FrontEndActions, id: String, onBack: } } if (d.description.isNotEmpty()) { - Rise(4) { SectionTitle("About", null) } + Rise(4) { SectionTitle(stringResource(R.string.store_about), null) } Rise(4) { Text(d.description, fontSize = 14.sp, lineHeight = 20.sp, color = colors.onBackground, modifier = Modifier.fillMaxWidth()) } } - Rise(5) { SectionTitle("Details", null) } + Rise(5) { SectionTitle(stringResource(R.string.store_details), null) } Rise(5) { Column(verticalArrangement = Arrangement.spacedBy(4.dp), modifier = Modifier.padding(bottom = 16.dp)) { listOfNotNull( - "App ID" to d.id, - d.license?.let { "License" to it }, - d.runtime?.let { "Runtime" to it.replace("/x86_64/", "/aarch64/") }, - if (d.installedSize > 0) "Installed size" to FileUtils.sizeToString(d.installedSize) + " (plus its runtime, shared between apps)" else null, - d.homepage?.let { "Website" to it }, + stringResource(R.string.store_app_id) to d.id, + d.license?.let { stringResource(R.string.store_license) to it }, + d.runtime?.let { stringResource(R.string.store_runtime) to it.replace("/x86_64/", "/aarch64/") }, + if (d.installedSize > 0) stringResource(R.string.store_installed_size) to stringResource(R.string.store_installed_size_value, FileUtils.sizeToString(d.installedSize)) else null, + d.homepage?.let { stringResource(R.string.store_website) to it }, ).forEach { (k, v) -> Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) { Text(k, fontSize = 13.sp, color = colors.onSurfaceVariant, modifier = Modifier.width(110.dp)) @@ -419,9 +420,9 @@ private fun AppTile(app: FlathubApi.AppSummary, modifier: Modifier, isFirst: Boo Column(modifier = Modifier.weight(1f)) { Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp)) { Text(app.name, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f, fill = false)) - if (app.verified) Icon(Icons.Outlined.Verified, contentDescription = "Verified", tint = pal.signal, modifier = Modifier.size(14.dp)) + if (app.verified) Icon(Icons.Outlined.Verified, contentDescription = stringResource(R.string.store_verified), tint = pal.signal, modifier = Modifier.size(14.dp)) } - Text(if (installed) "Installed" else app.summary, fontSize = 13.sp, color = if (installed) pal.good else colors.onSurfaceVariant, maxLines = 2, overflow = TextOverflow.Ellipsis) + Text(if (installed) stringResource(R.string.store_tab_installed) else app.summary, fontSize = 13.sp, color = if (installed) pal.good else colors.onSurfaceVariant, maxLines = 2, overflow = TextOverflow.Ellipsis) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/UpdatesPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/UpdatesPage.kt index 1fd6bf65e9..22c3948df1 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/UpdatesPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/UpdatesPage.kt @@ -1,5 +1,8 @@ package com.droiddeck.launcher.ui +import com.droiddeck.launcher.R +import androidx.compose.ui.res.pluralStringResource +import androidx.compose.ui.res.stringResource import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.expandVertically import androidx.compose.animation.fadeIn @@ -94,18 +97,18 @@ internal fun UpdatesPage(s: FrontEndState, a: FrontEndActions, modifier: Modifie val me = remember { AppUpdates.installed() } val colors = MaterialTheme.colorScheme Column(modifier = modifier) { - PageHeader("Updates") { + PageHeader(stringResource(R.string.upd_title)) { // The build that is running, beside the title where it is always in view. Text( - "DroidDeck ${me.version} · ${s.buildLabel}", fontSize = 12.5.sp, color = colors.onSurfaceVariant, + stringResource(R.string.upd_build, me.version, s.buildLabel), fontSize = 12.5.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f).padding(top = 6.dp), ) val checked = u.catalog?.checkedAt?.takeIf { it > 0 } if (!LocalNarrowPane.current) Text( - if (u.checking) "Checking…" else if (checked != null) "Checked ${ago(checked)}" else "Not checked yet", + if (u.checking) stringResource(R.string.common_checking) else if (checked != null) stringResource(R.string.upd_checked, ago(checked)) else stringResource(R.string.upd_not_checked), fontSize = 13.sp, color = colors.onSurfaceVariant, ) - ToolIcon(Icons.Outlined.Refresh, "Check for updates", busy = u.checking, enabled = !u.checking && u.stage == null, onClick = ua.onCheck) + ToolIcon(Icons.Outlined.Refresh, stringResource(R.string.store_check_updates), busy = u.checking, enabled = !u.checking && u.stage == null, onClick = ua.onCheck) } Column(modifier = Modifier.weight(1f).fillMaxWidth().verticalScroll(rememberScrollState()).padding(bottom = 8.dp)) { // Landscape has the width for channels and status side by side; a narrow pane stacks them. @@ -126,15 +129,14 @@ internal fun UpdatesPage(s: FrontEndState, a: FrontEndActions, modifier: Modifie } if (u.askPermission) AlertDialog( onDismissRequest = ua.onDismissPermission, - title = { Text("Let DroidDeck update itself") }, + title = { Text(stringResource(R.string.upd_perm_title)) }, text = { Text( - "Android asks once before an app may install updates. On the next screen, turn on " + - "\"Allow from this source\", then come back - the update carries on by itself.", + stringResource(R.string.upd_perm_text), ) }, - confirmButton = { TextButton(onClick = ua.onAllowInstalls) { Text("Open settings") } }, - dismissButton = { TextButton(onClick = ua.onDismissPermission) { Text("Not now") } }, + confirmButton = { TextButton(onClick = ua.onAllowInstalls) { Text(stringResource(R.string.upd_open_settings)) } }, + dismissButton = { TextButton(onClick = ua.onDismissPermission) { Text(stringResource(R.string.upd_not_now)) } }, ) } @@ -151,16 +153,16 @@ private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, m val installBlock = release?.let { AppUpdates.installBlock(it, me) } class Look(val tint: Color, val status: String, val headline: String, val detail: String?) val look = when { - !me.updatable -> Look(colors.onSurfaceVariant, "Signed differently", "Can't update in place", - "This copy isn't signed with DroidDeck's release key, so Android won't install the builds here over it. Uninstall it to switch.") - catalog == null -> Look(colors.onSurfaceVariant, if (u.checking) "Checking…" else "Not checked yet", "Updates", null) - offer == Offer.UPDATE -> Look(AttentionAmber, "Update available", newBuild(u.follow, release!!), null) - offer == Offer.SWITCH -> Look(pal.signal, "Ready to switch", newBuild(u.follow, release!!), null) - offer == Offer.AHEAD -> Look(pal.signal, "Ahead of Stable", "You're ahead of Stable", - "This build is newer than the last Stable release. You'll move onto Stable with its next one.") - offer == Offer.GONE -> Look(AttentionAmber, "Test ended", "This test has ended", - "Its fix was merged or dropped. Follow Preview to keep getting the newest fixes.") - else -> Look(pal.good, "Up to date", "You have the latest $name", null) + !me.updatable -> Look(colors.onSurfaceVariant, stringResource(R.string.upd_signed_status), stringResource(R.string.upd_signed_headline), + stringResource(R.string.upd_signed_detail)) + catalog == null -> Look(colors.onSurfaceVariant, if (u.checking) stringResource(R.string.common_checking) else stringResource(R.string.upd_not_checked), stringResource(R.string.upd_title), null) + offer == Offer.UPDATE -> Look(AttentionAmber, stringResource(R.string.upd_available), newBuild(u.follow, release!!), null) + offer == Offer.SWITCH -> Look(pal.signal, stringResource(R.string.upd_switch), newBuild(u.follow, release!!), null) + offer == Offer.AHEAD -> Look(pal.signal, stringResource(R.string.upd_ahead_status), stringResource(R.string.upd_ahead_headline), + stringResource(R.string.upd_ahead_detail)) + offer == Offer.GONE -> Look(AttentionAmber, stringResource(R.string.upd_gone_status), stringResource(R.string.upd_gone_headline), + stringResource(R.string.upd_gone_detail)) + else -> Look(pal.good, stringResource(R.string.upd_current_status), stringResource(R.string.upd_current_headline, name), null) } Column( modifier = Modifier.fillMaxWidth().clip(Shape16).background(colors.surface).border(1.dp, pal.line, Shape16).padding(18.dp), @@ -168,7 +170,7 @@ private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, m Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(7.dp)) { Box(Modifier.size(7.dp).clip(CircleShape).background(look.tint)) Text(look.status, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = look.tint) - if (offered) Text("· ${ago(release!!.publishedAt)}", fontSize = 13.sp, color = colors.onSurfaceVariant) + if (offered) Text(stringResource(R.string.upd_dot_ago, ago(release!!.publishedAt)), fontSize = 13.sp, color = colors.onSurfaceVariant) } Text(look.headline, fontSize = 22.sp, fontWeight = FontWeight.Bold, color = colors.onBackground, modifier = Modifier.padding(top = 4.dp)) if (offered) { @@ -184,19 +186,19 @@ private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, m Box(Modifier.padding(top = 14.dp)) { when { u.stage != null -> Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(8.dp)) { - Text(if (u.percent >= 0) "${u.stage}… ${u.percent}%" else "${u.stage}…", fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground) + Text(if (u.percent >= 0) stringResource(R.string.upd_stage_percent, u.stage, u.percent) else stringResource(R.string.upd_stage, u.stage), fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground) if (u.percent >= 0) LinearProgressIndicator(progress = { u.percent / 100f }, modifier = Modifier.fillMaxWidth().height(6.dp).clip(CircleShape)) else LinearProgressIndicator(modifier = Modifier.fillMaxWidth().height(6.dp).clip(CircleShape)) } - offer == Offer.UPDATE -> PrimaryButton("Update$button", enabled = installable, main = true) { ua.onInstall(release!!) } - offer == Offer.SWITCH -> PrimaryButton("Install$button", enabled = installable, main = true) { ua.onInstall(release!!) } + offer == Offer.UPDATE -> PrimaryButton(stringResource(R.string.upd_update_button, button), enabled = installable, main = true) { ua.onInstall(release!!) } + offer == Offer.SWITCH -> PrimaryButton(stringResource(R.string.upd_install_button, button), enabled = installable, main = true) { ua.onInstall(release!!) } offer == Offer.AHEAD && installBlock == null -> - SecondaryButton("Install Stable ${release?.version.orEmpty()} anyway", enabled = installable) { ua.onInstall(release!!) } - offer == Offer.GONE -> PrimaryButton("Follow Preview", main = true) { ua.onFollow(Follow(Channel.NIGHTLY)) } + SecondaryButton(stringResource(R.string.upd_install_anyway, release?.version.orEmpty()), enabled = installable) { ua.onInstall(release!!) } + offer == Offer.GONE -> PrimaryButton(stringResource(R.string.upd_follow_preview), main = true) { ua.onFollow(Follow(Channel.NIGHTLY)) } } } if (s.sessionRunning && (offered || offer == Offer.AHEAD)) { - Text("Stop the running session to update.", fontSize = 12.5.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(top = 8.dp)) + Text(stringResource(R.string.upd_stop_session), fontSize = 12.5.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(top = 8.dp)) } } } @@ -221,7 +223,7 @@ private fun ReleaseNotes(title: String, notes: String, key: String) { val hot = rememberHot(src) val toggle = { open = !open } Text( - if (open) "Less" else "More", fontSize = 13.5.sp, fontWeight = FontWeight.SemiBold, color = pal.signal, + if (open) stringResource(R.string.upd_less) else stringResource(R.string.upd_more), fontSize = 13.5.sp, fontWeight = FontWeight.SemiBold, color = pal.signal, modifier = Modifier.padding(top = 2.dp).offset(x = (-6).dp).paneItem("notes:more") .clip(Shape12).glideBorder(hot, Shape12, pal.signal) .hoverable(src).clickable(interactionSource = src, indication = null, role = Role.Button, onClick = toggle) @@ -232,23 +234,25 @@ private fun ReleaseNotes(title: String, notes: String, key: String) { } /** The headline for a build on offer: "DroidDeck 0.3.0", "New Preview build", "PR #93 test build". */ +@Composable private fun newBuild(f: Follow, r: Release) = when (f.channel) { - Channel.STABLE -> "DroidDeck ${r.version ?: r.tag}" - Channel.NIGHTLY -> "New Preview build" - Channel.TEST -> "PR #${r.pr} test build" + Channel.STABLE -> stringResource(R.string.upd_new_stable, r.version ?: r.tag) + Channel.NIGHTLY -> stringResource(R.string.upd_new_preview) + Channel.TEST -> stringResource(R.string.upd_new_test, r.pr) } /** A PR title as a sentence: "fix(steam): keep the client alive" -> "Keep the client alive". */ private fun changeTitle(t: String): String = t.replace(Regex("""^[a-z]+(\([^)]*\))?!?:\s*"""), "").replaceFirstChar { it.uppercase() } -private fun megabytes(bytes: Long) = "${(bytes + 524_288) / 1_048_576} MB" +@Composable +private fun megabytes(bytes: Long) = stringResource(R.string.upd_mb, ((bytes + 524_288) / 1_048_576).toInt()) /** The three channels as cards to pick from; Test builds opens its list of PRs under it. */ @Composable private fun ChannelLabel() { Text( - "UPDATE CHANNEL", fontSize = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.5.sp, + stringResource(R.string.upd_channel), fontSize = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.5.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(start = 2.dp, top = 2.dp, bottom = 10.dp), ) } @@ -260,16 +264,16 @@ private fun ChannelPicker(u: UpdatesState, ua: UpdatesActions) { val tests = catalog?.tests.orEmpty() Column(verticalArrangement = Arrangement.spacedBy(10.dp)) { ChannelCard( - Icons.Outlined.Verified, "Stable", "Tested releases, for most people", - catalog?.stable?.let { "${it.version ?: it.tag} · ${ago(it.publishedAt)}" }, u.follow.channel == Channel.STABLE, + Icons.Outlined.Verified, stringResource(R.string.upd_stable), stringResource(R.string.upd_stable_hint), + catalog?.stable?.let { stringResource(R.string.upd_version_ago, it.version ?: it.tag, ago(it.publishedAt)) }, u.follow.channel == Channel.STABLE, ) { ua.onFollow(Follow(Channel.STABLE)) } ChannelCard( - Icons.Outlined.Bolt, "Preview", "Newest main-branch fixes, before Stable", + Icons.Outlined.Bolt, stringResource(R.string.upd_preview), stringResource(R.string.upd_preview_hint), catalog?.preview?.let { ago(it.publishedAt) }, u.follow.channel == Channel.NIGHTLY, ) { ua.onFollow(Follow(Channel.NIGHTLY)) } ChannelCard( - Icons.Outlined.Science, "Test builds", "Try a fix before it's released", - when (tests.size) { 0 -> "None right now"; 1 -> "1 to try"; else -> "${tests.size} to try" }, + Icons.Outlined.Science, stringResource(R.string.upd_tests), stringResource(R.string.upd_tests_hint), + if (tests.isEmpty()) stringResource(R.string.upd_tests_none) else pluralStringResource(R.plurals.upd_tests_count, tests.size, tests.size), u.follow.channel == Channel.TEST, enabled = tests.isNotEmpty() || u.follow.channel == Channel.TEST, ) { tests.firstOrNull()?.let { ua.onFollow(Follow(Channel.TEST, it.pr)) } } AnimatedVisibility(u.follow.channel == Channel.TEST && tests.isNotEmpty(), enter = expandVertically(Motion.sp(1f)) + fadeIn(Motion.sp(1f)), exit = shrinkVertically(Motion.sp(1f)) + fadeOut(Motion.sp(1f))) { @@ -340,21 +344,23 @@ private fun TestRow(t: Release, selected: Boolean, onClick: () -> Unit) { ) { Text("#${t.pr}", fontSize = 13.sp, fontWeight = FontWeight.Bold, color = if (selected) pal.signal else colors.onSurfaceVariant) Column(Modifier.weight(1f)) { - Text(t.title.ifBlank { "PR #${t.pr}" }, fontSize = 13.5.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis) - Text(if (t.apk == null) "Not built for this copy of DroidDeck" else "Updated ${ago(t.publishedAt)}", fontSize = 12.sp, color = colors.onSurfaceVariant) + Text(t.title.ifBlank { stringResource(R.string.upd_pr, t.pr) }, fontSize = 13.5.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis) + Text(if (t.apk == null) stringResource(R.string.upd_not_built) else stringResource(R.string.upd_updated, ago(t.publishedAt)), fontSize = 12.sp, color = colors.onSurfaceVariant) } } } +@Composable private fun channelName(f: Follow) = when (f.channel) { - Channel.STABLE -> "Stable" - Channel.NIGHTLY -> "Preview" - Channel.TEST -> "the PR #${f.pr} test" + Channel.STABLE -> stringResource(R.string.upd_stable) + Channel.NIGHTLY -> stringResource(R.string.upd_preview) + Channel.TEST -> stringResource(R.string.upd_test_name, f.pr) } +@Composable private fun ago(millis: Long): String { - if (millis <= 0) return "a while ago" - if (System.currentTimeMillis() - millis in 0 until 60_000) return "just now" + if (millis <= 0) return stringResource(R.string.upd_while_ago) + if (System.currentTimeMillis() - millis in 0 until 60_000) return stringResource(R.string.upd_just_now) return android.text.format.DateUtils.getRelativeTimeSpanString( millis, System.currentTimeMillis(), android.text.format.DateUtils.MINUTE_IN_MILLIS, ).toString() diff --git a/app/src/main/java/com/droiddeck/launcher/ui/WirelessAdbFixPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/WirelessAdbFixPage.kt index a067ef020a..f369427a03 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/WirelessAdbFixPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/WirelessAdbFixPage.kt @@ -1,5 +1,7 @@ package com.droiddeck.launcher.ui +import com.droiddeck.launcher.R +import androidx.compose.ui.res.stringResource import android.text.Editable import android.text.InputType import android.text.TextWatcher @@ -89,22 +91,22 @@ fun WirelessAdbFixPage( } else { step = 1 busy = true - message = "Paired. Finding the Wireless debugging port…" + message = context.getString(R.string.wadb_finding_port) onFindConnectPort(endpoint.host) { discoveredPort -> if (discoveredPort == null) { connectionAddress = formatAddressHost(endpoint.host) + ":" busy = false - message = "Paired. Enter the port from Settings." + message = context.getString(R.string.wadb_enter_port) } else { connectionAddress = formatAdbAddress(endpoint.host, discoveredPort) - message = "Device found. Applying the setting…" + message = context.getString(R.string.wadb_applying) onApply(endpoint.host, discoveredPort, desiredEnabled) { applyError -> busy = false if (applyError == null) { step = 2 message = null } else { - message = "Could not apply automatically. Check the address below and retry. $applyError" + message = context.getString(R.string.wadb_apply_failed, applyError) messageIsError = true } } @@ -172,22 +174,22 @@ fun WirelessAdbFixPage( SettingsPage( host = rememberMenuHost(), title = when { - compactSplit && step < 2 -> "Wireless debugging" - step == 2 -> "Child-process limit updated" - else -> "Change the child-process limit" + compactSplit && step < 2 -> stringResource(R.string.wadb_title_wireless) + step == 2 -> stringResource(R.string.wadb_title_done) + else -> stringResource(R.string.wadb_title) }, - eyebrow = "Setup", + eyebrow = stringResource(R.string.setup_title), lede = when { - compactSplit && step == 0 -> "If the option is missing, pair over Wireless debugging." - compactSplit && step == 1 -> "Paired. Check IP address & Port in Wireless debugging." - compactSplit -> "The child-process limit was updated." - step == 0 -> "Use step 2 if Developer options has no child-process setting. In Android Settings, open Developer options → Wireless debugging → Pair device with pairing code." - step == 1 -> "Paired. Use the address below; update it from Wireless debugging → IP address & Port if needed." - else -> "The child-process limit was updated over Wireless debugging." + compactSplit && step == 0 -> stringResource(R.string.wadb_lede_compact0) + compactSplit && step == 1 -> stringResource(R.string.wadb_lede_compact1) + compactSplit -> stringResource(R.string.wadb_lede_done) + step == 0 -> stringResource(R.string.wadb_lede0) + step == 1 -> stringResource(R.string.wadb_lede1) + else -> stringResource(R.string.wadb_lede_done_long) }, onBack = { if (!busy) onBack() }, action = if (compactSplit && step < 2) { - { SecondaryButton("Developer options", compact = true, enabled = !busy, onClick = onOpenDeveloperOptions) } + { SecondaryButton(stringResource(R.string.setup_dev_options), compact = true, enabled = !busy, onClick = onOpenDeveloperOptions) } } else null, scrollContent = !compactSplit, compactLayout = compactSplit, @@ -199,14 +201,14 @@ fun WirelessAdbFixPage( modifier = Modifier.widthIn(max = 680.dp).fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(10.dp), ) { - SettingsGroup("Child-process limit", compact = compactSplit) { + SettingsGroup(stringResource(R.string.setup_limit), compact = compactSplit) { Text( - "Android confirmed the limit is ${if (desiredEnabled) "on" else "off"}.", + if (desiredEnabled) stringResource(R.string.wadb_confirmed_on) else stringResource(R.string.wadb_confirmed_off), color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(14.dp), ) } - PrimaryButton("Done", enabled = !busy, onClick = onBack) + PrimaryButton(stringResource(R.string.setup_check_done), enabled = !busy, onClick = onBack) } } else if (compactSplit) { Column( @@ -267,7 +269,7 @@ private fun WirelessStepForm( onPairAgain: () -> Unit, ) { if (step == 0) { - SettingsGroup("2 · Pair Wireless debugging", compact = compact) { + SettingsGroup(stringResource(R.string.wadb_pair_group), compact = compact) { Column( modifier = Modifier.fillMaxWidth().padding(horizontal = if (compact) 8.dp else 12.dp, vertical = if (compact) 6.dp else 12.dp), verticalArrangement = Arrangement.spacedBy(if (compact) 5.dp else 6.dp), @@ -275,7 +277,7 @@ private fun WirelessStepForm( AdbTextField( value = pairingAddress, onValueChange = onPairingAddressChange, - label = "Pairing pop-up IP address & Port", + label = stringResource(R.string.wadb_pair_address), placeholder = "192.168.1.42:37123", keyboardType = KeyboardType.Ascii, imeAction = ImeAction.Next, @@ -291,8 +293,8 @@ private fun WirelessStepForm( AdbTextField( value = pairingCode, onValueChange = onPairingCodeChange, - label = "Pairing code (PIN)", - placeholder = "6 digits", + label = stringResource(R.string.wadb_pin), + placeholder = stringResource(R.string.wadb_pin_placeholder), keyboardType = KeyboardType.Number, imeAction = ImeAction.Done, compact = compact, @@ -302,13 +304,13 @@ private fun WirelessStepForm( }, modifier = Modifier.weight(1f), ) - PrimaryButton("Pair", compact = compact, enabled = !busy && canPair, onClick = onPair) + PrimaryButton(stringResource(R.string.wadb_pair), compact = compact, enabled = !busy && canPair, onClick = onPair) } StatusMessage(busy, message, isError = messageIsError) } } } else { - SettingsGroup("2 · Apply over Wireless debugging", compact = compact) { + SettingsGroup(stringResource(R.string.wadb_apply_group), compact = compact) { Column( modifier = Modifier.fillMaxWidth().padding(horizontal = if (compact) 8.dp else 12.dp, vertical = if (compact) 6.dp else 12.dp), verticalArrangement = Arrangement.spacedBy(if (compact) 5.dp else 6.dp), @@ -316,7 +318,7 @@ private fun WirelessStepForm( AdbTextField( value = connectionAddress, onValueChange = onConnectionAddressChange, - label = "Connection IP address & Port", + label = stringResource(R.string.wadb_connect_address), placeholder = "192.168.1.42:45678", keyboardType = KeyboardType.Ascii, imeAction = ImeAction.Done, @@ -330,9 +332,9 @@ private fun WirelessStepForm( modifier = Modifier.fillMaxWidth(), ) { StatusMessage(busy, message, Modifier.weight(1f), isError = messageIsError) - SecondaryButton("Pair again", compact = compact, enabled = !busy, onClick = onPairAgain) + SecondaryButton(stringResource(R.string.wadb_pair_again), compact = compact, enabled = !busy, onClick = onPairAgain) PrimaryButton( - if (desiredEnabled) "Turn limit on" else "Turn limit off", + if (desiredEnabled) stringResource(R.string.setup_limit_turn_on) else stringResource(R.string.wadb_turn_off), compact = compact, enabled = !busy && parseAdbAddress(connectionAddress) != null, onClick = onApply, @@ -453,16 +455,16 @@ private fun FallbackOrder( busy: Boolean, onOpenDeveloperOptions: () -> Unit, ) { - SettingsGroup("Other ways to change it") { + SettingsGroup(stringResource(R.string.wadb_other_ways)) { Column( modifier = Modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 8.dp), verticalArrangement = Arrangement.spacedBy(4.dp), ) { - Text("1 · Developer options (try first)", style = MaterialTheme.typography.bodySmall, fontWeight = FontWeight.SemiBold, color = MaterialTheme.colorScheme.onBackground) - Text("Set “Restrict child processes” ${if (desiredEnabled) "on" else "off"}.", style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant) - SecondaryButton("Open Developer options", enabled = !busy, onClick = onOpenDeveloperOptions) - Text("3 · Computer ADB (last resort)", style = MaterialTheme.typography.bodySmall, fontWeight = FontWeight.SemiBold, color = MaterialTheme.colorScheme.onBackground) - Text("Only if Wireless debugging is unavailable.", style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant) + Text(stringResource(R.string.wadb_dev_try_first), style = MaterialTheme.typography.bodySmall, fontWeight = FontWeight.SemiBold, color = MaterialTheme.colorScheme.onBackground) + Text(if (desiredEnabled) stringResource(R.string.wadb_restrict_on) else stringResource(R.string.wadb_restrict_off), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant) + SecondaryButton(stringResource(R.string.gate_open_dev), enabled = !busy, onClick = onOpenDeveloperOptions) + Text(stringResource(R.string.wadb_computer_last), style = MaterialTheme.typography.bodySmall, fontWeight = FontWeight.SemiBold, color = MaterialTheme.colorScheme.onBackground) + Text(stringResource(R.string.wadb_only_if), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant) Text( PhantomProcessLimit.adbCommand(desiredEnabled), style = MaterialTheme.typography.bodySmall.copy(fontFamily = FontFamily.Monospace), @@ -474,7 +476,7 @@ private fun FallbackOrder( @Composable private fun CompactComputerFallback(desiredEnabled: Boolean) { - SettingsGroup("3 · Computer ADB last resort", compact = true) { + SettingsGroup(stringResource(R.string.wadb_computer_group), compact = true) { Text( PhantomProcessLimit.adbCommand(desiredEnabled), style = MaterialTheme.typography.labelSmall.copy(fontFamily = FontFamily.Monospace), @@ -489,7 +491,7 @@ private fun StatusMessage(busy: Boolean, message: String?, modifier: Modifier = if (busy) { Row(modifier = modifier, verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) { CircularProgressIndicator(modifier = Modifier.size(20.dp), strokeWidth = 2.dp) - Text(message ?: "Working…", style = MaterialTheme.typography.bodySmall) + Text(message ?: stringResource(R.string.common_working), style = MaterialTheme.typography.bodySmall) } } else { message?.let { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2202f8d7db..608b45afdb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -546,4 +546,198 @@ FEX, DXVK, VKD3D Controls Button mapping + Discover + Search + Installed + %1$s · %2$d + Store + Flathub · ARM64 + ● Flatpak ready + Install the Linux runtime from Setup first. + Set up Flatpak + Adds Flatpak and connects it to Flathub (about 20 MB). The first app also downloads its runtime. + Setting up… + Flatpak + Updates + %1$s · %2$s + %1$s · %2$s · %3$d%% + Starting… + Categories + Couldn\'t reach Flathub. Check your connection and try again. + Try again + Search Flathub + Firefox, games, emulators… + Search + All + Searching… + Search by name or pick a category. Only ARM64 apps are listed. + No ARM64 apps on Flathub match that. + Results + Check for updates + Update all (%1$d) + ● Everything is up to date + No apps yet. Find some under Discover or Search. + Set up Flatpak to install apps. + Update available · %1$s + Open + Details + Remove + Press again to remove + Installing… + Install + Set up Flatpak first + %1$s download + ● Installed + Couldn\'t load this app\'s Flathub page. + Loading from Flathub… + No ARM64 build on Flathub, so it can\'t be installed here. + Screenshots + About + App ID + License + Runtime + Installed size + %1$s (plus its shared runtime) + Website + Verified + Updates + DroidDeck %1$s · %2$s + Checked %1$s + Not checked yet + Let DroidDeck update itself + On the next screen, turn on Allow from this source, then come back. The update continues by itself. + Open settings + Not now + Signed differently + Can\'t update in place + This copy isn\'t signed with DroidDeck\'s release key, so updates can\'t install over it. Uninstall it to switch. + Update available + Ready to switch + Ahead of Stable + You\'re ahead of Stable + This build is newer than the latest Stable. You\'ll move to Stable with its next release. + Test ended + This test has ended + Its fix was merged or dropped. Follow Preview for the newest fixes. + Up to date + You have the latest %1$s + · %1$s + %1$s… %2$d%% + %1$s… + Update%1$s + Install%1$s + Install Stable %1$s anyway + Follow Preview + Stop the running session to update. + Less + More + DroidDeck %1$s + New Preview build + PR #%1$d test build + %1$d MB + UPDATE CHANNEL + Stable + Tested releases, for most people + %1$s · %2$s + Preview + Newest fixes, before Stable + Test builds + Try a fix before it\'s released + None right now + PR #%1$d + Not built for this copy of DroidDeck + Updated %1$s + the PR #%1$d test + a while ago + just now + + %1$d to try + %1$d to try + + One Android setting to change + Steam + Android stops apps that start many background processes, and Steam starts dozens. Until this changes, games close without an error. + Fix it for me + Turn on “Disable child process restrictions”, then come back. Leave Developer options on, or the switch turns off again. + Open Developer options + This Android version has no switch for it, so DroidDeck changes it over Wireless debugging. Takes about a minute, no computer needed. + Wireless debugging needs Wi-Fi. Any network works; it doesn\'t need internet. + The pairing code goes in a notification. Allow notifications for DroidDeck, or use Other ways. + Allow notifications + Open Settings → Developer options → Wireless debugging and turn it on + Tap “Pair device with pairing code” + Type the code into the DroidDeck notification + Waiting for the pairing pop-up… + Pop-up found. Enter its code in the notification. + Status + Checking every 2 seconds. This page closes when it\'s off. + Other ways + Wireless debugging, manual address, computer ADB + Manual address, computer ADB, Developer options + Use Wireless debugging instead + Some ROMs add the switch anyway. Look for “child process” in Developer options. + If the notification doesn\'t work, enter the pop-up\'s address and code yourself. + Enter address manually + From a computer with ADB: + Copy command + Choose which display to open Android Settings on. + Main screen + Paired. Finding the Wireless debugging port… + Paired. Enter the port from Settings. + Device found. Applying the setting… + Couldn\'t apply automatically. Check the address below and retry. %1$s + Wireless debugging + Child-process limit updated + Change the child-process limit + If the option is missing, pair over Wireless debugging. + Paired. Check the IP address and port in Wireless debugging. + The child-process limit was updated. + Use step 2 if Developer options has no child-process setting. Open Developer options → Wireless debugging → Pair device with pairing code. + Paired. Use the address below, or update it from Wireless debugging → IP address & Port. + The child-process limit was updated over Wireless debugging. + Android confirmed the limit is on. + Android confirmed the limit is off. + 2 · Pair Wireless debugging + Pairing pop-up IP address & port + Pairing code (PIN) + 6 digits + Pair + 2 · Apply over Wireless debugging + Connection IP address & port + Pair again + Turn limit off + Other ways to change it + 1 · Developer options (try first) + Set “Restrict child processes” on. + Set “Restrict child processes” off. + 3 · Computer ADB (last resort) + Only if Wireless debugging is unavailable. + 3 · Computer ADB (last resort) + When the touch controls appear in a session + Color + Tint of the on-screen buttons + Custom + Opacity + %1$d%% + Button size + 100% is the standard size + Stick click + Double-tap and hold a stick for L3 or R3 + Adaptive sticks + Sticks appear where you touch and hide on release + Layout + Custom positions saved + Fitted to this screen + Edit + Reset + Button mapping + Every button sends its own input + %1$d of %2$d buttons remapped + Configure + Reset controller + Restores all controller settings and the layout + What each on-screen button sends to the game. Hidden removes the button. + On-screen buttons + Defaults + Reset mapping