App 2.27.2: Terminal in the accent colour; Original as a colour choice

Retro and Terminal are one entry each; the accent colour drop-down
offers "Original" first for them, remembered per style. The old
"Retro (accent colour)" entry is folded in and its stored value
migrated. Emulator only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LhzAVaUyqcw5PkGjz4mWW6
This commit is contained in:
2026-10-24 21:38:01 +02:00
co-authored by Claude Opus 5.5
parent ef2ba89fba
commit 1c85fd2d9f
10 changed files with 137 additions and 51 deletions
@@ -68,6 +68,7 @@ public class MainActivity extends AppCompatActivity {
private OctagonView octagonView;
/** The styles built on {@link ClusterCanvasView}, fed together. */
private final java.util.List<ClusterCanvasView> canvasStyles = new java.util.ArrayList<>();
private TerminalView terminalView;
/** The pane of each Overview style, by its {@link OverviewStyle} ordinal. */
private View[] stylePanes;
private View consumptionPane;
@@ -282,11 +283,12 @@ public class MainActivity extends AppCompatActivity {
octagonView = new OctagonView(this, null);
View sciFiPane = drawnPane(sciFiView), cartoonPane = drawnPane(cartoonView),
blueprintPane = drawnPane(blueprintView), mgPane = drawnPane(octagonView);
java.util.Collections.addAll(canvasStyles, new MinimalView(this), new TerminalView(this),
terminalView = new TerminalView(this);
java.util.Collections.addAll(canvasStyles, new MinimalView(this), terminalView,
new AviationView(this), new NixieView(this), new ChronographView(this));
View[] canvasPanes = new View[canvasStyles.size()];
for (int i = 0; i < canvasPanes.length; i++) canvasPanes[i] = drawnPane(canvasStyles.get(i));
stylePanes = new View[] { vehiclePane, gaugesPane, cockpitPane, retroPane, retroPane,
stylePanes = new View[] { vehiclePane, gaugesPane, cockpitPane, retroPane,
futuristicPane, sciFiPane, cartoonPane, blueprintPane, mgPane,
canvasPanes[0], canvasPanes[1], canvasPanes[2], canvasPanes[3], canvasPanes[4] };
// The Overview page holds every style; Settings → Overview style picks the one shown.
@@ -1216,14 +1218,32 @@ public class MainActivity extends AppCompatActivity {
}
/** The accent colour; a change recreates the activity so every view takes it. */
/**
* The accent colour; a change recreates the activity so every view takes it. For a style
* with an original palette, "Original colours" comes first: it keeps the style in its own
* colours and leaves the app's accent as it is.
*/
private void bindAccentColor() {
OverviewStyle style = overviewStyle();
AccentColor[] colors = AccentColor.values();
String[] labels = new String[colors.length];
for (int i = 0; i < colors.length; i++) labels[i] = colors[i].label;
int offset = style.hasOriginal ? 1 : 0;
String[] labels = new String[colors.length + offset];
if (offset == 1) labels[0] = getString(R.string.accent_original);
for (int i = 0; i < colors.length; i++) labels[i + offset] = colors[i].label;
AccentColor current = AccentColor.fromPref(prefs.getString(AccentColor.PREF_KEY, null));
bindChoices(settingsPane.findViewById(R.id.accent_choices), labels, current.ordinal(), position -> {
if (colors[position] == current) return;
prefs.edit().putString(AccentColor.PREF_KEY, colors[position].name()).apply();
int selected = originalColours(style) ? 0 : current.ordinal() + offset;
bindChoices(settingsPane.findViewById(R.id.accent_choices), labels, selected, position -> {
if (style.hasOriginal) prefs.edit().putBoolean(style.originalKey(), position == 0).apply();
if (position < offset) {
applyOverviewStyle();
return;
}
AccentColor picked = colors[position - offset];
if (picked == current) {
applyOverviewStyle();
return;
}
prefs.edit().putString(AccentColor.PREF_KEY, picked.name()).apply();
recreate();
});
applyAccentAvailability();
@@ -1488,15 +1508,28 @@ public class MainActivity extends AppCompatActivity {
private Double dashTripKm;
private OverviewStyle overviewStyle() {
return OverviewStyle.fromPref(prefs.getString(PREF_OVERVIEW_STYLE, null));
String stored = prefs.getString(PREF_OVERVIEW_STYLE, null);
OverviewStyle style = OverviewStyle.fromPref(stored);
if (OverviewStyle.wasAccentEntry(stored)) {
// "Retro (accent colour)" before 2.27.2: now Retro, in the accent colour.
prefs.edit().putString(PREF_OVERVIEW_STYLE, style.name()).putBoolean(style.originalKey(), false).apply();
}
return style;
}
/** Whether a style with an original palette shows it (the default) or the accent colour. */
private boolean originalColours(OverviewStyle style) {
return style.hasOriginal && prefs.getBoolean(style.originalKey(), true);
}
private void applyOverviewStyle() {
OverviewStyle style = overviewStyle();
for (View pane : stylePanes) pane.setVisibility(pane == stylePanes[style.ordinal()] ? View.VISIBLE : View.GONE);
// Retro in either palette: one pane, the view told which.
retroView.setAccentPalette(style == OverviewStyle.RETRO_ACCENT);
applyAccentAvailability();
// Retro and Terminal: their original palette or the accent colour, as chosen for each.
retroView.setAccentPalette(!originalColours(OverviewStyle.RETRO));
terminalView.setAccentPalette(!originalColours(OverviewStyle.TERMINAL));
// The accent choices depend on the style ("Original colours" for Retro and Terminal).
if (settingsPane != null) bindAccentColor();
}
/**
@@ -1520,7 +1553,7 @@ public class MainActivity extends AppCompatActivity {
private String[] styleLabels() {
return new String[] { getString(R.string.overview_style_tiles), getString(R.string.overview_style_gauges),
getString(R.string.overview_style_cockpit), getString(R.string.overview_style_retro),
getString(R.string.overview_style_retro_accent), getString(R.string.overview_style_futuristic),
getString(R.string.overview_style_futuristic),
getString(R.string.overview_style_scifi), getString(R.string.overview_style_cartoon),
getString(R.string.overview_style_blueprint), getString(R.string.overview_style_mg),
getString(R.string.overview_style_minimal), getString(R.string.overview_style_terminal),
@@ -1533,8 +1566,8 @@ public class MainActivity extends AppCompatActivity {
OverviewStyle[] styles = OverviewStyle.values();
com.google.android.material.textfield.MaterialAutoCompleteTextView field =
settingsPane.findViewById(R.id.overview_style_choices);
// Wider than its field, which shares a row with the accent colour: "Retro (accent colour)".
field.setDropDownWidth(Math.round(360 * getResources().getDisplayMetrics().density));
// Wider than its field, which shares a row with the accent colour.
field.setDropDownWidth(Math.round(320 * getResources().getDisplayMetrics().density));
bindChoices(field, styleLabels(), overviewStyle().ordinal(),
position -> {
prefs.edit().putString(PREF_OVERVIEW_STYLE, styles[position].name()).apply();