Add translations for 23 more languages and fill missing strings (#669)

* Add translations for 23 more languages and fill missing strings

* Translate the strings added in main into every language

Cardboard VR and the session drawer's component downloads in all 31
languages, the game details facts and HowLongToBeat labels in the 23 new
ones, and the reworded Components page note there.
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-10-13 13:34:00 -04:00
1 parent 9a6d48c04b
commit 69e68a5008
45 files changed
+57044 -1053

No files matched your search

@@ -22,7 +22,11 @@ object AppLanguage {
const val SYSTEM = ""
/** The languages the app ships, as BCP 47 tags, in the order the picker lists them. */
val supported: List<String> = listOf("en", "es", "fr", "ru", "ja", "ko", "zh-CN", "zh-TW", "zh-HK")
val supported: List<String> = listOf(
"en", "id", "ms", "cs", "da", "de", "es", "es-419", "fr", "it", "hu", "nl", "nb", "pl",
"pt-BR", "pt-PT", "ro", "fi", "sv", "vi", "tr", "el", "bg", "ru", "uk", "ar", "hi", "th",
"ja", "ko", "zh-CN", "zh-TW", "zh-HK",
)
private const val PREFS = "language"
private const val KEY = "app_language"
@@ -97,9 +101,18 @@ object AppLanguage {
// 0 leaves it undefined, so only the locale is changed.
private fun override(locale: Locale) = Configuration().apply { fontScale = 0f; setLocales(LocaleList(locale)) }
private val latinAmerica = setOf(
"419", "AR", "BO", "BR", "BZ", "CL", "CO", "CR", "CU", "DO", "EC", "GT", "HN", "MX", "NI", "PA",
"PE", "PR", "PY", "SV", "US", "UY", "VE",
)
/** Which of the app's languages [locale] reads as, or null when the app does not ship it. */
fun supportedTag(locale: Locale): String? = when (locale.language) {
"en", "es", "fr", "ru", "ja", "ko" -> locale.language
"en", "fr", "ru", "ja", "ko", "ms", "cs", "da", "de", "it", "hu", "nl", "nb", "pl", "ro", "fi",
"sv", "vi", "tr", "el", "bg", "uk", "ar", "hi", "th" -> locale.language
"in", "id" -> "id"
"es" -> if (locale.country in latinAmerica) "es-419" else "es"
"pt" -> if (locale.country.isEmpty() || locale.country == "BR") "pt-BR" else "pt-PT"
"zh" -> when {
locale.script == "Hans" -> "zh-CN"
locale.country == "HK" || locale.country == "MO" -> "zh-HK"
@@ -116,9 +129,33 @@ object AppLanguage {
/** A language's name in that language, for the picker: what a reader of it looks for. */
fun nativeName(tag: String): String = when (tag) {
"en" -> "English"
"es" -> "Español"
"id" -> "Bahasa Indonesia"
"ms" -> "Bahasa Melayu"
"cs" -> "Čeština"
"da" -> "Dansk"
"de" -> "Deutsch"
"es" -> "Español (España)"
"es-419" -> "Español (Latinoamérica)"
"fr" -> "Français"
"it" -> "Italiano"
"hu" -> "Magyar"
"nl" -> "Nederlands"
"nb" -> "Norsk bokmål"
"pl" -> "Polski"
"pt-BR" -> "Português (Brasil)"
"pt-PT" -> "Português (Portugal)"
"ro" -> "Română"
"fi" -> "Suomi"
"sv" -> "Svenska"
"vi" -> "Tiếng Việt"
"tr" -> "Türkçe"
"el" -> "Ελληνικά"
"bg" -> "Български"
"ru" -> "Русский"
"uk" -> "Українська"
"ar" -> "العربية"
"hi" -> "हिन्दी"
"th" -> "ไทย"
"ja" -> "日本語"
"ko" -> "한국어"
"zh-CN" -> "简体中文"
@@ -13,6 +13,7 @@ import android.util.Log
import android.view.MotionEvent
import android.view.View
import android.widget.Toast
import com.droiddeck.launcher.R
import com.droiddeck.launcher.input.SteamTouchConfig.Element
import java.util.concurrent.Executors
import kotlin.math.abs
@@ -335,7 +336,7 @@ class SteamTouchControls(
if (editing) {
text.textSize = r * 0.3f
text.color = Color.argb(alpha / 2, 255, 255, 255)
canvas.drawText("Trackpad", x, y - (text.descent() + text.ascent()) / 2, text)
canvas.drawText(context.getString(R.string.deck_surface_trackpad), x, y - (text.descent() + text.ascent()) / 2, text)
}
}
SteamTouchConfig.STEAM -> {
@@ -579,7 +580,7 @@ class SteamTouchControls(
SteamTouchConfig.STEAM -> "STEAM"
SteamTouchConfig.THUMB -> "…"
SteamTouchConfig.KEYBOARD -> "⌨"
SteamTouchConfig.PASTE -> "Paste"
SteamTouchConfig.PASTE -> context.getString(R.string.touch_paste)
SteamTouchConfig.SELECT -> "⧉"
SteamTouchConfig.START -> "☰"
SteamTouchConfig.BUMPER_LEFT -> "LB"
@@ -880,15 +881,15 @@ class SteamTouchControls(
}
private fun controlName(type: Int) = when (type) {
SteamTouchConfig.DPAD -> "D-pad"
SteamTouchConfig.JOYSTICK_LEFT -> "Left stick"
SteamTouchConfig.JOYSTICK_RIGHT -> "Right stick"
SteamTouchConfig.TRACKPAD_LEFT -> "Left trackpad"
SteamTouchConfig.TRACKPAD_RIGHT -> "Right trackpad"
SteamTouchConfig.TRACKPAD_CENTER -> "Trackpad"
SteamTouchConfig.DPAD -> context.getString(R.string.touch_dpad)
SteamTouchConfig.JOYSTICK_LEFT -> context.getString(R.string.touch_left_stick)
SteamTouchConfig.JOYSTICK_RIGHT -> context.getString(R.string.touch_right_stick)
SteamTouchConfig.TRACKPAD_LEFT -> context.getString(R.string.deck_left_trackpad)
SteamTouchConfig.TRACKPAD_RIGHT -> context.getString(R.string.deck_right_trackpad)
SteamTouchConfig.TRACKPAD_CENTER -> context.getString(R.string.deck_surface_trackpad)
SteamTouchConfig.STEAM -> "Steam"
SteamTouchConfig.THUMB -> "Menu"
SteamTouchConfig.KEYBOARD -> "Keyboard"
SteamTouchConfig.THUMB -> context.getString(R.string.touch_menu)
SteamTouchConfig.KEYBOARD -> context.getString(R.string.touch_keyboard)
else -> label(type)
}
@@ -899,22 +900,22 @@ class SteamTouchControls(
val list = android.widget.LinearLayout(context).apply { orientation = android.widget.LinearLayout.VERTICAL; setPadding((12 * density).toInt(), 0, (12 * density).toInt(), 0) }
var close: () -> Unit = {}
val copied = prefs.getString("copiedLayout", null)
fun item(name: String, enabled: Boolean = true, action: () -> Unit) = list.addView(android.widget.Button(context).apply {
text = name
fun item(name: Int, enabled: Boolean = true, action: () -> Unit) = list.addView(android.widget.Button(context).apply {
setText(name)
isAllCaps = false
isEnabled = enabled
setOnClickListener { close(); action(); invalidate() }
})
item("Colour and opacity…") { pickColor() }
item("Copy this layout") {
item(R.string.touch_color_opacity) { pickColor() }
item(R.string.touch_copy_layout) {
prefs.edit().putString("copiedLayout", (editElements + hidden).joinToString(";") {
"${it.type},${it.visible},${it.x},${it.y},${it.xScale},${it.yScale}"
}).apply()
Toast.makeText(context, "Layout copied; paste it into any game's touch layout", Toast.LENGTH_SHORT).show()
Toast.makeText(context, R.string.touch_layout_copied, Toast.LENGTH_SHORT).show()
}
item("Paste copied layout", copied != null) { pasteLayout(copied ?: "") }
item("Reset to Steam's default") { resetEditSet() }
close = SteamTouchIconPicker.showPanel(host, "Layout", list, listOf("Close" to {}))
item(R.string.touch_paste_layout, copied != null) { pasteLayout(copied ?: "") }
item(R.string.touch_reset_layout) { resetEditSet() }
close = SteamTouchIconPicker.showPanel(host, context.getString(R.string.ctrl_layout), list, listOf(context.getString(R.string.common_close) to {}))
}
/** A copied layout onto this action set: each control the set has takes the copied place. */
@@ -985,11 +986,12 @@ class SteamTouchControls(
RectF(frame.left + l * s, frame.top + t * s, frame.left + r * s, frame.top + b * s)
private fun text(canvas: Canvas, str: String, x: Float, y: Float, size: Float, color: Int = Color.WHITE, bold: Boolean = true,
align: Paint.Align = Paint.Align.CENTER) {
align: Paint.Align = Paint.Align.CENTER, maxWidth: Float = 0f) {
val p = Paint(Paint.ANTI_ALIAS_FLAG).apply {
this.color = color; textSize = size; textAlign = align
typeface = if (bold) android.graphics.Typeface.DEFAULT_BOLD else android.graphics.Typeface.DEFAULT
}
if (maxWidth > 0f) p.measureText(str).let { if (it > maxWidth) p.textSize = size * maxWidth / it }
canvas.drawText(str, x, y - (p.descent() + p.ascent()) / 2, p)
}
@@ -1004,7 +1006,7 @@ class SteamTouchControls(
canvas.drawRoundRect(r, radius, radius, Paint(Paint.ANTI_ALIAS_FLAG).apply { color = line2; style = Paint.Style.STROKE; strokeWidth = 1.2f * s })
}
val ink = when { !enabled -> Color.argb(110, 242, 244, 247); primary -> onAccent; else -> onSurface }
text(canvas, text, r.centerX(), r.centerY(), 14f * s, ink)
text(canvas, text, r.centerX(), r.centerY(), 14f * s, ink, maxWidth = r.width() - 16f * s)
if (enabled) hots += Hot(r, onTap)
}
@@ -1044,7 +1046,7 @@ class SteamTouchControls(
BIG_PICTURE -> "Steam"
else -> gameNames[appId] ?: run {
val app = appId
gameNames[app] = "app $app"
gameNames[app] = context.getString(R.string.touch_app_id, app)
loader.execute {
val name = SteamTouchConfig.gameName(context, app) ?: return@execute
handler.post { gameNames[app] = name; invalidate() }
@@ -1061,7 +1063,7 @@ class SteamTouchControls(
// Header: power (DroidDeck's own menu: stop, settings), the Steam mark, what is running, close.
iconButton(canvas, ref(f, s, 494f, 18f, 531f, 55f), false, { menuOpen = false; onMenu() }) { c, r, col -> drawPower(c, r, col) }
drawMark(canvas, f.left + 104f * s, f.top + 37f * s, 13f * s)
text(canvas, "Touch controls", f.left + 124f * s, f.top + 30f * s, 14f * s, onSurface, align = Paint.Align.LEFT)
text(canvas, context.getString(R.string.touch_title), f.left + 124f * s, f.top + 30f * s, 14f * s, onSurface, align = Paint.Align.LEFT)
text(canvas, gameName(), f.left + 124f * s, f.top + 46f * s, 11f * s, muted, bold = false, align = Paint.Align.LEFT)
closeButton(canvas, f, s) { menuOpen = false }
val controller = options.inputMode != SteamTouchConfig.INPUT_MOUSE
@@ -1071,10 +1073,10 @@ class SteamTouchControls(
m -> SteamTouchConfig.INPUT_MOUSE
else -> SteamTouchConfig.INPUT_CONTROLLER
}))
tile(canvas, ref(f, s, 45f, 81f, 249f, 271f), s, "Touch Controller", controller, { setModes(!controller, mouse || controller) }) { c, r, col ->
tile(canvas, ref(f, s, 45f, 81f, 249f, 271f), s, context.getString(R.string.touch_controller), controller, { setModes(!controller, mouse || controller) }) { c, r, col ->
drawPhonePad(c, r, col)
}
tile(canvas, ref(f, s, 271f, 81f, 475f, 271f), s, "Mouse", mouse, { setModes(controller || mouse, !mouse) }) { c, r, col ->
tile(canvas, ref(f, s, 271f, 81f, 475f, 271f), s, context.getString(R.string.touch_mouse), mouse, { setModes(controller || mouse, !mouse) }) { c, r, col ->
drawMouse(c, r, col, crossed = false)
}
// Under the controller: gyroscope, fade, vibrate on touch.
@@ -1102,10 +1104,13 @@ class SteamTouchControls(
val speed = speeds.indexOfFirst { abs(it - options.trackpadSensitivity) < 0.2f }.coerceAtLeast(1)
iconButton(canvas, ref(f, s, 412f, 278f, 475f, 318f), mouse && relative, {
setOptions(options.copy(trackpadSensitivity = speeds[(speed + 1) % speeds.size]))
}) { c, r, col -> text(c, listOf("Slow", "Normal", "Fast")[speed], r.centerX(), r.centerY(), r.height() * 0.32f, col) }
}) { c, r, col ->
val name = context.getString(listOf(R.string.touch_speed_slow, R.string.touch_speed_normal, R.string.touch_speed_fast)[speed])
text(c, name, r.centerX(), r.centerY(), r.height() * 0.32f, col, maxWidth = r.width() - 6f * s)
}
drawVolume(canvas, f, s)
blueButton(canvas, ref(f, s, 45f, 329f, 249f, 372f), "Edit layout", s, primary = true) { menuOpen = false; startEditing() }
blueButton(canvas, ref(f, s, 271f, 329f, 475f, 372f), "DroidDeck menu", s) { menuOpen = false; onMenu() }
blueButton(canvas, ref(f, s, 45f, 329f, 249f, 372f), context.getString(R.string.touch_edit_layout), s, primary = true) { menuOpen = false; startEditing() }
blueButton(canvas, ref(f, s, 271f, 329f, 475f, 372f), context.getString(R.string.touch_droiddeck_menu), s) { menuOpen = false; onMenu() }
}
private val audio by lazy { context.getSystemService(Context.AUDIO_SERVICE) as android.media.AudioManager }
@@ -1173,7 +1178,7 @@ class SteamTouchControls(
canvas.drawRoundRect(r, radius, radius, Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = if (on) accent else line; style = Paint.Style.STROKE; strokeWidth = (if (on) 2f else 1.2f) * s
})
text(canvas, title, r.left + 16f * s, r.top + 22f * s, 14f * s, onSurface, align = Paint.Align.LEFT)
text(canvas, title, r.left + 16f * s, r.top + 22f * s, 14f * s, onSurface, align = Paint.Align.LEFT, maxWidth = r.width() - 72f * s)
// A switch, top right.
val sw = RectF(r.right - 50f * s, r.top + 12f * s, r.right - 14f * s, r.top + 32f * s)
canvas.drawRoundRect(sw, sw.height() / 2, sw.height() / 2, Paint(Paint.ANTI_ALIAS_FLAG).apply { color = if (on) accent else line2 })
@@ -1181,7 +1186,7 @@ class SteamTouchControls(
Paint(Paint.ANTI_ALIAS_FLAG).apply { color = if (on) onAccent else muted })
val artRect = RectF(r.centerX() - 58f * s, r.top + 62f * s, r.centerX() + 58f * s, r.top + 140f * s)
art(canvas, artRect, if (on) onSurface else muted)
text(canvas, if (on) "On" else "Off", r.left + 16f * s, r.bottom - 18f * s, 12f * s, if (on) accent else muted, bold = false, align = Paint.Align.LEFT)
text(canvas, context.getString(if (on) R.string.touch_on else R.string.touch_off), r.left + 16f * s, r.bottom - 18f * s, 12f * s, if (on) accent else muted, bold = false, align = Paint.Align.LEFT)
hots += Hot(r, toggle)
}
@@ -1194,9 +1199,9 @@ class SteamTouchControls(
closeButton(canvas, f, s) { save() }
val sets = SteamTouchConfig.actionSets(config)
val setName = sets.firstOrNull { it.first == editSet }?.second
val title = if (sets.size > 1 && setName != null) "${gameName()} · $setName" else "${gameName()} ${config.title ?: "Layout"}"
text(canvas, title, f.centerX(), f.top + 30f * s, 14f * s, onSurface)
text(canvas, "Drag controls onto the screen", f.centerX(), f.top + 47f * s, 11f * s, muted, bold = false)
val title = if (sets.size > 1 && setName != null) "${gameName()} · $setName" else "${gameName()} ${config.title ?: context.getString(R.string.ctrl_layout)}"
text(canvas, title, f.centerX(), f.top + 30f * s, 14f * s, onSurface, maxWidth = f.width() - 200f * s)
text(canvas, context.getString(R.string.touch_drag_hint), f.centerX(), f.top + 47f * s, 11f * s, muted, bold = false, maxWidth = f.width() - 200f * s)
if (sets.size > 1) {
arrowPill(canvas, ref(f, s, 120f, 26f, 150f, 44f), -1) { stepEditSet(-1) }
arrowPill(canvas, ref(f, s, 474f, 26f, 504f, 44f), 1) { stepEditSet(1) }
@@ -1251,8 +1256,8 @@ class SteamTouchControls(
shader = android.graphics.RadialGradient(wheel.centerX(), wheel.centerY(), wheel.width() / 2f, Color.WHITE, Color.TRANSPARENT, android.graphics.Shader.TileMode.CLAMP)
})
hots += Hot(wheel, { pickColor() })
blueButton(canvas, ref(f, s, 45f, 329f, 232f, 372f), "Arrange", s, primary = true) { trayOpen = false }
blueButton(canvas, ref(f, s, 254f, 329f, 441f, 372f), "Discard", s) { stopEditing() }
blueButton(canvas, ref(f, s, 45f, 329f, 232f, 372f), context.getString(R.string.touch_arrange), s, primary = true) { trayOpen = false }
blueButton(canvas, ref(f, s, 254f, 329f, 441f, 372f), context.getString(R.string.touch_discard), s) { stopEditing() }
}
private fun arrowPill(canvas: Canvas, r: RectF, dir: Int, onTap: () -> Unit) {
@@ -1290,7 +1295,10 @@ class SteamTouchControls(
return RectF(x - r, y - r, x + r, y + r)
}
private val contextLabels = listOf("Icon", "W−", "W+", "H−", "H+", "Hide")
private val contextLabels by lazy {
listOf(R.string.touch_icon, R.string.touch_narrower, R.string.touch_wider, R.string.touch_shorter, R.string.touch_taller, R.string.touch_hide)
.map(context::getString)
}
private fun contextRects(): List<RectF> {
val e = editElements.getOrNull(selected) ?: return emptyList()
@@ -1313,11 +1321,11 @@ class SteamTouchControls(
canvas.drawRoundRect(m, m.width() * 0.15f, m.width() * 0.15f, p)
drawDots(canvas, m.centerX(), m.centerY() - m.height() * 0.1f, m.width() * 0.5f, Color.WHITE)
hots += Hot(m, { trayOpen = true })
if (saving) text(canvas, "Saving…", width / 2f, height * 0.08f, 22f * max(unit(), 0.6f))
if (saving) text(canvas, context.getString(R.string.touch_saving), width / 2f, height * 0.08f, 22f * max(unit(), 0.6f))
contextRects().forEachIndexed { i, r ->
canvas.drawRoundRect(r, r.height() * 0.3f, r.height() * 0.3f, Paint(Paint.ANTI_ALIAS_FLAG).apply { color = surface })
canvas.drawRoundRect(r, r.height() * 0.3f, r.height() * 0.3f, Paint(Paint.ANTI_ALIAS_FLAG).apply { color = line2; style = Paint.Style.STROKE; strokeWidth = 1.2f })
text(canvas, contextLabels[i], r.centerX(), r.centerY(), r.height() * 0.4f, onSurface, bold = false)
text(canvas, contextLabels[i], r.centerX(), r.centerY(), r.height() * 0.4f, onSurface, bold = false, maxWidth = r.width() - 6f)
hots += Hot(r, { contextTool(i) })
}
}
@@ -1448,12 +1456,14 @@ class SteamTouchControls(
val ref = visual?.ref
val binding = visual?.binding
if (ref == null || binding == null) {
Toast.makeText(context, "This control has no binding in Steam to put an icon on", Toast.LENGTH_SHORT).show()
Toast.makeText(context, R.string.touch_no_binding, Toast.LENGTH_SHORT).show()
return
}
val name = if (e.type == SteamTouchConfig.DPAD) "D-pad " + listOf("up", "down", "left", "right")[selectedArm] else label(e.type)
val name = if (e.type == SteamTouchConfig.DPAD) {
context.getString(listOf(R.string.touch_dpad_up, R.string.touch_dpad_down, R.string.touch_dpad_left, R.string.touch_dpad_right)[selectedArm])
} else label(e.type)
val host = parent as? android.view.ViewGroup ?: return
SteamTouchIconPicker(context, host, appId, "Icon for $name", binding) { picked ->
SteamTouchIconPicker(context, host, appId, context.getString(R.string.touch_icon_for, name), binding) { picked ->
pendingBindings[ref] = picked
rebuildVisuals()
invalidate()
@@ -1480,9 +1490,9 @@ class SteamTouchControls(
}
}, android.widget.LinearLayout.LayoutParams(dp(30), dp(30)).apply { marginEnd = dp(6) })
}
root.addView(android.widget.TextView(context).apply { text = "Colour" })
root.addView(android.widget.TextView(context).apply { setText(R.string.ctrl_color) })
root.addView(android.widget.HorizontalScrollView(context).apply { addView(swatchRow) })
root.addView(android.widget.TextView(context).apply { text = "Opacity"; setPadding(0, dp(12), 0, 0) })
root.addView(android.widget.TextView(context).apply { setText(R.string.ctrl_opacity); setPadding(0, dp(12), 0, 0) })
val opacityRow = android.widget.LinearLayout(context)
listOf(20, 35, 50, 65, 80, 100).forEach { percent ->
opacityRow.addView(android.widget.Button(context).apply {
@@ -1497,7 +1507,7 @@ class SteamTouchControls(
}
root.addView(android.widget.HorizontalScrollView(context).apply { addView(opacityRow) })
val host = parent as? android.view.ViewGroup ?: return
SteamTouchIconPicker.showPanel(host, "Touch layout colour", root, listOf("Done" to {}))
SteamTouchIconPicker.showPanel(host, context.getString(R.string.touch_layout_color), root, listOf(context.getString(R.string.touch_done) to {}))
}
private fun save() {
@@ -1528,11 +1538,11 @@ class SteamTouchControls(
handler.post {
saving = false
if (file == null) {
Toast.makeText(context, "Could not save the touch layout", Toast.LENGTH_SHORT).show()
Toast.makeText(context, R.string.touch_save_failed, Toast.LENGTH_SHORT).show()
invalidate()
return@post
}
Toast.makeText(context, "Touch layout saved to Steam", Toast.LENGTH_SHORT).show()
Toast.makeText(context, R.string.touch_saved, Toast.LENGTH_SHORT).show()
onSaved()
stopEditing()
reloadConfig()
@@ -21,6 +21,7 @@ import android.widget.HorizontalScrollView
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.droiddeck.launcher.R
import java.util.concurrent.Executors
/**
@@ -50,7 +51,7 @@ class SteamTouchIconPicker(
val root = LinearLayout(context).apply { orientation = LinearLayout.HORIZONTAL; setPadding(dp(16), dp(8), dp(16), 0) }
val left = LinearLayout(context).apply { orientation = LinearLayout.VERTICAL }
val label = EditText(context).apply {
hint = "Label (optional)"
setHint(R.string.touch_label_hint)
setText(current.label)
inputType = InputType.TYPE_CLASS_TEXT
setSingleLine()
@@ -77,21 +78,22 @@ class SteamTouchIconPicker(
setPadding(0, dp(8), 0, 0)
addView(preview, LinearLayout.LayoutParams(dp(56), dp(56)))
addView(TextView(context).apply {
text = if (names.isEmpty()) "Steam's icons were not found" else "${names.size} icons from Steam"
text = if (names.isEmpty()) context.getString(R.string.touch_icons_missing)
else context.resources.getQuantityString(R.plurals.touch_icons_found, names.size, names.size)
setPadding(dp(12), 0, 0, 0)
})
})
left.addView(paletteRow("Icon colour", { foreground }) { foreground = it; adapter.notifyDataSetChanged(); updatePreview(preview) })
left.addView(paletteRow("Button colour", { background }) { background = it; adapter.notifyDataSetChanged(); updatePreview(preview) })
left.addView(paletteRow(context.getString(R.string.touch_icon_color), { foreground }) { foreground = it; adapter.notifyDataSetChanged(); updatePreview(preview) })
left.addView(paletteRow(context.getString(R.string.touch_button_color), { background }) { background = it; adapter.notifyDataSetChanged(); updatePreview(preview) })
root.addView(left, LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f))
root.addView(grid, LinearLayout.LayoutParams(0, dp(250), 1.2f).apply { marginStart = dp(16) })
updatePreview(preview)
showPanel(host, title, root, listOf(
"No icon" to {
context.getString(R.string.touch_no_icon) to {
onPicked(current.copy(label = label.text.toString().replace(",", " ").trim(), icon = "", foreground = "", background = ""))
},
"Cancel" to {},
"Use" to {
context.getString(R.string.common_cancel) to {},
context.getString(R.string.common_use) to {
onPicked(current.copy(label = label.text.toString().replace(",", " ").trim(), icon = icon,
foreground = if (icon.isEmpty()) "" else foreground, background = if (icon.isEmpty()) "" else background))
},
@@ -51,7 +51,7 @@ object AmazonBackend : StoreBackend {
val quiet = cached.isNotEmpty() && !force
StoresState.post {
if (cached.isNotEmpty()) publish(app, cached)
if (!quiet) StoresState.status[store] = "Fetching your library…"
if (!quiet) StoresState.status[store] = app.getString(com.droiddeck.launcher.R.string.stores_sync_library)
}
val result = AmazonLibrary.sync(app, force) { line -> if (!quiet) StoresState.post { StoresState.status[store] = line } }
StoresState.post {
@@ -94,7 +94,7 @@ object AmazonBackend : StoreBackend {
private val cancelled = AtomicBoolean(false)
override fun run(handle: DownloadQueue.JobHandle): String? {
handle.stage(DownloadStage.MANIFEST, "Checking sign-in…")
handle.stage(DownloadStage.MANIFEST, app.getString(com.droiddeck.launcher.R.string.stores_sync_sign_in))
val token = AmazonCredentialStore.getValidAccessToken(app) ?: throw AmazonDownloadManager.InstallException("Not signed in to Amazon Games")
StoreInstalls.begin(folder, Store.AMAZON, game.productId, game.title, item.tallImageUrl ?: item.imageUrl, item.imageUrl)
var downloading = false
@@ -111,7 +111,7 @@ object AmazonBackend : StoreBackend {
override fun onSizes(downloadBytes: Long, diskBytes: Long) { handle.diskSize(diskBytes) }
}) ?: return null
if (cancelled.get()) return null
handle.stage(DownloadStage.INSTALL, "Registering with Steam…")
handle.stage(DownloadStage.INSTALL, app.getString(com.droiddeck.launcher.R.string.stores_registering))
AmazonLibrary.rememberSize(app, game.productId, result.bytes)
AmazonPrefs.get(app).edit().putString("version_${game.productId}", result.versionId).apply()
val spec = AmazonLaunchHelper.buildLaunchSpec(folder, game.title)
@@ -3,6 +3,7 @@ package com.droiddeck.launcher.stores.amazon
import android.content.Context
import android.content.SharedPreferences
import android.util.Log
import com.droiddeck.launcher.R
import com.droiddeck.launcher.stores.CatalogItem
import com.droiddeck.launcher.stores.Store
import com.droiddeck.launcher.stores.StoreNet
@@ -66,38 +67,38 @@ object AmazonLibrary {
val p = AmazonPrefs.get(app)
val cachedList = cached(app)
if (!force && cachedList.isNotEmpty() && System.currentTimeMillis() - p.getLong(LAST_SYNC_KEY, 0L) < THROTTLE_MS) {
backfillPosters(p, cachedList, onStatus)
backfillPosters(app, p, cachedList, onStatus)
return SyncResult.Throttled
}
onStatus("Checking sign-in…")
onStatus(app.getString(R.string.stores_sync_sign_in))
val creds = AmazonCredentialStore.load(app) ?: return SyncResult.NotLoggedIn
val token = AmazonCredentialStore.getValidAccessToken(app) ?: return SyncResult.Failed(StoresState.notSignedInLine(Store.AMAZON))
onStatus("Fetching game list…")
onStatus(app.getString(R.string.stores_sync_game_list))
// Refused with the stored token (revoked, or an expiry read wrong): once more on a fresh one.
val all = AmazonApiClient.getEntitlements(token, creds.deviceSerial)
?: AmazonCredentialStore.refresh(app)?.let { AmazonApiClient.getEntitlements(it, creds.deviceSerial) }
if (all == null) return if (cachedList.isEmpty()) SyncResult.Failed("Amazon Games did not answer for your library: refresh, or sign in again") else SyncResult.Ok(cachedList)
if (all.isEmpty()) return if (cachedList.isEmpty()) SyncResult.Failed("No games found in your Amazon library") else SyncResult.Ok(cachedList)
if (all == null) return if (cachedList.isEmpty()) SyncResult.Failed(app.getString(R.string.stores_sync_amazon_no_answer)) else SyncResult.Ok(cachedList)
if (all.isEmpty()) return if (cachedList.isEmpty()) SyncResult.Failed(app.getString(R.string.stores_sync_no_games, Store.AMAZON.label)) else SyncResult.Ok(cachedList)
val games = all.filter { !(it.isDLC && it.parentProductId.isNotEmpty()) }.ifEmpty { all }
.sortedWith { a, b -> a.title.compareTo(b.title, ignoreCase = true) }
for (fresh in games) cachedList.firstOrNull { it.productId == fresh.productId }?.let { fresh.versionId = it.versionId }
saveCache(p, games)
p.edit().putLong(LAST_SYNC_KEY, System.currentTimeMillis()).apply()
backfillPosters(p, games, onStatus)
backfillPosters(app, p, games, onStatus)
Log.i(TAG, "sync: entitlements=${all.size} games=${games.size}")
return SyncResult.Ok(games)
} catch (e: Exception) {
Log.w(TAG, "sync failed: ${e.message}")
return SyncResult.Failed(e.message ?: "Sync failed")
return SyncResult.Failed(e.message ?: context.getString(R.string.stores_sync_failed))
} finally {
syncing.set(false)
}
}
private fun backfillPosters(p: SharedPreferences, games: List<AmazonGame>, onStatus: (String) -> Unit) {
private fun backfillPosters(app: Context, p: SharedPreferences, games: List<AmazonGame>, onStatus: (String) -> Unit) {
val missing = games.filter { it.productId.isNotEmpty() && !p.contains("vcover_${it.productId}") }.take(POSTER_BUDGET)
if (missing.isEmpty()) return
onStatus("Fetching cover art…")
onStatus(app.getString(R.string.stores_sync_cover_art))
val pool = Executors.newFixedThreadPool(4)
val futures = missing.map { g -> pool.submit(Callable { g.productId to StoreNet.sgdbPoster(g.title) }) }
pool.shutdown()
@@ -47,7 +47,7 @@ object EpicBackend : StoreBackend, EpicLaunchSupport {
val quiet = cached.isNotEmpty() && !force
StoresState.post {
if (cached.isNotEmpty()) StoresState.library[store] = com.droiddeck.launcher.stores.mergeItems(StoresState.library[store], cached)
if (!quiet) StoresState.status[store] = "Fetching your library…"
if (!quiet) StoresState.status[store] = app.getString(com.droiddeck.launcher.R.string.stores_sync_library)
}
val result = EpicLibrary.sync(app, force) { line -> if (!quiet) StoresState.post { StoresState.status[store] = line } }
StoresState.post {
@@ -122,7 +122,7 @@ object EpicBackend : StoreBackend, EpicLaunchSupport {
private fun hasChunks(dir: File): Boolean = dir.isDirectory && (dir.list()?.isNotEmpty() == true)
override fun run(handle: DownloadQueue.JobHandle): String? {
handle.stage(DownloadStage.MANIFEST, "Checking sign-in…")
handle.stage(DownloadStage.MANIFEST, app.getString(com.droiddeck.launcher.R.string.stores_sync_sign_in))
val token = EpicCredentialStore.getValidAccessToken(app) ?: throw EpicDownloadManager.InstallException("Not signed in to Epic Games")
StoreInstalls.begin(folder, Store.EPIC, item.id, item.title, item.tallImageUrl ?: item.imageUrl, item.imageUrl)
if (scratch == null && hasChunks(File(folder, ".chunks"))) handle.log("epic: resuming \"${item.title}\" with the chunks already beside it")
@@ -151,7 +151,7 @@ object EpicBackend : StoreBackend, EpicLaunchSupport {
}
}) ?: return null
if (cancelled.get()) return null
handle.stage(DownloadStage.INSTALL, "Registering with Steam…")
handle.stage(DownloadStage.INSTALL, app.getString(com.droiddeck.launcher.R.string.stores_registering))
EpicLibrary.rememberSize(app, item.id, result.bytes)
val deploymentId = runCatching { JSONObject(manifestJson).optString("deploymentId", "") }.getOrDefault("")
val exe = StoreExe.pick(folder, result.launchExe, item.title)
@@ -3,6 +3,7 @@ package com.droiddeck.launcher.stores.epic
import android.content.Context
import android.content.SharedPreferences
import android.util.Log
import com.droiddeck.launcher.R
import com.droiddeck.launcher.stores.CatalogItem
import com.droiddeck.launcher.stores.Store
import org.json.JSONArray
@@ -67,17 +68,17 @@ object EpicLibrary {
val cachedList = cached(app)
val lastSync = p.getLong(LAST_SYNC_KEY, 0L)
if (!force && cachedList.isNotEmpty() && System.currentTimeMillis() - lastSync < THROTTLE_MS) return SyncResult.Throttled
onStatus("Checking sign-in…")
onStatus(app.getString(R.string.stores_sync_sign_in))
val token = EpicCredentialStore.getValidAccessToken(app) ?: return SyncResult.NotLoggedIn
onStatus("Fetching game list…")
onStatus(app.getString(R.string.stores_sync_game_list))
val raw = EpicApiClient.getLibraryItems(token)
if (raw.isNullOrEmpty()) return if (cachedList.isEmpty()) SyncResult.Failed("No games found in your Epic library") else SyncResult.Ok(cachedList)
if (raw.isNullOrEmpty()) return if (cachedList.isEmpty()) SyncResult.Failed(app.getString(R.string.stores_sync_no_games, Store.EPIC.label)) else SyncResult.Ok(cachedList)
val total = raw.size
var done = 0
for (game in raw) {
EpicApiClient.enrichFromCatalog(token, game)
done++
if (done % 5 == 0) onStatus("Loading game details… ($done/$total)")
if (done % 5 == 0) onStatus(app.getString(R.string.stores_sync_details, done, total))
}
val main = raw.filter { !it.isDLC }
val display = (if (main.isEmpty()) raw else main).distinctBy { it.appName }.sortedWith { a, b -> a.title.compareTo(b.title, ignoreCase = true) }
@@ -92,7 +93,7 @@ object EpicLibrary {
return SyncResult.Ok(display)
} catch (e: Exception) {
Log.w(TAG, "sync failed: ${e.message}")
return SyncResult.Failed(e.message ?: "Sync failed")
return SyncResult.Failed(e.message ?: context.getString(R.string.stores_sync_failed))
} finally {
syncing.set(false)
}
@@ -38,7 +38,7 @@ object GogBackend : StoreBackend {
val quiet = cached.isNotEmpty() && !force
StoresState.post {
if (cached.isNotEmpty()) StoresState.library[store] = com.droiddeck.launcher.stores.mergeItems(StoresState.library[store], cached)
if (!quiet) StoresState.status[store] = "Fetching your library…"
if (!quiet) StoresState.status[store] = app.getString(com.droiddeck.launcher.R.string.stores_sync_library)
}
val result = GogLibrary.sync(app, force) { line -> if (!quiet) StoresState.post { StoresState.status[store] = line } }
StoresState.post {
@@ -106,7 +106,7 @@ object GogBackend : StoreBackend {
}
}, cancelled) ?: return null
if (cancelled.get()) return null
handle.stage(DownloadStage.INSTALL, "Registering with Steam…")
handle.stage(DownloadStage.INSTALL, app.getString(com.droiddeck.launcher.R.string.stores_registering))
val sidecar = StoreGameSidecar(
Store.GOG, game.gameId, game.title, exe = result.exeRelative.ifEmpty { "" },
installVersion = result.buildId, installedAt = System.currentTimeMillis(),
@@ -3,6 +3,7 @@ package com.droiddeck.launcher.stores.gog
import android.content.Context
import android.content.SharedPreferences
import android.util.Log
import com.droiddeck.launcher.R
import com.droiddeck.launcher.stores.CatalogItem
import com.droiddeck.launcher.stores.Store
import com.droiddeck.launcher.stores.StoreNet
@@ -60,9 +61,9 @@ object GogLibrary {
val app = context.applicationContext
val p = GogPrefs.get(app)
val token = GogAuth.validToken(app) ?: return SyncResult.NotLoggedIn
onStatus("Fetching game list…")
onStatus(app.getString(R.string.stores_sync_game_list))
val gamesJson = StoreNet.get("https://embed.gog.com/user/data/games", bearer = token, userAgent = GogAuth.GALAXY_UA)
?: return SyncResult.Failed("Couldn't reach GOG")
?: return SyncResult.Failed(app.getString(R.string.stores_sync_gog_unreachable))
val ids = ArrayList<String>()
val parsed = runCatching {
val owned = JSONObject(gamesJson).optJSONArray("owned")
@@ -72,7 +73,7 @@ object GogLibrary {
if (id != "1801418160" && id != "0") ids.add(id)
}
}.isSuccess
if (!parsed) return SyncResult.Failed("Error parsing library")
if (!parsed) return SyncResult.Failed(app.getString(R.string.stores_sync_gog_unreadable))
val ownedSet = ids.toHashSet()
val cachedList = cached(app)
@@ -92,7 +93,7 @@ object GogLibrary {
saveCache(p, list)
return SyncResult.Ok(list.sortedBy { it.title.lowercase() }, 0)
}
onStatus("Syncing ${idsToFetch.size} game${if (idsToFetch.size == 1) "" else "s"}…")
onStatus(app.resources.getQuantityString(R.plurals.stores_sync_games, idsToFetch.size, idsToFetch.size))
val pool = Executors.newFixedThreadPool(5)
val futures = idsToFetch.map { id -> pool.submit(Callable<GogGame?> { fetchGame(p, id, token, skipped) }) }
pool.shutdown()
@@ -100,7 +101,7 @@ object GogLibrary {
for ((idx, f) in futures.withIndex()) {
val g = runCatching { f.get() }.getOrNull()
if (g != null) { merged[g.gameId] = g; fetched++ }
if ((idx + 1) % 5 == 0) onStatus("Syncing… ${idx + 1}/${futures.size}")
if ((idx + 1) % 5 == 0) onStatus(app.getString(R.string.stores_sync_progress, idx + 1, futures.size))
}
val finalList = merged.values.toList()
saveCache(p, finalList)
@@ -111,7 +112,7 @@ object GogLibrary {
return SyncResult.Ok(finalList.sortedBy { it.title.lowercase() }, fetched)
} catch (e: Exception) {
Log.w(TAG, "sync failed: ${e.message}")
return SyncResult.Failed(e.message ?: "Sync failed")
return SyncResult.Failed(e.message ?: context.getString(R.string.stores_sync_failed))
} finally {
syncing.set(false)
}