From 039024c4ad04f4d61c2933349eefd729281c9444 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Fri, 9 Apr 2021 09:58:38 +0100 Subject: [PATCH] Allow 'data' style app files to be uploaded with the app (and switch over settings files for various apps) --- CHANGELOG.md | 1 + README.md | 10 ++++++++-- apps.json | 29 ++++++++++++++++++++++------- apps/setting/settings.min.json | 1 + bin/sanitycheck.js | 4 ++-- core | 2 +- 6 files changed, 35 insertions(+), 12 deletions(-) create mode 100644 apps/setting/settings.min.json diff --git a/CHANGELOG.md b/CHANGELOG.md index c243093c6..86fe0c10c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,3 +29,4 @@ Changed for individual apps are listed in `apps/appname/ChangeLog` * Added progress bar on Bangle.js for uploads * Provide a proper error message in case JSON decode fails * Check you're connecting with a Bangle.js of the correct version +* Allow 'data' style app files to be uploaded with the app (and switch over settings files for various apps) diff --git a/README.md b/README.md index 294b9cb75..e71d7eee0 100644 --- a/README.md +++ b/README.md @@ -249,14 +249,20 @@ and which gives information about the app for the Launcher. {"name":"appid.js", // filename to use in storage. // If name=='RAM', the code is sent directly to Bangle.js and is not saved to a file "url":"", // URL of file to load (currently relative to apps/) - "content":"..." // if supplied, this content is loaded directly - "evaluate":true // if supplied, data isn't quoted into a String before upload + "content":"...", // if supplied, this content is loaded directly + "evaluate":true, // if supplied, data isn't quoted into a String before upload // (eg it's evaluated as JS) + "noOverwrite":true // if supplied, this file will not be overwritten if it + // already exists }, ] "data": [ // list of files the app writes to {"name":"appid.data.json", // filename used in storage "storageFile":true // if supplied, file is treated as storageFile + "url":"", // if supplied URL of file to load (currently relative to apps/) + "content":"...", // if supplied, this content is loaded directly + "evaluate":true, // if supplied, data isn't quoted into a String before upload + // (eg it's evaluated as JS) }, {"wildcard":"appid.data.*" // wildcard of filenames used in storage }, // this is mutually exclusive with using "name" diff --git a/apps.json b/apps.json index e1766d311..f6ac2f7f0 100644 --- a/apps.json +++ b/apps.json @@ -180,6 +180,9 @@ {"name":"setting.boot.js","url":"boot.js"}, {"name":"setting.img","url":"settings-icon.js","evaluate":true} ], + "data": [ + {"name":"setting.json", "url":"settings.min.json","evaluate":true} + ], "sortorder" : -2 }, { "id": "alarm", @@ -439,8 +442,10 @@ "interface":"waypoints.html", "storage": [ {"name":"gpsnav.app.js","url":"app.min.js"}, - {"name":"waypoints.json","url":"waypoints.json","evaluate":false}, {"name":"gpsnav.img","url":"app-icon.js","evaluate":true} + ], + "data": [ + {"name":"waypoints.json","url":"waypoints.json"} ] }, { "id": "heart", @@ -2414,9 +2419,11 @@ "readme": "README.md", "storage": [ {"name":"worldclock.app.js","url":"app.js"}, - {"name":"worldclock.settings.json"}, {"name":"worldclock.img","url":"worldclock-icon.js","evaluate":true} - ] + ], + "data": [ + {"name":"worldclock.settings.json"} + ] }, { "id": "digiclock", "name": "Digital Clock Face", @@ -2659,8 +2666,10 @@ "readme": "README.md", "storage": [ {"name":"breath.app.js","url":"app.js"}, - {"name":"breath.settings.json","url":"settings.json"}, {"name":"breath.img","url":"app-icon.js","evaluate":true} + ], + "data": [ + {"name":"breath.settings.json","url":"settings.json"} ] }, { "id": "lazyclock", @@ -2757,9 +2766,11 @@ "storage": [ {"name":"gpsservice.app.js","url":"app.js"}, {"name":"gpsservice.settings.js","url":"settings.js"}, - {"name":"gpsservice.settings.json","url":"settings.json"}, {"name":"gpsservice.wid.js","url":"widget.js"}, {"name":"gpsservice.img","url":"gpsservice-icon.js","evaluate":true} + ], + "data": [ + {"name":"gpsservice.settings.json","url":"settings.json"} ] }, { "id": "mclockplus", @@ -2856,9 +2867,11 @@ "storage": [ {"name":"gpssetup","url":"gpssetup.js"}, {"name":"gpssetup.settings.js","url":"settings.js"}, - {"name":"gpssetup.settings.json","url":"settings.json"}, {"name":"gpssetup.app.js","url":"app.js"}, {"name":"gpssetup.img","url":"icon.js","evaluate":true} + ], + "data": [ + {"name":"gpssetup.settings.json","url":"settings.json"} ] }, { "id": "walkersclock", @@ -2959,8 +2972,10 @@ "interface":"waypoints.html", "storage": [ {"name":"waypointer.app.js","url":"app.js"}, - {"name":"waypoints.json","url":"waypoints.json","evaluate":false}, {"name":"waypointer.img","url":"icon.js","evaluate":true} + ], + "data": [ + {"name":"waypoints.json","url":"waypoints.json"} ] }, { "id": "color_catalog", diff --git a/apps/setting/settings.min.json b/apps/setting/settings.min.json new file mode 100644 index 000000000..984054c11 --- /dev/null +++ b/apps/setting/settings.min.json @@ -0,0 +1 @@ +{"ble":true,"blerepl":true,"log":false,"timeout":10,"vibrate":true,"beep":"vib","timezone":0,"HID":false,"clock":null,"12hour":false,"brightness":1,"options":{"wakeOnBTN1":true,"wakeOnBTN2":true,"wakeOnBTN3":true,"wakeOnFaceUp":false,"wakeOnTouch":false,"wakeOnTwist":true,"twistThreshold":819.2,"twistMaxY":-800,"twistTimeout":1000}} \ No newline at end of file diff --git a/bin/sanitycheck.js b/bin/sanitycheck.js index 2c6ac0d95..8cc78ea2a 100755 --- a/bin/sanitycheck.js +++ b/bin/sanitycheck.js @@ -54,8 +54,8 @@ const APP_KEYS = [ 'sortorder', 'readme', 'custom', 'interface', 'storage', 'data', 'allow_emulator', 'dependencies' ]; -const STORAGE_KEYS = ['name', 'url', 'content', 'evaluate']; -const DATA_KEYS = ['name', 'wildcard', 'storageFile']; +const STORAGE_KEYS = ['name', 'url', 'content', 'evaluate', 'noOverwite']; +const DATA_KEYS = ['name', 'wildcard', 'storageFile', 'url', 'content', 'evaluate']; const FORBIDDEN_FILE_NAME_CHARS = /[,;]/; // used as separators in appid.info const VALID_DUPLICATES = [ '.tfmodel', '.tfnames' ]; diff --git a/core b/core index e65920a91..7d04c4884 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit e65920a91f9f7178c9d8ed6551ac7d9af0a5d6e1 +Subproject commit 7d04c488496c873f392c5a068f72a6c75df40f70