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

@@ -287,7 +287,6 @@ private fun ArtOnlyEditor(
if (logoOpen && loaded != null) LogoPositionHost(chosen, arts, loaded, onBack = { logoOpen = false }, onCloseAll = { logoOpen = false; close() }) { version++; onChanged() }
}
/** The position as last read; null until it has been read, so the screen never opens on a guess and saves it over the real one. */
private class LoadedPosition(val value: LogoPosition.Value?)
@Composable
@@ -300,7 +299,6 @@ private fun rememberLogoPosition(target: ArtTarget?, version: Int): LoadedPositi
return position
}
/** The "Adjust logo" screen for [target], over the game's background and logo as they are now. */
@Composable
private fun LogoPositionHost(
target: ArtTarget, arts: List<AddedGameArt.SlotState>, start: LoadedPosition,
@@ -91,16 +91,12 @@ import java.io.File
private enum class MovieTab { INSTALLED, IMPORT, REPO, SOUND }
/** Downloads run here rather than in a tab, so switching tabs or closing the settings does not cancel one halfway. */
private val installScope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
/** The downloads under way, by post id and percent; kept here so they are still known when the tab or the settings come back. */
private val installProgress = mutableStateMapOf<String, Int>()
/** What the movie list looks like right now: every movie and the one Steam will play. */
private class MovieSnapshot(val entries: List<BootMovieLibrary.Entry>, val selected: String)
/** The movie list, read again every couple of seconds so a movie picked, added or removed inside Steam shows up here too. */
@Composable
private fun rememberMovies(refresh: Int, onSelectionChanged: () -> Unit): MovieSnapshot? {
val app = LocalContext.current.applicationContext
@@ -143,7 +139,6 @@ private fun TabChip(label: String, selected: Boolean, modifier: Modifier = Modif
}
}
/** The "Boot movie" settings group: Installed movies, Import your own movies, SteamDeckRepo and Sound. */
@Composable
internal fun BootMovieGroup(s: ModeSettings, a: ModeSettingsActions, host: MenuHost) {
var tab by rememberSaveable { mutableStateOf(MovieTab.INSTALLED) }
@@ -179,7 +174,6 @@ private fun InstalledTab(a: ModeSettingsActions) {
val app = LocalContext.current.applicationContext
val scope = rememberCoroutineScope()
var saving by remember { mutableStateOf(false) }
// The report is for bug reports, so it shows only while Debugging tools is on (read each time this tab opens).
val debugging = remember { com.droiddeck.launcher.agent.AgentAccess.commandsEnabled(app) }
if (debugging) {
SettingsRow(stringResource(R.string.boot_movie_report), stringResource(R.string.boot_movie_report_hint)) {
@@ -222,7 +216,6 @@ private fun movieSourceLabel(source: String): String = stringResource(
},
)
/** The installed movies as a list with covers; the one Steam plays is highlighted, and the list follows changes made in Steam. */
@Composable
private fun InstalledMoviesDialog(a: ModeSettingsActions, onDismiss: () -> Unit) {
val app = LocalContext.current.applicationContext
@@ -497,10 +490,8 @@ private fun RepoTab(a: ModeSettingsActions) {
}
}
/** Downloads [post] and puts it among the installed movies; returns a message when it failed, null when it worked. */
private fun install(app: android.content.Context, post: SteamDeckRepo.Post, onProgress: (Int) -> Unit): String? {
val folder = File(app.cacheDir, "boot-movie-download").apply { mkdirs() }
// Leftovers of a download that was cut short are cleared, and every download has a file of its own.
folder.listFiles()?.forEach { if (System.currentTimeMillis() - it.lastModified() > 60 * 60 * 1000L) it.delete() }
val file = File.createTempFile("movie-", ".webm", folder)
return try {
@@ -563,7 +554,6 @@ private const val AFTER_OPEN = 3
private const val AFTER_INSTALL = 1
private const val AFTER_USE = 2
/** Install and Use are different buttons in turn, and the button is disabled while installing; it takes focus back for the controller. */
@Composable
private fun RepoAction(
installed: Boolean, inUse: Boolean, percent: Int?, busy: Boolean, modifier: Modifier, onInstall: () -> Unit, onUse: () -> Unit,
@@ -593,7 +583,6 @@ private fun RepoAction(
)
}
/** A movie from SteamDeckRepo played straight from the site, so it can be checked before it is installed. */
@Composable
private fun PreviewDialog(
post: SteamDeckRepo.Post, installed: Boolean, inUse: Boolean, percent: Int?, busy: Boolean,
@@ -674,7 +663,6 @@ private fun MoviePreview(url: String, modifier: Modifier = Modifier) {
}
}
/** A dialog with one text box, for a search term or a page number; the Android keyboard comes up with it. */
@Composable
internal fun TextEntryDialog(
title: String, initial: String, number: Boolean, confirm: String, onSubmit: (String) -> Unit, onDismiss: () -> Unit,
@@ -697,7 +685,6 @@ internal fun TextEntryDialog(
}
}
/** Page buttons around the current page, which opens a box to type another page into; first and last page show their numbers. */
@OptIn(ExperimentalLayoutApi::class)
@Composable
private fun RepoPager(page: Int, last: Int?, hasMore: Boolean, onPage: (Int) -> Unit, onJump: () -> Unit) {
@@ -56,23 +56,14 @@ private const val STEAM_CHAT = "https://steamcommunity.com/chat"
private const val CHAT_PAGE_SCALE = 0.75f
private val STEAM_HOSTS = listOf("steamcommunity.com", "steam-chat.com", "steampowered.com", "steamstatic.com", "steamcontent.com")
/** Steam chat stays on Steam's own sites; anything else is not opened on the bottom screen. */
internal fun steamChatAllows(host: String?): Boolean =
host != null && STEAM_HOSTS.any { host == it || host.endsWith(".$it") }
/** The desktop chat fits the bottom panel better than the phone site; keep WebView's Chrome version. */
internal fun desktopUserAgent(webView: String?): String {
val chrome = webView?.let { Regex("Chrome/[\\d.]+").find(it)?.value } ?: "Chrome/127.0.6533.103"
return "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) $chrome Safari/537.36"
}
/**
* At the panel's own scale Steam's desktop chat gets about 600x300 CSS pixels and its friends list collapses, so the
* page is laid out [cssWidth] wide and drawn at [scale]. Steam's site header (the rows before .chat_main_flex; its
* class name is generated) is hidden to leave the height to the friends list and the chat. The group chat list keeps
* a fixed 114 px height and an empty-list note that cover the online friends, so it shrinks to its rows (at most a
* quarter of the panel) and the note is hidden.
*/
internal fun steamChatFitScript(cssWidth: Int, scale: Float): String {
val zoom = "%.2f".format(java.util.Locale.US, scale)
return "(function(){var m=document.querySelector('meta[name=viewport]');" +
@@ -92,7 +83,6 @@ fun BottomChatPage() {
val context = LocalContext.current
val colors = MaterialTheme.colorScheme
var chatOpen by remember { mutableStateOf(true) }
// Set when Android ended the page's renderer; the chat opens again once DroidDeck is back in front.
var stopped by remember { mutableStateOf(false) }
val lifecycle = LocalLifecycleOwner.current.lifecycle
DisposableEffect(lifecycle) {
@@ -105,7 +95,6 @@ fun BottomChatPage() {
lifecycle.addObserver(observer)
onDispose { lifecycle.removeObserver(observer) }
}
// null while the Steam client's sign-in is being copied, then whether there was one.
var fromSteam by remember { mutableStateOf<Boolean?>(null) }
LaunchedEffect(chatOpen) {
if (!chatOpen) {
@@ -145,7 +134,6 @@ fun BottomChatPage() {
}
}
/** With [onClose] set the chat is open: the row also carries Close and leaves out the long mic hint. */
@Composable
private fun VoiceRow(context: Context, onClose: (() -> Unit)? = null, note: String = "") {
val colors = MaterialTheme.colorScheme
@@ -153,7 +141,6 @@ private fun VoiceRow(context: Context, onClose: (() -> Unit)? = null, note: Stri
val max = remember { audio.getStreamMaxVolume(AudioManager.STREAM_MUSIC).coerceAtLeast(1) }
var volume by remember { mutableIntStateOf(audio.getStreamVolume(AudioManager.STREAM_MUSIC)) }
fun step(direction: Int) {
// No flags: Android's volume panel would cover the game on the main screen.
audio.adjustStreamVolume(AudioManager.STREAM_MUSIC, direction, 0)
volume = audio.getStreamVolume(AudioManager.STREAM_MUSIC)
}
@@ -178,8 +165,6 @@ private fun VoiceRow(context: Context, onClose: (() -> Unit)? = null, note: Stri
private fun SteamChatView(onStopped: () -> Unit) {
AndroidView(factory = { ctx ->
WebView(ctx).apply {
// AndroidView's default WRAP_CONTENT height gives the page a 0 px tall viewport, which collapses Steam
// chat's full-height layout (measured on the Retroid Pocket Duo: html and every container 0 px).
layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
setBackgroundColor(0xFF0A0B0D.toInt())
settings.javaScriptEnabled = true
@@ -199,8 +184,6 @@ private fun SteamChatView(onStopped: () -> Unit) {
if (view.width > 0) view.evaluateJavascript(steamChatFitScript((view.width / scale).roundToInt(), CHAT_PAGE_SCALE), null)
}
// Android ends the page's renderer once DroidDeck goes to picture-in-picture ("isolated not needed"
// on the Retroid Pocket Duo); the page cannot come back, so the chat closes and reopens on resume.
override fun onRenderProcessGone(view: WebView, detail: RenderProcessGoneDetail): Boolean {
onStopped()
return true
@@ -45,7 +45,6 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.droiddeck.launcher.R
/** A page the bottom screen can show while the game runs on the main screen. */
class BottomPage(
val id: String,
@StringRes val label: Int,
@@ -56,10 +55,6 @@ class BottomPage(
internal fun pickBottomPage(remembered: String?, ids: List<String>): String? =
ids.firstOrNull { it == remembered } ?: ids.firstOrNull { it == DEFAULT_PAGE } ?: ids.firstOrNull()
/**
* The tab picked during one session. Each Steam session starts with no pick, so the dashboard opens on Chat; reopened
* later in the same session it shows the tab picked last.
*/
internal object SessionBottomTab {
private var session: String? = null
private var tab: String? = null
@@ -74,13 +69,11 @@ internal object SessionBottomTab {
}
}
/** The page a game start switches to; not remembered as the user's pick. */
internal fun pageForGameStart(ids: List<String>): String? = GAME_PAGE.takeIf { it in ids }
private const val DEFAULT_PAGE = "chat"
private const val GAME_PAGE = "telemetry"
/** Tabs show their names while every tab still fits at [TAB_WIDTH]; otherwise only the open tab keeps its name. */
internal fun bottomTabsWithLabels(widthDp: Float, tabs: Int): Boolean = tabs * TAB_WIDTH + 2 * BAR_BUTTON <= widthDp
private const val TAB_WIDTH = 132f
@@ -42,7 +42,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.withContext
/** Bytes per second between two reads of the same download; 0 when it did not move or restarted. */
internal fun downloadRate(previousDone: Long, previousAt: Long, done: Long, at: Long): Long =
if (previousDone < 0L || done <= previousDone || at <= previousAt) 0L else (done - previousDone) * 1000L / (at - previousAt)
@@ -39,7 +39,6 @@ import com.droiddeck.launcher.R
import com.droiddeck.launcher.session.BottomNotifications
import kotlinx.coroutines.delay
/** DroidDeck's own switch on Android 11 and later; the list of all apps before that. */
internal fun notificationAccessIntent(context: android.content.Context): Intent =
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
Intent(Settings.ACTION_NOTIFICATION_LISTENER_DETAIL_SETTINGS).putExtra(
@@ -8,17 +8,13 @@ import androidx.compose.material.icons.outlined.Notifications
import androidx.compose.material.icons.outlined.PhotoLibrary
import com.droiddeck.launcher.R
/** What the bottom-screen pages can ask the running session to do. */
class BottomPageActions(
val takeScreenshot: ((onDone: (Boolean) -> Unit) -> Unit)? = null,
val fps: () -> Float? = { null },
/** Opens an Android settings page on the bottom screen; the dashboard comes back once [done] is true. */
val openSettings: ((intent: android.content.Intent, done: () -> Boolean) -> Unit)? = null,
/** The focused game's Steam app id as text (or another key for non-Steam programs); null in the Steam menus. */
val runningGame: () -> String? = { null },
)
/** The pages the bottom-screen dashboard offers during a session, in tab order. */
fun sessionBottomPages(actions: BottomPageActions): List<BottomPage> = listOf(
BottomPage("telemetry", R.string.bottom_page_telemetry, Icons.Outlined.Speed) { BottomTelemetryPage(actions.fps, actions.runningGame) },
BottomPage("downloads", R.string.bottom_page_downloads, Icons.Outlined.Download) { BottomDownloadsPage() },
@@ -78,10 +78,8 @@ private const val THUNDER_RETRY_MS = 3_000L
private const val ELITE_MS = 1_000L
private const val ELITE_SEARCH_MS = 10_000L
private const val OUTPUT_SCAN_MS = 3_000L
/** Top strip history: one reading a second for 30 s. */
private const val PERF_N = 30
/** What arrives on one telemetry port; written only by that port's listener. */
private class PortTraffic {
@Volatile var packets = 0L
@Volatile var length = 0
@@ -208,7 +206,6 @@ fun BottomTelemetryPage(fps: () -> Float?, runningGame: () -> String? = { null }
}
}
val f = file
// Status.json changes while Elite runs; one older than a minute belongs to an earlier session.
elite = if (f != null && now - f.lastModified() < 60_000L) {
withContext(Dispatchers.IO) { runCatching { GameStatusFiles.elite(f.readText()) }.getOrNull() }
} else null
@@ -335,7 +332,6 @@ private fun httpGet(url: String): String {
}
/** The Steam client the session runs, shown in the strip's top line while no game runs. */
internal fun steamClientLabel(arch: String): Int = if (arch == "x86_64") R.string.stats_steam_client_x86 else R.string.stats_steam_client_arm
@Composable
@@ -17,7 +17,6 @@ import android.widget.FrameLayout
import com.droiddeck.launcher.BuildConfig
import com.droiddeck.launcher.QuestXrActivity
/** A faint bottom-right tag on every screen of a test or local build; stable and preview builds draw none. */
object BuildWatermark {
private const val TITLE_LIMIT = 80
@@ -40,10 +40,8 @@ import kotlinx.coroutines.delay
import androidx.compose.runtime.setValue
import androidx.compose.runtime.getValue
/** A grid of cards with a game page that floods out of the opened card and drains back into it. */
internal val LocalDetailFloor = compositionLocalOf<() -> Float> { { Float.MAX_VALUE } }
/** How far the host reaches past the page's padding, so a game page can paint to the screen edge and still inset its content. */
internal class DetailInset(val horizontal: Dp, val top: Dp)
internal val LocalDetailInset = compositionLocalOf { DetailInset(0.dp, 0.dp) }
@@ -43,7 +43,6 @@ import kotlin.math.atan2
import kotlin.math.hypot
import kotlin.math.min
/** A small colour square; pressing it opens the colour picker. */
@Composable
internal fun ColorCube(color: Color, description: String, focus: FocusRequester? = null, onClick: () -> Unit) {
val pal = LocalPalette.current
@@ -59,7 +58,6 @@ internal fun ColorCube(color: Color, description: String, focus: FocusRequester?
)
}
/** Colour wheel (touch), hue / saturation / brightness sliders (controller and touch) and a hex box for one colour. */
@Composable
internal fun ColorPickerDialog(title: String, initial: Int, onDismiss: () -> Unit, onApply: (Int) -> Unit) {
val shown = rememberShown(onDismiss)
@@ -117,7 +115,6 @@ private fun Swatch(color: Color) {
Box(Modifier.size(48.dp).clip(shape).background(color).border(1.dp, LocalPalette.current.line2, shape))
}
/** Hue around the circle and saturation out from the middle, at full brightness; brightness has its own slider. */
@Composable
private fun ColorWheel(hue: Float, sat: Float, value: Float, onPick: (hue: Float, sat: Float) -> Unit) {
val rim = MaterialTheme.colorScheme.onBackground
@@ -930,7 +930,6 @@ private fun availableFor(l: String, catalog: List<CatalogItem>, snapshot: Snapsh
return catalog.filter { it.comp == l && ComponentsManager.safeName(it.file) !in stored }
}
// The rows to show: each stable row carries its paired nightly (if any), and a paired nightly has no row of its own.
private fun availableRows(l: String, catalog: List<CatalogItem>, snapshot: Snapshot?): List<Pair<CatalogItem, CatalogItem?>> {
val available = availableFor(l, catalog, snapshot)
val pairs = ComponentsManager.nightlyPairs(available)
@@ -1456,7 +1455,6 @@ private fun GetLine(
Box(Modifier.fillMaxWidth().height(1.dp).background(pal.line))
}
// Stable | Nightly in the same box as SmallButton: one focus stop, A (or a tap) flips it.
@Composable
private fun ChannelToggle(nightly: Boolean, enabled: Boolean, onFlip: () -> Unit) {
val colors = MaterialTheme.colorScheme
@@ -254,11 +254,8 @@ class DeckControlsPanel(
show()
}
/** Whether a finger going down at ([x], [y]) lands on one of the panel's controls. */
fun takesTouchAt(x: Float, y: Float): Boolean = controlUnder(this, x, y)
// Every control here takes the touches it gets: buttons and tabs (clickable), the scrolling tab strip,
// and the drawn surfaces, pads and face buttons. The layouts around them do not.
private fun controlUnder(view: View, x: Float, y: Float): Boolean {
if (view.visibility != VISIBLE || x < 0f || y < 0f || x >= view.width || y >= view.height) return false
if (view.isClickable || view is HorizontalScrollView || view is Surface || view is DirectionPad || view is FaceButtons) return true
@@ -6,7 +6,6 @@ import androidx.compose.ui.res.stringResource
import com.droiddeck.launcher.R
import com.droiddeck.launcher.hud.DroidDeckHudSize
/** Bannerlator's DroidDeck HUD settings (DeckOverlaySettings): one row per key of the HUD's config string. */
@Composable
internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) {
val cfg = a.hudConfig
@@ -97,12 +96,10 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri
private fun flag(on: Boolean) = if (on) "1" else "0"
// The Pill also draws the battery temperature and watts.
private val EXTRA = mapOf(DroidDeckHudSize.PILL to setOf("Temp", "Power"))
private class HudMetric(val chip: String, val key: String, val label: Int)
// DroidDeckHudSize.supportedChips() names; Wrapper and DX version have nothing to show in DroidDeck.
private val METRICS = listOf(
HudMetric("FPS", "showFPS", R.string.drawer_hud_fps),
HudMetric("FPS graph", "showFPSGraph", R.string.hud_metric_graph),
@@ -127,8 +124,6 @@ private val METRICS = listOf(
HudMetric("Clock", "showClock", R.string.hud_metric_clock),
)
// Switches a size lists but never draws (DroidDeckHudView): the Pill and Minimal always show the FPS, the
// Pill has no graph, Tiles has no graph and no 0.01% low, the Strip always shows the FPS.
private val HIDDEN = mapOf(
DroidDeckHudSize.PILL to setOf("FPS", "FPS graph"),
DroidDeckHudSize.MINIMAL to setOf("FPS"),
@@ -128,8 +128,6 @@ object DualScreenPanel {
val host = context as? ComponentActivity
val target = host?.getSystemService(Context.DISPLAY_SERVICE)
?.let { (it as android.hardware.display.DisplayManager).getDisplay(display) }
// A second-display activity makes the system launcher treat its bottom home as lost and bring itself forward;
// a presentation belongs to this task and leaves that home alone.
if (host != null && target != null) {
val shown = runCatching { DualScreenPresentation(host, target).also { it.show() } }
if (shown.isSuccess) {
@@ -170,7 +168,6 @@ object DualScreenPanel {
return true
}
// The panel resumes when an app opens over the owner on the primary screen; pulling the owner back would hide that app.
fun yieldTo(task: Int, app: Boolean) {
if (ownerTask == task) ownerYielded = app
}
@@ -66,7 +66,6 @@ internal class FocusGlide(view: View?) {
private set
fun accepts(view: View): Boolean {
// DropdownMenu recreates its popup view after closing.
if (this.view == null || deferredWindow && this.view !== view && host?.isAttached != true) this.view = view
return this.view === view
}
@@ -74,7 +74,6 @@ internal fun UninstallEpicLauncher(s: FrontEndState, a: FrontEndActions) {
}
}
/** A skipped sync is not a success: "0 files" used to show for a signed-out store or cloud saves turned off. */
internal fun cloudMessage(context: android.content.Context, r: com.droiddeck.launcher.stores.CloudSaves.Result): String = when (r.result) {
"ok" -> when {
r.conflicts > 0 -> context.getString(R.string.cloud_conflict_files, r.conflicts)
@@ -291,8 +291,6 @@ internal object Motion {
if (scale == 0f) snap() else spring(damping, stiffness)
}
private val Shape10 = RoundedCornerShape(10.dp)
internal val Shape12 = RoundedCornerShape(12.dp)
internal fun hueOf(name: String) = (name.hashCode().toUInt() % 360u).toFloat()
@@ -312,13 +310,6 @@ internal fun Rise(i: Int, modifier: Modifier = Modifier, content: @Composable ()
) { content() }
}
@Composable
private fun Modifier.staggerIn(i: Int): Modifier {
val t = remember { Animatable(0f) }
LaunchedEffect(Unit) { t.animateTo(1f, Motion.tw(360, i * 30)) }
return graphicsLayer { alpha = t.value; translationY = (1f - t.value) * 10.dp.toPx() }
}
@Composable
internal fun Modifier.shine(trigger: Boolean, strength: Float = 0.22f): Modifier {
val x = remember { Animatable(-1f) }
@@ -702,7 +702,6 @@ private fun GameSettingsCard(host: MenuHost, game: com.droiddeck.launcher.fronte
GameSettingsMenus(host, game, state)
}
/** The per-game settings menus, opened by setting [MenuHost.open] to [GAME_SETTINGS_MENU]. */
@Composable
internal fun GameSettingsMenus(host: MenuHost, game: com.droiddeck.launcher.frontend.Library.SteamGame, state: GameSettingsState) {
val appContext = androidx.compose.ui.platform.LocalContext.current.applicationContext
@@ -911,14 +910,12 @@ private fun LanguageRow(host: MenuHost, chosen: String, onPick: (String) -> Unit
}
}
/** How fast Inner Gamer cycles its colours. */
@Composable
private fun RgbSpeedRow() {
val ctx = androidx.compose.ui.platform.LocalContext.current.applicationContext
SliderRow(stringResource(R.string.theme_rgb_speed), stringResource(R.string.theme_rgb_speed_hint), Themes.rgbSpeed, 1..Themes.RGB_SPEEDS) { Themes.setRgbSpeed(ctx, it) }
}
/** The two colours of the Gradient theme, each a small square that opens the colour picker. */
@Composable
private fun GradientColorRows() {
val ctx = androidx.compose.ui.platform.LocalContext.current.applicationContext
@@ -264,23 +264,3 @@ internal fun SecondaryButton(text: String, enabled: Boolean = true, compact: Boo
}
}
@Composable
internal fun Cog(size: androidx.compose.ui.unit.Dp = 48.dp, onClick: () -> Unit) {
val colors = MaterialTheme.colorScheme
val src = remember { MutableInteractionSource() }
val hot = rememberHot(src)
var spins by remember { mutableIntStateOf(0) }
val rot by animateFloatAsState((if (hot) 90f else 0f) + spins * 180f, Motion.sp(0.55f), label = "cog")
val pal = LocalPalette.current
val placed = remember { arrayOfNulls<androidx.compose.ui.layout.LayoutCoordinates>(1) }
val cornerPx = with(androidx.compose.ui.platform.LocalDensity.current) { (if (size > 48.dp) 14.dp else 12.dp).toPx() }
Box(
contentAlignment = Alignment.Center,
modifier = Modifier.paneItem("cog").downToFirstTile().size(size).onGloballyPositioned { placed[0] = it }.clip(if (size > 48.dp) Shape14 else Shape12).background(Color.White.copy(alpha = 0.03f)).glideBorder(hot, if (size > 48.dp) Shape14 else Shape12, pal.signal, pal.line2)
.hoverable(src).clickable(role = androidx.compose.ui.semantics.Role.Button, interactionSource = src, indication = LocalIndication.current) {
placed[0]?.takeIf { it.isAttached }?.let { PageOrigin.mark(Origin(it.boundsInRoot(), cornerPx)) }
spins++
onClick()
},
) { Icon(Icons.Filled.Settings, stringResource(R.string.drawer_page_settings), tint = if (hot) pal.signal else colors.onBackground, modifier = Modifier.size(if (size > 48.dp) 20.dp else 18.dp).rotate(rot)) }
}
@@ -115,7 +115,6 @@ import java.io.File
import androidx.compose.runtime.setValue
import androidx.compose.runtime.getValue
/** What a game page shows: `app:<appId>` for a game in the library, `[app:]<store>:<id>` for a store product. */
internal class GameRef(val appId: Int?, val store: Store?, val storeId: String?) {
fun game(games: List<Library.SteamGame>): Library.SteamGame? = when {
appId != null -> games.firstOrNull { it.appId == appId }
@@ -195,7 +194,6 @@ internal fun GameDetail(
var inPage by remember(key) { mutableStateOf(false) }
var onStrip by remember(key) { mutableStateOf(false) }
var dropped by remember(key) { mutableStateOf(0) }
// A tab's content is swapped or refreshed under the focused row; focus goes back to the tabs, not to the rail.
LaunchedEffect(dropped) {
if (dropped == 0) return@LaunchedEffect
androidx.compose.runtime.withFrameNanos { }
@@ -319,7 +317,6 @@ private fun GameStatusLine(source: String, game: Library.SteamGame?, item: Catal
}
}
/** One frosted pill that holds the game's actions and its headline scores. */
@Composable
private fun GameCapsule(scores: GameScores?, actions: @Composable () -> Unit) {
Row(
@@ -500,7 +497,6 @@ internal fun GameActions(
}
}
/** Xbox Cloud Gaming rows the user added to the Library, for games not installed here. */
@Composable
internal fun rememberXboxCloudRows(s: FrontEndState): List<Library.SteamGame> {
val ctx = LocalContext.current
@@ -535,7 +531,6 @@ private fun XboxInstalledStream(id: String, title: String, item: CatalogItem?) {
private fun XboxLibraryButton(id: String, item: CatalogItem?) {
val ctx = LocalContext.current
LaunchedEffect(Unit) { XboxCloudGames.load(ctx) }
// Add and Remove replace each other; the controller focus moves to the new button instead of getting lost.
val slot = remember { FocusRequester() }
val inputMode = androidx.compose.ui.platform.LocalInputModeManager.current
val scope = rememberCoroutineScope()
@@ -572,7 +567,6 @@ private fun GameShortcutMenu(g: Library.SteamGame, a: FrontEndActions) {
}
}
/** The pencil opens the editor each kind of game always had: the shortcut editor for added games, art for the rest. */
@Composable
private fun rememberEditArt(g: Library.SteamGame): (() -> Unit)? {
val ctx = LocalContext.current
@@ -593,7 +587,6 @@ private fun EditArtButton(g: Library.SteamGame) {
IconAction(Icons.Outlined.Edit, stringResource(R.string.game_edit_art), "game:edit", onClick = open)
}
/** Narrow screens keep one More button in the capsule instead of a row of small ones. */
@Composable
private fun GameMoreMenu(g: Library.SteamGame, a: FrontEndActions) {
var open by remember(g.gameId) { mutableStateOf(false) }
@@ -932,7 +925,6 @@ private fun InstallTab(game: Library.SteamGame?, installed: InstalledStoreGame?,
}
}
/** Text a controller has to land on to bring it into view: focusable, with the focus ring. */
@Composable
internal fun Modifier.readable(): Modifier {
val pal = LocalPalette.current
@@ -953,7 +945,6 @@ internal fun FactRow(label: String, value: String, labelWidth: androidx.compose.
}
}
/** Store installs are measured by [StoreSizes]; Steam and added games by walking their folder once. */
@Composable
internal fun diskSize(installed: InstalledStoreGame?, folder: File): Long? {
val ctx = LocalContext.current
@@ -55,13 +55,8 @@ import coil.request.ImageRequest
import coil.size.Precision
import kotlin.math.max
/** Buttons in a capsule render as pills; elsewhere they keep their rounded-rectangle shape. */
internal val LocalPillButtons = compositionLocalOf { false }
/**
* The page's blurred art, shared so frosted surfaces can draw the part of it behind them.
* Coordinates are read when drawing, so a surface and the backdrop always agree on where they are.
*/
internal class GlassBackdrop {
var painter: Painter? = null
var coords: LayoutCoordinates? = null
@@ -79,7 +74,6 @@ internal class GlassBackdrop {
scope.drawCover(art, size, if (light) LightAmbient else DarkAmbient)
}
/** Drawn inside a layer, so it fades what was painted before it toward the page's end. */
fun fadeBottom(scope: DrawScope, size: Size) {
val fade = minOf(size.height * 0.5f, with(scope) { 240.dp.toPx() })
if (size.height <= 0f) return
@@ -121,7 +115,6 @@ private fun ambientRequest(ctx: android.content.Context, model: Any?): ImageRequ
private const val AmbientPixels = 6
/** How washed-out the art is: average brightness less its saturation, from a tiny decode, so pale art is dimmed while dark and vivid art are left alone. */
@Composable
private fun rememberArtBrightness(model: Any?): Float {
val ctx = LocalContext.current
@@ -148,10 +141,6 @@ private fun rememberArtBrightness(model: Any?): Float {
private const val SamplePixels = 8
private const val SaturationWeight = 0.6
/**
* A page whose game art fills the background: a blurred wash behind everything and the sharp art
* across the top, fading into the page. Surfaces inside draw frosted glass over the wash.
*/
@Composable
internal fun GameBackdrop(
art: Any?, ambient: Any?, fallbackHue: Float,
@@ -241,7 +230,6 @@ private fun ArtLayer(model: Any?, sample: Any?, fadeTop: Boolean, onPlaced: (and
private val ArtMin = 220.dp
private val ArtMax = 340.dp
/** A frosted surface: the page's wash behind it, a dark tint, and a thin rim. Plain surface when there is no backdrop. */
@Composable
internal fun Modifier.glass(shape: Shape, lift: Float = 0f): Modifier {
val g = LocalGlass.current
@@ -41,7 +41,6 @@ internal fun filterGestureActions(actions: List<GestureAction>, query: String, g
action.title.contains(word, ignoreCase = true) || action.id.removePrefix("key_").replace('_', ' ').contains(word, ignoreCase = true)
}
}.sortedWith(compareBy<GestureAction> { it.group.ordinal }.thenComparator { a, b ->
// Function keys follow their numeric sequence; names use the UI locale.
if (a.group == GestureActionGroup.FUNCTION) {
a.id.removePrefix("key_F").toInt().compareTo(b.id.removePrefix("key_F").toInt())
} else collator.compare(a.title, b.title)
@@ -28,7 +28,6 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.droiddeck.launcher.R
/** Actions for the phone while the picture is on the glasses. Null hides the button. */
internal class GlassesPhoneActions(
val onRecenter: (() -> Unit)?,
val onRecenterJoyCons: (() -> Unit)?,
@@ -225,7 +225,6 @@ internal fun GpuDriversBody(
val scroll = rememberScrollState()
val scope = rememberCoroutineScope()
val placed = remember { arrayOfNulls<LayoutCoordinates>(2) }
// Focusing the top mode shows as much of the in-use card above it as fits, without hiding the mode itself.
val revealCard = {
val (viewport, top) = placed
if (viewport != null && top != null && viewport.isAttached && top.isAttached) scope.launch {
@@ -112,7 +112,6 @@ import com.droiddeck.launcher.stores.sortGames
import kotlinx.coroutines.launch
import androidx.compose.runtime.setValue
/** One owned game: installed ones carry their [game], store products not installed yet only their [item]. */
internal class LibraryEntry(
val key: String, val source: String, val title: String,
val game: Library.SteamGame?, val item: CatalogItem?, val installed: Boolean,
@@ -120,7 +119,6 @@ internal class LibraryEntry(
val storeKey: String? get() = item?.key ?: game?.storeId?.let { "${game.source}:$it" }
}
/** Installed games first claim their store product, so a game owned and installed shows once. */
internal fun libraryEntries(
games: List<Library.SteamGame>, owned: Map<Store, List<CatalogItem>>, installedStore: Set<String>,
): List<LibraryEntry> {
@@ -159,7 +157,6 @@ internal fun librarySources(entries: List<LibraryEntry>, order: List<String>): L
(listOf(Library.SOURCE_STEAM) + arrangeStoreTabs(order, emptySet()).map { it.store.id } + Library.ADDED)
.filter { source -> entries.any { it.source == source } }
/** Survives leaving the page, so Stores can open the Library on one store's owned games. */
internal object LibraryDisplay {
val scales = listOf(0.75f, 0.875f, 1f, 1.2f, 1.45f)
var level by mutableIntStateOf(2)
@@ -797,7 +794,6 @@ internal fun HeaderIconButton(description: String, icon: androidx.compose.ui.gra
) { Icon(icon, null, tint = if (hot) pal.signal else colors.onSurfaceVariant, modifier = Modifier.size(18.dp)) }
}
/** Choosing Library in the rail lands on the first game, as Play Steam does on the Steam page. */
@Composable
internal fun Modifier.paneEntry(): Modifier {
val ff = LocalFrontFocus.current ?: return this
@@ -57,10 +57,8 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.File
/** Steam's library hero is 3840 x 1240, so the preview keeps that shape. */
private const val HERO_RATIO = 3840f / 1240f
/** The gap Steam leaves between the pinned logo and the edge of the hero, as a share of the hero's width. */
private const val EDGE = 0.03f
@Composable
@@ -86,10 +84,6 @@ private fun LogoPosition.Pin.alignment(): Alignment = when (this) {
internal fun logoPositionSummary(value: LogoPosition.Value?): String =
if (value == null) stringResource(R.string.logo_pos_default) else "${value.pin.label()} · ${value.widthPct}%"
/**
* Where a game's logo sits on its background in Steam's library: the logo box is [Value.widthPct] x [Value.heightPct] of the
* background, pinned to one of five places, and the logo is drawn as large as fits in it.
*/
@Composable
private fun LogoPreview(hero: File?, logo: File?, value: LogoPosition.Value) {
val shape = RoundedCornerShape(10.dp)
@@ -130,7 +124,6 @@ private fun PinChip(label: String, selected: Boolean, focus: FocusRequester?, on
}
}
/** The "Adjust logo" screen: the game's background with its logo on it, where to pin the logo and how large to draw it. */
@OptIn(ExperimentalLayoutApi::class)
@Composable
internal fun LogoPositionDialog(
@@ -81,9 +81,7 @@ class ModeSettings(
val picturePosition: String? = null,
val stretch16x9: Boolean? = null,
val steamClientArch: String? = null,
/** Steam only: a game launched from the front end returns there when it closes; null hides the row. */
val returnAfterGame: Boolean? = null,
/** Steam only: the client's Shader Pre-Caching setting; null hides the row. */
val shaderPrecache: Boolean? = null,
val steamRepairQueued: Boolean = false,
val mangoapp: Boolean = true,
@@ -156,15 +154,12 @@ class ModeSettingsActions(
val onDismiss: () -> Unit,
)
/** "2610 r3" from droiddeck-fex-update's FEX_TAG line (fex-2610-r3), the build x86 programs fall back to. */
internal fun fexVersionOf(script: String): String? =
Regex("""(?m)^FEX_TAG=(fex-\d+-r\d+)\s*$""").find(script)?.let { fexVersionOfTag(it.groupValues[1]) }
/** "2610 r5" from a tag such as fex-2610-r5. */
internal fun fexVersionOfTag(tag: String): String? =
Regex("""fex-(\d+)-r(\d+)""").matchEntire(tag.trim())?.let { "${it.groupValues[1]} r${it.groupValues[2]}" }
/** The build installed in the runtime, else the one fex.json names, else the one the launcher pins. */
@Composable
private fun x64FexVersion(context: android.content.Context): String? = remember {
val root = com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(context)
@@ -21,7 +21,6 @@ internal object PageSwipe {
var direction by mutableIntStateOf(0)
}
// Runs on the Final pass so carousels, sliders, scrollers and widgets that consumed the drag keep it.
@Composable
internal fun Modifier.pageSwipe(enabled: () -> Boolean, onSwipe: (Int) -> Unit): Modifier {
val enabledNow by rememberUpdatedState(enabled)
@@ -179,7 +179,6 @@ private fun CaptureShortcutKeys(onKey: (KeyEvent) -> Boolean) {
val window = (LocalView.current.parent as DialogWindowProvider).window
DisposableEffect(window) {
val previous = window.callback
// Capture before dialog navigation so Back and gamepad buttons can be assigned.
window.callback = object : Window.Callback by previous {
override fun dispatchKeyEvent(event: KeyEvent): Boolean =
currentOnKey(event) || previous.dispatchKeyEvent(event)
@@ -1605,7 +1605,6 @@ internal fun ComponentDownloadsDrawerGroup(
}
AnchoredMenu(open, onDismiss = { if (host.open == key) host.open = null },
title = ComponentsManager.LABEL.getValue(comp)) { firstItemFocus ->
// A nightly paired with a stable build rides on that row; Stable/Nightly tabs beside the row pick which one.
val pairs = ComponentsManager.nightlyPairs(items)
val rows = items.filter { it !in pairs.values }
fun shown(row: ComponentsManager.CatalogItem) = pairs[row]?.takeIf { nightlyPicked[row.file] == true } ?: row
@@ -72,7 +72,6 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import kotlinx.coroutines.withTimeoutOrNull
/** The last game frame, captured as the session left the screen, and where it sat in the overlay. */
class PausedFrame(val image: ImageBitmap, val bounds: android.graphics.Rect)
private const val CARD_SCALE = 0.82f
@@ -125,7 +124,6 @@ fun SessionPausedOverlay(
onFrameNeeded()
withTimeoutOrNull(FRAME_WAIT_MS) { snapshotFlow { currentFrame }.first { it != null } }
}
// Pausing mostly happens while the screen is off or the app is away, so it appears already settled.
press.snapTo(1f)
ring.snapTo(0f)
lift.snapTo(1f)
@@ -58,12 +58,10 @@ import kotlin.math.roundToInt
import kotlin.math.sin
private val DASH_H = 290.dp
/** Pedal and speed trace length: 150 readings at the page's 66 ms draw rate, about 10 s. */
internal const val TRACE_N = 150
internal class TraceData(val throttle: List<Float>, val brake: List<Float>, val speed: List<Float>)
/** The racing dash in [style] with speeds in [unit] (km/h or mph); a tap moves to the next one. */
@Composable
internal fun RaceDashView(style: StatsDash, t: Telemetry, trace: TraceData, unit: SpeedUnit, onTap: () -> Unit) {
Box(Modifier.fillMaxWidth().clickable(onClick = onTap)) {
@@ -87,7 +85,6 @@ private const val DIAL_SWEEP = 250f
private fun dialAngle(v: Float, max: Float) = DIAL_START + DIAL_SWEEP * (v / max).coerceIn(0f, 1f)
/** A 250° dial face: track, optional red zone from [red], ticks and numbers every [major]. */
private fun DrawScope.dialFace(
cx: Float, cy: Float, r: Float, max: Float, major: Float, label: (Float) -> String,
measurer: TextMeasurer, labelStyle: TextStyle, tick: Color, minor: Color, track: Color, red: Float?, redColor: Color,
@@ -468,7 +465,6 @@ private fun EdgeBar(value: Float?, color: Color) {
}
}
/** War Thunder's own labels the Flight layout places; others stay in the list. */
internal object FlightLabels {
const val IAS = "IAS, km/h"
const val ALTITUDE = "H, m"
@@ -573,7 +569,6 @@ private fun Pips(pips: List<Int>, modifier: Modifier) {
val pipH = (size.height - labelH) / 4f - 4.dp.toPx()
for (col in 0 until 3) {
val x = col * colW + (colW - pipW) / 2f
// Status.json counts half pips: 0..8 per system.
val value = pips[col] / 2f
for (i in 0 until 4) {
val y = size.height - labelH - (i + 1) * (pipH + 4.dp.toPx())
@@ -51,13 +51,11 @@ import com.droiddeck.launcher.session.StatsStrip
import kotlin.math.max
import kotlin.math.roundToInt
/** FusionHUD's metric colors, so the bottom screen reads like the HUD on the top screen. */
internal object StatsColors {
val cpu = Color(0xFF58A6FF)
val gpu = Color(0xFF5EE08A)
val ram = Color(0xFFFF7BC0)
val bat = Color(0xFFFFAB5E)
// Throttle and brake stay apart for red-green colour blindness (checked against the dark surface).
val throttle = Color(0xFF14A39A)
val brake = Color(0xFFE5484D)
val speed = Color(0xFF2E8FD6)
@@ -66,7 +64,6 @@ internal object StatsColors {
val badge = Color(0xFF0B0D10)
}
/** The last [capacity] readings, oldest first. */
internal class History(private val capacity: Int) {
private val values = ArrayDeque<Float>(capacity)
fun add(v: Float) {
@@ -78,7 +75,6 @@ internal class History(private val capacity: Int) {
private val MARK_RATIO = DroidDeckMark.widthFor(1f)
/** The DroidDeck mark (the split D with the blue orb), the same artwork the HUD draws. */
@Composable
internal fun DroidDeckLogo(height: Dp, modifier: Modifier = Modifier, body: Color = Color.White, orb: Color = LocalPalette.current.primary) {
Canvas(modifier.size(height * MARK_RATIO, height)) {
@@ -96,7 +92,6 @@ private fun LogoBadge(size: Dp) {
}
}
/** The mark and "DroidDeck" on the left, the running game's name in the middle, the clock on the right. */
@Composable
private fun LogoHeader(clock: String, game: String?) {
val colors = MaterialTheme.colorScheme
@@ -123,7 +118,6 @@ internal fun Sparkline(values: List<Float>, min: Float, max: Float, color: Color
}
}
/** A readout card: dark surface, a thin accent edge and the DroidDeck mark before the title ("" = mark only). */
@Composable
internal fun StatsCard(title: String?, modifier: Modifier = Modifier, content: @Composable ColumnScope.() -> Unit) {
val pal = LocalPalette.current
@@ -141,7 +135,6 @@ internal fun StatsCard(title: String?, modifier: Modifier = Modifier, content: @
}
}
/** What the top strip shows; histories hold one reading a second, oldest first. */
internal class StripData(
val fps: Float?,
val device: HudMetrics.Snapshot?,
@@ -161,7 +154,6 @@ private fun batteryText(s: HudMetrics.Snapshot?): String =
private fun fpsText(fps: Float?): String = fps?.takeIf { it > 0f }?.let { "%.1f".format(it) } ?: "–"
/** The top strip; a tap moves to the next style. */
@Composable
internal fun StatsStripView(style: StatsStrip, d: StripData, onTap: () -> Unit) {
Box(Modifier.fillMaxWidth().clickable(onClick = onTap)) {
@@ -621,7 +621,6 @@ private fun GamesView(report: StorageReport, sessionRunning: Boolean, a: FrontEn
Spacer(Modifier.height(8.dp))
Note(stringResource(R.string.storage_games_note))
confirm?.let { g ->
// steam://uninstall reaches only the session's client, the selected one.
val otherClient = g.x64 != (SessionPrefs.steamClientArch(LocalContext.current) == "x86_64")
if (otherClient) AlertDialog(
onDismissRequest = { confirm = null },
@@ -204,22 +204,6 @@ internal fun AchievementRow(a: Achievement, compact: Boolean, modifier: Modifier
}
}
@Composable
internal fun StoreAchievementsCard(game: StoreAchievements.Game, title: String, modifier: Modifier = Modifier) {
val label = StoreAchievements.forSource(game.source)?.label ?: return
val state = rememberAchievements(game) ?: return
var open by remember { mutableStateOf(false) }
StoreAchievementsCardContent(label, state, modifier) { open = true }
if (open) {
VeilRing()
Dialog(onDismissRequest = { open = false }, properties = DialogProperties(usePlatformDefaultWidth = false, decorFitsSystemWindows = false)) {
CompositionLocalProvider(LocalFrontFocus provides null) {
SessionAchievementsPanel(label, state, title, veil = Color.Transparent, floating = true, onClose = { open = false })
}
}
}
}
@Composable
internal fun StoreAchievementsCardContent(label: String, state: AchievementsState, modifier: Modifier = Modifier, onOpen: () -> Unit) {
val colors = MaterialTheme.colorScheme
@@ -177,7 +177,6 @@ internal fun StoreGameFacts(developer: String, publisher: String, releaseDate: S
}
}
/** The headline scores, small enough to sit inside the action capsule. */
@Composable
internal fun CapsuleScores(scores: GameScores, modifier: Modifier = Modifier) {
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(2.dp), modifier = modifier) {
@@ -216,7 +215,6 @@ private fun CapsuleStat(label: String, link: String?, showLabel: Boolean = true,
}
}
/** Credits and times as label and value rows, for the details panel. */
@Composable
internal fun StoreDetailRows(developer: String, publisher: String, releaseDate: String, scores: GameScores) {
val released = remember(releaseDate) { GameFacts.releaseLabel(releaseDate) }
@@ -1,6 +1,5 @@
package com.droiddeck.launcher.ui
// `split` is the size of a leading section that starts its own rows; 0 means one continuous grid.
internal fun storeGridNeighbor(index: Int, count: Int, columns: Int, direction: Int, split: Int = 0): Int? {
if (index !in 0 until count || columns < 1 || direction !in listOf(-1, 1)) return null
if (split !in 1 until count) return (index + columns * direction).takeIf { it in 0 until count }
@@ -808,14 +808,6 @@ private fun SignInButton(store: Store, large: Boolean = false) {
}
}
@Composable
internal fun StoreLogo(store: Store, size: Dp) {
val c = sourceColours(store.id)
Box(contentAlignment = Alignment.Center, modifier = Modifier.size(size).clip(Shape14).background(c.fill).border(1.dp, c.dot.copy(alpha = 0.5f), Shape14)) {
Text(store.shortLabel, fontSize = (size.value / 4).sp, fontWeight = FontWeight.Black, color = c.ink, maxLines = 1)
}
}
@Composable
private fun Storefront(
@@ -862,7 +854,6 @@ private fun Storefront(
val focus = LocalFrontFocus.current
val scope = rememberCoroutineScope()
val searching = q.isNotEmpty() || browsing || catalog
// A bar only while there is nothing else to look at: no shelves yet and no search results.
val bareTab = if (searching) visible.isEmpty() else shelves == null || shelves.isEmpty
val barLine = StoresState.status[store]?.takeIf { bareTab && syncCount(it) != null }
val itchBar = store == Store.ITCH && q.isEmpty()
@@ -1423,15 +1414,6 @@ internal fun ConfirmButton(label: String, confirm: String, compact: Boolean = fa
SecondaryButton(if (armed) confirm else label, compact = compact) { if (!armed) armed = true else { armed = false; onConfirm() } }
}
@Composable
internal fun stageLabel(stage: DownloadStage): String = when (stage) {
DownloadStage.MANIFEST -> stringResource(R.string.stores_stage_manifest)
DownloadStage.DOWNLOAD -> stringResource(R.string.stores_stage_download)
DownloadStage.VERIFY -> stringResource(R.string.stores_stage_verify)
DownloadStage.INSTALL -> stringResource(R.string.stores_stage_install)
DownloadStage.DONE -> stringResource(R.string.stores_stage_done)
}
internal fun openStoreUrl(ctx: android.content.Context, item: CatalogItem) = openUrl(ctx, item.storeUrl)
internal fun openUrl(ctx: android.content.Context, url: String) {
@@ -46,7 +46,6 @@ import java.io.File
internal class SyncLocation(val root: File, val label: String, val icon: ImageVector)
/** The Linux runtime's /root, which is HOME for everything DroidDeck runs in the container. */
internal fun containerHome(context: Context) = File(LinuxRuntime.rootDir(context), "root")
internal fun syncLocations(context: Context): List<SyncLocation> {
@@ -62,7 +61,6 @@ internal fun syncLocations(context: Context): List<SyncLocation> {
shared + SyncLocation(roots.first(), context.getString(R.string.sync_location_app), Icons.Outlined.Folder)
}
/** Browses only DroidDeck's own storage and returns a folder Syncthing is allowed to use. */
@Composable
internal fun SyncFolderPicker(title: String, suggestedName: String?, onDismiss: () -> Unit, onPick: (File) -> Unit) {
val ctx = LocalContext.current
@@ -159,7 +159,6 @@ private fun SyncRunning(snap: SyncSnapshot, onShowId: () -> Unit, onAdvanced: ()
)
}
/** Two columns of settings groups side by side, stacked on narrow panes. */
@Composable
internal fun PairedColumns(left: @Composable ColumnScope.() -> Unit, right: @Composable ColumnScope.() -> Unit) {
if (LocalNarrowPane.current) {
@@ -52,7 +52,6 @@ object Themes {
const val DEFAULT_PRIMARY = 0xFF8B5CF6.toInt()
const val DEFAULT_SECONDARY = 0xFF22D3EE.toInt()
/** The two colours of the custom Gradient theme: primary, then secondary. Changing them restyles the app at once. */
var gradientColors by mutableStateOf(DEFAULT_PRIMARY to DEFAULT_SECONDARY)
private set
@@ -60,11 +59,9 @@ object Themes {
const val DEFAULT_RGB_SPEED = 3
const val RGB_HUE_STEP = 3f
/** How fast Inner Gamer cycles, 1 (slow) to [RGB_SPEEDS] (fast). */
var rgbSpeed by mutableStateOf(DEFAULT_RGB_SPEED)
private set
/** Where Inner Gamer is on the colour wheel, in whole [RGB_HUE_STEP] steps so the app restyles only when the colour visibly moves. */
var rgbHue by mutableStateOf(0f)
private set
@@ -78,7 +75,6 @@ object Themes {
rgbSpeed = value
}
/** Milliseconds for one trip round the colour wheel. */
fun rgbCycleMillis(speed: Int): Int = 30_000 / speed.coerceIn(1, RGB_SPEEDS)
fun loadGradient(context: Context) {
@@ -86,7 +82,6 @@ object Themes {
rgbSpeed = SessionPrefs.rgbSpeed(context)
}
/** The Inner Gamer palette at one point on the colour wheel. */
fun innerGamer(hue: Float): Palette = ThemeColors.palette(
Color.hsv(hue % 360f, 0.9f, 1f).toArgb(), Color.hsv((hue + 60f) % 360f, 0.9f, 1f).toArgb(),
R.string.theme_inner_gamer, R.string.theme_inner_gamer_detail, INNER_GAMER,
@@ -97,7 +92,6 @@ object Themes {
gradientColors = primary to secondary
}
/** The theme the person chose, with the custom colours read first; for code that is not in a composition. */
fun current(context: Context): Palette {
val id = SessionPrefs.theme(context)
if (id == GRADIENT || id == INNER_GAMER) loadGradient(context)
@@ -186,14 +180,12 @@ private val ContentDirected = Typography().run {
)
}
/** Turns the colour wheel on the system's own animation clock; with animations off, in the app or in Android, the colour holds still. */
@Composable
private fun InnerGamerHue(speed: Int) {
if (Motion.scale == 0f) return
key(speed) { InnerGamerCycle(speed) }
}
/** One run of the cycle at one speed, picking up from the colour on screen so a new speed takes over at once without a jump. */
@Composable
private fun InnerGamerCycle(speed: Int) {
val start = remember { Themes.rgbHue }
@@ -7,9 +7,7 @@ import kotlin.math.max
import kotlin.math.min
import kotlin.math.roundToInt
/** Colour maths for the custom gradient theme: hue, saturation and brightness in, a readable palette out. */
internal object ThemeColors {
/** Hue 0..360, saturation and brightness 0..1. */
class Hsv(val h: Float, val s: Float, val v: Float)
fun toHsv(argb: Int): Hsv {
@@ -32,7 +30,6 @@ internal object ThemeColors {
fun hex(argb: Int): String = "#%06X".format(argb and 0xFFFFFF)
/** `#RRGGBB`, `RRGGBB` or `#RGB`; null for anything else. */
fun parseHex(text: String): Int? {
val digits = text.trim().removePrefix("#")
if (!digits.all { it in '0'..'9' || it in 'a'..'f' || it in 'A'..'F' }) return null
@@ -46,7 +43,6 @@ internal object ThemeColors {
private const val MIN_LUMINANCE = 0.10f
/** The colour, made brighter (then paler, for a deep blue that brightness alone cannot lift) when it is too dark to show on the dark background. */
fun readable(argb: Int): Int {
if (Color(argb).luminance() >= MIN_LUMINANCE) return argb or 0xFF000000.toInt()
val hsv = toHsv(argb)
@@ -64,7 +60,6 @@ internal object ThemeColors {
return out
}
/** A dark neutral tinted with the primary's hue; plain greys stay grey. */
fun tint(primary: Int, saturation: Float, brightness: Float): Color {
val hsv = toHsv(primary)
val strength = (hsv.s / 0.35f).coerceIn(0f, 1f)
@@ -79,7 +74,6 @@ internal object ThemeColors {
return (max(x, y) + 0.05f) / (min(x, y) + 0.05f)
}
/** Dark or white text, whichever reads better on the worse of the two gradient colours. */
internal fun inkFor(first: Int, second: Int): Color {
fun worst(ink: Color) = min(contrast(ink, Color(first)), contrast(ink, Color(second)))
return if (worst(DARK_INK) >= worst(Color.White)) DARK_INK else Color.White
@@ -87,7 +81,6 @@ internal object ThemeColors {
private const val MIN_CONTRAST = 4.5f
/** The colour nudged just enough, lighter for dark text and darker for white text, to give [ink] a readable contrast on it. */
private fun fitTo(ink: Color, argb: Int): Int {
fun short(color: Int) = contrast(ink, Color(color)) < MIN_CONTRAST
if (!short(argb)) return argb
@@ -55,7 +55,6 @@ import com.droiddeck.launcher.input.TouchGestureConfig.Companion.MOUSE_DRAG_MOVE
@Composable
fun TouchGestureDialog(game: String?, onDismiss: () -> Unit, onSaved: () -> Unit) {
val context = LocalContext.current
// Keep an open editor attached to the game it was opened for.
val targetGame = remember { game }
val initialDefaults = remember { GesturePrefs.read(context) }
val initialGame = remember { targetGame?.takeIf { GesturePrefs.hasOverride(context, it) }?.let { GesturePrefs.read(context, it) } }
@@ -169,7 +168,6 @@ fun TouchGestureDialog(game: String?, onDismiss: () -> Unit, onSaved: () -> Unit
private fun GestureDialogFrame(onDismiss: () -> Unit,
footer: @Composable () -> Unit = {}, content: @Composable ColumnScope.() -> Unit) {
val p = LocalPalette.current
// The app window does not opt into RTL, so these dialogs follow their resource locale explicitly.
val direction = if (LocalConfiguration.current.layoutDirection == android.view.View.LAYOUT_DIRECTION_RTL) LayoutDirection.Rtl else LayoutDirection.Ltr
Dialog(onDismissRequest = onDismiss, properties = DialogProperties(usePlatformDefaultWidth = false, decorFitsSystemWindows = false)) {
CompositionLocalProvider(LocalLayoutDirection provides direction) {