App 2.14.4: all UI text in strings.xml
The Charging, Consumption and Settings labels, toasts, the trip-reset dialog, the charging and Wi-Fi states, the daily summary and the "—" placeholder move from layouts and code into strings.xml; lint now reports no hard-coded text. Upload-log entries stay in code, as log text. No visible change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QLJfZQZeAKAwSqViTmLzki
This commit is contained in:
@@ -1218,9 +1218,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
String ssid = wifi.currentSsid();
|
||||
wifiSsid.setText(ssid == null ? getString(R.string.wifi_not_connected) : ssid);
|
||||
if (ssid != null) {
|
||||
wifiState.setText("Connected ♥");
|
||||
wifiState.setText(R.string.wifi_connected);
|
||||
} else if (!wifi.isWifiEnabled()) {
|
||||
wifiState.setText("Wi-Fi off");
|
||||
wifiState.setText(R.string.wifi_off);
|
||||
}
|
||||
// Left alone otherwise: a message the button just set says more about what is
|
||||
// happening than "not connected" would.
|
||||
@@ -1378,11 +1378,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
selectPeriodButton(R.id.consumption_lifetime);
|
||||
consumptionReset.setOnClickListener(v -> {
|
||||
if (consumptionPeriod != ConsumptionTracker.Period.TRIP_A && consumptionPeriod != ConsumptionTracker.Period.TRIP_B) return;
|
||||
String name = consumptionPeriod == ConsumptionTracker.Period.TRIP_A ? "Trip A" : "Trip B";
|
||||
new MaterialAlertDialogBuilder(this).setTitle("Reset " + name + "?")
|
||||
.setMessage("This counter's recorded consumption history will be permanently deleted.")
|
||||
.setNegativeButton("Cancel", null)
|
||||
.setPositiveButton("Reset", (d, w) -> {
|
||||
String name = getString(consumptionPeriod == ConsumptionTracker.Period.TRIP_A
|
||||
? R.string.consumption_trip_a : R.string.consumption_trip_b);
|
||||
new MaterialAlertDialogBuilder(this).setTitle(getString(R.string.trip_reset_title, name))
|
||||
.setMessage(R.string.trip_reset_message)
|
||||
.setNegativeButton(R.string.pair_cancel, null)
|
||||
.setPositiveButton(R.string.trip_reset_confirm, (d, w) -> {
|
||||
consumptionTracker.reset(consumptionPeriod);
|
||||
refreshConsumption();
|
||||
}).show();
|
||||
@@ -1409,9 +1410,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
if (!consumptionTracker.setSohPercent(value)) throw new NumberFormatException();
|
||||
consumptionSohLayout.setError(null);
|
||||
consumptionSohInput.setText(String.format(java.util.Locale.US, "%.1f", value));
|
||||
Toast.makeText(this, "SoH saved", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(this, R.string.soh_saved, Toast.LENGTH_SHORT).show();
|
||||
} catch (NumberFormatException e) {
|
||||
consumptionSohLayout.setError("Enter a value between 1 and 100");
|
||||
consumptionSohLayout.setError(getString(R.string.soh_invalid));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1469,9 +1470,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
if (!chargeSessionTracker.setPricePerKwh(value)) throw new NumberFormatException();
|
||||
chargePriceLayout.setError(null);
|
||||
chargePriceInput.setText(String.format(java.util.Locale.US, "%.2f", value));
|
||||
Toast.makeText(this, "Charging price saved", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(this, R.string.price_saved, Toast.LENGTH_SHORT).show();
|
||||
} catch (NumberFormatException e) {
|
||||
chargePriceLayout.setError("Enter a valid €/kWh value");
|
||||
chargePriceLayout.setError(getString(R.string.price_invalid));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1486,9 +1487,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
// below — which then describe the previous DC session — be read as this charge.
|
||||
boolean dc = ChargingState.isDcCharging(
|
||||
code, s.getChargePortConnected(), s.getBatteryPowerKw(), s.getSpeedKmh());
|
||||
chargeStatus.setText(dc ? "DC fast charging"
|
||||
: charging ? "AC charging (not metered)"
|
||||
: (session.startedAtMs > 0 ? "Last charge" : "Not charging"));
|
||||
chargeStatus.setText(dc ? R.string.charge_dc
|
||||
: charging ? R.string.charge_ac_not_metered
|
||||
: (session.startedAtMs > 0 ? R.string.charge_last : R.string.charging_not_charging));
|
||||
chargeSoc.setText(fmt(s.getSocPercent(), "%.1f %%"));
|
||||
chargeStartSoc.setText(fmt(session.startSocPercent, "%.1f %%"));
|
||||
chargeVoltage.setText(fmt(s.getBatteryVoltageV(), "%.1f V"));
|
||||
@@ -1529,13 +1530,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
ConsumptionTracker.Totals day = cloudDay(selectedConsumptionDate);
|
||||
if (day == null) day = consumptionTracker.totalsForDay(selectedConsumptionDate);
|
||||
if (day.km == 0 && day.kwh == 0 && day.hours == 0 && day.soc == 0) {
|
||||
consumptionDailyHistory.setText("No records for this date");
|
||||
consumptionDailyHistory.setText(R.string.consumption_no_records);
|
||||
} else {
|
||||
String average = day.km < 0.1 ? "—" : String.format(java.util.Locale.getDefault(),
|
||||
"%.1f kWh/100 km", day.kwh * 100d / day.km);
|
||||
long dayMinutes = Math.round(day.hours * 60d);
|
||||
consumptionDailyHistory.setText(String.format(java.util.Locale.getDefault(),
|
||||
"Distance %.1f km\nEnergy %.2f kWh\nAverage %s\nDuration %d h %02d min\nSOC change %.1f %%",
|
||||
consumptionDailyHistory.setText(getString(R.string.consumption_day_summary,
|
||||
day.km, day.kwh, average, dayMinutes / 60, dayMinutes % 60, day.soc));
|
||||
}
|
||||
}
|
||||
@@ -1598,21 +1598,21 @@ public class MainActivity extends AppCompatActivity {
|
||||
* The codes are the vehicle's own — see EVHardware.PROP_VENDOR_CHARGE_STATUS. An
|
||||
* unrecognised code is shown as itself rather than guessed at.
|
||||
*/
|
||||
private static String chargingLabel(EnergySnapshot s) {
|
||||
private String chargingLabel(EnergySnapshot s) {
|
||||
Integer status = s.getChargingStatus();
|
||||
if (status != null) {
|
||||
switch (status) {
|
||||
case 1: return "AC charging ♥";
|
||||
case 10: return "DC fast charging ♥";
|
||||
case 5: return "Connecting…";
|
||||
case 7: return "Plugged in, not charging";
|
||||
case 8: return "Stopped";
|
||||
case 0: return "Not charging";
|
||||
default: return "Status " + status;
|
||||
case 1: return getString(R.string.charge_status_ac);
|
||||
case 10: return getString(R.string.charge_status_dc);
|
||||
case 5: return getString(R.string.charge_status_connecting);
|
||||
case 7: return getString(R.string.charge_status_plugged);
|
||||
case 8: return getString(R.string.charge_status_stopped);
|
||||
case 0: return getString(R.string.charging_not_charging);
|
||||
default: return getString(R.string.charge_status_code, status);
|
||||
}
|
||||
}
|
||||
Boolean plugged = s.getChargePortConnected();
|
||||
if (plugged != null) return plugged ? "Connected ♥" : "Not connected";
|
||||
if (plugged != null) return getString(plugged ? R.string.charge_status_connected : R.string.charge_status_unplugged);
|
||||
return "—";
|
||||
}
|
||||
|
||||
@@ -1652,7 +1652,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
consumptionCloudClient.invalidateHistory();
|
||||
runOnUiThread(() -> {
|
||||
refreshConsumption();
|
||||
Toast.makeText(this, "Consumption refreshed", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(this, R.string.consumption_refreshed, Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
}, "cloud-refresh").start();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user