From 9b02a568b033f78c5463fb609051cc2488d8bd91 Mon Sep 17 00:00:00 2001 From: "Luis Guzman (AppDevForAll)" Date: Mon, 10 Aug 2026 10:37:58 -0600 Subject: [PATCH 1/2] ADFA-5074 refactor(ui): the working animation, resolved instead of copied MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Lottie block was pasted verbatim into three card layouts — ZIM, Maps and module install — each with the file name written in its XML, and was missing from Courses entirely. That is how a type ends up without one and how three copies drift apart. One shared layout now holds the block, and each card includes it where its own composition wants it: placement stays the card's business, the asset does not. The block declares no lottie_rawRes on purpose — a layout that can show an animation on its own is a layout that can contradict the rule — so nothing plays until a card asks ProgressVisuals for it. The rule itself is in the domain: ProgressVisual resolves from the execution class, live work is a download and stopped work is a build, unit-tested on the JVM. ProgressVisuals maps that to a raw resource, and is the only place in the app where the file name appears. BUILD deliberately resolves to the same asset for now: Maps wants art of its own and does not have it yet, and a placeholder beats a second copy. Giving it one is a line there, or a case in the domain if a single module turns out to need its own — no layout is touched either way. The three existing blocks were verified identical before extracting, so they render as before. Courses gains the animation in the same position as the others, which is the only visible change. --- .../presentation/KolibriSeedingFragment.java | 2 + .../redesign/MapsPreparingFragment.java | 1 + .../redesign/ModuleInstallFragment.java | 1 + .../controller/redesign/ProgressVisuals.java | 113 ++++++++++++++++++ .../redesign/ZimPreparingFragment.java | 2 + .../system/domain/ProgressVisual.java | 64 ++++++++++ .../layout/fragment_k2go_kolibri_seeding.xml | 4 + .../layout/fragment_k2go_maps_preparing.xml | 66 +--------- .../layout/fragment_k2go_module_install.xml | 61 +--------- .../layout/fragment_k2go_zim_preparing.xml | 66 +--------- .../res/layout/view_k2go_working_anim.xml | 73 +++++++++++ .../system/domain/ProgressVisualTest.java | 52 ++++++++ .../ADR-5061-rest-vs-proot-operation-model.md | 26 ++++ controller/docs/content-execution-order.svg | 9 +- controller/docs/operation-model-roadmap.svg | 2 +- 15 files changed, 350 insertions(+), 192 deletions(-) create mode 100644 controller/app/src/main/java/org/iiab/controller/redesign/ProgressVisuals.java create mode 100644 controller/app/src/main/java/org/iiab/controller/system/domain/ProgressVisual.java create mode 100644 controller/app/src/main/res/layout/view_k2go_working_anim.xml create mode 100644 controller/app/src/test/java/org/iiab/controller/system/domain/ProgressVisualTest.java diff --git a/controller/app/src/main/java/org/iiab/controller/kolibri/presentation/KolibriSeedingFragment.java b/controller/app/src/main/java/org/iiab/controller/kolibri/presentation/KolibriSeedingFragment.java index 3901ae669..ed13ffaf6 100644 --- a/controller/app/src/main/java/org/iiab/controller/kolibri/presentation/KolibriSeedingFragment.java +++ b/controller/app/src/main/java/org/iiab/controller/kolibri/presentation/KolibriSeedingFragment.java @@ -68,6 +68,8 @@ public void onViewCreated(@NonNull View v, @Nullable Bundle savedInstanceState) detailView = v.findViewById(R.id.k2go_kseed_detail); bar = v.findViewById(R.id.k2go_kseed_bar); list = v.findViewById(R.id.k2go_kseed_list); + org.iiab.controller.redesign.ProgressVisuals.apply( + v, org.iiab.controller.system.domain.ContentType.COURSES); // ADFA-5074 footer = v.findViewById(R.id.k2go_kseed_footer); footerNote = v.findViewById(R.id.k2go_kseed_footer_note); done = v.findViewById(R.id.k2go_kseed_done); diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/MapsPreparingFragment.java b/controller/app/src/main/java/org/iiab/controller/redesign/MapsPreparingFragment.java index 8992c20f7..1f03dcc27 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/MapsPreparingFragment.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/MapsPreparingFragment.java @@ -127,6 +127,7 @@ && getActivity() instanceof SetupLibraryActivity // ADFA-4901: collapsible live log. The status line mirrors the latest line; expanding shows // the full terminal (LogRepository snapshot + live appends), auto-scrolled. logLabel = root.findViewById(R.id.k2go_prep_log_label); + ProgressVisuals.apply(root, org.iiab.controller.system.domain.ContentType.MAPS); // ADFA-5074 logChevron = root.findViewById(R.id.k2go_prep_log_chevron); logScroll = root.findViewById(R.id.k2go_prep_log_scroll); logText = root.findViewById(R.id.k2go_prep_log_text); diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/ModuleInstallFragment.java b/controller/app/src/main/java/org/iiab/controller/redesign/ModuleInstallFragment.java index 4977d7827..a8aea5add 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/ModuleInstallFragment.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/ModuleInstallFragment.java @@ -68,6 +68,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c status = root.findViewById(R.id.k2go_modinst_status); logLabel = root.findViewById(R.id.k2go_modinst_log_label); + ProgressVisuals.applyForModule(root); // ADFA-5074 logChevron = root.findViewById(R.id.k2go_modinst_log_chevron); logScroll = root.findViewById(R.id.k2go_modinst_log_scroll); logText = root.findViewById(R.id.k2go_modinst_log_text); diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/ProgressVisuals.java b/controller/app/src/main/java/org/iiab/controller/redesign/ProgressVisuals.java new file mode 100644 index 000000000..f7f635f27 --- /dev/null +++ b/controller/app/src/main/java/org/iiab/controller/redesign/ProgressVisuals.java @@ -0,0 +1,113 @@ +/* + * ============================================================================ + * Name : ProgressVisuals.java + * Author : AppDevForAll + * Copyright : Copyright (c) 2026 AppDevForAll + * Description : Turns a resolved ProgressVisual into the asset that plays it. + * The one place a file name appears (ADFA-5074). + * ============================================================================ + */ +package org.iiab.controller.redesign; + +import androidx.annotation.RawRes; + +import org.iiab.controller.R; +import org.iiab.controller.system.domain.ContentType; +import org.iiab.controller.system.domain.Operation; +import org.iiab.controller.system.domain.ProgressVisual; + +/** + * The Android half of the progress animation: which raw resource plays which intent, and + * how a progress row's key becomes an operation to ask about. + * + *

