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 @@ -79,7 +79,14 @@ public static void show(Activity act, String endpoint, String title, int iconRes
hcol.addView(tv);
TextView subtitle = new TextView(ctx);
String project = (card != null) ? act.getString(card.subRes) : "";
subtitle.setText(project.isEmpty() ? stateLabel(act, state) : project + " · " + stateLabel(act, state));
int sizeRes = ModuleCards.sizeLabelRes(key); // ADFA-4958 §5.3: subtitle is project · state · size
long bytes = ModuleSizes.bytesFor(ctx, key);
StringBuilder sub = new StringBuilder();
if (!project.isEmpty()) sub.append(project).append(" · ");
sub.append(stateLabel(act, state));
if (sizeRes != 0) sub.append(" · ").append(act.getString(sizeRes));
else if (bytes >= 0) sub.append(" · ≈ ").append(org.iiab.controller.util.ByteFormatter.toHuman(bytes));
subtitle.setText(sub.toString());
subtitle.setTextAppearance(com.google.android.material.R.style.TextAppearance_Material3_BodySmall);
subtitle.setTextColor(ContextCompat.getColor(ctx, R.color.k2go_muted));
hcol.addView(subtitle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ public static String license(String key) {
}
}

/** ADFA-4958: curated size label for modules whose real footprint is selection-dependent
* (maps grows with the layers/levels the user picks), shown instead of a single measured
* value. 0 -> fall back to the measured ModuleSizes value. */
public static int sizeLabelRes(String key) {
if ("maps".equals(key)) return R.string.k2go_mod_maps_size;
if ("matomo".equals(key)) return R.string.k2go_mod_matomo_size; // ADFA-4958: curated (~114 MB, incl. MariaDB + tarball)
return 0;
}

/** ADFA-4958: matomo ships as a demo/example module — it runs, but it is not a real production
* feature; flagged so the detail can show a "Demo" chip. */
public static boolean isDemo(String key) {
return "matomo".equals(key);
}

/** ADFA-4958: "What it includes" line — makes module-vs-content explicit. 0 -> hide. */
public static int includesRes(String key) {
if (key == null) return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c

// ADFA-4958: meta chips (size / version / Runs offline), "What it includes", and license.
LinearLayout chips = root.findViewById(R.id.k2go_moddet_chips);
int sizeRes = ModuleCards.sizeLabelRes(c.key()); // ADFA-4958: maps uses a curated "200 MB+" floor
long bytes = ModuleSizes.bytesFor(requireContext(), c.key());
String sizeText = (bytes >= 0)
? "\u2248 " + org.iiab.controller.util.ByteFormatter.toHuman(bytes)
String sizeText = (sizeRes != 0) ? getString(sizeRes)
: (bytes >= 0) ? "\u2248 " + org.iiab.controller.util.ByteFormatter.toHuman(bytes)
: "\u2248 NA";
chips.addView(chip(sizeText, R.color.k2go_teal));
String ver = ModuleCards.version(c.key());
if (ver != null) chips.addView(chip("v" + ver, R.color.k2go_teal));
chips.addView(chip(getString(R.string.k2go_mod_runs_offline), R.color.k2go_leaf));
if (ModuleCards.isDemo(c.key())) chips.addView(chip(getString(R.string.k2go_mod_demo), R.color.k2go_amber_text)); // ADFA-4958

int inc = ModuleCards.includesRes(c.key());
if (inc != 0) {
Expand Down Expand Up @@ -120,8 +122,14 @@ private TextView chip(String text, int colorRes) {
TextView t = new TextView(requireContext());
t.setText(text);
t.setTextAppearance(com.google.android.material.R.style.TextAppearance_Material3_LabelMedium);
t.setTextColor(ContextCompat.getColor(requireContext(), colorRes));
t.setBackgroundResource(R.drawable.k2go_chip_bg);
int color = ContextCompat.getColor(requireContext(), colorRes); // ADFA-4958 §5.4: outlined pill (teal-on-teal fill was invisible)
t.setTextColor(color);
android.graphics.drawable.GradientDrawable bg = new android.graphics.drawable.GradientDrawable();
bg.setShape(android.graphics.drawable.GradientDrawable.RECTANGLE);
bg.setColor(android.graphics.Color.TRANSPARENT);
bg.setCornerRadius(11 * d);
bg.setStroke(Math.max(1, Math.round(1.4f * d)), color);
t.setBackground(bg);
int hp = Math.round(10 * d), vp = Math.round(5 * d);
t.setPadding(hp, vp, hp, vp);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,7 @@ private void addHiddenSection() {
col.addView(sub);
row.addView(col, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f));

TextView restore = new TextView(requireContext());
restore.setText(R.string.k2go_mod_restore);
restore.setTextColor(ContextCompat.getColor(requireContext(), R.color.k2go_teal));
restore.setBackgroundResource(R.drawable.k2go_chip_bg);
TextView restore = statePill(getString(R.string.k2go_mod_restore), R.color.k2go_teal); // ADFA-4958 §5.7: outlined teal pill
restore.setPadding(px(14), px(6), px(14), px(6));
restore.setOnClickListener(v -> { HiddenModules.remove(requireContext(), key); buildCards(); });
row.addView(restore);
Expand Down
3 changes: 3 additions & 0 deletions controller/app/src/main/res/values/strings_k2go.xml
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,9 @@
<string name="k2go_mod_maps_desc" translatable="false">Offline world maps to browse and search on the device. Pick the layers and region, then it builds into your system.</string>
<!-- ADFA-4958 module detail enrichment -->
<string name="k2go_mod_runs_offline" translatable="false">Runs offline</string>
<string name="k2go_mod_maps_size" translatable="false">200 MB+</string>
<string name="k2go_mod_matomo_size" translatable="false">≈ 114 MB</string>
<string name="k2go_mod_demo" translatable="false">Demo</string>
<string name="k2go_mod_includes_title" translatable="false">What it includes</string>
<string name="k2go_mod_license_fmt" translatable="false">License · %1$s</string>
<string name="k2go_mod_kolibri_includes" translatable="false">Sample courses included — add more in Get more.</string>
Expand Down
Loading