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..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,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.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); 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..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,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); + 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 4977d7827..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,6 +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); + // 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 0c1deb3b3..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 @@ -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. + 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 new file mode 100644 index 000000000..3796aa13b --- /dev/null +++ b/controller/app/src/main/java/org/iiab/controller/system/domain/ProgressVisual.java @@ -0,0 +1,101 @@ +/* + * ============================================================================ + * 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()); + } + + /** 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: 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/util/ProgressVisuals.java b/controller/app/src/main/java/org/iiab/controller/util/ProgressVisuals.java
new file mode 100644
index 000000000..64214b006
--- /dev/null
+++ b/controller/app/src/main/java/org/iiab/controller/util/ProgressVisuals.java
@@ -0,0 +1,98 @@
+/*
+ * ============================================================================
+ * 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.util;
+
+import androidx.annotation.RawRes;
+
+import org.iiab.controller.R;
+import org.iiab.controller.system.domain.ContentType;
+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() {
+ }
+
+ /**
+ * 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 asset for one of the index's row keys, in one call. */
+ @RawRes
+ public static int rawResForKey(String key) {
+ return rawResFor(ProgressVisual.forKey(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.
+ *
+ * @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;
+ }
+ com.airbnb.lottie.LottieAnimationView anim = root.findViewById(R.id.k2go_working_anim);
+ if (anim == null) {
+ return;
+ }
+ anim.setAnimation(rawResFor(ProgressVisual.forModuleInstall(moduleKey)));
+ anim.playAnimation();
+ }
+}
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" />
+
+