chore: remove source comments and unused code, translate every missing string (#1965)

* chore(i18n): translate every missing string in all locales

Adds the 87 strings the bottom-screen Dashboard and in-game stats pages
introduced to all 32 locales, plus the 51 older settings strings Japanese
and the 50 Chinese locales were still missing. Every locale now has all
3456 translatable strings with the same placeholders as English.

Also translates 36 entries that were still English where the language
does not use the English word, and makes es-419 touch_app_id use the same
%1$s placeholder as English.

* chore(patches): drop comments from the lines downstream patches add

Removes comment lines and trailing comments from lines our patches add,
with hunk headers recounted. Lines that a later patch uses as context
and the upstream backport 0123 are left as they are.

The gamescope, FEX, proot and xodus series still apply to their pinned
sources, and the patched trees differ only in those comments.
test_hud_frames now finds the HUD writer by its first declaration.

* docs: credit Greenlight, Better xCloud, viture-v2, GameNative and DiRTTelemetryErrorFix

These were credited only in source headers and NOTICE files.

* chore: remove source comments and unused functions

Removes explanatory comments from first-party Kotlin, Java, C, C++,
Rust, TypeScript, Python, shell, Gradle, CMake and workflow files.
License and attribution headers stay, and vendored third-party trees,
generated files and license files are untouched. A shellcheck directive
is kept, and udevmon's fallthrough comments became fallthrough attributes.

Syntax trees and token streams match the previous sources apart from the
comments and Python docstrings. Module docstrings that argparse prints
are kept, and device-smoke.sh prints the same --help text from a heredoc.

Also removes 37 functions and 4 fields that nothing referenced.

* chore: remove comments from the Syncthing integration and the latest main sources

* docs: credit Syncthing and the syncthing-android fork

* chore(i18n): translate the Syncthing strings in all locales

The 107 strings the Syncthing integration added are now in all 32 locales.
sync_web_path_locked names the Syncthing tab by its label.

* docs: credit @xXJSONDeruloXx for the HUD metric readers

The CPU, GPU load, thermal and battery readers come from their
PerformanceHudView pull requests #777, #877, #991, #1406 and #1573.
The FusionHUD credit line is unchanged.

* docs: credit the HUD metric readers to @xXJSONDeruloXx's work
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-01 16:27:27 -05:00
1 parent d730f0fa8b
commit c5577478ca
511 files changed
+6813 -4068

No files matched your search

@@ -25,7 +25,6 @@ object SyncPrefs {
fun userPaused(context: Context): Boolean = prefs(context).getBoolean("paused", false)
fun setUserPaused(context: Context, on: Boolean) { prefs(context).edit().putBoolean("paused", on).apply() }
/** Whether DroidDeck has paused all devices through the API and must resume them. */
fun pauseApplied(context: Context): Boolean = prefs(context).getBoolean("pause-applied", false)
fun setPauseApplied(context: Context, on: Boolean) { prefs(context).edit().putBoolean("pause-applied", on).apply() }
@@ -48,10 +48,8 @@ object Syncthing {
var apiKeyTail by mutableStateOf<String?>(null); private set
var userPaused by mutableStateOf(false); private set
var autoPause by mutableStateOf<AutoPause?>(null); private set
/** Whether Syncthing has confirmed every device is paused, as opposed to a pause only being requested. */
var devicesPaused by mutableStateOf(false); private set
val pauseRequested get() = userPaused || autoPause != null
/** Bumped to ask the Setup page to show the Sync tab. */
var openRequests by mutableStateOf(0)
private set
var openPending = false
@@ -63,7 +61,6 @@ object Syncthing {
val needsAttention get() = phase == Phase.FAILED || snapshot?.needsAttention == true
/** Called on the main thread whenever the state above changes; the background service follows it. */
@Volatile var onChange: (() -> Unit)? = null
private val main = Handler(Looper.getMainLooper())
@@ -87,7 +84,6 @@ object Syncthing {
private fun guiSocket(context: Context) = File(home(context), "gui.sock")
private fun binary(context: Context) = File(context.applicationInfo.nativeLibraryDir, "libsyncthingnative.so")
/** DroidDeck's own storage: its private data directory and its folder on each shared volume. */
fun storageRoots(context: Context): List<File> =
listOf(context.dataDir) + context.getExternalFilesDirs(null).filterNotNull().mapNotNull { it.parentFile }
@@ -138,7 +134,6 @@ object Syncthing {
worker.execute { api?.let { applyPause(it) } }
}
/** Starts or stops Syncthing to match the settings and whether DroidDeck is on screen. */
fun evaluate() {
if (Looper.myLooper() != Looper.getMainLooper()) { main.post { evaluate() }; return }
val enabled = SyncPrefs.enabled(app)
@@ -200,7 +195,6 @@ object Syncthing {
}
}
/** Adds a folder at [path] shared with [devices]; pass the offered folder's [id] to accept a share. */
fun addFolder(context: Context, path: File, label: String, devices: List<String>, id: String = newFolderId(), onDone: (Boolean) -> Unit) {
worker.execute {
val ok = runCatching {
@@ -228,14 +222,12 @@ object Syncthing {
worker.execute { api?.let { a -> runCatching { a.removeFolder(id) }.onFailure { Log.w(TAG, "remove $id failed", it) } } }
}
/** Starts a loopback proxy for the in-app web UI, which can't reach Syncthing's private socket itself. */
fun webUiProxy(context: Context): SyncthingProxy? {
if (phase != Phase.RUNNING) return null
val token = Base64.encodeToString("${SyncthingConfig.GUI_USER}:${SyncPrefs.guiPassword(context)}".toByteArray(), Base64.NO_WRAP)
return runCatching { SyncthingProxy(guiSocket(context), "Basic $token") }.onFailure { Log.w(TAG, "web UI proxy failed", it) }.getOrNull()
}
/** UI screens showing live status call this so the status refreshes faster while they're visible. */
fun watch(): () -> Unit {
watchers.incrementAndGet()
return { watchers.decrementAndGet() }
@@ -456,7 +448,6 @@ object Syncthing {
java.time.OffsetDateTime.parse(s).toInstant().toEpochMilli().takeIf { it > 86_400_000L }
}.getOrNull()
/** Pauses any folder outside DroidDeck's storage as soon as Syncthing saves its config, and stops Syncthing if it can't. */
private fun enforce(gen: Int, guard: SyncthingGuard) {
var since = 0L
var pending = true
@@ -509,7 +500,6 @@ object Syncthing {
}
}
// Runs from the worker, poll and enforce threads; serialised so an older decision can't land after a newer one.
private fun applyPause(client: SyncthingApi) = synchronized(pauseLock) {
val context = app
val auto = autoPauseReason()
@@ -524,7 +514,6 @@ object Syncthing {
if (want && !held && pauseFailures.get() >= ENFORCE_ATTEMPTS) failClosed(generation, IllegalStateException(FAILURE_PAUSE), FAILURE_PAUSE)
}
// An unreadable peer list counts as unpaused, so a required pause is reasserted rather than assumed.
private fun hasUnpausedPeer(client: SyncthingApi): Boolean = runCatching {
val myId = client.myId()
val devices = client.devices()
@@ -29,7 +29,6 @@ class SyncthingApi(val socket: File, private val apiKey: String) {
private fun merge(path: String, change: JSONObject.() -> Unit) = send("PUT", path, get(path).apply(change))
/** Long-polls for config saves; returns the last event id seen, or [since] on timeout. */
fun waitForConfigSaved(since: Long, timeoutSeconds: Int): Pair<Long, Boolean> {
val events = JSONArray(request("GET", "/rest/events?events=ConfigSaved&since=$since&timeout=$timeoutSeconds", null, (timeoutSeconds + 10) * 1000))
if (events.length() == 0) return since to false
@@ -37,7 +37,6 @@ object SyncthingConfig {
val root = doc.documentElement
val gui = root.child("gui") ?: doc.createElement("gui").also { root.appendChild(it) }
gui.setAttribute("tls", "false")
// An absolute path makes Syncthing listen on a Unix socket, which other apps can't reach in our private storage.
gui.set("address", guiSocket)
gui.set("unixSocketPermissions", "600")
val options = root.child("options") ?: doc.createElement("options").also { root.appendChild(it) }
@@ -2,7 +2,6 @@ package com.droiddeck.launcher.sync
import java.io.File
/** Decides which Syncthing folder paths stay inside DroidDeck's own storage. */
class SyncthingGuard(private val home: File, roots: List<File>, forbidden: List<File>) {
private val roots = roots.map { it.canonicalFile }
private val forbidden = forbidden.map { it.canonicalFile }
@@ -20,7 +19,6 @@ class SyncthingGuard(private val home: File, roots: List<File>, forbidden: List<
return roots.any { within(target, it) } && forbidden.none { within(target, it) || within(it, target) }
}
/** Whether [dir] can be opened while looking for a folder: inside DroidDeck's storage and outside Syncthing's own files. */
fun browsable(dir: File): Boolean {
val target = runCatching { dir.canonicalFile }.getOrNull() ?: return false
return roots.any { within(target, it) } && forbidden.none { within(target, it) }
@@ -5,7 +5,6 @@ import java.io.IOException
import java.io.InputStream
import java.io.OutputStream
/** Just enough HTTP/1.1 to talk to Syncthing over its Unix socket, one request per connection. */
internal object SyncthingHttp {
private const val LINE_LIMIT = 16 shl 10
private const val HEADER_LIMIT = 100
@@ -32,7 +31,6 @@ internal object SyncthingHttp {
return code to String(body, Charsets.UTF_8)
}
/** Reads one CRLF-terminated line, or null at end of stream. */
fun readLine(input: InputStream): String? {
val line = ByteArrayOutputStream()
while (true) {
@@ -7,7 +7,6 @@ import java.net.ServerSocket
data class SyncthingPorts(val sync: Int, val discovery: Int)
object SyncthingPortPicker {
// Syncthing's defaults, plus the alternates Syncthing-Fork's debug build uses.
internal val RESERVED = setOf(8384, 8385, 22000, 22001, 21027, 21028)
internal const val SYNC = 22100
internal const val DISCOVERY = 21127
@@ -15,12 +15,7 @@ import java.util.Collections
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.Semaphore
/**
* Bridges the in-app WebView to Syncthing's Unix socket while the web UI is open. Any app can connect to a
* loopback port, so requests without this session's cookie are refused before they reach Syncthing.
*/
class SyncthingProxy(private val socket: File, private val auth: String) : Closeable {
// Android's getLoopbackAddress() is ::1, but the WebView is pointed at 127.0.0.1.
private val server = ServerSocket(0, 16, InetAddress.getByAddress(byteArrayOf(127, 0, 0, 1)))
private val token = SyncPrefs.randomToken()
val url = "http://127.0.0.1:${server.localPort}/"
@@ -82,7 +77,6 @@ class SyncthingProxy(private val socket: File, private val auth: String) : Close
val kept = if (name.equals("Cookie", ignoreCase = true)) withoutToken(value) else value
if (kept.isNotEmpty()) head.append(name).append(": ").append(kept).append("\r\n")
}
// One request per connection keeps every request behind serve's cookie check.
head.append("Authorization: ").append(auth).append("\r\nConnection: close\r\n\r\n")
upstream.outputStream.write(head.toString().toByteArray(Charsets.ISO_8859_1))
Thread({ runCatching { input.copyTo(upstream.outputStream) } }, "syncthing-proxy-body").apply { isDaemon = true }.start()
@@ -98,7 +92,6 @@ class SyncthingProxy(private val socket: File, private val auth: String) : Close
private fun withoutToken(header: String) = cookies(header).filter { !it.startsWith("$COOKIE=") }.joinToString("; ")
/** Bounds the whole request line and headers by one deadline, so a slow client can't hold a worker. */
private class HeadDeadline(private val client: Socket, input: InputStream, private val until: Long) : FilterInputStream(input) {
@Volatile private var lifted = false
@@ -13,7 +13,6 @@ import com.droiddeck.launcher.FrontEndActivity
import com.droiddeck.launcher.R
import com.droiddeck.launcher.stores.download.StoreDownloadService
/** Keeps the app process, and with it Syncthing, alive while "Run in the background" is chosen. */
class SyncthingService : Service() {
override fun onBind(intent: Intent?): IBinder? = null
@@ -31,7 +31,6 @@ data class SyncSnapshot(
val syncing get() = folders.any { it.syncing }
val needBytes get() = folders.filter { it.syncing }.sumOf { it.needBytes }
/** Share of the syncing folders' data already in place, 0..100. */
val percent: Int get() {
val active = folders.filter { it.syncing }
val global = active.sumOf { it.globalBytes }
@@ -41,7 +40,6 @@ data class SyncSnapshot(
}
internal object SyncthingParse {
/** Stands in for a folder whose status request failed, so it shows as an error rather than as up to date. */
fun unreadableStatus(): JSONObject = JSONObject().put("state", "error").put("errors", 1)
fun folder(config: JSONObject, status: JSONObject?, blocked: Boolean, names: Map<String, String>): SyncFolder {
@@ -40,7 +40,6 @@ import com.droiddeck.launcher.ui.DroidDeckTheme
import com.droiddeck.launcher.ui.LocalPalette
import com.droiddeck.launcher.ui.SecondaryButton
/** Syncthing's own web UI, signed in automatically and kept on the loopback address. */
class SyncthingWebActivity : ComponentActivity() {
private var web: WebView? = null
@@ -100,7 +99,6 @@ class SyncthingWebActivity : ComponentActivity() {
cookies.setAcceptCookie(true)
val origin = Uri.parse(url).authority
webViewClient = object : WebViewClient() {
// The proxy cookie isn't port-scoped, so nothing else on loopback may receive it.
override fun shouldInterceptRequest(view: WebView, request: WebResourceRequest): WebResourceResponse? =
if (request.url.authority == origin) null else WebResourceResponse("text/plain", "utf-8", 403, "Forbidden", emptyMap(), null)
@@ -115,7 +113,6 @@ class SyncthingWebActivity : ComponentActivity() {
}
}
/** Keeps Syncthing's folder path field read-only, so new folders get the default path inside DroidDeck's Sync folder. */
private fun lockFolderPath(note: String) = """
(function (note) {
if (window.droiddeckPathLock) return;