App 2.24.0: Overview styles Sci-fi, Cartoon and Blueprint
Sci-fi: a starship console with elbow frames, pill labels and block graphs, red alert below 20 %. Cartoon: comic panels, a battery with a face, a springy speedometer and sound words for power. Blueprint: a top-view drawing with the battery hatched to the charge, tyre pressures on leader lines, power as a force arrow and a title block. Styles are now mapped to panes in a table. 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:
@@ -69,6 +69,14 @@ public class MainActivity extends AppCompatActivity {
|
||||
private View gaugesPane;
|
||||
private View cockpitPane;
|
||||
private View retroPane, futuristicPane;
|
||||
/** The drawn styles' views, each fed the same {@link ClusterValues} per reading. */
|
||||
private RetroView retroView;
|
||||
private FlowView flowView;
|
||||
private SciFiView sciFiView;
|
||||
private CartoonView cartoonView;
|
||||
private BlueprintView blueprintView;
|
||||
/** The pane of each Overview style, by its index in {@link #OVERVIEW_STYLES}. */
|
||||
private View[] stylePanes;
|
||||
private View consumptionPane;
|
||||
private View chargingPane;
|
||||
/** Display, battery, charging price and Wi-Fi. */
|
||||
@@ -249,7 +257,16 @@ public class MainActivity extends AppCompatActivity {
|
||||
cockpitPane = inflatePane(R.layout.pane_cockpit);
|
||||
retroPane = inflatePane(R.layout.pane_retro);
|
||||
futuristicPane = inflatePane(R.layout.pane_futuristic);
|
||||
// The Overview page holds both styles; Settings → Overview style picks the one shown.
|
||||
retroView = retroPane.findViewById(R.id.retro_view);
|
||||
flowView = futuristicPane.findViewById(R.id.flow_view);
|
||||
sciFiView = new SciFiView(this, null);
|
||||
cartoonView = new CartoonView(this, null);
|
||||
blueprintView = new BlueprintView(this, null);
|
||||
View sciFiPane = drawnPane(sciFiView), cartoonPane = drawnPane(cartoonView),
|
||||
blueprintPane = drawnPane(blueprintView);
|
||||
stylePanes = new View[] { vehiclePane, gaugesPane, cockpitPane, retroPane, retroPane,
|
||||
futuristicPane, sciFiPane, cartoonPane, blueprintPane };
|
||||
// The Overview page holds every style; Settings → Overview style picks the one shown.
|
||||
android.widget.FrameLayout overviewPage = new android.widget.FrameLayout(this);
|
||||
overviewPage.setLayoutParams(new android.view.ViewGroup.LayoutParams(
|
||||
android.view.ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
@@ -259,6 +276,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
overviewPage.addView(cockpitPane);
|
||||
overviewPage.addView(retroPane);
|
||||
overviewPage.addView(futuristicPane);
|
||||
overviewPage.addView(sciFiPane);
|
||||
overviewPage.addView(cartoonPane);
|
||||
overviewPage.addView(blueprintPane);
|
||||
consumptionPane = inflatePane(R.layout.pane_consumption);
|
||||
chargingPane = inflatePane(R.layout.pane_charging);
|
||||
settingsPane = inflatePane(R.layout.pane_settings);
|
||||
@@ -1442,7 +1462,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
private Double dashTripKm;
|
||||
|
||||
/** The stored values of the Overview styles, in the order of the drop-down. */
|
||||
private static final String[] OVERVIEW_STYLES = { "TILES", "GAUGES", "COCKPIT", "RETRO", "RETRO_ACCENT", "FUTURISTIC" };
|
||||
private static final String[] OVERVIEW_STYLES = { "TILES", "GAUGES", "COCKPIT", "RETRO", "RETRO_ACCENT", "FUTURISTIC",
|
||||
"SCIFI", "CARTOON", "BLUEPRINT" };
|
||||
|
||||
/** The chosen style's index in {@link #OVERVIEW_STYLES}; anything unknown is Tiles. */
|
||||
private int overviewStyle() {
|
||||
@@ -1454,20 +1475,18 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private void applyOverviewStyle() {
|
||||
int style = overviewStyle();
|
||||
vehiclePane.setVisibility(style == 0 ? View.VISIBLE : View.GONE);
|
||||
gaugesPane.setVisibility(style == 1 ? View.VISIBLE : View.GONE);
|
||||
cockpitPane.setVisibility(style == 2 ? View.VISIBLE : View.GONE);
|
||||
for (View pane : stylePanes) pane.setVisibility(pane == stylePanes[style] ? View.VISIBLE : View.GONE);
|
||||
// Retro in either palette: one pane, the view told which.
|
||||
retroPane.setVisibility(style == 3 || style == 4 ? View.VISIBLE : View.GONE);
|
||||
((RetroView) retroPane.findViewById(R.id.retro_view)).setAccentPalette(style == 4);
|
||||
futuristicPane.setVisibility(style == 5 ? View.VISIBLE : View.GONE);
|
||||
retroView.setAccentPalette("RETRO_ACCENT".equals(OVERVIEW_STYLES[style]));
|
||||
}
|
||||
|
||||
/** Tiles, Gauges, Cockpit, Retro (classic or accent colour) or Futuristic; all are fed on every reading. */
|
||||
/** The style drop-down; every style is fed on every reading, only the chosen one is shown. */
|
||||
private void bindOverviewStyle() {
|
||||
String[] labels = { 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_retro_accent), getString(R.string.overview_style_futuristic),
|
||||
getString(R.string.overview_style_scifi), getString(R.string.overview_style_cartoon),
|
||||
getString(R.string.overview_style_blueprint) };
|
||||
bindChoices(settingsPane.findViewById(R.id.overview_style_choices), labels, overviewStyle(),
|
||||
position -> {
|
||||
prefs.edit().putString(PREF_OVERVIEW_STYLE, OVERVIEW_STYLES[position]).apply();
|
||||
@@ -1496,9 +1515,17 @@ public class MainActivity extends AppCompatActivity {
|
||||
private final java.text.SimpleDateFormat clockFormat =
|
||||
new java.text.SimpleDateFormat("HH:mm", java.util.Locale.US);
|
||||
|
||||
/** A drawn style's view in a pane with the Overview's margins. */
|
||||
private View drawnPane(View view) {
|
||||
android.widget.FrameLayout pane = new android.widget.FrameLayout(this);
|
||||
float dp = getResources().getDisplayMetrics().density;
|
||||
pane.setPadding(Math.round(24 * dp), Math.round(12 * dp), Math.round(24 * dp), Math.round(12 * dp));
|
||||
pane.addView(view, new android.widget.FrameLayout.LayoutParams(
|
||||
android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
return pane;
|
||||
}
|
||||
|
||||
private void showDrawnStyles(EnergySnapshot s) {
|
||||
RetroView retro = retroPane.findViewById(R.id.retro_view);
|
||||
FlowView flow = futuristicPane.findViewById(R.id.flow_view);
|
||||
ClusterValues v = new ClusterValues();
|
||||
v.socPercent = s.getSocPercent();
|
||||
v.rangeKm = s.getRangeKm();
|
||||
@@ -1511,8 +1538,16 @@ public class MainActivity extends AppCompatActivity {
|
||||
v.climateCelsius = s.getClimate().getDriverTargetCelsius();
|
||||
v.odometerKm = s.getOdometerKm();
|
||||
v.clock = clockFormat.format(new java.util.Date());
|
||||
retro.setValues(v);
|
||||
flow.setValues(v);
|
||||
PressureUnit unit = PressureUnit.fromPref(prefs.getString(PressureUnit.PREF_KEY, null));
|
||||
v.tyreFl = unit.format(s.getTirePressures().getFrontLeftKpa());
|
||||
v.tyreFr = unit.format(s.getTirePressures().getFrontRightKpa());
|
||||
v.tyreRl = unit.format(s.getTirePressures().getRearLeftKpa());
|
||||
v.tyreRr = unit.format(s.getTirePressures().getRearRightKpa());
|
||||
retroView.setValues(v);
|
||||
flowView.setValues(v);
|
||||
sciFiView.setValues(v);
|
||||
cartoonView.setValues(v);
|
||||
blueprintView.setValues(v);
|
||||
}
|
||||
|
||||
// ---------- Cockpit (Overview style) ----------
|
||||
|
||||
Reference in New Issue
Block a user