Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
* <p><b>Why this is resolved rather than placed.</b> 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.
*
* <p>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.
*
* <p><b>Where a per-module exception goes.</b> Inside {@link #forOperation}, as a case on
* the platform name <em>before</em> 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.
*
* <p>This enum names the <em>intent</em>, 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.
*
* <p>The keys are {@code "zim"}, {@code "books"}, {@code "kolibri"}, {@code "maps"} and
* {@code "mod:<name>"} 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.
*
* <p>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.
}
Original file line number Diff line number Diff line change
@@ -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.
*
* <p>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.
*
* <p>{@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}.
*
* <p>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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
android:textAppearance="?attr/textAppearanceBodyMedium"
android:textColor="@color/k2go_muted" />

<!-- ADFA-5074: Courses was the one card without the working animation, which is what
a per-layout copy gets you. Same block, same place as the others. -->
<include layout="@layout/view_k2go_working_anim" />

<TextView
android:id="@+id/k2go_kseed_pct"
android:layout_width="match_parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,70 +33,8 @@
android:textAppearance="?attr/textAppearanceBodyMedium"
android:textColor="@color/k2go_muted" />

<!-- ADFA-4910: real "working" Lottie (cloud -> streaming dots -> logo) in place of the
placeholder spinner. The animation ships WITHOUT the logo (see SPEC); the K2Go
launcher foreground is composited on top, over the built-in green glow, positioned by
a weighted scaffold so it tracks the art at any width. adjustViewBounds locks the
600:368 ratio; Lottie falls back to a static first frame when system animations are off. -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp">

<com.airbnb.lottie.LottieAnimationView
android:id="@+id/k2go_prep_anim"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
app:lottie_rawRes="@raw/k2go_working_loop"
app:lottie_autoPlay="true"
app:lottie_loop="true" />

<!-- Logo overlay (fills the art rect). The weights are the knobs: vertical
top/logo/bottom and horizontal left/logo/right center the logo at ~0.80W / 0.54H,
sized to sit over the green glow. -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="300" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="480"
android:orientation="horizontal">

<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="680" />

<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="295"
android:src="@drawable/ic_launcher_foreground"
android:scaleType="fitCenter"
android:contentDescription="@null" />

<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="25" />
</LinearLayout>

<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="220" />
</LinearLayout>
</FrameLayout>
<!-- ADFA-5074: shared block; the asset is chosen by ProgressVisuals. -->
<include layout="@layout/view_k2go_working_anim" />

<!-- The process's own text, not an invented percentage. -->
<!-- ADFA-4910: fixed 2-line height (minLines=maxLines=2) so the note below never jumps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,65 +33,14 @@
android:textAppearance="?attr/textAppearanceBodyMedium"
android:textColor="@color/k2go_muted" />

<!-- ADFA-4842: same "working" Lottie as maps (cloud -> streaming dots -> logo), standardized
across every module install. The animation ships WITHOUT the logo; the K2Go launcher
foreground is composited on top of the built-in green glow via a weighted scaffold. -->
<FrameLayout
<!-- ADFA-5074: shared block; the asset is chosen by ProgressVisuals. The margin is
overridden because this card always spaced it at 16dp, not the shared 12dp —
overriding layout attrs on an <include> requires restating width and height. -->
<include
layout="@layout/view_k2go_working_anim"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp">

<com.airbnb.lottie.LottieAnimationView
android:id="@+id/k2go_modinst_anim"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
app:lottie_rawRes="@raw/k2go_working_loop"
app:lottie_autoPlay="true"
app:lottie_loop="true" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="300" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="480"
android:orientation="horizontal">

<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="680" />

<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="295"
android:src="@drawable/ic_launcher_foreground"
android:scaleType="fitCenter"
android:contentDescription="@null" />

<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="25" />
</LinearLayout>

<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="220" />
</LinearLayout>
</FrameLayout>
android:layout_marginTop="16dp" />

<TextView
android:id="@+id/k2go_modinst_status"
Expand Down
Loading
Loading