refactor: one copy of shared logic and widgets; GPS is asked for, not switched on silently

Duplicates found between the L1 and L2 frontends, and inside the L2 one:
- geo::fmtLocShare / fmtLatLon / turnDeg / isAhead (GeoUtils.h): the [LOC]
  text was built in five places, the turn angle and its "ahead" threshold in
  both navigations, coordinates by hand in nine. Tested.
- LiveShareEngine::setEnabled: live share was switched in three places.
- L1 waypoint share uses WaypointModel::shareText; Trail's "Share my pos"
  goes through UITask::quickShareMyLocation, so it now sends to a running
  live-share session as the home Map page does.
- L2 Widgets.h: switchCreate (one switch size, was four), switchRow with a
  state and callback (16 hand-wired copies), switchRowOpens (Bluetooth, WiFi,
  GPS), primaryButton (one height for Save / Measure / New area / Update).

GPS: with it off, starting the trail, live share or track back, sharing or
marking a position, or centring the map asks first ("GPS is off") on both
L1 and L2; Cancel leaves it undone. A share or a mark waits for a fresh fix
(a switched-off module may still report its last one), which also fixes the
L1 "Share my pos" sending a stale position. SOS still turns the GPS on itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-11-02 10:32:23 +01:00
co-authored by Claude Opus 5.5
parent 781a480aef
commit ada5b8e545
35 changed files with 301 additions and 208 deletions
@@ -1614,6 +1614,7 @@ public:
display.setTextSize(1);
display.drawTextCentered(display.width() / 2, content_y + step, "hibernating..."); // the panel's Hibernate row
}
if (_page == HomePage::MAP && _tile_menu.active) _tile_menu.render(display); // "GPS is off"
if (slide >= 0) { // page turn: the page left behind slides out, this one in
display.slideCompose(_slide_dir * (int)(display.width() * slide + 0.5f));
anim_ms = 15;
@@ -1634,6 +1635,14 @@ public:
}
bool handleInput(char c) override {
// Map page: "GPS is off" before a share (the tile menu, free on this page).
if (_page == HomePage::MAP && _tile_menu.active) {
if (_tile_menu.handleInput(c) == PopupMenu::SELECTED && _tile_menu.selectedIndex() == 0) {
_task->toggleGPS(false);
_task->showAlert("GPS on, share once it has a fix", 1500);
}
return true;
}
// Favourites grid claims joystick UP/DOWN and inner LEFT/RIGHT; LEFT at the
// left column and RIGHT at the right column fall through to page nav so the
// user can still leave the page sideways.
@@ -1759,6 +1768,12 @@ public:
return true;
}
if (c == KEY_CONTEXT_MENU && _page == HomePage::MAP) {
if (_task->hasGPS() && !_task->getGPSState()) { // its last fix may be stale: asked first
_tile_menu.begin("GPS is off", 2);
_tile_menu.addItem("Enable GPS");
_tile_menu.addItem("Cancel");
return true;
}
_task->quickShareMyLocation();
return true;
}