Fix broken reset

master
Anton 2024-04-01 22:49:47 +02:00
parent ec9f9cecf9
commit 953fe9c8d5
4 changed files with 45 additions and 46 deletions

View File

@ -20,3 +20,4 @@
0.18: Add 'back' icon in top-left to go back to clock 0.18: Add 'back' icon in top-left to go back to clock
0.19: Fix regression after back button added (returnToClock was called twice!) 0.19: Fix regression after back button added (returnToClock was called twice!)
0.20: Use Bangle.showClock for changing to clock 0.20: Use Bangle.showClock for changing to clock
0.21: Fix a bug where a warning would stay on screen forever

View File

@ -42,47 +42,51 @@ let apps = launchCache.apps;
if (!settings.fullscreen) if (!settings.fullscreen)
Bangle.loadWidgets(); Bangle.loadWidgets();
E.showScroller({ const drawMenu = () => {
h : 64*scaleval, c : apps.length, E.showScroller({
draw : (i, r) => { h : 64*scaleval, c : apps.length,
var app = apps[i]; draw : (i, r) => {
if (!app) return; var app = apps[i];
g.clearRect((r.x),(r.y),(r.x+r.w-1), (r.y+r.h-1)); if (!app) return;
g.setFont(font).setFontAlign(-1,0).drawString(app.name,64*scaleval,r.y+(32*scaleval)); g.clearRect((r.x),(r.y),(r.x+r.w-1), (r.y+r.h-1));
if (app.icon) { g.setFont(font).setFontAlign(-1,0).drawString(app.name,64*scaleval,r.y+(32*scaleval));
if (!app.img) app.img = s.read(app.icon); // load icon if it wasn't loaded if (app.icon) {
try {g.drawImage(app.img,8*scaleval, r.y+(8*scaleval), {scale: scaleval});} catch(e){} if (!app.img) app.img = s.read(app.icon); // load icon if it wasn't loaded
try {g.drawImage(app.img,8*scaleval, r.y+(8*scaleval), {scale: scaleval});} catch(e){}
}
},
select : i => {
var app = apps[i];
if (!app) return;
if (!app.src || require("Storage").read(app.src)===undefined) {
E.showMessage(/*LANG*/"App Source\nNot found");
setTimeout(drawMenu, 2000);
} else {
load(app.src);
}
},
back : Bangle.showClock, // button press or tap in top left shows clock now
remove : () => {
// cleanup the timeout to not leave anything behind after being removed from ram
if (lockTimeout) clearTimeout(lockTimeout);
Bangle.removeListener("lock", lockHandler);
} }
}, });
select : i => { g.flip(); // force a render before widgets have finished drawing
var app = apps[i];
if (!app) return; // 10s of inactivity goes back to clock
if (!app.src || require("Storage").read(app.src)===undefined) { Bangle.setLocked(false); // unlock initially
E.showMessage(/*LANG*/"App Source\nNot found"); let lockTimeout;
setTimeout(drawMenu, 2000); let lockHandler = function(locked) {
} else { if (lockTimeout) clearTimeout(lockTimeout);
load(app.src); lockTimeout = undefined;
} if (locked)
}, lockTimeout = setTimeout(Bangle.showClock, 10000);
back : Bangle.showClock, // button press or tap in top left shows clock now }
remove : () => { Bangle.on("lock", lockHandler);
// cleanup the timeout to not leave anything behind after being removed from ram };
if (lockTimeout) clearTimeout(lockTimeout); drawMenu();
Bangle.removeListener("lock", lockHandler);
}
});
g.flip(); // force a render before widgets have finished drawing
// 10s of inactivity goes back to clock
Bangle.setLocked(false); // unlock initially
let lockTimeout;
let lockHandler = function(locked) {
if (lockTimeout) clearTimeout(lockTimeout);
lockTimeout = undefined;
if (locked)
lockTimeout = setTimeout(Bangle.showClock, 10000);
}
Bangle.on("lock", lockHandler);
if (!settings.fullscreen) // finally draw widgets if (!settings.fullscreen) // finally draw widgets
Bangle.drawWidgets(); Bangle.drawWidgets();
} }

View File

@ -2,7 +2,7 @@
"id": "launch", "id": "launch",
"name": "Launcher", "name": "Launcher",
"shortName": "Launcher", "shortName": "Launcher",
"version": "0.20", "version": "0.21",
"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",

View File

@ -1002,12 +1002,6 @@ module.exports = {
"no-undef" "no-undef"
] ]
}, },
"launch/app.js": {
"hash": "7d5b7d7f2adbe4c8c137f76b6560a06437ab142cfeffb3f0ff261f1250a6b687",
"rules": [
"no-undef"
]
},
"kitchen/stepo2.kit.js": { "kitchen/stepo2.kit.js": {
"hash": "b7660bef1a2560f23ff696b03d297cdd39936ca61c01b3d0a316d49f9cf72590", "hash": "b7660bef1a2560f23ff696b03d297cdd39936ca61c01b3d0a316d49f9cf72590",
"rules": [ "rules": [