|
|
|
@@ -66,7 +66,7 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
private View serverPane;
|
|
|
|
|
private View logPane;
|
|
|
|
|
private View vehiclePane;
|
|
|
|
|
private View dashboardPane;
|
|
|
|
|
private View gaugesPane;
|
|
|
|
|
private View cockpitPane;
|
|
|
|
|
private View consumptionPane;
|
|
|
|
|
private View chargingPane;
|
|
|
|
@@ -244,7 +244,7 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
servicePane = inflatePane(R.layout.pane_service);
|
|
|
|
|
serverPane = inflatePane(R.layout.pane_server);
|
|
|
|
|
vehiclePane = inflatePane(R.layout.pane_vehicle);
|
|
|
|
|
dashboardPane = inflatePane(R.layout.pane_dashboard);
|
|
|
|
|
gaugesPane = inflatePane(R.layout.pane_gauges);
|
|
|
|
|
cockpitPane = inflatePane(R.layout.pane_cockpit);
|
|
|
|
|
// The Overview page holds both styles; Settings → Overview style picks the one shown.
|
|
|
|
|
android.widget.FrameLayout overviewPage = new android.widget.FrameLayout(this);
|
|
|
|
@@ -252,7 +252,7 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
android.view.ViewGroup.LayoutParams.MATCH_PARENT,
|
|
|
|
|
android.view.ViewGroup.LayoutParams.MATCH_PARENT));
|
|
|
|
|
overviewPage.addView(vehiclePane);
|
|
|
|
|
overviewPage.addView(dashboardPane);
|
|
|
|
|
overviewPage.addView(gaugesPane);
|
|
|
|
|
overviewPage.addView(cockpitPane);
|
|
|
|
|
consumptionPane = inflatePane(R.layout.pane_consumption);
|
|
|
|
|
chargingPane = inflatePane(R.layout.pane_charging);
|
|
|
|
@@ -263,7 +263,7 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
UpdateLog.noteVersion(this, BuildConfig.VERSION_NAME);
|
|
|
|
|
bindVehiclePane();
|
|
|
|
|
bindDashboard();
|
|
|
|
|
bindGauges();
|
|
|
|
|
bindCockpit();
|
|
|
|
|
bindConsumptionPane();
|
|
|
|
|
bindChargingPane();
|
|
|
|
@@ -1424,7 +1424,7 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ---------- Dashboard (Overview style) ----------
|
|
|
|
|
// ---------- Gauges (Overview style) ----------
|
|
|
|
|
|
|
|
|
|
static final String PREF_OVERVIEW_STYLE = "overview_style";
|
|
|
|
|
private GaugeView dashPower, dashSpeed, dashBattery;
|
|
|
|
@@ -1434,11 +1434,12 @@ 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", "DASHBOARD", "COCKPIT" };
|
|
|
|
|
private static final String[] OVERVIEW_STYLES = { "TILES", "GAUGES", "COCKPIT" };
|
|
|
|
|
|
|
|
|
|
/** The chosen style's index in {@link #OVERVIEW_STYLES}; anything unknown is Tiles. */
|
|
|
|
|
private int overviewStyle() {
|
|
|
|
|
String style = prefs.getString(PREF_OVERVIEW_STYLE, "TILES");
|
|
|
|
|
if ("DASHBOARD".equals(style)) style = "GAUGES"; // its name before 2.22.3
|
|
|
|
|
for (int i = 0; i < OVERVIEW_STYLES.length; i++) if (OVERVIEW_STYLES[i].equals(style)) return i;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
@@ -1446,13 +1447,13 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
private void applyOverviewStyle() {
|
|
|
|
|
int style = overviewStyle();
|
|
|
|
|
vehiclePane.setVisibility(style == 0 ? View.VISIBLE : View.GONE);
|
|
|
|
|
dashboardPane.setVisibility(style == 1 ? View.VISIBLE : View.GONE);
|
|
|
|
|
gaugesPane.setVisibility(style == 1 ? View.VISIBLE : View.GONE);
|
|
|
|
|
cockpitPane.setVisibility(style == 2 ? View.VISIBLE : View.GONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Tiles (the cards), Dashboard (gauges) or Cockpit (rings); all are fed on every reading. */
|
|
|
|
|
/** Tiles (the cards), Gauges (needles) or Cockpit (rings); all are fed on every reading. */
|
|
|
|
|
private void bindOverviewStyle() {
|
|
|
|
|
String[] labels = { getString(R.string.overview_style_tiles), getString(R.string.overview_style_dashboard),
|
|
|
|
|
String[] labels = { getString(R.string.overview_style_tiles), getString(R.string.overview_style_gauges),
|
|
|
|
|
getString(R.string.overview_style_cockpit) };
|
|
|
|
|
bindChoices(settingsPane.findViewById(R.id.overview_style_choices), labels, overviewStyle(),
|
|
|
|
|
position -> {
|
|
|
|
@@ -1461,15 +1462,15 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void bindDashboard() {
|
|
|
|
|
dashPower = dashboardPane.findViewById(R.id.dash_power);
|
|
|
|
|
dashSpeed = dashboardPane.findViewById(R.id.dash_speed);
|
|
|
|
|
dashBattery = dashboardPane.findViewById(R.id.dash_battery);
|
|
|
|
|
dashBatteryBar = dashboardPane.findViewById(R.id.dash_battery_bar);
|
|
|
|
|
dashGear = dashboardPane.findViewById(R.id.dash_gear);
|
|
|
|
|
dashClimate = dashboardPane.findViewById(R.id.dash_climate);
|
|
|
|
|
dashUsage = dashboardPane.findViewById(R.id.dash_usage);
|
|
|
|
|
dashBatteryText = dashboardPane.findViewById(R.id.dash_battery_text);
|
|
|
|
|
private void bindGauges() {
|
|
|
|
|
dashPower = gaugesPane.findViewById(R.id.dash_power);
|
|
|
|
|
dashSpeed = gaugesPane.findViewById(R.id.dash_speed);
|
|
|
|
|
dashBattery = gaugesPane.findViewById(R.id.dash_battery);
|
|
|
|
|
dashBatteryBar = gaugesPane.findViewById(R.id.dash_battery_bar);
|
|
|
|
|
dashGear = gaugesPane.findViewById(R.id.dash_gear);
|
|
|
|
|
dashClimate = gaugesPane.findViewById(R.id.dash_climate);
|
|
|
|
|
dashUsage = gaugesPane.findViewById(R.id.dash_usage);
|
|
|
|
|
dashBatteryText = gaugesPane.findViewById(R.id.dash_battery_text);
|
|
|
|
|
dashPower.configure(-50f, 150f, 50f, 5, getString(R.string.dash_unit_kw));
|
|
|
|
|
dashSpeed.configure(0f, 180f, 20f, 4, getString(R.string.dash_unit_kmh));
|
|
|
|
|
dashBattery.configure(0f, 100f, 25f, 5, getString(R.string.dash_unit_battery));
|
|
|
|
@@ -1538,7 +1539,7 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** The gauges and the strip; every value null-safe ("—", no needle). */
|
|
|
|
|
private void showDashboard(EnergySnapshot s) {
|
|
|
|
|
private void showGauges(EnergySnapshot s) {
|
|
|
|
|
if (dashPower == null) return;
|
|
|
|
|
Float power = s.getBatteryPowerKw();
|
|
|
|
|
dashPower.setValue(power, power == null ? null : String.format(java.util.Locale.US, "%.1f", power), null);
|
|
|
|
@@ -1575,7 +1576,7 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
vehTireFr.setText(unit.format(s.getTirePressures().getFrontRightKpa()));
|
|
|
|
|
vehTireRl.setText(unit.format(s.getTirePressures().getRearLeftKpa()));
|
|
|
|
|
vehTireRr.setText(unit.format(s.getTirePressures().getRearRightKpa()));
|
|
|
|
|
showDashboard(s);
|
|
|
|
|
showGauges(s);
|
|
|
|
|
showCockpit(s);
|
|
|
|
|
} catch (Throwable ignored) {
|
|
|
|
|
// Leave the last good reading on screen.
|
|
|
|
|