From aedd05af703b89c87fa43da3a5308813b24ed9c2 Mon Sep 17 00:00:00 2001 From: Marco H Date: Sun, 1 Jan 2023 20:04:34 +0100 Subject: [PATCH] Show last success date Do not start A-GPS update automatically --- apps/agpsdata/ChangeLog | 2 ++ apps/agpsdata/app.js | 24 +++++++++++++++++++----- apps/agpsdata/metadata.json | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/apps/agpsdata/ChangeLog b/apps/agpsdata/ChangeLog index 8ada244d7..d900841d7 100644 --- a/apps/agpsdata/ChangeLog +++ b/apps/agpsdata/ChangeLog @@ -3,3 +3,5 @@ 0.03: Do not load AGPS data on boot Increase minimum interval to 6 hours 0.04: Write AGPS data chunks with delay to improve reliability +0.05: Show last success date + Do not start A-GPS update automatically diff --git a/apps/agpsdata/app.js b/apps/agpsdata/app.js index 4a6d2ba5c..48714d6d2 100644 --- a/apps/agpsdata/app.js +++ b/apps/agpsdata/app.js @@ -23,12 +23,26 @@ Bangle.drawWidgets(); let waiting = false; -function start() { +function start(restart) { g.reset(); g.clear(); waiting = false; - display("Retry?", "touch to retry"); + if (!restart) { + display("Start?", "touch to start"); + } + else { + display("Retry?", "touch to retry"); + } Bangle.on("touch", () => { updateAgps(); }); + + const file = "agpsdata.json"; + let data = require("Storage").readJSON(file, 1) || {}; + if (data.lastUpdate) { + g.setFont("Vector", 11); + g.drawString("last success:", 5, g.getHeight() - 22); + g.drawString(new Date(data.lastUpdate).toISOString(), 5, g.getHeight() - 11); + } + } function updateAgps() { @@ -36,7 +50,7 @@ function updateAgps() { g.clear(); if (!waiting) { waiting = true; - display("Updating A-GPS...", "takes ~ 10 seconds"); + display("Updating A-GPS...", "takes ~10 seconds"); require("agpsdata").pull(function() { waiting = false; display("A-GPS updated.", "touch to close"); @@ -45,10 +59,10 @@ function updateAgps() { function(error) { waiting = false; E.showAlert(error, "Error") - .then(() => { start(); }); + .then(() => { start(true); }); }); } else { display("Waiting..."); } } -updateAgps(); +start(false); diff --git a/apps/agpsdata/metadata.json b/apps/agpsdata/metadata.json index 203a00f72..7f0b53217 100644 --- a/apps/agpsdata/metadata.json +++ b/apps/agpsdata/metadata.json @@ -2,7 +2,7 @@ "name": "A-GPS Data Downloader App", "shortName":"A-GPS Data", "icon": "agpsdata.png", - "version":"0.04", + "version":"0.05", "description": "Once installed, this app allows you to download assisted GPS (A-GPS) data directly to your Bangle.js **via Gadgetbridge on an Android phone** when you run the app. If you just want to upload the latest AGPS data from this app loader, please use the `Assisted GPS Update (AGPS)` app.", "tags": "boot,tool,assisted,gps,agps,http", "allow_emulator":true,