Phase 6: glance widget with cached address
App type changed to widget for glance support. GlanceView shows event type, date/time, and street+housenumber (or coordinates as fallback). Addresses are cached in Event storage on first view in history. Glance-required modules annotated with (:glance). Address distance threshold raised to 70m. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
eea1a835cd
commit
79cdb9f210
9 changed files with 134 additions and 12 deletions
|
|
@ -2,12 +2,14 @@ import Toybox.Lang;
|
|||
|
||||
// Value object for a protocol entry. Serialized as a plain Dictionary
|
||||
// so Application.Storage can persist it.
|
||||
(:glance)
|
||||
class Event {
|
||||
public var type as String;
|
||||
public var timestamp as Number; // unix seconds
|
||||
public var lat as Float or Null;
|
||||
public var lon as Float or Null;
|
||||
public var accuracy as Float or Null;
|
||||
public var address as String or Null;
|
||||
|
||||
function initialize(type as String, timestamp as Number,
|
||||
lat as Float or Null, lon as Float or Null,
|
||||
|
|
@ -17,25 +19,34 @@ class Event {
|
|||
self.lat = lat;
|
||||
self.lon = lon;
|
||||
self.accuracy = accuracy;
|
||||
self.address = null;
|
||||
}
|
||||
|
||||
function toDict() as Dictionary {
|
||||
return {
|
||||
var d = {
|
||||
"t" => type,
|
||||
"ts" => timestamp,
|
||||
"lat" => lat,
|
||||
"lon" => lon,
|
||||
"acc" => accuracy
|
||||
};
|
||||
if (address != null) {
|
||||
d["addr"] = address;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
static function fromDict(d as Dictionary) as Event {
|
||||
return new Event(
|
||||
var evt = new Event(
|
||||
d["t"] as String,
|
||||
d["ts"] as Number,
|
||||
d["lat"] as Float or Null,
|
||||
d["lon"] as Float or Null,
|
||||
d["acc"] as Float or Null
|
||||
);
|
||||
if (d.hasKey("addr")) {
|
||||
evt.address = d["addr"] as String or Null;
|
||||
}
|
||||
return evt;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue