From a5f608b9d752f8f99e4929829de7e5e6f6501e7e Mon Sep 17 00:00:00 2001 From: The412Banner Date: Thu, 8 Oct 2026 20:51:51 -0400 Subject: [PATCH] Stores: progress per stage, and the install stage reports its own MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A 13 GB Epic install spent three minutes assembling behind a still bar. The entry now carries the active stage's own count - an amount and, when it counts files, the files - and which stages are already behind it. Epic reports its verify pass and its assembly (native and the fallback loop), GOG its chunk-cache removal. The Downloads row draws one segment per stage, passed ones full and the active one filling, and reads e.g. Installing 42% · 120/515 files; speed and ETA show only while downloading, and leaving Download clears the measured speed. Cards and the game page follow the active stage's percent. --- .../stores/download/DownloadModels.kt | 28 +++++++-- .../launcher/stores/download/DownloadQueue.kt | 32 +++++++++- .../stores/download/StoreDownloadService.kt | 3 +- .../launcher/stores/epic/EpicBackend.kt | 4 ++ .../stores/epic/EpicDownloadManager.java | 15 +++++ .../launcher/stores/gog/GogBackend.kt | 4 ++ .../stores/gog/GogDownloadManager.java | 22 ++++++- .../droiddeck/launcher/ui/StoresDownloads.kt | 60 ++++++++++++------- app/src/main/res/values/strings.xml | 7 +++ .../stores/download/DownloadEntryTest.kt | 31 ++++++++++ docs/progress-log.md | 7 +++ 11 files changed, 182 insertions(+), 31 deletions(-) create mode 100644 app/src/test/java/com/droiddeck/launcher/stores/download/DownloadEntryTest.kt diff --git a/app/src/main/java/com/droiddeck/launcher/stores/download/DownloadModels.kt b/app/src/main/java/com/droiddeck/launcher/stores/download/DownloadModels.kt index a9dd628148..be88366a7f 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/download/DownloadModels.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/download/DownloadModels.kt @@ -43,15 +43,31 @@ data class DownloadEntry( val startedAt: Long = 0L, /** Where it is going: the install target's name ("Internal storage", the card's name). */ val location: String = "", + /** + * The active stage's own progress outside Download (which runs on [bytesDone]/[bytesTotal]): + * an amount ([stageDone] of [stageTotal], bytes or items) and, when it counts files, [stageItems] + * of [stageItemsTotal]. Reset when the stage changes. + */ + val stageDone: Long = 0L, + val stageTotal: Long = 0L, + val stageItems: Int = 0, + val stageItemsTotal: Int = 0, + /** Stages already passed, one bit per [DownloadStage] ordinal; stages can come back (Epic checks files before it fetches). */ + val stagesPassed: Int = 0, ) { + fun passed(s: DownloadStage): Boolean = state == DownloadState.INSTALLED || (stagesPassed and (1 shl s.ordinal)) != 0 + val key: String get() = "${store.id}:$id" val isActive: Boolean get() = state == DownloadState.QUEUED || state == DownloadState.RUNNING || state == DownloadState.PAUSED - /** 0..1 for the bar: the byte fraction while downloading, full once past it. */ - val fraction: Float get() = when { - state == DownloadState.INSTALLED -> 1f - stage == DownloadStage.VERIFY || stage == DownloadStage.INSTALL || stage == DownloadStage.DONE -> 1f - bytesTotal > 0L -> (bytesDone.toDouble() / bytesTotal).toFloat().coerceIn(0f, 1f) - else -> 0f + /** The active stage's progress, 0..1, or -1 while it has nothing to count yet. */ + val stageFraction: Float get() = when { + state == DownloadState.INSTALLED || stage == DownloadStage.DONE -> 1f + stage == DownloadStage.DOWNLOAD -> if (bytesTotal > 0L) (bytesDone.toDouble() / bytesTotal).toFloat().coerceIn(0f, 1f) else -1f + stageTotal > 0L -> (stageDone.toDouble() / stageTotal).toFloat().coerceIn(0f, 1f) + stageItemsTotal > 0 -> (stageItems.toFloat() / stageItemsTotal).coerceIn(0f, 1f) + else -> -1f } + /** 0..1 for a single bar (a card, the game page): the active stage's progress. */ + val fraction: Float get() = stageFraction.coerceAtLeast(0f) val percent: Int get() = (fraction * 100).toInt() } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/download/DownloadQueue.kt b/app/src/main/java/com/droiddeck/launcher/stores/download/DownloadQueue.kt index 4f303e3e76..d54b478cc6 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/download/DownloadQueue.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/download/DownloadQueue.kt @@ -33,7 +33,12 @@ object DownloadQueue { /** What a running job reports with. */ class JobHandle internal constructor(val key: String, internal val cancelled: AtomicBoolean) { val isCancelled: Boolean get() = cancelled.get() - fun stage(stage: DownloadStage, detail: String = "") = update(key) { it.copy(stage = stage, detail = stripSpeed(detail).ifEmpty { it.detail }, state = DownloadState.RUNNING) } + /** Enters [stage] (a repeat of the current one only updates the line); a new stage starts its own count from zero. */ + fun stage(stage: DownloadStage, detail: String = "") = enter(key, stage, stripSpeed(detail)) + /** The active stage's own count outside Download: an amount (bytes or items) and, when it counts files, the files. */ + fun stageProgress(done: Long, total: Long, items: Int = 0, itemsTotal: Int = 0) = update(key) { + it.copy(stageDone = done, stageTotal = total, stageItems = items, stageItemsTotal = itemsTotal) + } /** * Bytes so far (negative = unchanged), the total (<= 0 = unchanged), a line. [speedBps] is the * engine's own figure: a burst rate at the network side, which jumps while the write side @@ -47,12 +52,37 @@ object DownloadQueue { /** "Downloading: data.pak 12.3 MB/s" → "Downloading: data.pak": the engine's burst rate is not shown twice. */ private fun stripSpeed(s: String): String = s.replace(Regex("\\s+\\S+ [KMG]B/s\\s*$"), "").trimEnd() + private fun enter(key: String, stage: DownloadStage, detail: String) { + synchronized(lock) { + val item = items[key] ?: return + transitionLocked(item, stage) + item.entry = item.entry.copy(detail = detail.ifEmpty { item.entry.detail }, state = DownloadState.RUNNING) + publishLocked() + } + } + + /** + * Moves an item to [stage] when it is elsewhere: the old stage is marked passed, the new one + * counts from zero, and the measured speed is cleared - the next stage writes or checks, it + * does not fetch, and a stale rate there would read as a download. Caller holds [lock]. + */ + private fun transitionLocked(item: Item, stage: DownloadStage) { + val e = item.entry + if (e.stage == stage) return + item.speedAt = 0L; item.speedBytes = 0L; item.speedEwma = 0.0 + item.entry = e.copy( + stage = stage, stagesPassed = e.stagesPassed or (1 shl e.stage.ordinal), speedBps = 0, etaSeconds = -1, + stageDone = 0, stageTotal = 0, stageItems = 0, stageItemsTotal = 0, + ) + } + /** How far back the shown speed looks: a few seconds, so the figure settles instead of following each file. */ private const val SPEED_WINDOW_MS = 3000.0 private fun measure(key: String, bytesDone: Long, bytesTotal: Long, detail: String?) { synchronized(lock) { val item = items[key] ?: return + transitionLocked(item, DownloadStage.DOWNLOAD) val e = item.entry val done = if (bytesDone >= 0) bytesDone else e.bytesDone val total = if (bytesTotal > 0) bytesTotal else e.bytesTotal diff --git a/app/src/main/java/com/droiddeck/launcher/stores/download/StoreDownloadService.kt b/app/src/main/java/com/droiddeck/launcher/stores/download/StoreDownloadService.kt index fd533ad81d..f3c2a52db7 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/download/StoreDownloadService.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/download/StoreDownloadService.kt @@ -57,7 +57,8 @@ class StoreDownloadService : Service() { val title = if (active.size > 1) getString(R.string.stores_notification_many, active.size) else getString(R.string.stores_notification_one) val text = when { first == null -> getString(R.string.stores_notification_waiting) - first.bytesTotal > 0 -> "${first.name} · ${first.percent}% (${formatBytes(first.bytesDone)} / ${formatBytes(first.bytesTotal)})" + first.stage == com.droiddeck.launcher.stores.download.DownloadStage.DOWNLOAD && first.bytesTotal > 0 -> "${first.name} · ${first.percent}% (${formatBytes(first.bytesDone)} / ${formatBytes(first.bytesTotal)})" + first.stageFraction >= 0f -> "${first.name} · ${first.percent}%" else -> first.name } val tap = PendingIntent.getActivity(this, 0, Intent(this, MainActivity::class.java), PendingIntent.FLAG_IMMUTABLE) diff --git a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicBackend.kt b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicBackend.kt index 01d631eb35..fbd9c4cb77 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicBackend.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicBackend.kt @@ -127,6 +127,10 @@ object EpicBackend : StoreBackend, EpicLaunchSupport { } override fun onBytes(done: Long, total: Long, speedBps: Long) { handle.progress(done, total, null, speedBps) } override fun onLog(line: String) { handle.log(line) } + override fun onStage(stage: String, done: Long, total: Long, items: Int, itemsTotal: Int) { + handle.stage(if (stage == "verify") DownloadStage.VERIFY else DownloadStage.INSTALL) + handle.stageProgress(done, total, items, itemsTotal) + } }) ?: return null if (cancelled.get()) return null handle.stage(DownloadStage.INSTALL, "Registering with Steam…") diff --git a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicDownloadManager.java b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicDownloadManager.java index 0c9d373b80..76fc15d00c 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicDownloadManager.java +++ b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicDownloadManager.java @@ -56,6 +56,12 @@ public final class EpicDownloadManager { void onProgress(String message, int pct); default void onBytes(long done, long total, long speedBps) {} default void onLog(String line) {} + /** + * The active stage's own count: {@code stage} is "verify" or "install", {@code done} of + * {@code total} an amount (bytes, or items when there are no bytes), {@code items} of + * {@code itemsTotal} the files, when it counts files. + */ + default void onStage(String stage, long done, long total, int items, int itemsTotal) {} } private EpicDownloadManager() {} @@ -154,11 +160,15 @@ public final class EpicDownloadManager { cb.onProgress("Verifying existing files…", 0); List pending = new ArrayList<>(selected.size()); int checked = 0, good = 0; + long checkedBytes = 0; + cb.onStage("verify", 0, installBytes, 0, selected.size()); for (FileInfo f : selected) { if (cancel.get()) return null; File out = new File(installDir, f.filename.replace("\\", "/")); if (fileExistsWithCorrectHash(out, f.fileSize(), f.sha1)) good++; else pending.add(f); checked++; + checkedBytes += f.fileSize(); + if ((checked & 15) == 0 || checked == selected.size()) cb.onStage("verify", checkedBytes, installBytes, checked, selected.size()); if ((checked & 63) == 0) cb.onProgress("Verifying existing files… (" + checked + "/" + selected.size() + ")", 0); } cb.onLog("epic: delta " + good + " up to date, " + pending.size() + " to download"); @@ -256,6 +266,8 @@ public final class EpicDownloadManager { cb.onLog("epic: assembler not started (" + r.error + "); writing the files here"); } int totalFiles = pending.size(), doneFiles = 0; + long writtenBytes = 0, writeTotal = 0; + for (FileInfo f : pending) writeTotal += f.fileSize(); for (FileInfo file : pending) { if (cancel.get()) return null; String relPath = file.filename.replace("\\", "/"); @@ -272,6 +284,8 @@ public final class EpicDownloadManager { } } doneFiles++; + writtenBytes += file.fileSize(); + cb.onStage("install", writtenBytes, writeTotal, doneFiles, totalFiles); } deleteDir(chunkCacheDir); cb.onProgress("Complete", 100); @@ -341,6 +355,7 @@ public final class EpicDownloadManager { EpicNative.Result res = EpicNative.assemble(manifestBytes, installDirPath, cachePath, pendingIdx, cancel, new EpicNative.Listener() { @Override public void onPlan(int chunksTotal, long bytesTotal, String chunkDir) {} @Override public void onProgress(long bytesDone, long bytesTotal, int done, int total) { + cb.onStage("install", bytesDone, bytesTotal, done, Math.max(total, totalFiles)); cb.onProgress("Writing files (" + done + "/" + Math.max(total, totalFiles) + ")", 80 + (int) (done * 20L / Math.max(1, Math.max(total, totalFiles)))); } @Override public void onLog(String line) { cb.onLog(line); } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogBackend.kt b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogBackend.kt index a7bc48ae00..cd98524605 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogBackend.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogBackend.kt @@ -95,6 +95,10 @@ object GogBackend : StoreBackend { } override fun onBytes(done: Long, total: Long, speedBps: Long) { handle.progress(done, total, null, speedBps) } override fun onLog(line: String) { handle.log(line) } + override fun onStage(stage: String, done: Long, total: Long, items: Int, itemsTotal: Int) { + handle.stage(if (stage == "verify") DownloadStage.VERIFY else DownloadStage.INSTALL) + handle.stageProgress(done, total, items, itemsTotal) + } }, cancelled) ?: return null if (cancelled.get()) return null handle.stage(DownloadStage.INSTALL, "Registering with Steam…") diff --git a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogDownloadManager.java b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogDownloadManager.java index 9eac5a2cd1..4d45c92c17 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogDownloadManager.java +++ b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogDownloadManager.java @@ -62,6 +62,13 @@ public final class GogDownloadManager { default void onBytes(long done, long total, long speedBps) {} /** A diagnostic line for the engine log. */ default void onLog(String line) {} + /** + * The active stage's own count: {@code stage} is "verify" or "install", {@code done} of + * {@code total} an amount (bytes, or items when there are no bytes), {@code items} of + * {@code itemsTotal} the files, when it counts files. + */ + default void onStage(String stage, long done, long total, int items, int itemsTotal) {} + } /** What an install leaves behind for the sidecar. */ @@ -245,7 +252,7 @@ public final class GogDownloadManager { cb.onProgress("Finishing…", 96); writeFile(new File(installPath, MARKER), ("{\"gameId\":\"" + game.gameId + "\",\"buildId\":\"" + gm.buildId + "\"}").getBytes("UTF-8")); - deleteDir(new File(installPath, ".gog_chunks")); + deleteCounted(new File(installPath, ".gog_chunks"), cb); String clientId = manifest.optString("clientId", null); if (clientId != null && !clientId.isEmpty()) GogPrefs.get(ctx).edit().putString("client_id_" + game.gameId, clientId).apply(); out.result = new Result(pickExe(installPath, tempExe, game.title), gm.buildId, planned); @@ -888,6 +895,19 @@ public final class GogDownloadManager { try (FileOutputStream fos = new FileOutputStream(f)) { fos.write(data); } } + /** Removes the chunk cache, counting its files as the Install stage's progress (a large cache takes a while). */ + private static void deleteCounted(File dir, Callback cb) { + File[] files = dir.listFiles(); + if (files == null) { dir.delete(); return; } + int total = files.length, done = 0; + for (File f : files) { + deleteDir(f); + done++; + if ((done & 31) == 0 || done == total) cb.onStage("install", done, total, done, total); + } + dir.delete(); + } + static void deleteDir(File dir) { if (dir == null || !dir.exists()) return; File[] children = dir.listFiles(); diff --git a/app/src/main/java/com/droiddeck/launcher/ui/StoresDownloads.kt b/app/src/main/java/com/droiddeck/launcher/ui/StoresDownloads.kt index 2102500742..01cfd37b5d 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/StoresDownloads.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/StoresDownloads.kt @@ -100,11 +100,7 @@ private fun DownloadCard(d: DownloadEntry, s: FrontEndState, a: FrontEndActions) SourceChip(d.store.id, small = true) if (d.location.isNotBlank()) Text(d.location, fontSize = 11.sp, color = dim, maxLines = 1, overflow = TextOverflow.Ellipsis) } - if (!narrow) Stages(d) - ProgressBarThin( - if (d.state == DownloadState.INSTALLED) 1f else d.fraction, paused = d.state == DownloadState.PAUSED, - verify = d.stage == DownloadStage.VERIFY, height = 6.dp, done = d.state == DownloadState.INSTALLED, - ) + StageBar(d) Row(horizontalArrangement = Arrangement.spacedBy(14.dp)) { val meta = when (d.state) { DownloadState.INSTALLED -> stringResource(R.string.stores_installed_chip) @@ -112,13 +108,17 @@ private fun DownloadCard(d: DownloadEntry, s: FrontEndState, a: FrontEndActions) DownloadState.FAILED -> d.error?.let { stringResource(R.string.stores_dl_failed_reason, it) } ?: stringResource(R.string.stores_dl_failed) DownloadState.PAUSED -> stringResource(R.string.stores_dl_paused) DownloadState.QUEUED -> if (d.queuePosition > 0) stringResource(R.string.stores_dl_queued_at, d.queuePosition) else stringResource(R.string.stores_dl_queued) - DownloadState.RUNNING -> when { - d.stage == DownloadStage.DOWNLOAD && d.bytesTotal > 0 -> stringResource(R.string.stores_dl_bytes, formatBytes(d.bytesDone), formatBytes(d.bytesTotal), d.percent) - else -> stageLabel(d.stage) + DownloadState.RUNNING -> { + val head = if (d.stageFraction >= 0f) stringResource(R.string.stores_dl_active_percent, activeStageLabel(d.stage), d.percent) else activeStageLabel(d.stage) + when { + d.stage == DownloadStage.DOWNLOAD && d.bytesTotal > 0 -> stringResource(R.string.stores_dl_with, head, stringResource(R.string.stores_dl_amount, formatBytes(d.bytesDone), formatBytes(d.bytesTotal))) + d.stageItemsTotal > 0 -> stringResource(R.string.stores_dl_with, head, stringResource(R.string.stores_dl_items, d.stageItems, d.stageItemsTotal)) + else -> head + } } } Text(meta, fontSize = 12.sp, color = dim, maxLines = 2, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f, fill = false)) - if (d.state == DownloadState.RUNNING && d.speedBps > 0) { + if (d.state == DownloadState.RUNNING && d.stage == DownloadStage.DOWNLOAD && d.speedBps > 0) { Text(formatSpeed(d.speedBps), fontSize = 12.sp, color = dim, maxLines = 1) if (d.etaSeconds >= 0) Text(eta(d.etaSeconds), fontSize = 12.sp, color = dim, maxLines = 1) } @@ -150,24 +150,40 @@ private fun DownloadCard(d: DownloadEntry, s: FrontEndState, a: FrontEndActions) } } -/** Manifest → Download → Verify → Install → Done, the one under way lit, the ones behind it green. */ +/** + * One segment per stage - Manifest, Download, Verify, Install - equal widths: a passed stage full, the + * active one filling with its own progress (a sliver while it has nothing to count), the rest empty. + */ @Composable -private fun Stages(d: DownloadEntry) { - val colors = MaterialTheme.colorScheme - val pal = LocalPalette.current - Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) { - for (stage in DownloadStage.entries) { - val passed = d.state == DownloadState.INSTALLED || stage.ordinal < d.stage.ordinal - val on = d.state == DownloadState.RUNNING && stage == d.stage - Text( - stageLabel(stage), fontSize = 10.sp, fontWeight = FontWeight.SemiBold, maxLines = 1, - color = when { on -> pal.signal; passed -> pal.good; else -> colors.onSurfaceVariant }, - modifier = Modifier.clip(RoundedCornerShape(6.dp)).background(if (on) pal.signal.copy(alpha = 0.18f) else colors.surfaceVariant).padding(horizontal = 6.dp, vertical = 2.dp), - ) +private fun StageBar(d: DownloadEntry) { + val stages = listOf(DownloadStage.MANIFEST, DownloadStage.DOWNLOAD, DownloadStage.VERIFY, DownloadStage.INSTALL) + Row(horizontalArrangement = Arrangement.spacedBy(3.dp), modifier = Modifier.fillMaxWidth()) { + for (st in stages) { + val active = d.state != DownloadState.INSTALLED && d.stage == st + val fill = when { + active -> d.stageFraction.let { if (it < 0f) 0.04f else it } + d.passed(st) || d.stage == DownloadStage.DONE -> 1f + else -> 0f + } + Box(Modifier.weight(1f)) { + ProgressBarThin( + fill, paused = active && d.state == DownloadState.PAUSED, verify = active && st == DownloadStage.VERIFY, + height = 6.dp, done = !active && fill >= 1f, + ) + } } } } +@Composable +private fun activeStageLabel(stage: DownloadStage): String = when (stage) { + DownloadStage.MANIFEST -> stringResource(R.string.stores_stage_manifest) + DownloadStage.DOWNLOAD -> stringResource(R.string.stores_stage_downloading) + DownloadStage.VERIFY -> stringResource(R.string.stores_stage_verifying) + DownloadStage.INSTALL -> stringResource(R.string.stores_stage_installing) + DownloadStage.DONE -> stringResource(R.string.stores_stage_done) +} + private fun eta(seconds: Long): String = when { seconds < 60 -> "<1 min" seconds < 3600 -> "~${seconds / 60} min" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 184c85e521..e60e2dcee1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2062,6 +2062,13 @@ Verify Install Done + Downloading + Verifying + Installing + %1$s %2$d%% + %1$s · %2$s + %1$s / %2$s + %1$d/%2$d files Download manager Downloads at a time Install to diff --git a/app/src/test/java/com/droiddeck/launcher/stores/download/DownloadEntryTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/download/DownloadEntryTest.kt new file mode 100644 index 0000000000..23c6b93db4 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/stores/download/DownloadEntryTest.kt @@ -0,0 +1,31 @@ +package com.droiddeck.launcher.stores.download + +import com.droiddeck.launcher.stores.Store +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test + +/** The Downloads row reads the active stage's own progress, and which stages are behind it. */ +class DownloadEntryTest { + private val base = DownloadEntry(Store.EPIC, "doomblade", "DOOMBLADE", state = DownloadState.RUNNING) + + @Test fun downloadRunsOnBytesAndInstallOnItsOwnCount() { + val dl = base.copy(stage = DownloadStage.DOWNLOAD, bytesDone = 50, bytesTotal = 200) + assertEquals(0.25f, dl.stageFraction, 0.001f) + // Past Download the bytes no longer drive the bar; the stage's own count does. + val inst = dl.copy(stage = DownloadStage.INSTALL, stageDone = 30, stageTotal = 40, stageItems = 3, stageItemsTotal = 4) + assertEquals(0.75f, inst.stageFraction, 0.001f) + assertEquals(75, inst.percent) + // Nothing counted yet: unknown, not empty and not full. + assertEquals(-1f, base.copy(stage = DownloadStage.INSTALL).stageFraction, 0f) + } + + @Test fun passedStagesComeFromTheBitsNotTheOrder() { + // Epic checks files before it fetches: Verify is behind Download there. + val e = base.copy(stage = DownloadStage.DOWNLOAD, stagesPassed = (1 shl DownloadStage.MANIFEST.ordinal) or (1 shl DownloadStage.VERIFY.ordinal)) + assertTrue(e.passed(DownloadStage.VERIFY)) + assertFalse(e.passed(DownloadStage.INSTALL)) + assertTrue(e.copy(state = DownloadState.INSTALLED).passed(DownloadStage.INSTALL)) + } +} diff --git a/docs/progress-log.md b/docs/progress-log.md index db35e91cd7..e8a33d8b9b 100644 --- a/docs/progress-log.md +++ b/docs/progress-log.md @@ -135,6 +135,13 @@ without it and Setup says "Stores engine not built"). when installed, Resume, the download percentage, the install size, or Free / price / discount. A thin bar over the art while downloading. Install, Resume, Uninstall, Get and Buy live on the game page; A on a card opens it. +- **Per-stage progress** (device: Epic DOOMBLADE, 13 GB, ~3 min of assembly with a still bar). The + entry carries the active stage's own count (amount + files) and which stages are passed; the + Downloads row draws one segment per stage (Manifest, Download, Verify, Install), and its line + reads e.g. "Installing 42% · 120/515 files" (speed and ETA only during Download). Fed by Epic's + verify pass, its native and fallback assembly, and GOG's chunk-cache removal; Amazon writes while + it downloads and has no long stage after it. Leaving Download clears the measured speed. Cards + and the game page follow the active stage's percent. - **The art is the card** (maintainer feedback): a store card is its art edge to edge, sharp above and, under the one line, a blurred and darkened copy of the same picture (blur on API 31+, a stronger scrim below it). A Downloads row is the game's wide art cropped to the row with a dark