App 2.11.0, server 2.3.0: live data straight to ABRP; settings regrouped

ABRP keeps getting live data while the car server is down: with an ABRP
API key and user token set in the app (Live data tab, or abrp_api_key /
abrp_token in the config file), the car sends the newest sample to ABRP
itself at every upload. It tells the server the newest sample ABRP took
(abrpSentUtc), and the server forwards only newer ones, so ABRP gets
each sample once. Without credentials in the app the server forwards
everything, as before. The credentials sit in encrypted storage, go in
the request body, and neither they nor ABRP's answer are logged.

Settings are grouped by what they are for:
- Live data (was Upload): on/off, ABRP credentials, upload frequency.
- Settings (replaces the Wi-Fi tab): full screen and voice key,
  usable capacity and manual SoH (were on Consumption), charging price
  (was on Charging), Wi-Fi.
Charging and Live data get icons of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QLJfZQZeAKAwSqViTmLzki
This commit is contained in:
2026-10-18 12:15:21 +02:00
co-authored by Claude Opus 5.5
parent 087f193f8c
commit ca2f899403
36 changed files with 636 additions and 163 deletions
+21 -13
View File
@@ -47,32 +47,36 @@ vehicle there, so every value shows as a dash).
## How it fits together ## How it fits together
``` ```
car ──live telemetry───▶ car.k8s.stinnesbeck.com (Go) ──▶ ABRP car ──live telemetry───▶ car.k8s.stinnesbeck.com (Go) ──▶ ABRP (what the car did not send)
──daily chunks─────▶ │ │ ──daily chunks─────▶ │
──charging sessions▶ ▼ │ ──charging sessions▶ ▼
InfluxDB 2 ◀── Grafana │ InfluxDB 2 ◀── Grafana
└──live telemetry (optional, direct)──────────────────▶ ABRP
``` ```
The ABRP credentials live only on the server, never in the APK. The car authenticates with a With ABRP credentials set in the app (Live data tab), the car sends live data to ABRP itself,
token of its own, obtained by pairing with a phone (below). so ABRP keeps getting it while the server is down; the server then forwards only samples the
car could not deliver. Without them in the app, the server forwards everything with its own
ABRP credentials. The car authenticates with the server using a token of its own, obtained by
pairing with a phone (below).
## The app ## The app
| Tab | What it shows | | Tab | What it shows |
|---|---| |---|---|
| **Overview** | Battery, range, range estimates at current power and at the 5-minute average, power, speed; odometer, climate setpoint and tyre pressures | | **Overview** | Battery, range, range since start and at the 5-minute average with their usage, power, speed; odometer, climate setpoint and tyre pressures |
| **Consumption** | Daily and period consumption, efficiency | | **Consumption** | Daily and period consumption, efficiency |
| **Charging** | Charging sessions and curves, cost in euro | | **Charging** | Charging sessions and curves, cost in euro |
| **Upload** | Live telemetry on/off, full screen, voice key, upload cadence | | **Live data** | Live data on/off, ABRP credentials for sending directly from the car, upload frequency |
| **Server** | Server URL, pairing by QR code, ingest token, installation ID, config import | | **Server** | Server URL, pairing by QR code, ingest token, installation ID, config import |
| **Wi-Fi** | Joins a network the head unit already knows (e.g. the phone hotspot) | | **Settings** | Full screen, voice key, battery (usable capacity, manual SoH), charging price, Wi-Fi |
| **Logs** | Upload log and the last steering-wheel key reports | | **Logs** | Upload log and the last steering-wheel key reports |
- **Opening the app:** the MG4 launcher does not list third-party apps. **Double-press the - **Opening the app:** the MG4 launcher does not list third-party apps. **Double-press the
voice key** on the steering wheel and the app comes to the front (switch on the Upload tab, voice key** on the steering wheel and the app comes to the front (switch on the Settings
on by default). tab, on by default).
- **Full screen:** hides SAIC's top and bottom bars while the app is open; a swipe from the - **Full screen:** hides SAIC's top and bottom bars while the app is open; a swipe from the
edge shows them briefly (Upload tab, on by default). edge shows them briefly (Settings tab, on by default).
- **Live telemetry:** every 15 s while driving or charging, much less often while parked. A - **Live telemetry:** every 15 s while driving or charging, much less often while parked. A
value the car cannot read is left out, never sent as zero, so ABRP is never told the battery value the car cannot read is left out, never sent as zero, so ABRP is never told the battery
is empty because a read failed. is empty because a read failed.
@@ -113,7 +117,9 @@ pointed at this repository's releases (see `SPECS.md`).
2. On the **Server** tab the URL is already `https://car.k8s.stinnesbeck.com`. 2. On the **Server** tab the URL is already `https://car.k8s.stinnesbeck.com`.
3. Tap **Pair with phone**. Scan the QR code with a phone (or open the address shown and enter 3. Tap **Pair with phone**. Scan the QR code with a phone (or open the address shown and enter
the code), and approve with the server's approval password. The car receives its token. the code), and approve with the server's approval password. The car receives its token.
4. On the **Upload** tab, turn live telemetry on. The service starts with the car from then on. 4. On the **Live data** tab, turn live data on. The service starts with the car from then on.
5. Optional: enter your ABRP API key and user token on the same tab, so the car also sends
live data straight to ABRP.
### Config file ### Config file
@@ -135,6 +141,8 @@ installation_id = only to carry over history from an install older than 2.9.0
interval_sec = 60 # 15 / 30 / 60 / 120 / 300 interval_sec = 60 # 15 / 30 / 60 / 120 / 300
boost_low_soc = true boost_low_soc = true
low_soc_percent = 20 low_soc_percent = 20
abrp_api_key = optional: your ABRP API key, to send to ABRP directly
abrp_token = optional: your ABRP user token
``` ```
After a successful import the app deletes the file, since it holds the token; credentials live After a successful import the app deletes the file, since it holds the token; credentials live
+10
View File
@@ -112,6 +112,16 @@ tyre pressures, GPS (lat, lon, elevation, heading) and the is_* flags. It does *
INGEST_TOKEN) into git and pushed it. Commit amended and force-pushed; both values regenerated in INGEST_TOKEN) into git and pushed it. Commit amended and force-pushed; both values regenerated in
the now gitignored `k8s/secrets.yaml` (since moved to `k8s/secrets/secrets.yaml`, outside the now gitignored `k8s/secrets.yaml` (since moved to `k8s/secrets/secrets.yaml`, outside
`kubectl apply -f k8s/`). Filled-in secrets live only there from now on. `kubectl apply -f k8s/`). Filled-in secrets live only there from now on.
- 2026-10-18 — App 2.11.0, server 2.3.0:
- Live data goes to ABRP straight from the car when ABRP credentials are set in the app
(Live data tab or config file: `abrp_api_key`, `abrp_token`), so ABRP keeps getting it
while the server is down. The car tells the server the newest sample ABRP took
(`abrpSentUtc`); the server forwards only newer ones. Without credentials in the app the
server forwards as before. This deliberately puts ABRP credentials in the car again
(encrypted, never logged).
- Settings regrouped: Live data (on/off, ABRP, frequency), Server, Settings (full screen, voice
key, usable capacity and SoH from Consumption, charging price from Charging, Wi-Fi, which
lost its own tab). Charging and Live data have their own icons.
- 2026-10-18 — App 2.10.2: the range shows "∞" instead of "> 999 km" while recuperating. - 2026-10-18 — App 2.10.2: the range shows "∞" instead of "> 999 km" while recuperating.
- 2026-10-18 — App 2.10.1: net regeneration (recuperating downhill) shows as negative usage, and - 2026-10-18 — App 2.10.1: net regeneration (recuperating downhill) shows as negative usage, and
the range as "> 999 km" with "while recuperating", instead of "needs a few minutes of driving". the range as "> 999 km" with "while recuperating", instead of "needs a few minutes of driving".
+2 -2
View File
@@ -34,8 +34,8 @@ android {
applicationId "com.stinnesbeck.nilsmg4" applicationId "com.stinnesbeck.nilsmg4"
minSdk 27 minSdk 27
targetSdk 36 targetSdk 36
versionCode 72 versionCode 73
versionName "2.10.2" versionName "2.11.0"
// Nothing about the server ships in the APK: its URL and ingest token are entered in // Nothing about the server ships in the APK: its URL and ingest token are entered in
// the app's Server tab (ServerConfig), and the database is only reachable by the server. // the app's Server tab (ServerConfig), and the database is only reachable by the server.
@@ -0,0 +1,59 @@
package com.evsuite.abrp;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
/**
* ABRP's telemetry API, for sending live data straight from the car.
*
* Credentials go in the POST body, never in the query string: a URL travels through proxies,
* access logs and crash reports, a body does not. Neither is ever logged.
*/
final class AbrpApi {
/** No query string: credentials travel in the body, so the URL is a constant. */
static final String SEND_URL = "https://api.iternio.com/1/tlm/send";
/**
* Read-only endpoint used to check credentials. The Test button must never touch
* /tlm/send: a placeholder sample would tell ABRP the car really is in that state and
* corrupt a live route plan.
*/
static final String VERIFY_URL = "https://api.iternio.com/1/tlm/get_next_charge";
private AbrpApi() { }
/** Posts one tlm sample. Throws on a network failure. */
static ServerHttp.Response send(AbrpConfig config, String tlmJson) throws Exception {
byte[] body = formBody(config.apiKey, config.userToken, tlmJson).getBytes(StandardCharsets.UTF_8);
return ServerHttp.send("POST", SEND_URL, null, "application/x-www-form-urlencoded", body);
}
/**
* Checks the credentials without writing anything. This endpoint only takes the token as a
* query parameter; the API key goes in the Authorization header. One token in one URL when
* the user presses Test beats writing fake telemetry on every press.
*/
static ServerHttp.Response verify(AbrpConfig config) throws Exception {
String url = VERIFY_URL + "?token=" + URLEncoder.encode(config.userToken, StandardCharsets.UTF_8.name());
return ServerHttp.send("GET", url, "APIKEY " + config.apiKey, null, null);
}
/** The form body: credentials and the sample, each URL-encoded. */
static String formBody(String apiKey, String userToken, String tlmJson) throws Exception {
String utf8 = StandardCharsets.UTF_8.name();
return "api_key=" + URLEncoder.encode(apiKey, utf8)
+ "&token=" + URLEncoder.encode(userToken, utf8)
+ "&tlm=" + URLEncoder.encode(tlmJson, utf8);
}
/** ABRP answers 200 with {"status":"ok"}; anything else is a rejection. */
static boolean accepted(ServerHttp.Response response) {
if (!response.ok()) return false;
try {
return "ok".equals(new org.json.JSONObject(response.body).optString("status"));
} catch (Exception e) {
return false;
}
}
}
@@ -0,0 +1,63 @@
package com.evsuite.abrp;
import android.content.Context;
import android.content.SharedPreferences;
/**
* The ABRP credentials for sending live data straight from the car: the API key (which app is
* sending) and the user token (which car in which ABRP account). Kept in {@link SecurePrefs}
* next to the server settings, entered on the Live data tab or imported from a config file.
*
* With both set, the car sends to ABRP itself, so ABRP keeps getting live data when the car
* server is down; the server then only forwards what the car could not deliver. Without them,
* the server forwards as before.
*/
final class AbrpConfig {
static final String KEY_API_KEY = "abrp_api_key";
static final String KEY_USER_TOKEN = "abrp_user_token";
final String apiKey;
final String userToken;
private static volatile AbrpConfig current;
AbrpConfig(String apiKey, String userToken) {
this.apiKey = apiKey;
this.userToken = userToken;
}
boolean isConfigured() {
return !apiKey.isEmpty() && !userToken.isEmpty();
}
static AbrpConfig get(Context context) {
AbrpConfig config = current;
if (config != null) return config;
synchronized (AbrpConfig.class) {
if (current == null) {
SharedPreferences prefs = SecurePrefs.get(context);
current = new AbrpConfig(prefs.getString(KEY_API_KEY, ""), prefs.getString(KEY_USER_TOKEN, ""));
}
return current;
}
}
/** Stores trimmed values; empty strings switch direct sending off. */
static synchronized void save(Context context, String apiKey, String userToken) {
String key = apiKey == null ? "" : apiKey.trim();
String token = userToken == null ? "" : userToken.trim();
SecurePrefs.get(context).edit()
.putString(KEY_API_KEY, key)
.putString(KEY_USER_TOKEN, token)
.apply();
current = new AbrpConfig(key, token);
}
/** Plausible as an ABRP credential: no spaces, not absurdly short or long. */
static boolean isPlausible(String value) {
if (value == null) return false;
String v = value.trim();
return v.length() >= 8 && v.length() <= 200 && !v.contains(" ");
}
}
@@ -173,7 +173,9 @@ public class AbrpUploadService extends Service {
} }
UploadSettings settings = UploadSettings.from(prefs); UploadSettings settings = UploadSettings.from(prefs);
if (!ServerConfig.get(this).isConfigured()) { // Live data goes to the server, to ABRP directly, or both; with neither set up there is
// nowhere to send it.
if (!ServerConfig.get(this).isConfigured() && !AbrpConfig.get(this).isConfigured()) {
telemetryUploader.stop(); // no live telemetry, so no GPS either telemetryUploader.stop(); // no live telemetry, so no GPS either
updateNotification(getString(R.string.server_not_configured)); updateNotification(getString(R.string.server_not_configured));
} else if (!settings.abrpUploadEnabled) { } else if (!settings.abrpUploadEnabled) {
@@ -13,6 +13,8 @@ package com.evsuite.abrp;
* interval_sec = 60 * interval_sec = 60
* boost_low_soc = true * boost_low_soc = true
* low_soc_percent = 20 * low_soc_percent = 20
* abrp_api_key = your-abrp-api-key (optional: send live data to ABRP directly)
* abrp_token = your-abrp-user-token
* </pre> * </pre>
* *
* Usually only server_url and token are needed. installation_id is for a reinstall: it puts * Usually only server_url and token are needed. installation_id is for a reinstall: it puts
@@ -29,25 +31,29 @@ final class ConfigImport {
final Integer intervalSec; final Integer intervalSec;
final Boolean boostLowSoc; final Boolean boostLowSoc;
final Integer lowSocPercent; final Integer lowSocPercent;
final String abrpApiKey;
final String abrpToken;
private ConfigImport(String serverUrl, String token, String installationId, Integer intervalSec, private ConfigImport(String serverUrl, String token, String installationId, Integer intervalSec,
Boolean boostLowSoc, Integer lowSocPercent) { Boolean boostLowSoc, Integer lowSocPercent, String abrpApiKey, String abrpToken) {
this.serverUrl = serverUrl; this.serverUrl = serverUrl;
this.token = token; this.token = token;
this.installationId = installationId; this.installationId = installationId;
this.intervalSec = intervalSec; this.intervalSec = intervalSec;
this.boostLowSoc = boostLowSoc; this.boostLowSoc = boostLowSoc;
this.lowSocPercent = lowSocPercent; this.lowSocPercent = lowSocPercent;
this.abrpApiKey = abrpApiKey;
this.abrpToken = abrpToken;
} }
/** True when the file yielded nothing usable — an empty or malformed file, not a config. */ /** True when the file yielded nothing usable — an empty or malformed file, not a config. */
boolean isEmpty() { boolean isEmpty() {
return serverUrl == null && token == null && installationId == null && intervalSec == null return serverUrl == null && token == null && installationId == null && intervalSec == null
&& boostLowSoc == null && lowSocPercent == null; && boostLowSoc == null && lowSocPercent == null && abrpApiKey == null && abrpToken == null;
} }
static ConfigImport parse(String text) { static ConfigImport parse(String text) {
String serverUrl = null, token = null, installationId = null; String serverUrl = null, token = null, installationId = null, abrpApiKey = null, abrpToken = null;
Integer intervalSec = null, lowSocPercent = null; Integer intervalSec = null, lowSocPercent = null;
Boolean boostLowSoc = null; Boolean boostLowSoc = null;
@@ -85,13 +91,21 @@ final class ConfigImport {
case "low_soc_percent": case "low_soc_percent":
lowSocPercent = clampPercent(value); lowSocPercent = clampPercent(value);
break; break;
case "abrp_api_key":
abrpApiKey = value;
break;
case "abrp_token":
case "abrp_user_token":
abrpToken = value;
break;
default: default:
// Unknown keys are ignored rather than rejected, so a file can carry // Unknown keys are ignored rather than rejected, so a file can carry
// comments or future keys without breaking an older build. // comments or future keys without breaking an older build.
break; break;
} }
} }
return new ConfigImport(serverUrl, token, installationId, intervalSec, boostLowSoc, lowSocPercent); return new ConfigImport(serverUrl, token, installationId, intervalSec, boostLowSoc, lowSocPercent,
abrpApiKey, abrpToken);
} }
/** Snaps to the nearest offered choice: the UI spinner has no free-form interval. */ /** Snaps to the nearest offered choice: the UI spinner has no free-form interval. */
@@ -42,16 +42,16 @@ public class MainActivity extends AppCompatActivity {
/** Navigation destinations in page order. Parallel to {@link #panes}. */ /** Navigation destinations in page order. Parallel to {@link #panes}. */
private static final int[] TAB_IDS = private static final int[] TAB_IDS =
{ R.id.tabVehicle, R.id.tabConsumption, R.id.tabCharging, R.id.tabService, R.id.tabServer, { R.id.tabVehicle, R.id.tabConsumption, R.id.tabCharging, R.id.tabService, R.id.tabServer,
R.id.tabWifi, R.id.tabLog }; R.id.tabSettings, R.id.tabLog };
private static final int[] PAGE_TITLES = { private static final int[] PAGE_TITLES = {
R.string.design_overview_title, R.string.consumption_title, R.string.charging_title, R.string.design_overview_title, R.string.consumption_title, R.string.charging_title,
R.string.design_service_title, R.string.design_server_title, R.string.design_wifi_title, R.string.design_service_title, R.string.design_server_title, R.string.design_settings_title,
R.string.design_log_title R.string.design_log_title
}; };
private static final int[] PAGE_SUBTITLES = { private static final int[] PAGE_SUBTITLES = {
R.string.design_overview_subtitle, R.string.consumption_subtitle, R.string.charging_subtitle, R.string.design_overview_subtitle, R.string.consumption_subtitle, R.string.charging_subtitle,
R.string.design_service_subtitle, R.string.design_server_subtitle, R.string.design_wifi_subtitle, R.string.design_service_subtitle, R.string.design_server_subtitle, R.string.design_settings_subtitle,
R.string.design_log_subtitle R.string.design_log_subtitle
}; };
@@ -70,7 +70,8 @@ public class MainActivity extends AppCompatActivity {
private View vehiclePane; private View vehiclePane;
private View consumptionPane; private View consumptionPane;
private View chargingPane; private View chargingPane;
private View wifiPane; /** Display, battery, charging price and Wi-Fi. */
private View settingsPane;
/** The pages in navigation order. Parallel to {@link #TAB_IDS}. */ /** The pages in navigation order. Parallel to {@link #TAB_IDS}. */
private View[] panes; private View[] panes;
@@ -241,10 +242,10 @@ public class MainActivity extends AppCompatActivity {
vehiclePane = inflatePane(R.layout.pane_vehicle); vehiclePane = inflatePane(R.layout.pane_vehicle);
consumptionPane = inflatePane(R.layout.pane_consumption); consumptionPane = inflatePane(R.layout.pane_consumption);
chargingPane = inflatePane(R.layout.pane_charging); chargingPane = inflatePane(R.layout.pane_charging);
wifiPane = inflatePane(R.layout.pane_wifi); settingsPane = inflatePane(R.layout.pane_settings);
logPane = inflatePane(R.layout.pane_log); logPane = inflatePane(R.layout.pane_log);
panes = new View[] { vehiclePane, consumptionPane, chargingPane, servicePane, serverPane, panes = new View[] { vehiclePane, consumptionPane, chargingPane, servicePane, serverPane,
wifiPane, logPane }; settingsPane, logPane };
bindVehiclePane(); bindVehiclePane();
bindConsumptionPane(); bindConsumptionPane();
@@ -836,6 +837,14 @@ public class MainActivity extends AppCompatActivity {
return false; return false;
} }
} }
if (config.abrpApiKey != null || config.abrpToken != null) {
AbrpConfig abrp = AbrpConfig.get(this);
if (!saveAbrpConfig(config.abrpApiKey != null ? config.abrpApiKey : abrp.apiKey,
config.abrpToken != null ? config.abrpToken : abrp.userToken)) {
setConnectionStatus(COLOR_ERROR, getString(R.string.abrp_invalid));
return false;
}
}
SharedPreferences.Editor edit = prefs.edit(); SharedPreferences.Editor edit = prefs.edit();
if (config.intervalSec != null) edit.putInt(UploadSettings.KEY_INTERVAL_SEC, config.intervalSec); if (config.intervalSec != null) edit.putInt(UploadSettings.KEY_INTERVAL_SEC, config.intervalSec);
if (config.boostLowSoc != null) edit.putBoolean(UploadSettings.KEY_BOOST_LOW_SOC, config.boostLowSoc); if (config.boostLowSoc != null) edit.putBoolean(UploadSettings.KEY_BOOST_LOW_SOC, config.boostLowSoc);
@@ -850,11 +859,11 @@ public class MainActivity extends AppCompatActivity {
// ---------- Upload page ---------- // ---------- Upload page ----------
private void bindServicePane() { private void bindServicePane() {
voiceKeySwitch = servicePane.findViewById(R.id.voice_key_switch); voiceKeySwitch = settingsPane.findViewById(R.id.voice_key_switch);
voiceKeySwitch.setChecked(UploadSettings.voiceKeyOpensApp(prefs)); voiceKeySwitch.setChecked(UploadSettings.voiceKeyOpensApp(prefs));
voiceKeySwitch.setOnCheckedChangeListener((btn, checked) -> voiceKeySwitch.setOnCheckedChangeListener((btn, checked) ->
prefs.edit().putBoolean(UploadSettings.KEY_VOICE_KEY_OPENS, checked).apply()); prefs.edit().putBoolean(UploadSettings.KEY_VOICE_KEY_OPENS, checked).apply());
fullScreenSwitch = servicePane.findViewById(R.id.full_screen_switch); fullScreenSwitch = settingsPane.findViewById(R.id.full_screen_switch);
fullScreenSwitch.setChecked(UploadSettings.fullScreen(prefs)); fullScreenSwitch.setChecked(UploadSettings.fullScreen(prefs));
fullScreenSwitch.setOnCheckedChangeListener((btn, checked) -> { fullScreenSwitch.setOnCheckedChangeListener((btn, checked) -> {
prefs.edit().putBoolean(UploadSettings.KEY_FULL_SCREEN, checked).apply(); prefs.edit().putBoolean(UploadSettings.KEY_FULL_SCREEN, checked).apply();
@@ -871,6 +880,66 @@ public class MainActivity extends AppCompatActivity {
refreshStatus(); refreshStatus();
}); });
bindCadenceControls(); bindCadenceControls();
bindAbrpControls();
}
// ---------- ABRP, directly from the car ----------
private TextInputEditText abrpApiKeyInput, abrpTokenInput;
private TextView abrpStatusText;
private void bindAbrpControls() {
abrpApiKeyInput = servicePane.findViewById(R.id.abrp_api_key_input);
abrpTokenInput = servicePane.findViewById(R.id.abrp_token_input);
abrpStatusText = servicePane.findViewById(R.id.abrp_status_text);
AbrpConfig current = AbrpConfig.get(this);
abrpApiKeyInput.setText(current.apiKey);
abrpTokenInput.setText(current.userToken);
servicePane.findViewById(R.id.abrp_save_button).setOnClickListener(v ->
saveAbrpConfig(text(abrpApiKeyInput), text(abrpTokenInput)));
servicePane.findViewById(R.id.abrp_test_button).setOnClickListener(v -> testAbrpConfig());
}
private static String text(TextInputEditText input) {
CharSequence raw = input.getText();
return raw == null ? "" : raw.toString().trim();
}
/** Both set and plausible, or both empty (direct sending off). Returns whether it saved. */
private boolean saveAbrpConfig(String apiKey, String token) {
boolean clear = apiKey.isEmpty() && token.isEmpty();
if (!clear && !(AbrpConfig.isPlausible(apiKey) && AbrpConfig.isPlausible(token))) {
abrpStatusText.setText(R.string.abrp_invalid);
return false;
}
AbrpConfig.save(this, apiKey, token);
abrpApiKeyInput.setText(apiKey);
abrpTokenInput.setText(token);
abrpStatusText.setText(clear ? R.string.abrp_cleared : R.string.abrp_saved);
refreshStatus();
return true;
}
/** Read-only check against ABRP; never sends telemetry. Off the main thread. */
private void testAbrpConfig() {
AbrpConfig config = new AbrpConfig(text(abrpApiKeyInput), text(abrpTokenInput));
if (!config.isConfigured()) {
abrpStatusText.setText(R.string.abrp_not_set);
return;
}
abrpStatusText.setText(R.string.abrp_testing);
new Thread(() -> {
String message;
try {
ServerHttp.Response response = AbrpApi.verify(config);
message = response.ok() ? getString(R.string.abrp_test_ok)
: getString(R.string.abrp_test_failed, response.status);
} catch (Exception e) {
message = getString(R.string.abrp_test_offline, e.getClass().getSimpleName());
}
String shown = message;
runOnUiThread(() -> abrpStatusText.setText(shown));
}, "abrp-test").start();
} }
/** The service reads these settings on every tick, so a change applies without a restart. */ /** The service reads these settings on every tick, so a change applies without a restart. */
@@ -946,16 +1015,16 @@ public class MainActivity extends AppCompatActivity {
private void bindWifiPane() { private void bindWifiPane() {
wifi = new WifiAutoConnect(getApplicationContext()); wifi = new WifiAutoConnect(getApplicationContext());
wifiSsid = wifiPane.findViewById(R.id.wifi_ssid); wifiSsid = settingsPane.findViewById(R.id.wifi_ssid);
wifiState = wifiPane.findViewById(R.id.wifi_state); wifiState = settingsPane.findViewById(R.id.wifi_state);
wifiSavedList = wifiPane.findViewById(R.id.wifi_saved_list); wifiSavedList = settingsPane.findViewById(R.id.wifi_saved_list);
SwitchMaterial auto = wifiPane.findViewById(R.id.wifi_auto_switch); SwitchMaterial auto = settingsPane.findViewById(R.id.wifi_auto_switch);
auto.setChecked(prefs.getBoolean(WIFI_AUTO_KEY, true)); auto.setChecked(prefs.getBoolean(WIFI_AUTO_KEY, true));
auto.setOnCheckedChangeListener((btn, checked) -> auto.setOnCheckedChangeListener((btn, checked) ->
prefs.edit().putBoolean(WIFI_AUTO_KEY, checked).apply()); prefs.edit().putBoolean(WIFI_AUTO_KEY, checked).apply());
wifiPane.findViewById(R.id.wifi_connect_button).setOnClickListener(v -> { settingsPane.findViewById(R.id.wifi_connect_button).setOnClickListener(v -> {
// force: the driver is asking now, so the rate limit does not apply. // force: the driver is asking now, so the rate limit does not apply.
WifiAutoConnect.Result r = wifi.ensureConnected(true); WifiAutoConnect.Result r = wifi.ensureConnected(true);
wifiState.setText(r.message); wifiState.setText(r.message);
@@ -1099,16 +1168,16 @@ public class MainActivity extends AppCompatActivity {
consumptionDateButton.setOnClickListener(v -> showConsumptionDatePicker()); consumptionDateButton.setOnClickListener(v -> showConsumptionDatePicker());
consumptionPane.findViewById(R.id.consumption_refresh).setOnClickListener(v -> refreshFromCloud()); consumptionPane.findViewById(R.id.consumption_refresh).setOnClickListener(v -> refreshFromCloud());
consumptionReset = consumptionPane.findViewById(R.id.consumption_reset); consumptionReset = consumptionPane.findViewById(R.id.consumption_reset);
consumptionSohLayout = consumptionPane.findViewById(R.id.consumption_soh_layout); consumptionSohLayout = settingsPane.findViewById(R.id.consumption_soh_layout);
consumptionSohInput = consumptionPane.findViewById(R.id.consumption_soh_input); consumptionSohInput = settingsPane.findViewById(R.id.consumption_soh_input);
Float savedSoh = consumptionTracker.sohPercent(); Float savedSoh = consumptionTracker.sohPercent();
if (savedSoh != null) consumptionSohInput.setText(String.format( if (savedSoh != null) consumptionSohInput.setText(String.format(
java.util.Locale.US, "%.1f", savedSoh)); java.util.Locale.US, "%.1f", savedSoh));
consumptionPane.findViewById(R.id.consumption_soh_save).setOnClickListener(v -> saveSoh()); settingsPane.findViewById(R.id.consumption_soh_save).setOnClickListener(v -> saveSoh());
usableCapacityLayout = consumptionPane.findViewById(R.id.usable_capacity_layout); usableCapacityLayout = settingsPane.findViewById(R.id.usable_capacity_layout);
usableCapacityInput = consumptionPane.findViewById(R.id.usable_capacity_input); usableCapacityInput = settingsPane.findViewById(R.id.usable_capacity_input);
usableCapacityInput.setText(String.format(java.util.Locale.US, "%.1f", usableKwh())); usableCapacityInput.setText(String.format(java.util.Locale.US, "%.1f", usableKwh()));
consumptionPane.findViewById(R.id.usable_capacity_save).setOnClickListener(v -> saveUsableCapacity()); settingsPane.findViewById(R.id.usable_capacity_save).setOnClickListener(v -> saveUsableCapacity());
bindPeriodButton(R.id.consumption_lifetime, ConsumptionTracker.Period.LIFETIME); bindPeriodButton(R.id.consumption_lifetime, ConsumptionTracker.Period.LIFETIME);
bindPeriodButton(R.id.consumption_week, ConsumptionTracker.Period.WEEK); bindPeriodButton(R.id.consumption_week, ConsumptionTracker.Period.WEEK);
bindPeriodButton(R.id.consumption_month, ConsumptionTracker.Period.MONTH); bindPeriodButton(R.id.consumption_month, ConsumptionTracker.Period.MONTH);
@@ -1192,11 +1261,11 @@ public class MainActivity extends AppCompatActivity {
chargeTotalCost = chargingPane.findViewById(R.id.charge_total_cost); chargeTotalCost = chargingPane.findViewById(R.id.charge_total_cost);
chargeGraph = chargingPane.findViewById(R.id.charge_graph); chargeGraph = chargingPane.findViewById(R.id.charge_graph);
chargeCurveTable = chargingPane.findViewById(R.id.charge_curve_table); chargeCurveTable = chargingPane.findViewById(R.id.charge_curve_table);
chargePriceLayout = chargingPane.findViewById(R.id.charge_price_layout); chargePriceLayout = settingsPane.findViewById(R.id.charge_price_layout);
chargePriceInput = chargingPane.findViewById(R.id.charge_price_input); chargePriceInput = settingsPane.findViewById(R.id.charge_price_input);
chargePriceInput.setText(String.format(java.util.Locale.US, "%.2f", chargePriceInput.setText(String.format(java.util.Locale.US, "%.2f",
chargeSessionTracker.pricePerKwh())); chargeSessionTracker.pricePerKwh()));
chargingPane.findViewById(R.id.charge_price_save).setOnClickListener(v -> saveChargePrice()); settingsPane.findViewById(R.id.charge_price_save).setOnClickListener(v -> saveChargePrice());
} }
private void saveChargePrice() { private void saveChargePrice() {
@@ -1446,9 +1515,13 @@ public class MainActivity extends AppCompatActivity {
break; break;
case RUNNING: case RUNNING:
case STARTING: case STARTING:
if (!ServerConfig.get(this).isConfigured()) { boolean server = ServerConfig.get(this).isConfigured();
if (!server && !AbrpConfig.get(this).isConfigured()) {
statusText.setText(R.string.server_not_configured); statusText.setText(R.string.server_not_configured);
statusText.setTextColor(COLOR_ERROR); statusText.setTextColor(COLOR_ERROR);
} else if (!server && UploadSettings.from(prefs).abrpUploadEnabled) {
statusText.setText(R.string.state_abrp_only);
statusText.setTextColor(COLOR_PENDING);
} else if (!UploadSettings.from(prefs).abrpUploadEnabled) { } else if (!UploadSettings.from(prefs).abrpUploadEnabled) {
statusText.setText(R.string.state_tracking_locally); statusText.setText(R.string.state_tracking_locally);
statusText.setTextColor(COLOR_PENDING); statusText.setTextColor(COLOR_PENDING);
@@ -10,7 +10,8 @@ import java.net.URL;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
/** /**
* One JSON request to the car server, shared by telemetry, consumption sync and pairing. * One JSON request to the car server, shared by telemetry, consumption sync and pairing (and,
* through {@link #send}, the direct ABRP upload).
* Blocking, with short timeouts — call it off the main thread. * Blocking, with short timeouts — call it off the main thread.
* *
* The token goes in the Authorization header, never the URL, and is never logged. The answer * The token goes in the Authorization header, never the URL, and is never logged. The answer
@@ -48,17 +49,26 @@ final class ServerHttp {
* {@code token} may be null for the unauthenticated pairing calls. * {@code token} may be null for the unauthenticated pairing calls.
*/ */
static Response request(String method, String url, String token, JSONObject json) throws Exception { static Response request(String method, String url, String token, JSONObject json) throws Exception {
byte[] body = json == null ? null : json.toString().getBytes(StandardCharsets.UTF_8);
return send(method, url, token == null ? null : "Bearer " + token, "application/json", body);
}
/**
* The request underneath, also used for ABRP ({@link AbrpApi}): {@code authorization} is the
* whole header value or null, {@code body} null for none.
*/
static Response send(String method, String url, String authorization, String contentType, byte[] body)
throws Exception {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
try { try {
connection.setRequestMethod(method); connection.setRequestMethod(method);
connection.setConnectTimeout(TIMEOUT_MS); connection.setConnectTimeout(TIMEOUT_MS);
connection.setReadTimeout(TIMEOUT_MS); connection.setReadTimeout(TIMEOUT_MS);
if (token != null) connection.setRequestProperty("Authorization", "Bearer " + token); if (authorization != null) connection.setRequestProperty("Authorization", authorization);
if (json != null) { if (body != null) {
byte[] body = json.toString().getBytes(StandardCharsets.UTF_8);
connection.setDoOutput(true); connection.setDoOutput(true);
connection.setFixedLengthStreamingMode(body.length); connection.setFixedLengthStreamingMode(body.length);
connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestProperty("Content-Type", contentType);
try (OutputStream out = connection.getOutputStream()) { out.write(body); } try (OutputStream out = connection.getOutputStream()) { out.write(body); }
} }
int status = connection.getResponseCode(); int status = connection.getResponseCode();
@@ -52,6 +52,9 @@ final class TelemetryQueue {
for (int i = 0; i < count && !samples.isEmpty(); i++) samples.removeFirst(); for (int i = 0; i < count && !samples.isEmpty(); i++) samples.removeFirst();
} }
/** The newest sample, or null when the queue is empty; it stays queued. */
synchronized String newest() { return samples.peekLast(); }
synchronized int size() { return samples.size(); } synchronized int size() { return samples.size(); }
/** Samples lost to the capacity limit since the queue was created. */ /** Samples lost to the capacity limit since the queue was created. */
@@ -152,9 +152,12 @@ final class TelemetryUploader {
// ---------- Upload ---------- // ---------- Upload ----------
private void flush() { private void flush() {
// ABRP first and on its own: live data must not wait for, or fail with, the server.
sendNewestToAbrp();
ServerConfig config = ServerConfig.get(context); ServerConfig config = ServerConfig.get(context);
if (!config.isConfigured()) { if (!config.isConfigured()) {
Log.i(TAG, "Telemetry not sent: server not configured (" + queue.size() + " queued)"); // Kept for the server once one is set up; the queue is bounded.
Log.i(TAG, "Telemetry not sent to a server: none configured (" + queue.size() + " queued)");
return; return;
} }
for (int i = 0; i < MAX_BATCHES_PER_TICK && queue.size() > 0; i++) { for (int i = 0; i < MAX_BATCHES_PER_TICK && queue.size() > 0; i++) {
@@ -190,9 +193,53 @@ final class TelemetryUploader {
JSONObject body = new JSONObject() JSONObject body = new JSONObject()
.put("installationId", config.installationId) .put("installationId", config.installationId)
.put("samples", samples); .put("samples", samples);
// What the car already delivered to ABRP itself; the server forwards only newer samples.
if (lastAbrpUtc > 0) body.put("abrpSentUtc", lastAbrpUtc);
return ServerHttp.request("POST", config.url + "/v1/telemetry", config.token, body); return ServerHttp.request("POST", config.url + "/v1/telemetry", config.token, body);
} }
// ---------- ABRP, directly ----------
/** Older than this, a sample is history rather than live state, and ABRP gets nothing. */
private static final long ABRP_MAX_AGE_S = 5 * 60;
/** Time of the newest sample ABRP accepted from the car; 0 before the first. */
private volatile long lastAbrpUtc;
/**
* Sends the newest queued sample straight to ABRP when ABRP credentials are set: once per
* upload, only if it is newer than the last one sent and still live. It stays queued for
* the server either way.
*/
private void sendNewestToAbrp() {
AbrpConfig abrp = AbrpConfig.get(context);
if (!abrp.isConfigured()) return;
String newest = queue.newest();
if (newest == null) return;
long utc = utcOf(newest);
if (utc <= lastAbrpUtc || System.currentTimeMillis() / 1000 - utc > ABRP_MAX_AGE_S) return;
String summary = TelemetryPayload.summarize(newest);
try {
ServerHttp.Response response = AbrpApi.send(abrp, newest);
boolean ok = AbrpApi.accepted(response);
if (ok) lastAbrpUtc = utc;
// ABRP's answer is not quoted: it can echo the request, credentials included.
AbrpUploadService.log().record(new UploadLog.Entry(System.currentTimeMillis(), response.status, ok,
ok ? "ABRP: live data sent" : "ABRP rejected: HTTP " + response.status, summary));
} catch (Exception e) {
AbrpUploadService.log().record(new UploadLog.Entry(System.currentTimeMillis(), 0, false,
"ABRP offline: " + e.getClass().getSimpleName(), summary));
}
}
static long utcOf(String sampleJson) {
try {
return new JSONObject(sampleJson).optLong("utc", 0L);
} catch (Exception e) {
return 0L;
}
}
/** ", 2 value(s) dropped by the server" when it left anything out, for the upload log. */ /** ", 2 value(s) dropped by the server" when it left anything out, for the upload log. */
static String droppedNote(ServerHttp.Response response) { static String droppedNote(ServerHttp.Response response) {
try { try {
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lightning bolt: the Charging tab. Tinted by @color/nav_tab_foreground. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M13,2L4,14H11L10,22L20,9H13L13,2Z" />
</vector>
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Broadcast waves around a dot: the Live data tab. Tinted by @color/nav_tab_foreground. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M12,10a2,2 0,1 1,0 4a2,2 0,1 1,0 -4z" />
<path
android:strokeColor="#FFFFFFFF"
android:strokeWidth="2"
android:strokeLineCap="round"
android:fillColor="#00000000"
android:pathData="M8.5,8.5A5,5 0,0 0,8.5 15.5M15.5,8.5A5,5 0,0 1,15.5 15.5M5.6,5.6A9,9 0,0 0,5.6 18.4M18.4,5.6A9,9 0,0 1,18.4 18.4" />
</vector>
+1 -1
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Engrenage : onglet Service. Teinté par @color/nav_tab_foreground. --> <!-- Gear: the Settings tab. Tinted by @color/nav_tab_foreground. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
-12
View File
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Wi-Fi arcs, for the Wi-Fi page. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M1,9l2,2c4.97,-4.97 13.03,-4.97 18,0l2,-2C16.93,2.93 7.08,2.93 1,9zM9,17l3,3 3,-3c-1.65,-1.66 -4.34,-1.66 -6,0zM5,13l2,2c2.76,-2.76 7.24,-2.76 10,0l2,-2C15.14,9.14 8.87,9.14 5,13z" />
</vector>
@@ -8,10 +8,10 @@
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/design_brand_caption" android:textAppearance="@style/Text.EV.Secondary" android:paddingStart="14dp" android:layout_marginBottom="24dp" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/design_brand_caption" android:textAppearance="@style/Text.EV.Secondary" android:paddingStart="14dp" android:layout_marginBottom="24dp" />
<com.google.android.material.button.MaterialButton android:id="@+id/tabVehicle" style="@style/Widget.EV.NavTab" android:layout_width="match_parent" android:layout_height="64dp" android:layout_marginBottom="6dp" android:text="@string/tab_vehicle" app:icon="@drawable/ic_tab_vehicle" /> <com.google.android.material.button.MaterialButton android:id="@+id/tabVehicle" style="@style/Widget.EV.NavTab" android:layout_width="match_parent" android:layout_height="64dp" android:layout_marginBottom="6dp" android:text="@string/tab_vehicle" app:icon="@drawable/ic_tab_vehicle" />
<com.google.android.material.button.MaterialButton android:id="@+id/tabConsumption" style="@style/Widget.EV.NavTab" android:layout_width="match_parent" android:layout_height="64dp" android:layout_marginBottom="6dp" android:text="@string/tab_consumption" app:icon="@drawable/ic_tab_vehicle" /> <com.google.android.material.button.MaterialButton android:id="@+id/tabConsumption" style="@style/Widget.EV.NavTab" android:layout_width="match_parent" android:layout_height="64dp" android:layout_marginBottom="6dp" android:text="@string/tab_consumption" app:icon="@drawable/ic_tab_vehicle" />
<com.google.android.material.button.MaterialButton android:id="@+id/tabCharging" style="@style/Widget.EV.NavTab" android:layout_width="match_parent" android:layout_height="64dp" android:layout_marginBottom="6dp" android:text="@string/tab_charging" app:icon="@drawable/ic_tab_service" /> <com.google.android.material.button.MaterialButton android:id="@+id/tabCharging" style="@style/Widget.EV.NavTab" android:layout_width="match_parent" android:layout_height="64dp" android:layout_marginBottom="6dp" android:text="@string/tab_charging" app:icon="@drawable/ic_tab_charging" />
<com.google.android.material.button.MaterialButton android:id="@+id/tabService" style="@style/Widget.EV.NavTab" android:layout_width="match_parent" android:layout_height="64dp" android:layout_marginBottom="6dp" android:text="@string/tab_service" app:icon="@drawable/ic_tab_service" /> <com.google.android.material.button.MaterialButton android:id="@+id/tabService" style="@style/Widget.EV.NavTab" android:layout_width="match_parent" android:layout_height="64dp" android:layout_marginBottom="6dp" android:text="@string/tab_service" app:icon="@drawable/ic_tab_live" />
<com.google.android.material.button.MaterialButton android:id="@+id/tabServer" style="@style/Widget.EV.NavTab" android:layout_width="match_parent" android:layout_height="64dp" android:layout_marginBottom="6dp" android:text="@string/tab_server" app:icon="@drawable/ic_tab_server" /> <com.google.android.material.button.MaterialButton android:id="@+id/tabServer" style="@style/Widget.EV.NavTab" android:layout_width="match_parent" android:layout_height="64dp" android:layout_marginBottom="6dp" android:text="@string/tab_server" app:icon="@drawable/ic_tab_server" />
<com.google.android.material.button.MaterialButton android:id="@+id/tabWifi" style="@style/Widget.EV.NavTab" android:layout_width="match_parent" android:layout_height="64dp" android:layout_marginBottom="6dp" android:text="@string/tab_wifi" app:icon="@drawable/ic_tab_wifi" /> <com.google.android.material.button.MaterialButton android:id="@+id/tabSettings" style="@style/Widget.EV.NavTab" android:layout_width="match_parent" android:layout_height="64dp" android:layout_marginBottom="6dp" android:text="@string/tab_settings" app:icon="@drawable/ic_tab_service" />
<com.google.android.material.button.MaterialButton android:id="@+id/tabLog" style="@style/Widget.EV.NavTab" android:layout_width="match_parent" android:layout_height="64dp" android:layout_marginBottom="6dp" android:text="@string/tab_log" app:icon="@drawable/ic_tab_log" /> <com.google.android.material.button.MaterialButton android:id="@+id/tabLog" style="@style/Widget.EV.NavTab" android:layout_width="match_parent" android:layout_height="64dp" android:layout_marginBottom="6dp" android:text="@string/tab_log" app:icon="@drawable/ic_tab_log" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
@@ -1,17 +1,29 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.evsuite.abrp.StableScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true" android:clipToPadding="false"> <com.evsuite.abrp.StableScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true" android:clipToPadding="false">
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="24dp" android:baselineAligned="false"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="24dp" android:baselineAligned="false">
<LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical" android:layout_marginEnd="16dp" android:padding="24dp" android:background="@drawable/bg_glass"> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical" android:layout_marginEnd="16dp">
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="24dp" android:background="@drawable/bg_glass">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/design_service_controls" android:textAppearance="@style/Text.EV.Eyebrow" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/design_service_controls" android:textAppearance="@style/Text.EV.Eyebrow" />
<TextView android:id="@+id/status_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/bg_input_panel" android:padding="16dp" android:layout_marginTop="20dp" android:layout_marginBottom="12dp" android:text="@string/state_stopped" android:textAppearance="@style/Text.EV.Body" /> <TextView android:id="@+id/status_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/bg_input_panel" android:padding="16dp" android:layout_marginTop="20dp" android:layout_marginBottom="12dp" android:text="@string/state_stopped" android:textAppearance="@style/Text.EV.Body" />
<com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/abrp_upload_switch" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:text="@string/label_abrp_upload_enabled" android:textAppearance="@style/Text.EV.Body" android:paddingTop="8dp" android:paddingBottom="8dp" app:useMaterialThemeColors="true" app:thumbTint="@color/switch_thumb" app:trackTint="@color/switch_track" android:textColor="@color/ev_text_primary" /> <com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/abrp_upload_switch" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:text="@string/label_abrp_upload_enabled" android:textAppearance="@style/Text.EV.Body" android:paddingTop="8dp" android:paddingBottom="8dp" app:useMaterialThemeColors="true" app:thumbTint="@color/switch_thumb" app:trackTint="@color/switch_track" android:textColor="@color/ev_text_primary" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/hint_abrp_upload_enabled" android:textAppearance="@style/Text.EV.Secondary" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/hint_abrp_upload_enabled" android:textAppearance="@style/Text.EV.Secondary" />
<com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/full_screen_switch" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:text="@string/label_full_screen" android:textAppearance="@style/Text.EV.Body" android:paddingTop="8dp" android:paddingBottom="8dp" app:useMaterialThemeColors="true" app:thumbTint="@color/switch_thumb" app:trackTint="@color/switch_track" android:textColor="@color/ev_text_primary" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/hint_full_screen" android:textAppearance="@style/Text.EV.Secondary" />
<com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/voice_key_switch" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:text="@string/label_voice_key" android:textAppearance="@style/Text.EV.Body" android:paddingTop="8dp" android:paddingBottom="8dp" app:useMaterialThemeColors="true" app:thumbTint="@color/switch_thumb" app:trackTint="@color/switch_track" android:textColor="@color/ev_text_primary" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/hint_voice_key" android:textAppearance="@style/Text.EV.Secondary" />
</LinearLayout> </LinearLayout>
<LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical" android:padding="24dp" android:background="@drawable/bg_glass"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="24dp" android:background="@drawable/bg_glass" android:layout_marginTop="16dp">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/design_abrp_title" android:textAppearance="@style/Text.EV.Eyebrow" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" android:text="@string/hint_abrp_direct" android:textAppearance="@style/Text.EV.Secondary" />
<com.google.android.material.textfield.TextInputLayout android:id="@+id/abrp_api_key_layout" style="@style/Widget.EV.Input" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="18dp" android:hint="@string/hint_abrp_api_key" app:endIconMode="password_toggle" app:endIconMinSize="72dp">
<com.google.android.material.textfield.TextInputEditText android:id="@+id/abrp_api_key_input" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:inputType="textPassword" android:singleLine="true" android:textSize="20sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout android:id="@+id/abrp_token_layout" style="@style/Widget.EV.Input" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="18dp" android:hint="@string/hint_abrp_token" app:endIconMode="password_toggle" app:endIconMinSize="72dp">
<com.google.android.material.textfield.TextInputEditText android:id="@+id/abrp_token_input" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:inputType="textPassword" android:singleLine="true" android:textSize="20sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton android:id="@+id/abrp_save_button" style="@style/Widget.EV.Button" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/btn_save" android:layout_marginTop="20dp" />
<com.google.android.material.button.MaterialButton android:id="@+id/abrp_test_button" style="@style/Widget.EV.Button.Outlined" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/btn_test" android:layout_marginTop="8dp" />
<TextView android:id="@+id/abrp_status_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" android:textAppearance="@style/Text.EV.Body" />
</LinearLayout>
</LinearLayout>
<LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical">
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="24dp" android:background="@drawable/bg_glass">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/design_service_timing" android:textAppearance="@style/Text.EV.Eyebrow" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/design_service_timing" android:textAppearance="@style/Text.EV.Eyebrow" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/label_frequency" android:textAppearance="@style/Text.EV.Body" android:layout_marginTop="20dp" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/label_frequency" android:textAppearance="@style/Text.EV.Body" android:layout_marginTop="20dp" />
<Spinner android:id="@+id/interval_spinner" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:layout_marginTop="12dp" android:background="@drawable/bg_input_panel" android:popupBackground="@color/ev_surface_raised" android:contentDescription="@string/label_frequency" android:spinnerMode="dropdown" /> <Spinner android:id="@+id/interval_spinner" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:layout_marginTop="12dp" android:background="@drawable/bg_input_panel" android:popupBackground="@color/ev_surface_raised" android:contentDescription="@string/label_frequency" android:spinnerMode="dropdown" />
@@ -22,4 +34,5 @@
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout>
</com.evsuite.abrp.StableScrollView> </com.evsuite.abrp.StableScrollView>
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<com.evsuite.abrp.StableScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true" android:clipToPadding="false">
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="24dp" android:baselineAligned="false">
<LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical" android:layout_marginEnd="16dp">
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="24dp" android:background="@drawable/bg_glass">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/design_display_title" android:textAppearance="@style/Text.EV.Eyebrow" />
<com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/full_screen_switch" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:text="@string/label_full_screen" android:textAppearance="@style/Text.EV.Body" android:paddingTop="8dp" android:paddingBottom="8dp" app:useMaterialThemeColors="true" app:thumbTint="@color/switch_thumb" app:trackTint="@color/switch_track" android:textColor="@color/ev_text_primary" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/hint_full_screen" android:textAppearance="@style/Text.EV.Secondary" />
<com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/voice_key_switch" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:text="@string/label_voice_key" android:textAppearance="@style/Text.EV.Body" android:paddingTop="8dp" android:paddingBottom="8dp" app:useMaterialThemeColors="true" app:thumbTint="@color/switch_thumb" app:trackTint="@color/switch_track" android:textColor="@color/ev_text_primary" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/hint_voice_key" android:textAppearance="@style/Text.EV.Secondary" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="24dp" android:background="@drawable/bg_glass" android:layout_marginTop="16dp">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/design_battery_settings_title" android:textAppearance="@style/Text.EV.Eyebrow" />
<com.google.android.material.textfield.TextInputLayout android:id="@+id/consumption_soh_layout" style="@style/Widget.Material3.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" android:hint="Manual SoH (%)" app:suffixText="%">
<com.google.android.material.textfield.TextInputEditText android:id="@+id/consumption_soh_input" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="numberDecimal" android:maxLength="5" android:minHeight="72dp"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton android:id="@+id/consumption_soh_save" style="@style/Widget.EV.Button" android:layout_width="match_parent" android:layout_height="72dp" android:layout_marginTop="8dp" android:text="Save SoH value"/>
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:text="This manual value is stored on the device and sent to your server with the daily totals." android:textAppearance="@style/Text.EV.Secondary"/>
<com.google.android.material.textfield.TextInputLayout android:id="@+id/usable_capacity_layout" style="@style/Widget.Material3.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:hint="@string/hint_usable_capacity" app:suffixText="kWh">
<com.google.android.material.textfield.TextInputEditText android:id="@+id/usable_capacity_input" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="numberDecimal" android:maxLength="5" android:minHeight="72dp"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton android:id="@+id/usable_capacity_save" style="@style/Widget.EV.Button" android:layout_width="match_parent" android:layout_height="72dp" android:layout_marginTop="8dp" android:text="@string/btn_save_capacity"/>
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:text="@string/helper_usable_capacity" android:textAppearance="@style/Text.EV.Secondary"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="24dp" android:background="@drawable/bg_glass" android:layout_marginTop="16dp">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/design_price_title" android:textAppearance="@style/Text.EV.Eyebrow" />
<com.google.android.material.textfield.TextInputLayout android:id="@+id/charge_price_layout" style="@style/Widget.Material3.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" android:hint="Unit price" app:suffixText="€/kWh">
<com.google.android.material.textfield.TextInputEditText android:id="@+id/charge_price_input" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="numberDecimal" android:maxLength="10" android:minHeight="72dp"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton android:id="@+id/charge_price_save" style="@style/Widget.EV.Button" android:layout_width="match_parent" android:layout_height="72dp" android:layout_marginTop="8dp" android:text="Save price"/>
</LinearLayout>
</LinearLayout>
<LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical">
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="24dp" android:background="@drawable/bg_glass">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/wifi_card_title" android:textAppearance="@style/Text.EV.Eyebrow" />
<TextView android:id="@+id/wifi_ssid" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="—" android:textAppearance="@style/Text.EV.Metric" android:layout_marginTop="20dp" />
<TextView android:id="@+id/wifi_state" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="—" android:textAppearance="@style/Text.EV.Secondary" android:layout_marginTop="12dp" />
<com.google.android.material.button.MaterialButton android:id="@+id/wifi_connect_button" style="@style/Widget.EV.Button" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/wifi_connect_now" android:layout_marginTop="24dp" />
<com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/wifi_auto_switch" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:text="@string/wifi_auto_label" android:textAppearance="@style/Text.EV.Body" android:paddingTop="8dp" android:paddingBottom="8dp" app:useMaterialThemeColors="true" app:thumbTint="@color/switch_thumb" app:trackTint="@color/switch_track" android:textColor="@color/ev_text_primary" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/wifi_auto_hint" android:textAppearance="@style/Text.EV.Secondary" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="24dp" android:background="@drawable/bg_glass" android:layout_marginTop="16dp">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/wifi_saved_title" android:textAppearance="@style/Text.EV.Eyebrow" />
<TextView android:id="@+id/wifi_saved_list" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:textAppearance="@style/Text.EV.Body" android:lineSpacingExtra="16dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</com.evsuite.abrp.StableScrollView>
@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<com.evsuite.abrp.StableScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true" android:clipToPadding="false">
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="24dp" android:baselineAligned="false">
<LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1.3" android:orientation="vertical" android:layout_marginEnd="16dp" android:padding="24dp" android:background="@drawable/bg_glass">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/wifi_card_title" android:textAppearance="@style/Text.EV.Eyebrow" />
<TextView android:id="@+id/wifi_ssid" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="—" android:textAppearance="@style/Text.EV.Metric" android:layout_marginTop="20dp" />
<TextView android:id="@+id/wifi_state" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="—" android:textAppearance="@style/Text.EV.Secondary" android:layout_marginTop="12dp" />
<com.google.android.material.button.MaterialButton android:id="@+id/wifi_connect_button" style="@style/Widget.EV.Button" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/wifi_connect_now" android:layout_marginTop="24dp" />
<com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/wifi_auto_switch" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:text="@string/wifi_auto_label" android:textAppearance="@style/Text.EV.Body" android:paddingTop="8dp" android:paddingBottom="8dp" app:useMaterialThemeColors="true" app:thumbTint="@color/switch_thumb" app:trackTint="@color/switch_track" android:textColor="@color/ev_text_primary" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/wifi_auto_hint" android:textAppearance="@style/Text.EV.Secondary" />
</LinearLayout>
<LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical" android:padding="24dp" android:background="@drawable/bg_glass">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/wifi_saved_title" android:textAppearance="@style/Text.EV.Eyebrow" />
<TextView android:id="@+id/wifi_saved_list" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:textAppearance="@style/Text.EV.Body" android:lineSpacingExtra="16dp" />
</LinearLayout>
</LinearLayout>
</com.evsuite.abrp.StableScrollView>
+3 -3
View File
@@ -15,10 +15,10 @@
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="8dp" android:background="@drawable/bg_sidebar"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="8dp" android:background="@drawable/bg_sidebar">
<com.google.android.material.button.MaterialButton android:id="@+id/tabVehicle" style="@style/Widget.EV.NavTab.Compact" android:layout_width="0dp" android:layout_height="76dp" android:layout_weight="1" android:text="@string/tab_vehicle" app:icon="@drawable/ic_tab_vehicle"/> <com.google.android.material.button.MaterialButton android:id="@+id/tabVehicle" style="@style/Widget.EV.NavTab.Compact" android:layout_width="0dp" android:layout_height="76dp" android:layout_weight="1" android:text="@string/tab_vehicle" app:icon="@drawable/ic_tab_vehicle"/>
<com.google.android.material.button.MaterialButton android:id="@+id/tabConsumption" style="@style/Widget.EV.NavTab.Compact" android:layout_width="0dp" android:layout_height="76dp" android:layout_weight="1" android:text="@string/tab_consumption" app:icon="@drawable/ic_tab_vehicle"/> <com.google.android.material.button.MaterialButton android:id="@+id/tabConsumption" style="@style/Widget.EV.NavTab.Compact" android:layout_width="0dp" android:layout_height="76dp" android:layout_weight="1" android:text="@string/tab_consumption" app:icon="@drawable/ic_tab_vehicle"/>
<com.google.android.material.button.MaterialButton android:id="@+id/tabCharging" style="@style/Widget.EV.NavTab.Compact" android:layout_width="0dp" android:layout_height="76dp" android:layout_weight="1" android:text="@string/tab_charging" app:icon="@drawable/ic_tab_service"/> <com.google.android.material.button.MaterialButton android:id="@+id/tabCharging" style="@style/Widget.EV.NavTab.Compact" android:layout_width="0dp" android:layout_height="76dp" android:layout_weight="1" android:text="@string/tab_charging" app:icon="@drawable/ic_tab_charging"/>
<com.google.android.material.button.MaterialButton android:id="@+id/tabService" style="@style/Widget.EV.NavTab.Compact" android:layout_width="0dp" android:layout_height="76dp" android:layout_weight="1" android:text="@string/tab_service" app:icon="@drawable/ic_tab_service"/> <com.google.android.material.button.MaterialButton android:id="@+id/tabService" style="@style/Widget.EV.NavTab.Compact" android:layout_width="0dp" android:layout_height="76dp" android:layout_weight="1" android:text="@string/tab_service" app:icon="@drawable/ic_tab_live"/>
<com.google.android.material.button.MaterialButton android:id="@+id/tabServer" style="@style/Widget.EV.NavTab.Compact" android:layout_width="0dp" android:layout_height="76dp" android:layout_weight="1" android:text="@string/tab_server" app:icon="@drawable/ic_tab_server"/> <com.google.android.material.button.MaterialButton android:id="@+id/tabServer" style="@style/Widget.EV.NavTab.Compact" android:layout_width="0dp" android:layout_height="76dp" android:layout_weight="1" android:text="@string/tab_server" app:icon="@drawable/ic_tab_server"/>
<com.google.android.material.button.MaterialButton android:id="@+id/tabWifi" style="@style/Widget.EV.NavTab.Compact" android:layout_width="0dp" android:layout_height="76dp" android:layout_weight="1" android:text="@string/tab_wifi" app:icon="@drawable/ic_tab_wifi"/> <com.google.android.material.button.MaterialButton android:id="@+id/tabSettings" style="@style/Widget.EV.NavTab.Compact" android:layout_width="0dp" android:layout_height="76dp" android:layout_weight="1" android:text="@string/tab_settings" app:icon="@drawable/ic_tab_service"/>
<com.google.android.material.button.MaterialButton android:id="@+id/tabLog" style="@style/Widget.EV.NavTab.Compact" android:layout_width="0dp" android:layout_height="76dp" android:layout_weight="1" android:text="@string/tab_log" app:icon="@drawable/ic_tab_log"/> <com.google.android.material.button.MaterialButton android:id="@+id/tabLog" style="@style/Widget.EV.NavTab.Compact" android:layout_width="0dp" android:layout_height="76dp" android:layout_weight="1" android:text="@string/tab_log" app:icon="@drawable/ic_tab_log"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
@@ -15,13 +15,6 @@
<TextView android:layout_width="0dp" android:layout_columnWeight="1" android:padding="10dp" android:text="Total cost" android:textAppearance="@style/DataLabel"/><TextView android:id="@+id/charge_total_cost" android:layout_width="0dp" android:layout_columnWeight="1" android:padding="10dp" android:text="—" android:textAppearance="@style/DataValue"/> <TextView android:layout_width="0dp" android:layout_columnWeight="1" android:padding="10dp" android:text="Total cost" android:textAppearance="@style/DataLabel"/><TextView android:id="@+id/charge_total_cost" android:layout_width="0dp" android:layout_columnWeight="1" android:padding="10dp" android:text="—" android:textAppearance="@style/DataValue"/>
</GridLayout> </GridLayout>
</LinearLayout> </LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="20dp" android:layout_marginTop="16dp" android:background="@drawable/bg_glass">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="CHARGING PRICE" android:textAppearance="@style/Text.EV.Eyebrow"/>
<com.google.android.material.textfield.TextInputLayout android:id="@+id/charge_price_layout" style="@style/Widget.Material3.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" android:hint="Unit price" app:suffixText="€/kWh">
<com.google.android.material.textfield.TextInputEditText android:id="@+id/charge_price_input" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="numberDecimal" android:maxLength="10" android:minHeight="72dp"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton android:id="@+id/charge_price_save" style="@style/Widget.EV.Button" android:layout_width="match_parent" android:layout_height="72dp" android:layout_marginTop="8dp" android:text="Save price"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="20dp" android:layout_marginTop="16dp" android:background="@drawable/bg_glass"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="20dp" android:layout_marginTop="16dp" android:background="@drawable/bg_glass">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="CHARGING CURVE" android:textAppearance="@style/Text.EV.Eyebrow"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="CHARGING CURVE" android:textAppearance="@style/Text.EV.Eyebrow"/>
<com.evsuite.abrp.ChargingGraphView android:id="@+id/charge_graph" android:layout_width="match_parent" android:layout_height="280dp" android:layout_marginTop="12dp"/> <com.evsuite.abrp.ChargingGraphView android:id="@+id/charge_graph" android:layout_width="match_parent" android:layout_height="280dp" android:layout_marginTop="12dp"/>
@@ -26,19 +26,6 @@
<com.google.android.material.button.MaterialButton android:id="@+id/consumption_reset" style="@style/Widget.EV.Button.Outlined" android:layout_width="match_parent" android:layout_height="64dp" android:layout_marginTop="12dp" android:text="Reset selected trip" android:visibility="gone"/> <com.google.android.material.button.MaterialButton android:id="@+id/consumption_reset" style="@style/Widget.EV.Button.Outlined" android:layout_width="match_parent" android:layout_height="64dp" android:layout_marginTop="12dp" android:text="Reset selected trip" android:visibility="gone"/>
</LinearLayout> </LinearLayout>
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" android:text="Last 7/30 days, lifetime and Trip A/B are stored permanently on the device; app and OTA updates do not erase them." android:textAppearance="@style/Text.EV.Secondary"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" android:text="Last 7/30 days, lifetime and Trip A/B are stored permanently on the device; app and OTA updates do not erase them." android:textAppearance="@style/Text.EV.Secondary"/>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="20dp" android:layout_marginTop="16dp" android:background="@drawable/bg_glass">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="BATTERY HEALTH (SOH)" android:textAppearance="@style/Text.EV.Eyebrow"/>
<com.google.android.material.textfield.TextInputLayout android:id="@+id/consumption_soh_layout" style="@style/Widget.Material3.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" android:hint="Manual SoH (%)" app:suffixText="%">
<com.google.android.material.textfield.TextInputEditText android:id="@+id/consumption_soh_input" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="numberDecimal" android:maxLength="5" android:minHeight="72dp"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton android:id="@+id/consumption_soh_save" style="@style/Widget.EV.Button" android:layout_width="match_parent" android:layout_height="72dp" android:layout_marginTop="8dp" android:text="Save SoH value"/>
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:text="This manual value is stored on the device and sent to your server with the daily totals." android:textAppearance="@style/Text.EV.Secondary"/>
<com.google.android.material.textfield.TextInputLayout android:id="@+id/usable_capacity_layout" style="@style/Widget.Material3.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:hint="@string/hint_usable_capacity" app:suffixText="kWh">
<com.google.android.material.textfield.TextInputEditText android:id="@+id/usable_capacity_input" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="numberDecimal" android:maxLength="5" android:minHeight="72dp"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton android:id="@+id/usable_capacity_save" style="@style/Widget.EV.Button" android:layout_width="match_parent" android:layout_height="72dp" android:layout_marginTop="8dp" android:text="@string/btn_save_capacity"/>
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:text="@string/helper_usable_capacity" android:textAppearance="@style/Text.EV.Secondary"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="20dp" android:layout_marginTop="16dp" android:background="@drawable/bg_glass"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="20dp" android:layout_marginTop="16dp" android:background="@drawable/bg_glass">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="DAILY LOG · LAST 4 MONTHS" android:textAppearance="@style/Text.EV.Eyebrow"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="DAILY LOG · LAST 4 MONTHS" android:textAppearance="@style/Text.EV.Eyebrow"/>
<com.google.android.material.button.MaterialButton android:id="@+id/consumption_date_button" style="@style/Widget.EV.Button.Outlined" android:layout_width="match_parent" android:layout_height="56dp" android:layout_marginTop="12dp" android:text="Pick a date"/> <com.google.android.material.button.MaterialButton android:id="@+id/consumption_date_button" style="@style/Widget.EV.Button.Outlined" android:layout_width="match_parent" android:layout_height="56dp" android:layout_marginTop="12dp" android:text="Pick a date"/>
+14 -6
View File
@@ -6,13 +6,21 @@
<TextView android:id="@+id/status_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/bg_input_panel" android:padding="16dp" android:layout_marginTop="20dp" android:layout_marginBottom="12dp" android:text="@string/state_stopped" android:textAppearance="@style/Text.EV.Body" /> <TextView android:id="@+id/status_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/bg_input_panel" android:padding="16dp" android:layout_marginTop="20dp" android:layout_marginBottom="12dp" android:text="@string/state_stopped" android:textAppearance="@style/Text.EV.Body" />
<com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/abrp_upload_switch" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:text="@string/label_abrp_upload_enabled" android:textAppearance="@style/Text.EV.Body" android:paddingTop="8dp" android:paddingBottom="8dp" app:useMaterialThemeColors="true" app:thumbTint="@color/switch_thumb" app:trackTint="@color/switch_track" android:textColor="@color/ev_text_primary" /> <com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/abrp_upload_switch" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:text="@string/label_abrp_upload_enabled" android:textAppearance="@style/Text.EV.Body" android:paddingTop="8dp" android:paddingBottom="8dp" app:useMaterialThemeColors="true" app:thumbTint="@color/switch_thumb" app:trackTint="@color/switch_track" android:textColor="@color/ev_text_primary" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/hint_abrp_upload_enabled" android:textAppearance="@style/Text.EV.Secondary" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/hint_abrp_upload_enabled" android:textAppearance="@style/Text.EV.Secondary" />
<com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/full_screen_switch" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:text="@string/label_full_screen" android:textAppearance="@style/Text.EV.Body" android:paddingTop="8dp" android:paddingBottom="8dp" app:useMaterialThemeColors="true" app:thumbTint="@color/switch_thumb" app:trackTint="@color/switch_track" android:textColor="@color/ev_text_primary" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/hint_full_screen" android:textAppearance="@style/Text.EV.Secondary" />
<com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/voice_key_switch" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:text="@string/label_voice_key" android:textAppearance="@style/Text.EV.Body" android:paddingTop="8dp" android:paddingBottom="8dp" app:useMaterialThemeColors="true" app:thumbTint="@color/switch_thumb" app:trackTint="@color/switch_track" android:textColor="@color/ev_text_primary" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/hint_voice_key" android:textAppearance="@style/Text.EV.Secondary" />
</LinearLayout> </LinearLayout>
<Space android:layout_width="1dp" android:layout_height="20dp" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="24dp" android:background="@drawable/bg_glass" android:layout_marginTop="16dp">
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="24dp" android:background="@drawable/bg_glass"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/design_abrp_title" android:textAppearance="@style/Text.EV.Eyebrow" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" android:text="@string/hint_abrp_direct" android:textAppearance="@style/Text.EV.Secondary" />
<com.google.android.material.textfield.TextInputLayout android:id="@+id/abrp_api_key_layout" style="@style/Widget.EV.Input" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="18dp" android:hint="@string/hint_abrp_api_key" app:endIconMode="password_toggle" app:endIconMinSize="72dp">
<com.google.android.material.textfield.TextInputEditText android:id="@+id/abrp_api_key_input" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:inputType="textPassword" android:singleLine="true" android:textSize="20sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout android:id="@+id/abrp_token_layout" style="@style/Widget.EV.Input" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="18dp" android:hint="@string/hint_abrp_token" app:endIconMode="password_toggle" app:endIconMinSize="72dp">
<com.google.android.material.textfield.TextInputEditText android:id="@+id/abrp_token_input" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:inputType="textPassword" android:singleLine="true" android:textSize="20sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton android:id="@+id/abrp_save_button" style="@style/Widget.EV.Button" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/btn_save" android:layout_marginTop="20dp" />
<com.google.android.material.button.MaterialButton android:id="@+id/abrp_test_button" style="@style/Widget.EV.Button.Outlined" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/btn_test" android:layout_marginTop="8dp" />
<TextView android:id="@+id/abrp_status_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" android:textAppearance="@style/Text.EV.Body" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="24dp" android:background="@drawable/bg_glass" android:layout_marginTop="16dp">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/design_service_timing" android:textAppearance="@style/Text.EV.Eyebrow" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/design_service_timing" android:textAppearance="@style/Text.EV.Eyebrow" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/label_frequency" android:textAppearance="@style/Text.EV.Body" android:layout_marginTop="20dp" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/label_frequency" android:textAppearance="@style/Text.EV.Body" android:layout_marginTop="20dp" />
<Spinner android:id="@+id/interval_spinner" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:layout_marginTop="12dp" android:background="@drawable/bg_input_panel" android:popupBackground="@color/ev_surface_raised" android:contentDescription="@string/label_frequency" android:spinnerMode="dropdown" /> <Spinner android:id="@+id/interval_spinner" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:layout_marginTop="12dp" android:background="@drawable/bg_input_panel" android:popupBackground="@color/ev_surface_raised" android:contentDescription="@string/label_frequency" android:spinnerMode="dropdown" />
+44
View File
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<com.evsuite.abrp.StableScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true" android:clipToPadding="false">
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="24dp">
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="24dp" android:background="@drawable/bg_glass">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/design_display_title" android:textAppearance="@style/Text.EV.Eyebrow" />
<com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/full_screen_switch" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:text="@string/label_full_screen" android:textAppearance="@style/Text.EV.Body" android:paddingTop="8dp" android:paddingBottom="8dp" app:useMaterialThemeColors="true" app:thumbTint="@color/switch_thumb" app:trackTint="@color/switch_track" android:textColor="@color/ev_text_primary" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/hint_full_screen" android:textAppearance="@style/Text.EV.Secondary" />
<com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/voice_key_switch" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:text="@string/label_voice_key" android:textAppearance="@style/Text.EV.Body" android:paddingTop="8dp" android:paddingBottom="8dp" app:useMaterialThemeColors="true" app:thumbTint="@color/switch_thumb" app:trackTint="@color/switch_track" android:textColor="@color/ev_text_primary" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/hint_voice_key" android:textAppearance="@style/Text.EV.Secondary" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="24dp" android:background="@drawable/bg_glass" android:layout_marginTop="16dp">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/design_battery_settings_title" android:textAppearance="@style/Text.EV.Eyebrow" />
<com.google.android.material.textfield.TextInputLayout android:id="@+id/consumption_soh_layout" style="@style/Widget.Material3.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" android:hint="Manual SoH (%)" app:suffixText="%">
<com.google.android.material.textfield.TextInputEditText android:id="@+id/consumption_soh_input" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="numberDecimal" android:maxLength="5" android:minHeight="72dp"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton android:id="@+id/consumption_soh_save" style="@style/Widget.EV.Button" android:layout_width="match_parent" android:layout_height="72dp" android:layout_marginTop="8dp" android:text="Save SoH value"/>
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:text="This manual value is stored on the device and sent to your server with the daily totals." android:textAppearance="@style/Text.EV.Secondary"/>
<com.google.android.material.textfield.TextInputLayout android:id="@+id/usable_capacity_layout" style="@style/Widget.Material3.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:hint="@string/hint_usable_capacity" app:suffixText="kWh">
<com.google.android.material.textfield.TextInputEditText android:id="@+id/usable_capacity_input" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="numberDecimal" android:maxLength="5" android:minHeight="72dp"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton android:id="@+id/usable_capacity_save" style="@style/Widget.EV.Button" android:layout_width="match_parent" android:layout_height="72dp" android:layout_marginTop="8dp" android:text="@string/btn_save_capacity"/>
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:text="@string/helper_usable_capacity" android:textAppearance="@style/Text.EV.Secondary"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="24dp" android:background="@drawable/bg_glass" android:layout_marginTop="16dp">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/design_price_title" android:textAppearance="@style/Text.EV.Eyebrow" />
<com.google.android.material.textfield.TextInputLayout android:id="@+id/charge_price_layout" style="@style/Widget.Material3.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" android:hint="Unit price" app:suffixText="€/kWh">
<com.google.android.material.textfield.TextInputEditText android:id="@+id/charge_price_input" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="numberDecimal" android:maxLength="10" android:minHeight="72dp"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton android:id="@+id/charge_price_save" style="@style/Widget.EV.Button" android:layout_width="match_parent" android:layout_height="72dp" android:layout_marginTop="8dp" android:text="Save price"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="24dp" android:background="@drawable/bg_glass" android:layout_marginTop="16dp">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/wifi_card_title" android:textAppearance="@style/Text.EV.Eyebrow" />
<TextView android:id="@+id/wifi_ssid" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="—" android:textAppearance="@style/Text.EV.Metric" android:layout_marginTop="20dp" />
<TextView android:id="@+id/wifi_state" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="—" android:textAppearance="@style/Text.EV.Secondary" android:layout_marginTop="12dp" />
<com.google.android.material.button.MaterialButton android:id="@+id/wifi_connect_button" style="@style/Widget.EV.Button" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/wifi_connect_now" android:layout_marginTop="24dp" />
<com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/wifi_auto_switch" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:text="@string/wifi_auto_label" android:textAppearance="@style/Text.EV.Body" android:paddingTop="8dp" android:paddingBottom="8dp" app:useMaterialThemeColors="true" app:thumbTint="@color/switch_thumb" app:trackTint="@color/switch_track" android:textColor="@color/ev_text_primary" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/wifi_auto_hint" android:textAppearance="@style/Text.EV.Secondary" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="24dp" android:background="@drawable/bg_glass" android:layout_marginTop="16dp">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/wifi_saved_title" android:textAppearance="@style/Text.EV.Eyebrow" />
<TextView android:id="@+id/wifi_saved_list" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:textAppearance="@style/Text.EV.Body" android:lineSpacingExtra="16dp" />
</LinearLayout>
</LinearLayout>
</com.evsuite.abrp.StableScrollView>
-18
View File
@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<com.evsuite.abrp.StableScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true" android:clipToPadding="false">
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="24dp">
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="24dp" android:background="@drawable/bg_glass">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/wifi_card_title" android:textAppearance="@style/Text.EV.Eyebrow" />
<TextView android:id="@+id/wifi_ssid" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="—" android:textAppearance="@style/Text.EV.Metric" android:layout_marginTop="20dp" />
<TextView android:id="@+id/wifi_state" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="—" android:textAppearance="@style/Text.EV.Secondary" android:layout_marginTop="12dp" />
<com.google.android.material.button.MaterialButton android:id="@+id/wifi_connect_button" style="@style/Widget.EV.Button" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/wifi_connect_now" android:layout_marginTop="24dp" />
<com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/wifi_auto_switch" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="72dp" android:text="@string/wifi_auto_label" android:textAppearance="@style/Text.EV.Body" android:paddingTop="8dp" android:paddingBottom="8dp" app:useMaterialThemeColors="true" app:thumbTint="@color/switch_thumb" app:trackTint="@color/switch_track" android:textColor="@color/ev_text_primary" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/wifi_auto_hint" android:textAppearance="@style/Text.EV.Secondary" />
</LinearLayout>
<Space android:layout_width="1dp" android:layout_height="20dp" />
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="24dp" android:background="@drawable/bg_glass">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/wifi_saved_title" android:textAppearance="@style/Text.EV.Eyebrow" />
<TextView android:id="@+id/wifi_saved_list" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:textAppearance="@style/Text.EV.Body" android:lineSpacingExtra="16dp" />
</LinearLayout>
</LinearLayout>
</com.evsuite.abrp.StableScrollView>
+18 -6
View File
@@ -2,7 +2,7 @@
<string name="app_name">Nils\' MG4</string> <string name="app_name">Nils\' MG4</string>
<!-- Main screen --> <!-- Main screen -->
<string name="tab_service">Upload</string> <string name="tab_service">Live data</string>
<string name="tab_vehicle">Overview</string> <string name="tab_vehicle">Overview</string>
<string name="tab_consumption">Consumption</string> <string name="tab_consumption">Consumption</string>
<string name="tab_charging">Charging</string> <string name="tab_charging">Charging</string>
@@ -11,17 +11,17 @@
<string name="charging_title">Charging</string> <string name="charging_title">Charging</string>
<string name="charging_subtitle">Live battery values and SOC/power curve</string> <string name="charging_subtitle">Live battery values and SOC/power curve</string>
<string name="tab_server">Server</string> <string name="tab_server">Server</string>
<string name="tab_wifi">Wi-Fi</string> <string name="tab_settings">Settings</string>
<string name="tab_log">Logs</string> <string name="tab_log">Logs</string>
<!-- Wi-Fi page --> <!-- Wi-Fi page -->
<string name="wifi_card_title">Wi-Fi Connection</string> <string name="wifi_card_title">WI-FI</string>
<string name="wifi_current">Connected network</string> <string name="wifi_current">Connected network</string>
<string name="wifi_state">Status</string> <string name="wifi_state">Status</string>
<string name="wifi_connect_now">Connect Now</string> <string name="wifi_connect_now">Connect Now</string>
<string name="wifi_auto_label">Auto-connect in the background</string> <string name="wifi_auto_label">Auto-connect in the background</string>
<string name="wifi_auto_hint">While the upload service is running, it tries to reconnect to saved networks on its own when the connection drops.</string> <string name="wifi_auto_hint">While the upload service is running, it tries to reconnect to saved networks on its own when the connection drops.</string>
<string name="wifi_saved_title">Saved Networks</string> <string name="wifi_saved_title">SAVED NETWORKS</string>
<string name="wifi_saved_empty">Could not read saved networks</string> <string name="wifi_saved_empty">Could not read saved networks</string>
<string name="wifi_not_connected">Not connected</string> <string name="wifi_not_connected">Not connected</string>
@@ -121,8 +121,19 @@
<string name="label_steering_keys">Steering-wheel keys</string> <string name="label_steering_keys">Steering-wheel keys</string>
<string name="hint_steering_keys">The last key reports the car sent, newest first. If double-pressing the voice key does not open the app, a photo of this list shows how the car reports it.</string> <string name="hint_steering_keys">The last key reports the car sent, newest first. If double-pressing the voice key does not open the app, a photo of this list shows how the car reports it.</string>
<string name="steering_keys_empty">No key reports received yet. Press a steering-wheel key.</string> <string name="steering_keys_empty">No key reports received yet. Press a steering-wheel key.</string>
<string name="label_abrp_upload_enabled">Send live telemetry to the server</string> <string name="label_abrp_upload_enabled">Send live data</string>
<string name="hint_abrp_upload_enabled">The server stores it and forwards it to ABRP. Turn this off when another app feeds ABRP; consumption and charging tracking keep running.</string> <string name="hint_abrp_upload_enabled">To your server, which stores it, and to ABRP: straight from the car when the ABRP credentials below are set, otherwise forwarded by the server. Consumption and charging tracking keep running when this is off.</string>
<string name="hint_abrp_direct">With your ABRP API key and user token here, the car sends live data to ABRP itself, so ABRP keeps getting it while your server is down. The server then forwards only what the car could not send. Leave both empty to let the server forward everything.</string>
<string name="hint_abrp_api_key">ABRP API key</string>
<string name="hint_abrp_token">ABRP user token</string>
<string name="abrp_saved">Saved: the car sends live data to ABRP directly</string>
<string name="abrp_cleared">Cleared: the server forwards live data to ABRP</string>
<string name="abrp_invalid">Enter both, without spaces, or leave both empty</string>
<string name="abrp_testing">Checking with ABRP…</string>
<string name="abrp_test_ok">ABRP accepted these credentials</string>
<string name="abrp_test_failed">ABRP refused: HTTP %1$d</string>
<string name="abrp_test_offline">ABRP not reachable: %1$s</string>
<string name="abrp_not_set">Set both first</string>
<!-- Cadence configuration --> <!-- Cadence configuration -->
@@ -143,6 +154,7 @@
<string name="state_stopped">Stopped</string> <string name="state_stopped">Stopped</string>
<string name="state_starting">Starting…</string> <string name="state_starting">Starting…</string>
<string name="state_running">Running</string> <string name="state_running">Running</string>
<string name="state_abrp_only">Running — live data to ABRP only, no server set up</string>
<string name="state_tracking_locally">Tracking locally — live telemetry off</string> <string name="state_tracking_locally">Tracking locally — live telemetry off</string>
<string name="notif_tracking_locally">Tracking locally — live telemetry off</string> <string name="notif_tracking_locally">Tracking locally — live telemetry off</string>
<string name="state_error">In error — last %1$d uploads failed</string> <string name="state_error">In error — last %1$d uploads failed</string>
+9 -5
View File
@@ -9,10 +9,10 @@
<string name="design_overview_subtitle">Data from your car, all in one place.</string> <string name="design_overview_subtitle">Data from your car, all in one place.</string>
<string name="design_server_title">Where your data goes.</string> <string name="design_server_title">Where your data goes.</string>
<string name="design_server_subtitle">Your own server stores it and passes it on to ABRP.</string> <string name="design_server_subtitle">Your own server stores it and passes it on to ABRP.</string>
<string name="design_service_title">You focus on the road.</string> <string name="design_service_title">Live data.</string>
<string name="design_service_subtitle">Your data stays up to date in the background.</string> <string name="design_service_subtitle">Where your car\'s live data goes, and how often.</string>
<string name="design_wifi_title">Stay connected.</string> <string name="design_settings_title">Settings.</string>
<string name="design_wifi_subtitle">The internet connection for your journey.</string> <string name="design_settings_subtitle">Display, battery, charging price and Wi-Fi.</string>
<string name="design_log_title">Every upload, right here.</string> <string name="design_log_title">Every upload, right here.</string>
<string name="design_log_subtitle">Status and details of recent uploads.</string> <string name="design_log_subtitle">Status and details of recent uploads.</string>
<string name="design_battery">BATTERY</string> <string name="design_battery">BATTERY</string>
@@ -22,7 +22,11 @@
<string name="design_private_title">Your private connection.</string> <string name="design_private_title">Your private connection.</string>
<string name="design_private_body">The token lets the car write to your server. It is stored encrypted on this device; your ABRP credentials stay on the server.</string> <string name="design_private_body">The token lets the car write to your server. It is stored encrypted on this device; your ABRP credentials stay on the server.</string>
<string name="design_no_data">Values that cannot be read are shown as &#x2014;.</string> <string name="design_no_data">Values that cannot be read are shown as &#x2014;.</string>
<string name="design_service_controls">UPLOAD CONTROL</string> <string name="design_service_controls">LIVE DATA</string>
<string name="design_abrp_title">ABRP, DIRECTLY FROM THE CAR</string>
<string name="design_display_title">DISPLAY AND STEERING WHEEL</string>
<string name="design_battery_settings_title">BATTERY</string>
<string name="design_price_title">CHARGING PRICE</string>
<string name="design_service_timing">UPDATE FREQUENCY</string> <string name="design_service_timing">UPDATE FREQUENCY</string>
<string name="design_car_desc">Tire pressure positions on the vehicle</string> <string name="design_car_desc">Tire pressure positions on the vehicle</string>
</resources> </resources>
@@ -0,0 +1,40 @@
package com.evsuite.abrp;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/** The direct ABRP request and its answer — pure JVM, nothing is sent. */
public class AbrpApiTest {
@Test
public void credentialsGoInTheBodyEncoded() throws Exception {
String body = AbrpApi.formBody("key+1", "tok&en", "{\"utc\":1790000000,\"soc\":80}");
assertEquals("api_key=key%2B1&token=tok%26en&tlm=%7B%22utc%22%3A1790000000%2C%22soc%22%3A80%7D", body);
assertFalse(AbrpApi.SEND_URL.contains("?"));
}
@Test
public void onlyAnOkStatusIsAccepted() {
assertTrue(AbrpApi.accepted(new ServerHttp.Response(200, "{\"status\":\"ok\"}")));
assertFalse(AbrpApi.accepted(new ServerHttp.Response(200, "{\"status\":\"error\",\"errors\":[\"bad token\"]}")));
assertFalse(AbrpApi.accepted(new ServerHttp.Response(401, "{\"status\":\"ok\"}")));
assertFalse(AbrpApi.accepted(new ServerHttp.Response(200, "not json")));
}
@Test
public void credentialsMustLookLikeCredentials() {
assertTrue(AbrpConfig.isPlausible("0a1b2c3d-4e5f-6789"));
assertFalse(AbrpConfig.isPlausible("short"));
assertFalse(AbrpConfig.isPlausible("has a space in it"));
assertFalse(AbrpConfig.isPlausible(null));
}
@Test
public void theSampleTimeIsReadFromItsJson() {
assertEquals(1790000000L, TelemetryUploader.utcOf("{\"utc\":1790000000,\"soc\":5}"));
assertEquals(0L, TelemetryUploader.utcOf("garbage"));
}
}
@@ -87,4 +87,13 @@ public class ConfigImportTest {
assertEquals("https://k.example", c.serverUrl); assertEquals("https://k.example", c.serverUrl);
assertEquals("t", c.token); assertEquals("t", c.token);
} }
@Test
public void abrpCredentialsAreRead() {
ConfigImport c = ConfigImport.parse("abrp_api_key = key-1234567890\nABRP_TOKEN = token-abcdefghij\n");
assertEquals("key-1234567890", c.abrpApiKey);
assertEquals("token-abcdefghij", c.abrpToken);
assertFalse(c.isEmpty());
assertEquals("token-2", ConfigImport.parse("abrp_user_token = token-2").abrpToken);
}
} }
+2 -1
View File
@@ -26,7 +26,8 @@ stringData:
# Approves a car on your phone when it pairs by QR code (at least 12 characters). Leave it # Approves a car on your phone when it pairs by QR code (at least 12 characters). Leave it
# empty to switch pairing off; then only the INGEST_TOKEN above works. # empty to switch pairing off; then only the INGEST_TOKEN above works.
APPROVAL_PASSWORD: CHANGE-ME-at-least-12-characters APPROVAL_PASSWORD: CHANGE-ME-at-least-12-characters
# Your ABRP credentials. Leave either empty to switch forwarding off. # Your ABRP credentials. Leave either empty to switch forwarding off. Keep them set even
# when the app sends to ABRP itself: the server then forwards only what the car could not.
ABRP_API_KEY: CHANGE-ME ABRP_API_KEY: CHANGE-ME
ABRP_USER_TOKEN: CHANGE-ME ABRP_USER_TOKEN: CHANGE-ME
ABRP_MIN_INTERVAL_SECONDS: "5" ABRP_MIN_INTERVAL_SECONDS: "5"
+2 -2
View File
@@ -29,8 +29,8 @@ spec:
type: RuntimeDefault type: RuntimeDefault
containers: containers:
- name: server - name: server
# 2.2.0, pinned by digest so a re-pushed tag cannot change what runs. # 2.3.0, pinned by digest so a re-pushed tag cannot change what runs.
image: git.stinnesbeck.com/nils/mg4-server@sha256:09eb151ff65300b3990a74063cc44a14d24bef810461e4e0e63451cfbcfd8258 image: git.stinnesbeck.com/nils/mg4-server@sha256:dc5eb49cd88a1fd6a8e853c6e2291f2b5d62252e8bb6daf1750e1c3698bc7e0a
ports: ports:
- name: http - name: http
containerPort: 8080 containerPort: 8080
+3 -1
View File
@@ -40,7 +40,9 @@ with (403 otherwise); the shared token works for any.
a plausible time (before 2001, or more than an hour ahead) is dropped whole. The rest is stored a plausible time (before 2001, or more than an hour ahead) is dropped whole. The rest is stored
and the answer is `200 {stored, droppedCount, dropped}`, even when nothing was usable, since and the answer is `200 {stored, droppedCount, dropped}`, even when nothing was usable, since
the car would only send it again. The newest sample is forwarded to ABRP if it is under the car would only send it again. The newest sample is forwarded to ABRP if it is under
5 minutes old and not ahead of the server's clock. 5 minutes old and not ahead of the server's clock. A car that sends to ABRP itself adds
`abrpSentUtc`, the newest sample ABRP took from it; only samples newer than that are
forwarded, so ABRP gets each one once.
- `PUT /v1/consumption/daily` — one delta chunk of a day's consumption. - `PUT /v1/consumption/daily` — one delta chunk of a day's consumption.
- `PUT /v1/charging-sessions/{sessionId}` — a finished DC session with its curve. - `PUT /v1/charging-sessions/{sessionId}` — a finished DC session with its curve.
- `GET /v1/consumption/history/{installationId}` — the car reads its own totals back. - `GET /v1/consumption/history/{installationId}` — the car reads its own totals back.
+15 -1
View File
@@ -117,6 +117,20 @@ func (a *API) ingest(h handler) http.HandlerFunc {
} }
} }
// notYetAtAbrp leaves out the samples the car already sent to ABRP itself.
func notYetAtAbrp(samples []TelemetrySample, sentUTC int64) []TelemetrySample {
if sentUTC == 0 {
return samples
}
out := make([]TelemetrySample, 0, len(samples))
for _, s := range samples {
if s.UTC > sentUTC {
out = append(out, s)
}
}
return out
}
// maxDroppedListed caps the dropped values named in a telemetry response and log line. // maxDroppedListed caps the dropped values named in a telemetry response and log line.
const maxDroppedListed = 20 const maxDroppedListed = 20
@@ -136,7 +150,7 @@ func (a *API) telemetry(w http.ResponseWriter, r *http.Request, c caller, body [
if err := a.Store.WriteTelemetry(r.Context(), batch.InstallationID, batch.Samples); err != nil { if err := a.Store.WriteTelemetry(r.Context(), batch.InstallationID, batch.Samples); err != nil {
return err return err
} }
a.Forwarder.Forward(batch.Samples) a.Forwarder.Forward(notYetAtAbrp(batch.Samples, batch.AbrpSentUTC))
} }
dropped := batch.Dropped dropped := batch.Dropped
if len(dropped) > maxDroppedListed { if len(dropped) > maxDroppedListed {
+20
View File
@@ -204,3 +204,23 @@ func jsonInt(v int64) string {
b, _ := json.Marshal(v) b, _ := json.Marshal(v)
return string(b) return string(b)
} }
func TestSamplesTheCarSentToAbrpAreNotForwardedAgain(t *testing.T) {
samples := []TelemetrySample{{UTC: 100}, {UTC: 115}, {UTC: 130}}
if got := notYetAtAbrp(samples, 0); len(got) != 3 {
t.Fatalf("without abrpSentUtc everything is forwardable: %d", len(got))
}
if got := notYetAtAbrp(samples, 130); len(got) != 0 {
t.Fatalf("the car sent the newest: %d left", len(got))
}
if got := notYetAtAbrp(samples, 115); len(got) != 1 || got[0].UTC != 130 {
t.Fatalf("only the newer sample: %+v", got)
}
b, err := validateTelemetryBatch([]byte(`{"installationId":"`+testInstallation+`","abrpSentUtc":1790000000,"samples":[{"utc":1790000000}]}`), testNow)
if err != nil || b.AbrpSentUTC != 1790000000 {
t.Fatalf("abrpSentUtc not read: %v %d", err, b.AbrpSentUTC)
}
if _, err := validateTelemetryBatch([]byte(`{"installationId":"`+testInstallation+`","abrpSentUtc":"x","samples":[{"utc":1790000000}]}`), testNow); !isValidationError(err) {
t.Fatal("a malformed abrpSentUtc was accepted")
}
}
+3
View File
@@ -107,4 +107,7 @@ type TelemetryBatch struct {
Samples []TelemetrySample Samples []TelemetrySample
// Dropped names the values and samples validation left out, e.g. "samples[3].speed". // Dropped names the values and samples validation left out, e.g. "samples[3].speed".
Dropped []string Dropped []string
// AbrpSentUTC is the newest sample the car delivered to ABRP itself (0: none). The
// server forwards only samples newer than that, so ABRP gets each one once.
AbrpSentUTC int64
} }
+5
View File
@@ -273,6 +273,11 @@ func validateTelemetryBatch(body []byte, now time.Time) (TelemetryBatch, error)
return TelemetryBatch{}, invalid("samples is invalid") return TelemetryBatch{}, invalid("samples is invalid")
} }
batch := TelemetryBatch{InstallationID: id, Samples: make([]TelemetrySample, 0, len(raw))} batch := TelemetryBatch{InstallationID: id, Samples: make([]TelemetrySample, 0, len(raw))}
if o.has("abrpSentUtc") {
if batch.AbrpSentUTC, err = integer(o["abrpSentUtc"], "abrpSentUtc"); err != nil {
return TelemetryBatch{}, err
}
}
latest := now.Add(maxClockAhead).Unix() latest := now.Add(maxClockAhead).Unix()
for i, entry := range raw { for i, entry := range raw {
name := fmt.Sprintf("samples[%d]", i) name := fmt.Sprintf("samples[%d]", i)