fix(ui-lvgl): smooth WiFi/Bluetooth switches; retry 404 tiles

- The WiFi and Bluetooth rows rebuilt the whole Settings page to update
  their hint, cutting the switch's animation short; the hint is now
  rewritten in place (rowHintSet). The "Bluetooth on" echo toast is gone.
- Map download: a 404 gets the same one retry as other errors
  (OpenTopoMap sends the odd 404 for a tile not rendered yet), and a
  download that ends with gaps says "Done, N missing - download again".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-09-29 10:41:18 +02:00
co-authored by Claude Opus 5.5
parent 890ee6533e
commit bc266a4f5c
4 changed files with 47 additions and 33 deletions
+14 -14
View File
@@ -33,8 +33,19 @@ static void onWifiForget(lv_event_t* e) {
s_wifi_forget_btn = nullptr;
s_ui->wifiForget((int)(uintptr_t)lv_event_get_user_data(e));
}
static void wifiHint(char* sub, size_t n) {
int saved = lvport::wifiSavedCount();
if (!lvport::wifiAllowed()) snprintf(sub, n, "Off");
else if (saved == 1) snprintf(sub, n, "%s", lvport::wifiSaved(0)->ssid);
else if (saved > 1) snprintf(sub, n, "%d saved networks", saved);
else snprintf(sub, n, "Tap to pick a network");
}
static void onWifiAllowed(lv_event_t* e) {
s_ui->wifiSetAllowed(lv_obj_has_state((lv_obj_t*)lv_event_get_target(e), LV_STATE_CHECKED));
lv_obj_t* sw = (lv_obj_t*)lv_event_get_target(e);
s_ui->wifiSetAllowed(lv_obj_has_state(sw, LV_STATE_CHECKED));
char sub[48];
wifiHint(sub, sizeof(sub));
rowHintSet(lv_obj_get_parent(sw), sub);
}
static void onWifiField(lv_event_t* e) { s_ui->wifiEdit((lv_obj_t*)lv_event_get_target(e)); }
static void onWifiKb(lv_event_t* e) {
@@ -165,14 +176,9 @@ void UITask::wifiKeyboardHide() {
// on / off, the row opens the network settings.
static void wifiRow(lv_obj_t* body) {
char sub[48];
int n = lvport::wifiSavedCount();
bool on = lvport::wifiAllowed();
if (!on) snprintf(sub, sizeof(sub), "Off");
else if (n == 1) snprintf(sub, sizeof(sub), "%s", lvport::wifiSaved(0)->ssid);
else if (n > 1) snprintf(sub, sizeof(sub), "%d saved networks", n);
else snprintf(sub, sizeof(sub), "Tap to pick a network");
wifiHint(sub, sizeof(sub));
lv_obj_t* sw = switchRow(body, LV_SYMBOL_WIFI " WiFi", sub, nullptr);
if (on) lv_obj_add_state(sw, LV_STATE_CHECKED);
if (lvport::wifiAllowed()) lv_obj_add_state(sw, LV_STATE_CHECKED);
lv_obj_add_event_cb(sw, onWifiAllowed, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_t* row = lv_obj_get_parent(sw);
lv_obj_add_flag(row, LV_OBJ_FLAG_CLICKABLE);
@@ -189,12 +195,6 @@ void UITask::wifiSetAllowed(bool on) {
if (mapview::s_dl.active()) mapDownloadStop();
if (_wifi_scanning) { _wifi_scanning = false; lvport::netEnd(); }
}
if (_screen == SCR_SETTINGS) { // the row's subtitle
lv_obj_t* body = _body;
int32_t y = body ? lv_obj_get_scroll_y(body) : 0;
buildSettings();
if (_body) { lv_obj_update_layout(_body); lv_obj_scroll_to_y(_body, y, LV_ANIM_OFF); }
}
}
void UITask::wifiScan() {