Use Bangle.setUI({remove:...}) to allow loading the launcher without a full reset on 2v16

master
Gordon Williams 2022-09-23 17:43:09 +01:00
parent 899233394d
commit f6b38b3443
6 changed files with 61 additions and 39 deletions

View File

@ -10,4 +10,5 @@
week is buffered until date or timezone changes week is buffered until date or timezone changes
0.07: align default settings with app.js (otherwise the initial displayed settings will be confusing to users) 0.07: align default settings with app.js (otherwise the initial displayed settings will be confusing to users)
0.08: fixed calendar weeknumber not shortened to two digits 0.08: fixed calendar weeknumber not shortened to two digits
0.09: Use default Bangle formatter for booleans 0.09: Use default Bangle formatter for booleans
0.10: Use Bangle.setUI({remove:...}) to allow loading the launcher without a full reset on 2v16

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{ {
"id": "antonclk", "id": "antonclk",
"name": "Anton Clock", "name": "Anton Clock",
"version": "0.09", "version": "0.10",
"description": "A clock using the bold Anton font, optionally showing seconds and date in ISO-8601 format.", "description": "A clock using the bold Anton font, optionally showing seconds and date in ISO-8601 format.",
"readme":"README.md", "readme":"README.md",
"icon": "app.png", "icon": "app.png",

View File

@ -14,3 +14,4 @@
Add /*LANG*/ tags for internationalisation Add /*LANG*/ tags for internationalisation
0.13: Add fullscreen mode 0.13: Add fullscreen mode
0.14: Use default Bangle formatter for booleans 0.14: Use default Bangle formatter for booleans
0.15: Support for unload and quick return to the clock on 2v16

View File

@ -1,7 +1,8 @@
var s = require("Storage"); { // must be inside our own scope here so that when we are unloaded everything disappears
var scaleval = 1; let s = require("Storage");
var vectorval = 20; let scaleval = 1;
var font = g.getFonts().includes("12x20") ? "12x20" : "6x8:2"; let vectorval = 20;
let font = g.getFonts().includes("12x20") ? "12x20" : "6x8:2";
let settings = Object.assign({ let settings = Object.assign({
showClocks: true, showClocks: true,
fullscreen: false fullscreen: false
@ -20,7 +21,7 @@ if ("font" in settings){
scaleval = (font.split("x")[1])/20; scaleval = (font.split("x")[1])/20;
} }
} }
var apps = s.list(/\.info$/).map(app=>{var a=s.readJSON(app,1);return a&&{name:a.name,type:a.type,icon:a.icon,sortorder:a.sortorder,src:a.src};}).filter(app=>app && (app.type=="app" || (app.type=="clock" && settings.showClocks) || !app.type)); let apps = s.list(/\.info$/).map(app=>{var a=s.readJSON(app,1);return a&&{name:a.name,type:a.type,icon:a.icon,sortorder:a.sortorder,src:a.src};}).filter(app=>app && (app.type=="app" || (app.type=="clock" && settings.showClocks) || !app.type));
apps.sort((a,b)=>{ apps.sort((a,b)=>{
var n=(0|a.sortorder)-(0|b.sortorder); var n=(0|a.sortorder)-(0|b.sortorder);
if (n) return n; // do sortorder first if (n) return n; // do sortorder first
@ -69,18 +70,30 @@ E.showScroller({
} }
}); });
function returnToClock() {
// unload everything manually
// ... or we could just call `load();` but it will be slower
Bangle.setUI(); // remove scroller's handling
if (lockTimeout) clearTimeout(lockTimeout);
Bangle.removeListener("lock", lockHandler);
// now load the default clock - just call .bootcde as this has the code already
setTimeout(eval,0,s.read(".bootcde"));
}
// on bangle.js 2, the screen is used for navigating, so the single button goes back // on bangle.js 2, the screen is used for navigating, so the single button goes back
// on bangle.js 1, the buttons are used for navigating // on bangle.js 1, the buttons are used for navigating
if (process.env.HWVERSION==2) { if (process.env.HWVERSION==2) {
setWatch(_=>load(), BTN1, {edge:"falling"}); setWatch(returnToClock, BTN1, {edge:"falling"});
} }
// 10s of inactivity goes back to clock // 10s of inactivity goes back to clock
Bangle.setLocked(false); // unlock initially Bangle.setLocked(false); // unlock initially
var lockTimeout; let lockTimeout;
Bangle.on("lock", locked => { function lockHandler(locked) {
if (lockTimeout) clearTimeout(lockTimeout); if (lockTimeout) clearTimeout(lockTimeout);
lockTimeout = undefined; lockTimeout = undefined;
if (locked) if (locked)
lockTimeout = setTimeout(_=>load(), 10000); lockTimeout = setTimeout(returnToClock, 10000);
}); }
Bangle.on("lock", lockHandler);
}

View File

@ -2,7 +2,7 @@
"id": "launch", "id": "launch",
"name": "Launcher", "name": "Launcher",
"shortName": "Launcher", "shortName": "Launcher",
"version": "0.14", "version": "0.15",
"description": "This is needed to display a menu allowing you to choose your own applications. You can replace this with a customised launcher.", "description": "This is needed to display a menu allowing you to choose your own applications. You can replace this with a customised launcher.",
"readme": "README.md", "readme": "README.md",
"icon": "app.png", "icon": "app.png",