diff --git a/apps/agenda/ChangeLog b/apps/agenda/ChangeLog index ae650deeb..048595af1 100644 --- a/apps/agenda/ChangeLog +++ b/apps/agenda/ChangeLog @@ -1,2 +1,3 @@ 0.01: Basic agenda with events from GB 0.02: Added settings page to force calendar sync +0.03: Disable past events display from settings diff --git a/apps/agenda/agenda.js b/apps/agenda/agenda.js index f39e31c75..c600ef7f6 100644 --- a/apps/agenda/agenda.js +++ b/apps/agenda/agenda.js @@ -24,6 +24,7 @@ var fontLarge = g.getFonts().includes("6x15")?"6x15:2":"6x8:4"; //FIXME maybe write the end from GB already? Not durationInSeconds here (or do while receiving?) var CALENDAR = require("Storage").readJSON("android.calendar.json",true)||[]; +var settings = require("Storage").readJSON("agenda.settings.json",true)||{}; CALENDAR=CALENDAR.sort((a,b)=>a.timestamp - b.timestamp) @@ -89,6 +90,12 @@ function showEvent(ev) { } function showList() { + //it might take time for GB to delete old events, decide whether to show them grayed out or hide entirely + if(!settings.pastEvents) { + let now = new Date(); + //TODO add threshold here? + CALENDAR = CALENDAR.filter(ev=>ev.timestamp + ev.durationInSeconds > now/1000); + } if(CALENDAR.length == 0) { E.showMessage("No events"); return; @@ -101,10 +108,10 @@ function showList() { g.setColor(g.theme.fg); g.clearRect(r.x,r.y,r.x+r.w, r.y+r.h); if (!ev) return; - var isPast = ev.timestamp + ev.durationInSeconds < (new Date())/1000; + var isPast = false; var x = r.x+2, title = ev.title; - var body = formatDateShort(getDate(ev.timestamp))+"\n"+ev.location; - var m = ev.title+"\n"+ev.location, longBody=false; + var body = formatDateShort(getDate(ev.timestamp))+"\n"+(ev.location?ev.location:/*LANG*/"No location"); + if(settings.pastEvents) isPast = ev.timestamp + ev.durationInSeconds < (new Date())/1000; if (title) g.setFontAlign(-1,-1).setFont(fontBig) .setColor(isPast ? "#888" : g.theme.fg).drawString(title, x,r.y+2); if (body) { @@ -114,10 +121,8 @@ function showList() { l = l.slice(0,3); l[l.length-1]+="..."; } - longBody = l.length>2; g.drawString(l.join("\n"), x+10,r.y+20); } - //if (!longBody && msg.src) g.setFontAlign(1,1).setFont("6x8").drawString(msg.src, r.x+r.w-2, r.y+r.h-2); g.setColor("#888").fillRect(r.x,r.y+r.h-1,r.x+r.w-1,r.y+r.h-1); // dividing line between items }, select : idx => showEvent(CALENDAR[idx]), diff --git a/apps/agenda/metadata.json b/apps/agenda/metadata.json index ce8438686..b057d37e0 100644 --- a/apps/agenda/metadata.json +++ b/apps/agenda/metadata.json @@ -1,7 +1,7 @@ { "id": "agenda", "name": "Agenda", - "version": "0.02", + "version": "0.03", "description": "Simple agenda", "icon": "agenda.png", "screenshots": [{"url":"screenshot_agenda_overview.png"}, {"url":"screenshot_agenda_event1.png"}, {"url":"screenshot_agenda_event2.png"}], @@ -13,5 +13,6 @@ {"name":"agenda.app.js","url":"agenda.js"}, {"name":"agenda.settings.js","url":"settings.js"}, {"name":"agenda.img","url":"agenda-icon.js","evaluate":true} - ] + ], + "data": [{"name":"agenda.settings.json"}] } diff --git a/apps/agenda/settings.js b/apps/agenda/settings.js index fe9dab2d8..4220fcb63 100644 --- a/apps/agenda/settings.js +++ b/apps/agenda/settings.js @@ -3,6 +3,10 @@ Bluetooth.println(""); Bluetooth.println(JSON.stringify(message)); } + var settings = require("Storage").readJSON("agenda.settings.json",1)||{}; + function updateSettings() { + require("Storage").writeJSON("agenda.settings.json", settings); + } var CALENDAR = require("Storage").readJSON("android.calendar.json",true)||[]; var mainmenu = { "" : { "title" : "Agenda" }, @@ -32,6 +36,13 @@ E.showAlert(/*LANG*/"You are not connected").then(()=>E.showMenu(mainmenu)); } }, + /*LANG*/"Show past events" : { + value : !!settings.pastEvents, + onchange: v => { + settings.pastEvents = v; + updateSettings(); + } + }, }; E.showMenu(mainmenu); }) diff --git a/apps/android/ChangeLog b/apps/android/ChangeLog index 76658af49..0cc7aedd4 100644 --- a/apps/android/ChangeLog +++ b/apps/android/ChangeLog @@ -11,4 +11,5 @@ 0.10: Fix SMS bug 0.12: Use default Bangle formatter for booleans 0.13: Added Bangle.http function (see Readme file for more info) -0.14: Fix timeout of http function not beeing cleaned up +0.14: Fix timeout of http function not being cleaned up +0.15: Allow method/body/headers to be specified for `http` (needs Gadgetbridge 0.68.0b or later) diff --git a/apps/android/boot.js b/apps/android/boot.js index 99d4dbb2c..bc8e3032d 100644 --- a/apps/android/boot.js +++ b/apps/android/boot.js @@ -150,6 +150,9 @@ //send the request var req = {t: "http", url:url, id:options.id}; if (options.xpath) req.xpath = options.xpath; + if (options.method) req.method = options.method; + if (options.body) req.body = options.body; + if (options.headers) req.headers = options.headers; gbSend(req); //create the promise var promise = new Promise(function(resolve,reject) { diff --git a/apps/android/metadata.json b/apps/android/metadata.json index 91f74c36f..5d1b2f561 100644 --- a/apps/android/metadata.json +++ b/apps/android/metadata.json @@ -2,7 +2,7 @@ "id": "android", "name": "Android Integration", "shortName": "Android", - "version": "0.14", + "version": "0.15", "description": "Display notifications/music/etc sent from the Gadgetbridge app on Android. This replaces the old 'Gadgetbridge' Bangle.js widget.", "icon": "app.png", "tags": "tool,system,messages,notifications,gadgetbridge", diff --git a/apps/espruinoprog/ChangeLog b/apps/espruinoprog/ChangeLog index 5560f00bc..6fdcad1d6 100644 --- a/apps/espruinoprog/ChangeLog +++ b/apps/espruinoprog/ChangeLog @@ -1 +1,4 @@ 0.01: New App! +0.02: Add 'pre' code that can erase the device + Wait more between sending code snippets + Now force use of 'Storage' (assume 2v00 or later) diff --git a/apps/espruinoprog/README.md b/apps/espruinoprog/README.md index a8f15d3e9..aef4cccad 100644 --- a/apps/espruinoprog/README.md +++ b/apps/espruinoprog/README.md @@ -13,6 +13,9 @@ Click on the Customise button in the app loader to set up the programmer. * First you need to choose the kind of devices you want to upload to. This is the text that should match the Bluetooth advertising name. So `Puck.js` for Puck.js devices, or `Bangle.js` for Bangles. +* In the next box, you have code to run before the upload of the main code. By default +the code `require("Storage").list().forEach(f=>require("Storage").erase(f));reset();` will +erase all files on the device and reset it. * Now paste in the code you want to write to the device. This is automatically written to flash (`.bootcde`). See https://www.espruino.com/Saving#save-on-send-to-flash- for more information. @@ -35,8 +38,6 @@ To stop scanning, long-press the button to return to the clock. ## Notes -* Right now the Espruino Tools used here are unaware of the device they're writing to, -and as a result they don't use Storage and so the size of the files you can -write to the device are quite limited. You should be find with up to 4k of code. +* This assumes the device being written to is at least version 2v00 of Espruino * Currently, code is not minified before upload (so you need to supply pre-minified code if you want that) diff --git a/apps/espruinoprog/app.js b/apps/espruinoprog/app.js index b939d4007..58fac4a0b 100644 --- a/apps/espruinoprog/app.js +++ b/apps/espruinoprog/app.js @@ -58,21 +58,31 @@ function scanAndConnect() { term.print("Connected...\r\n"); uart.removeAllListeners(); uart.on('data', function(d) { term.print(d); }); - uart.write(json.code+"\n").then(() => { - term.print("\r\nUpload Complete...\r\n"); - // main upload completed - wait a bit + term.print("Upload initial...\r\n"); + uart.write((json.pre||"")+"\n").then(() => { + term.print("\r\Done.\r\n"); uploadTimeout = setTimeout(function() { - term.print("\r\nFinal Upload...\r\n"); - // now upload the code to run after... - uart.write(json.post+"\n").then(() => { - term.print("\r\nDone.\r\n"); - // now wait and disconnect (if not already done!) + uploadTimeout = undefined; + term.print("\r\nUpload Code...\r\n"); + uart.write((json.code||"")+"\n").then(() => { + term.print("\r\Done.\r\n"); + // main upload completed - wait a bit uploadTimeout = setTimeout(function() { - term.print("\r\nDisconnecting...\r\n"); - if (uart) uart.disconnect(); - }, 500); + uploadTimeout = undefined; + term.print("\r\Upload final...\r\n"); + // now upload the code to run after... + uart.write((json.post||"")+"\n").then(() => { + term.print("\r\nDone.\r\n"); + // now wait and disconnect (if not already done!) + uploadTimeout = setTimeout(function() { + uploadTimeout = undefined; + term.print("\r\nDisconnecting...\r\n"); + if (uart) uart.disconnect(); + }, 500); + }); + }, 2000); }); - }, 1000); + }, 2000); }); }); }).catch(err => { diff --git a/apps/espruinoprog/custom.html b/apps/espruinoprog/custom.html index c994aaea7..a12189707 100644 --- a/apps/espruinoprog/custom.html +++ b/apps/espruinoprog/custom.html @@ -17,6 +17,8 @@

Upload code to devices with names starting with:

+

Enter the code to send before upload here:

+

Enter your program to upload here:

Enter the code to send after upload here:

@@ -24,12 +26,17 @@

Then click  

Click here to reset to defaults.