Skip to content

Commit 386642f

Browse files
K2GO-385 refactor(ui): K2GoChip owns the neutral-by-default metadata colour
Second-pass review follow-up on PR3b. The "metadata is neutral" fact was repeated at every call site (each passed R.color.k2go_muted). Encode it once: add K2GoChip.create(ctx, text) / style(chip, text) that default to the neutral tag, and drop the explicit muted at the metadata call sites (DashboardDetail REST/core/version, ModuleDetail size/version). The 3-arg overloads stay for valence traits ("Runs offline" = leaf, "Demo" = amber), matching the metadata colour rule: neutral by default, semantic only for valence.
1 parent 2ed8f36 commit 386642f

3 files changed

Lines changed: 22 additions & 6 deletions

File tree

‎controller/app/src/main/java/org/appdevforall/k2go/redesign/DashboardDetailFragment.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
110110
// System core are neutral metadata tags (colour there is noise -- the metadata colour rule).
111111
statusChip = K2GoStatusBadge.create(requireContext(), getString(R.string.k2go_dash_chip_checking), R.color.k2go_muted);
112112
chips.addView(statusChip);
113-
chips.addView(K2GoChip.create(requireContext(), getString(R.string.k2go_dash_chip_rest), R.color.k2go_muted));
114-
chips.addView(K2GoChip.create(requireContext(), getString(R.string.k2go_dash_chip_core), R.color.k2go_muted));
113+
chips.addView(K2GoChip.create(requireContext(), getString(R.string.k2go_dash_chip_rest)));
114+
chips.addView(K2GoChip.create(requireContext(), getString(R.string.k2go_dash_chip_core)));
115115
fetchVersionChip();
116116

117117
((TextView) root.findViewById(R.id.k2go_moddet_includes_body)).setText(R.string.k2go_dash_includes);
@@ -420,10 +420,10 @@ private void fetchVersionChip() {
420420
main.post(() -> {
421421
if (!isAdded() || chips == null || ver == null) return;
422422
if (versionChip == null) {
423-
versionChip = K2GoChip.create(requireContext(), "v" + ver, R.color.k2go_muted);
423+
versionChip = K2GoChip.create(requireContext(), "v" + ver);
424424
chips.addView(versionChip, 0);
425425
} else {
426-
K2GoChip.style(versionChip, "v" + ver, R.color.k2go_muted);
426+
K2GoChip.style(versionChip, "v" + ver);
427427
}
428428
});
429429
});

‎controller/app/src/main/java/org/appdevforall/k2go/redesign/K2GoChip.java‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,26 @@
2323
import androidx.annotation.ColorRes;
2424
import androidx.core.content.ContextCompat;
2525

26+
import org.appdevforall.k2go.R;
27+
2628
public final class K2GoChip {
2729

2830
private K2GoChip() {}
2931

32+
/** The neutral tag colour. Metadata is neutral by default (the metadata colour rule); pass an
33+
* explicit colour to the 3-arg overloads only for a valence trait (e.g. leaf "Runs offline"). */
34+
@ColorRes private static final int NEUTRAL = R.color.k2go_muted;
35+
36+
/** A neutral metadata tag (version, size, "REST API", "System core") -- the common case. */
37+
public static TextView create(Context context, CharSequence text) {
38+
return create(context, text, NEUTRAL);
39+
}
40+
41+
/** Re-apply a neutral metadata tag's text/colour in place. */
42+
public static void style(TextView chip, CharSequence text) {
43+
style(chip, text, NEUTRAL);
44+
}
45+
3046
/**
3147
* Build a chip laid out for a horizontal meta-chip row: WRAP content, an 8dp end margin, and
3248
* the shared outline applied. Callers add it to a {@link LinearLayout} row.

‎controller/app/src/main/java/org/appdevforall/k2go/redesign/ModuleDetailFragment.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
7272
: "\u2248 NA";
7373
// K2GO-385 (PR3): size / version are neutral metadata tags (colour is noise); "Runs offline" is a
7474
// leaf trait (a capability that carries valence). The lifecycle status below is a dot+text badge.
75-
chips.addView(K2GoChip.create(requireContext(), sizeText, R.color.k2go_muted));
75+
chips.addView(K2GoChip.create(requireContext(), sizeText));
7676
String ver = ModuleCards.version(c.key());
77-
if (ver != null) chips.addView(K2GoChip.create(requireContext(), "v" + ver, R.color.k2go_muted));
77+
if (ver != null) chips.addView(K2GoChip.create(requireContext(), "v" + ver));
7878
chips.addView(K2GoChip.create(requireContext(), getString(R.string.k2go_mod_runs_offline), R.color.k2go_leaf));
7979
if (ModuleCards.isDemo(c.key())) chips.addView(K2GoChip.create(requireContext(), getString(R.string.k2go_mod_demo), R.color.k2go_amber_text)); // ADFA-4958
8080

0 commit comments

Comments
 (0)