Custom icons, improved GPS, history layout, address fixes

- Replace placeholder SVG icons with custom PNG icons (80x80 padded)
- AffineTransform for pixel-perfect icon centering in menu ring
- Colored circles behind icons with icon drawn at 60% size
- GPS: always wait full timeout (30s), keep best quality fix
- History: show address, PLZ+city, coordinates on separate lines
- Geocoding: fall back to "name" field for street-level results,
  include PLZ+city in cached address data
- Address distance threshold raised to 70m

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
EiSiMo 2026-04-13 19:05:17 +02:00
parent 79cdb9f210
commit 216d40c2c5
18 changed files with 108 additions and 101 deletions

View file

@ -64,7 +64,7 @@ class HistoryView extends WatchUi.View {
var evt = _events[_index];
// Use cached address from event if available.
if (evt.address != null) {
_addressCache[_index] = evt.address;
_addressCache[_index] = { "addr" => evt.address, "zip" => evt.zip };
return;
}
if (evt.lat == null || evt.lon == null) { return; }
@ -76,13 +76,14 @@ class HistoryView extends WatchUi.View {
_geocoder.start();
}
function _onAddress(address as String or Null) as Void {
_addressCache[_index] = address;
function _onAddress(result as Dictionary or Null) as Void {
_addressCache[_index] = result;
_addressLoading = false;
// Persist address in the event so the glance can show it.
if (address != null && _index < _events.size()) {
// Persist in the event so the glance can show it.
if (result != null && _index < _events.size()) {
var evt = _events[_index];
evt.address = address;
evt.address = result["addr"] as String or Null;
evt.zip = result["zip"] as String or Null;
EventStore.updateAt(_index, evt);
}
WatchUi.requestUpdate();
@ -134,51 +135,51 @@ class HistoryView extends WatchUi.View {
private function _drawMiddleSection(dc as Dc, cx as Number, topH as Number, botY as Number) as Void {
var evt = _events[_index];
var midY = topH + (botY - topH) / 2;
var fontDetail = Graphics.FONT_XTINY;
var lineH = dc.getFontHeight(fontDetail);
var sectionMid = topH + (botY - topH) / 2;
// Event type label.
var label = _eventLabel(evt.type);
var color = _eventColor(evt.type);
dc.setColor(color, Config.COLOR_BG);
var fontLabel = Graphics.FONT_SMALL;
var lineH = dc.getFontHeight(fontLabel);
dc.drawText(cx, midY - lineH * 2, fontLabel, label,
Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER);
// Collect lines to draw.
var lines = [] as Array<Array>; // [text, color]
// Date + time.
dc.setColor(Config.COLOR_FG, Config.COLOR_BG);
var fontDetail = Graphics.FONT_TINY;
var dateStr = _formatTimestamp(evt.timestamp);
dc.drawText(cx, midY - lineH / 2, fontDetail, dateStr,
Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER);
// 1: Event type (colored).
lines.add([_eventLabel(evt.type), _eventColor(evt.type)]);
// Address / coordinates / status.
var locStr = _locationString(evt);
dc.drawText(cx, midY + lineH / 2, fontDetail, locStr,
Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER);
// 2: Date + time.
lines.add([_formatTimestamp(evt.timestamp), Config.COLOR_FG]);
// Counter (e.g. "3/7").
dc.setColor(0x888888, Config.COLOR_BG);
dc.drawText(cx, midY + lineH * 3 / 2, Graphics.FONT_XTINY,
(_index + 1) + "/" + _events.size(),
Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER);
}
private function _locationString(evt as Event) as String {
// 3: Address or status.
if (evt.lat == null || evt.lon == null) {
return WatchUi.loadResource(Rez.Strings.history_no_gps) as String;
}
if (_addressCache.hasKey(_index)) {
var cached = _addressCache[_index];
lines.add([WatchUi.loadResource(Rez.Strings.history_no_gps) as String, Config.COLOR_FG]);
} else if (_addressCache.hasKey(_index)) {
var cached = _addressCache[_index] as Dictionary or Null;
if (cached != null) {
return cached as String;
lines.add([cached["addr"] as String, Config.COLOR_FG]);
var zip = cached["zip"] as String or Null;
if (zip != null) {
lines.add([zip, 0x888888]);
}
}
return _formatCoords(evt.lat as Float, evt.lon as Float);
} else if (_addressLoading) {
lines.add([WatchUi.loadResource(Rez.Strings.history_loading_address) as String, 0x888888]);
}
if (_addressLoading) {
return WatchUi.loadResource(Rez.Strings.history_loading_address) as String;
// 4: Coordinates (always, if available).
if (evt.lat != null && evt.lon != null) {
lines.add([_formatCoords(evt.lat as Float, evt.lon as Float), 0x888888]);
}
// 5: Counter.
lines.add([(_index + 1) + "/" + _events.size(), 0x666666]);
// Draw centered vertically.
var totalH = lines.size() * lineH;
var startY = sectionMid - totalH / 2 + lineH / 2;
for (var i = 0; i < lines.size(); i++) {
dc.setColor(lines[i][1] as Number, Config.COLOR_BG);
dc.drawText(cx, startY + i * lineH, fontDetail, lines[i][0] as String,
Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER);
}
return _formatCoords(evt.lat as Float, evt.lon as Float);
}
private function _formatCoords(lat as Float, lon as Float) as String {