Kept apart from {@link ProgressVisual} so the rule — live work downloads, stopped work + * builds — stays unit-testable without a device, and so a file name appears exactly once in + * the app. + */ +public final class ProgressVisuals { + + private ProgressVisuals() { + } + + /** Prefix the install index uses for a proot module row. */ + private static final String MODULE_PREFIX = "mod:"; + + /** + * The asset for an intent. + * + *

{@code BUILD} deliberately plays the download art for now: Maps wants something of + * its own and does not have it yet, and a placeholder beats a second copy of the same + * file. Giving it one is this line, and no layout changes. + */ + @RawRes + public static int rawResFor(ProgressVisual visual) { + switch (visual) { + case BUILD: + case DOWNLOAD: + default: + return R.raw.k2go_working_loop; + } + } + + /** + * The intent for one of the index's row keys. + * + *

The keys are a presentation vocabulary — {@code "zim"}, {@code "books"}, + * {@code "kolibri"}, {@code "maps"}, and {@code "mod:"} for a proot module — so + * turning one into an {@link Operation} belongs here rather than in the domain. Anything + * unrecognised is treated as content, which is the case three of the four types are in. + */ + public static ProgressVisual visualForKey(String key) { + if (key == null) { + return ProgressVisual.DOWNLOAD; + } + if (key.startsWith(MODULE_PREFIX)) { + return ProgressVisual.forOperation( + Operation.appInstall(key.substring(MODULE_PREFIX.length()))); + } + ContentType type = ContentType.byKey(key); + return type == null ? ProgressVisual.DOWNLOAD : ProgressVisual.forContent(type); + } + + /** The asset for one of the index's row keys, in one call. */ + @RawRes + public static int rawResForKey(String key) { + return rawResFor(visualForKey(key)); + } + + /** + * Loads the right animation into a card that included + * {@code view_k2go_working_anim}. + * + *

One line per card, and the only line any card needs: the block itself declares no + * asset, so nothing plays until this runs. That is deliberate — a layout that could show + * an animation on its own is a layout that can disagree with the rule. + * + * @param root the inflated card + * @param type what the card is adding; null falls back to the download art + */ + public static void apply(android.view.View root, ContentType type) { + if (root == null) { + return; + } + com.airbnb.lottie.LottieAnimationView anim = root.findViewById(R.id.k2go_working_anim); + if (anim == null) { + return; // a card that chose not to include the block + } + anim.setAnimation(rawResFor(ProgressVisual.forContent(type))); + anim.playAnimation(); + } + + /** The same, for a proot module install rather than a content type. */ + public static void applyForModule(android.view.View root) { + if (root == null) { + return; + } + com.airbnb.lottie.LottieAnimationView anim = root.findViewById(R.id.k2go_working_anim); + if (anim == null) { + return; + } + anim.setAnimation(rawResFor(ProgressVisual.forOperation(Operation.appInstall("")))); + anim.playAnimation(); + } +} diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/ZimPreparingFragment.java b/controller/app/src/main/java/org/iiab/controller/redesign/ZimPreparingFragment.java index 0c1deb3b3..657dc2d61 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/ZimPreparingFragment.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/ZimPreparingFragment.java @@ -76,6 +76,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c detail = root.findViewById(R.id.k2go_zprep_detail); bar = root.findViewById(R.id.k2go_zprep_bar); listv = root.findViewById(R.id.k2go_zprep_list); + // ADFA-5074: the shared animation block declares no asset; the rule picks it. + ProgressVisuals.apply(root, org.iiab.controller.system.domain.ContentType.ZIM); runBgBtn = root.findViewById(R.id.k2go_zprep_run_bg); runBgBtn.setOnClickListener(v -> { diff --git a/controller/app/src/main/java/org/iiab/controller/system/domain/ProgressVisual.java b/controller/app/src/main/java/org/iiab/controller/system/domain/ProgressVisual.java new file mode 100644 index 000000000..e5bbbaae9 --- /dev/null +++ b/controller/app/src/main/java/org/iiab/controller/system/domain/ProgressVisual.java @@ -0,0 +1,64 @@ +/* + * ============================================================================ + * Name : ProgressVisual.java + * Author : AppDevForAll + * Copyright : Copyright (c) 2026 AppDevForAll + * Description : Which animation a running operation gets, decided from what the + * operation is. Pure JVM, no Android (ADFA-5074). + * ============================================================================ + */ +package org.iiab.controller.system.domain; + +/** + * What the progress screen should be showing while an operation runs. + * + *

Why this is resolved rather than placed. The working animation lived in one + * fragment's layout — ZIM's — so Courses had none and Maps had none. Copying it into each + * layout would have recreated the drift this exists to remove: hand-kept copies that agree + * until someone edits one. Putting a single animation in the shared host instead would have + * traded that duplication for a lie: the art is a cloud sending data to the device, which is + * literal for ZIM, Books and Courses and false for Maps, an Ansible runrole building tiles + * with the server stopped. + * + *

So it is shared along the axis that already exists. The + * {@link Operation.ExecutionClass} decides: live work is a download, stopped work is a + * build. One rule, no per-type layout owning an animation. + * + *

Where a per-module exception goes. Inside {@link #forOperation}, as a case on + * the platform name before the class fallback. Nothing needs one today; the point + * of resolving rather than placing is that when something does, it is a line here and no + * layout is touched. + * + *

This enum names the intent, not a file. Which asset each intent maps to is a + * presentation concern, so this stays testable on a plain JVM. + */ +public enum ProgressVisual { + + /** Something is coming down from the network. The server does the transfer. */ + DOWNLOAD, + + /** + * Something is being built on the device, with the box stopped — a runrole. Deliberately + * mapped to the same asset as {@link #DOWNLOAD} for now: Maps wants art of its own and + * does not have it yet, and a placeholder beats a second copy. Changing that is one line + * in the presentation mapping. + */ + BUILD; + + /** + * @param op what is running; null answers {@link #DOWNLOAD}, the common case, rather + * than throwing at a screen that only wants something to draw + */ + public static ProgressVisual forOperation(Operation op) { + if (op == null) { + return DOWNLOAD; + } + // A per-platform exception would go here, on op.platform(), before the fallback. + return op.isLive() ? DOWNLOAD : BUILD; + } + + /** The visual for adding content of this type. */ + public static ProgressVisual forContent(ContentType type) { + return type == null ? DOWNLOAD : forOperation(type.operation()); + } +} diff --git a/controller/app/src/main/res/layout/fragment_k2go_kolibri_seeding.xml b/controller/app/src/main/res/layout/fragment_k2go_kolibri_seeding.xml index 6973e304d..7033ae582 100644 --- a/controller/app/src/main/res/layout/fragment_k2go_kolibri_seeding.xml +++ b/controller/app/src/main/res/layout/fragment_k2go_kolibri_seeding.xml @@ -45,6 +45,10 @@ android:textAppearance="?attr/textAppearanceBodyMedium" android:textColor="@color/k2go_muted" /> + + + - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/controller/app/src/test/java/org/iiab/controller/system/domain/ProgressVisualTest.java b/controller/app/src/test/java/org/iiab/controller/system/domain/ProgressVisualTest.java new file mode 100644 index 000000000..b7002e9ee --- /dev/null +++ b/controller/app/src/test/java/org/iiab/controller/system/domain/ProgressVisualTest.java @@ -0,0 +1,52 @@ +package org.iiab.controller.system.domain; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +/** + * Unit tests for {@link ProgressVisual} — which animation an operation gets, and why it is + * the execution class that decides rather than the content type. Pure JVM. + */ +public class ProgressVisualTest { + + @Test + public void whatDownloadsGetsTheDownloadArt() { + // ZIM, Books and Courses are all REST: the server pulls the bytes, and the cloud + // sending data to the device is literally what is happening. + assertEquals(ProgressVisual.DOWNLOAD, ProgressVisual.forContent(ContentType.ZIM)); + assertEquals(ProgressVisual.DOWNLOAD, ProgressVisual.forContent(ContentType.BOOKS)); + assertEquals(ProgressVisual.DOWNLOAD, ProgressVisual.forContent(ContentType.COURSES)); + } + + @Test + public void whatBuildsDoesNotClaimToBeDownloading() { + // Maps is a runrole assembling tiles with the box stopped. Showing it a download + // animation would describe something that is not happening — which is the reason + // this is resolved from the class instead of one asset being shared by all four. + assertEquals(ProgressVisual.BUILD, ProgressVisual.forContent(ContentType.MAPS)); + } + + @Test + public void installingAPlatformIsABuildWhateverItsContentIs() { + // The Courses app is a proot module while its channels are REST. The visual follows + // the operation in hand, not the platform's name. + assertEquals(ProgressVisual.BUILD, + ProgressVisual.forOperation(Operation.appInstall("kolibri"))); + assertEquals(ProgressVisual.DOWNLOAD, + ProgressVisual.forOperation(Operation.content("kolibri"))); + } + + @Test + public void replacingTheSystemIsABuild() { + assertEquals(ProgressVisual.BUILD, ProgressVisual.forOperation(Operation.system())); + } + + @Test + public void nothingToGoOnFallsBackToTheCommonCase() { + // A screen asking this only wants something to draw; refusing to answer would be + // worse than answering with the case three of the four types are in. + assertEquals(ProgressVisual.DOWNLOAD, ProgressVisual.forOperation(null)); + assertEquals(ProgressVisual.DOWNLOAD, ProgressVisual.forContent(null)); + } +} diff --git a/controller/docs/ADR-5061-rest-vs-proot-operation-model.md b/controller/docs/ADR-5061-rest-vs-proot-operation-model.md index e77f6ff15..21e38f77e 100644 --- a/controller/docs/ADR-5061-rest-vs-proot-operation-model.md +++ b/controller/docs/ADR-5061-rest-vs-proot-operation-model.md @@ -327,6 +327,32 @@ most expensive by the third platform. A is B done safely over time. in background" that Courses lacks while Courses has a terminal action and a retry-before-leaving note the others lack. **ADFA-5074 owns this.** + **The progress animation is resolved, not placed.** Today the Lottie + (`k2go_working_loop` — cloud sending data to the device) lives in + `fragment_k2go_zim_preparing.xml` and nowhere else, so Courses has none. Copying it + into the Courses layout would recreate exactly the drift this item exists to remove: + two hand-kept copies that agree until someone edits one. + + But "one animation for all four" would trade a duplication for a lie. That cloud is + literal for ZIM, Books and Courses — the server downloads. Maps is an Ansible + runrole building tiles with the server stopped, and it already has its own + collapsible log; a download animation over it would describe something that is not + happening. + + So it is shared along the axis that already exists: **the execution class decides**, + not the content type. The shape agreed with Luis (ADFA-5074): + - the domain answers *which visual* an operation gets — an enum (`DOWNLOAD` for + LIVE, `BUILD` for STOPPED), pure and unit-testable, with room for a per-module + override when one earns it; + - presentation maps that answer to a raw resource, in one place; + - the host reads it and puts it above the fragment slot, so no per-type layout owns + an animation and ZIM's copy goes away. + + For now `BUILD` deliberately resolves to the same file: Maps wants a different one + and does not have it yet, and shipping a placeholder beats shipping a second copy. + The point of the indirection is that changing it later is one line, and that a + module which turns out to need its own can have it without anyone touching a layout. + Also decide **which lifetime each piece of state gets**. Three mechanisms are in use and nothing says which is for what: a `ViewModel` (survives a configuration change only), a `SavedStateHandle` (also survives a process death, riding the task's instance state), and diff --git a/controller/docs/content-execution-order.svg b/controller/docs/content-execution-order.svg index da8e3e74b..6ef5c2704 100644 --- a/controller/docs/content-execution-order.svg +++ b/controller/docs/content-execution-order.svg @@ -1,4 +1,4 @@ - + Content installation — mechanism and order How the four content types install: which mechanism each uses, why they are serialised, where the server is stopped, and what is still unsolved. Companion to operation-model-roadmap.svg, which tracks ticket state rather than behaviour. Update when the behaviour changes, not when a ticket moves. @@ -30,7 +30,7 @@ - + Content installation — mechanism and order Four content types, two mechanisms. What runs when, what waits for what, and why. @@ -101,7 +101,7 @@ ZimConfirmFragment:94 · MapsChooseFragment:270 · KolibriConfirmFragment:211 — three readings, three moments, no total - + OPEN Five landings for one kind of work — owned by ADFA-5074 @@ -109,7 +109,8 @@ Get More: ZIM → ZimPreparingFragment inside SetupLibraryActivity · Books → the index, with a hint that jumps straight to the detail · Maps → the index list · Courses → KolibriSeedingFragment inside SetupLibraryActivity. The screens are NOT duplicated: SetupProgressActivity.openDetail() hosts those same fragments, with a fromIndex flag for the chrome. -What differs is the host — so Back walks out of a live download, a notification returns you elsewhere, and nothing opens the index at all. +What differs is the host, so Back still walks out of a live download and a notification returns you to a different screen than you left. +Closed already: the Home header opens the index (PR 1) · a finished session no longer gates anything (PR 2). Hosting is what remains. diff --git a/controller/docs/operation-model-roadmap.svg b/controller/docs/operation-model-roadmap.svg index 20e9124ff..88aad0369 100644 --- a/controller/docs/operation-model-roadmap.svg +++ b/controller/docs/operation-model-roadmap.svg @@ -135,7 +135,7 @@ Front door + re-entry (onNewIntent) A session gates only work in flight -Get More notices a platform arriving +Get More notices a platform arriving One host for every progress screen Do not close 4758 as superseded: the migration half From 40aa2c95244ed9458099926f1e0e691620b44c57 Mon Sep 17 00:00:00 2001 From: "Luis Guzman (AppDevForAll)" Date: Mon, 10 Aug 2026 12:35:27 -0600 Subject: [PATCH 2/2] ADFA-5074 refactor(ui): make the per-module hook reachable, and stop overclaiming MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review follow-ups. applyForModule took no module name, so it built the operation with an empty platform — and the per-platform exception in forOperation matches on platform(). The hook that justified resolving instead of placing was unreachable from the one place most likely to need it. It takes the key now, and a test fails if that regresses. The key parsing moved to the domain as ProgressVisual.forKey, which is where ContentType.byKey already lives; it had been put in presentation out of habit. That also makes it testable, so "mod:", an unknown key and an empty one are covered — the prefix is the part that breaks quietly, and an off-by-one there would classify every module as content. The module-install card's block was spaced at 16dp, not the shared 12dp. I called the three blocks identical having compared only their contents, not the frame around them; its include overrides the margin. ProgressVisuals moved out of redesign to util, beside Snackbars and ByteFormatter, so a shared UI helper does not live in the legacy flat package and kolibri stops reaching into it for this. And the shared layout no longer says "the animation, once", because it is not: BackupJobFragment picks k2go_backup_loop or k2go_restore_loop from its mode (ADFA-4961), by this same principle, written earlier. It stays outside on purpose — backup and restore are system operations, not content — so the comment names it and a TODO says to extend that precedent rather than build a third mechanism. --- .../presentation/KolibriSeedingFragment.java | 2 +- .../redesign/MapsPreparingFragment.java | 2 +- .../redesign/ModuleInstallFragment.java | 3 +- .../redesign/ZimPreparingFragment.java | 2 +- .../system/domain/ProgressVisual.java | 37 +++++++++++++++++ .../{redesign => util}/ProgressVisuals.java | 41 ++++++------------- .../layout/fragment_k2go_module_install.xml | 10 ++++- .../res/layout/view_k2go_working_anim.xml | 9 +++- .../system/domain/ProgressVisualTest.java | 40 ++++++++++++++++++ 9 files changed, 111 insertions(+), 35 deletions(-) rename controller/app/src/main/java/org/iiab/controller/{redesign => util}/ProgressVisuals.java (68%) diff --git a/controller/app/src/main/java/org/iiab/controller/kolibri/presentation/KolibriSeedingFragment.java b/controller/app/src/main/java/org/iiab/controller/kolibri/presentation/KolibriSeedingFragment.java index ed13ffaf6..c8f8ab359 100644 --- a/controller/app/src/main/java/org/iiab/controller/kolibri/presentation/KolibriSeedingFragment.java +++ b/controller/app/src/main/java/org/iiab/controller/kolibri/presentation/KolibriSeedingFragment.java @@ -68,7 +68,7 @@ public void onViewCreated(@NonNull View v, @Nullable Bundle savedInstanceState) detailView = v.findViewById(R.id.k2go_kseed_detail); bar = v.findViewById(R.id.k2go_kseed_bar); list = v.findViewById(R.id.k2go_kseed_list); - org.iiab.controller.redesign.ProgressVisuals.apply( + org.iiab.controller.util.ProgressVisuals.apply( v, org.iiab.controller.system.domain.ContentType.COURSES); // ADFA-5074 footer = v.findViewById(R.id.k2go_kseed_footer); footerNote = v.findViewById(R.id.k2go_kseed_footer_note); diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/MapsPreparingFragment.java b/controller/app/src/main/java/org/iiab/controller/redesign/MapsPreparingFragment.java index 1f03dcc27..d9d1a6258 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/MapsPreparingFragment.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/MapsPreparingFragment.java @@ -127,7 +127,7 @@ && getActivity() instanceof SetupLibraryActivity // ADFA-4901: collapsible live log. The status line mirrors the latest line; expanding shows // the full terminal (LogRepository snapshot + live appends), auto-scrolled. logLabel = root.findViewById(R.id.k2go_prep_log_label); - ProgressVisuals.apply(root, org.iiab.controller.system.domain.ContentType.MAPS); // ADFA-5074 + org.iiab.controller.util.ProgressVisuals.apply(root, org.iiab.controller.system.domain.ContentType.MAPS); // ADFA-5074 logChevron = root.findViewById(R.id.k2go_prep_log_chevron); logScroll = root.findViewById(R.id.k2go_prep_log_scroll); logText = root.findViewById(R.id.k2go_prep_log_text); diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/ModuleInstallFragment.java b/controller/app/src/main/java/org/iiab/controller/redesign/ModuleInstallFragment.java index a8aea5add..2eaffea12 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/ModuleInstallFragment.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/ModuleInstallFragment.java @@ -68,7 +68,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c status = root.findViewById(R.id.k2go_modinst_status); logLabel = root.findViewById(R.id.k2go_modinst_log_label); - ProgressVisuals.applyForModule(root); // ADFA-5074 + // ADFA-5074: the key is passed so a module that earns its own art can be matched. + org.iiab.controller.util.ProgressVisuals.applyForModule(root, key); logChevron = root.findViewById(R.id.k2go_modinst_log_chevron); logScroll = root.findViewById(R.id.k2go_modinst_log_scroll); logText = root.findViewById(R.id.k2go_modinst_log_text); diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/ZimPreparingFragment.java b/controller/app/src/main/java/org/iiab/controller/redesign/ZimPreparingFragment.java index 657dc2d61..ad820b39d 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/ZimPreparingFragment.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/ZimPreparingFragment.java @@ -77,7 +77,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c bar = root.findViewById(R.id.k2go_zprep_bar); listv = root.findViewById(R.id.k2go_zprep_list); // ADFA-5074: the shared animation block declares no asset; the rule picks it. - ProgressVisuals.apply(root, org.iiab.controller.system.domain.ContentType.ZIM); + org.iiab.controller.util.ProgressVisuals.apply(root, org.iiab.controller.system.domain.ContentType.ZIM); runBgBtn = root.findViewById(R.id.k2go_zprep_run_bg); runBgBtn.setOnClickListener(v -> { diff --git a/controller/app/src/main/java/org/iiab/controller/system/domain/ProgressVisual.java b/controller/app/src/main/java/org/iiab/controller/system/domain/ProgressVisual.java index e5bbbaae9..3796aa13b 100644 --- a/controller/app/src/main/java/org/iiab/controller/system/domain/ProgressVisual.java +++ b/controller/app/src/main/java/org/iiab/controller/system/domain/ProgressVisual.java @@ -61,4 +61,41 @@ public static ProgressVisual forOperation(Operation op) { public static ProgressVisual forContent(ContentType type) { return type == null ? DOWNLOAD : forOperation(type.operation()); } + + /** The visual for installing a platform's app — a runrole, so always a build. */ + public static ProgressVisual forModuleInstall(String moduleKey) { + return forOperation(Operation.appInstall(moduleKey == null ? "" : moduleKey)); + } + + /** + * The visual for one of the progress index's row keys. + * + *

The keys are {@code "zim"}, {@code "books"}, {@code "kolibri"}, {@code "maps"} and + * {@code "mod:"} for a proot module. {@link ContentType} already owns the first + * four, so the prefix is parsed here rather than in presentation — and the parsing is + * the part that breaks quietly, so it is the part with a test. + * + *

An unrecognised key is treated as content, which is the case three of the four + * types are in. + */ + public static ProgressVisual forKey(String key) { + if (key == null) { + return DOWNLOAD; + } + if (key.startsWith(MODULE_PREFIX)) { + return forModuleInstall(key.substring(MODULE_PREFIX.length())); + } + return forContent(ContentType.byKey(key)); + } + + /** Prefix the progress index uses for a proot module row. */ + public static final String MODULE_PREFIX = "mod:"; + + // TODO(ADFA-5074): this model is deliberately incomplete. The app has four working + // animations — k2go_working_loop, k2go_backup_loop, k2go_restore_loop — and this enum + // names two. BackupJobFragment (ADFA-4961) already resolves its own from the mode, by + // the same principle: the layout declares no asset and the code decides from what the + // operation is. It was written first and is not folded in here because backup and + // restore are system operations rather than content, which is a wider change. Whoever + // extends this should extend that precedent rather than build a third mechanism. } diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/ProgressVisuals.java b/controller/app/src/main/java/org/iiab/controller/util/ProgressVisuals.java similarity index 68% rename from controller/app/src/main/java/org/iiab/controller/redesign/ProgressVisuals.java rename to controller/app/src/main/java/org/iiab/controller/util/ProgressVisuals.java index f7f635f27..64214b006 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/ProgressVisuals.java +++ b/controller/app/src/main/java/org/iiab/controller/util/ProgressVisuals.java @@ -7,13 +7,12 @@ * The one place a file name appears (ADFA-5074). * ============================================================================ */ -package org.iiab.controller.redesign; +package org.iiab.controller.util; import androidx.annotation.RawRes; import org.iiab.controller.R; import org.iiab.controller.system.domain.ContentType; -import org.iiab.controller.system.domain.Operation; import org.iiab.controller.system.domain.ProgressVisual; /** @@ -29,9 +28,6 @@ public final class ProgressVisuals { private ProgressVisuals() { } - /** Prefix the install index uses for a proot module row. */ - private static final String MODULE_PREFIX = "mod:"; - /** * The asset for an intent. * @@ -49,30 +45,11 @@ public static int rawResFor(ProgressVisual visual) { } } - /** - * The intent for one of the index's row keys. - * - *

The keys are a presentation vocabulary — {@code "zim"}, {@code "books"}, - * {@code "kolibri"}, {@code "maps"}, and {@code "mod:"} for a proot module — so - * turning one into an {@link Operation} belongs here rather than in the domain. Anything - * unrecognised is treated as content, which is the case three of the four types are in. - */ - public static ProgressVisual visualForKey(String key) { - if (key == null) { - return ProgressVisual.DOWNLOAD; - } - if (key.startsWith(MODULE_PREFIX)) { - return ProgressVisual.forOperation( - Operation.appInstall(key.substring(MODULE_PREFIX.length()))); - } - ContentType type = ContentType.byKey(key); - return type == null ? ProgressVisual.DOWNLOAD : ProgressVisual.forContent(type); - } /** The asset for one of the index's row keys, in one call. */ @RawRes public static int rawResForKey(String key) { - return rawResFor(visualForKey(key)); + return rawResFor(ProgressVisual.forKey(key)); } /** @@ -98,8 +75,16 @@ public static void apply(android.view.View root, ContentType type) { anim.playAnimation(); } - /** The same, for a proot module install rather than a content type. */ - public static void applyForModule(android.view.View root) { + /** + * The same, for a proot module install. + * + * @param moduleKey which module. Passed on rather than dropped: the per-platform + * exception in {@link ProgressVisual#forOperation} matches on the + * platform name, and a module is the likeliest thing to want art of + * its own — handing it an empty name would have made that hook + * unreachable from the one place it is for. + */ + public static void applyForModule(android.view.View root, String moduleKey) { if (root == null) { return; } @@ -107,7 +92,7 @@ public static void applyForModule(android.view.View root) { if (anim == null) { return; } - anim.setAnimation(rawResFor(ProgressVisual.forOperation(Operation.appInstall("")))); + anim.setAnimation(rawResFor(ProgressVisual.forModuleInstall(moduleKey))); anim.playAnimation(); } } diff --git a/controller/app/src/main/res/layout/fragment_k2go_module_install.xml b/controller/app/src/main/res/layout/fragment_k2go_module_install.xml index 674256cdc..3dbcc3086 100644 --- a/controller/app/src/main/res/layout/fragment_k2go_module_install.xml +++ b/controller/app/src/main/res/layout/fragment_k2go_module_install.xml @@ -33,8 +33,14 @@ android:textAppearance="?attr/textAppearanceBodyMedium" android:textColor="@color/k2go_muted" /> - - + + -