taglaunch: Fix lockhandler

master
Erik Andresen 2023-07-28 08:00:22 +02:00
parent 2024f9267c
commit c64b8d2fa6
1 changed files with 13 additions and 11 deletions

View File

@ -79,6 +79,17 @@ const unload = () => {
Bangle.removeListener("lock", lockHandler); Bangle.removeListener("lock", lockHandler);
}; };
// 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);
}
};
let showTagMenu = (tag) => { let showTagMenu = (tag) => {
E.showScroller({ E.showScroller({
h : 64*scaleval, c : appsByTag[tag].length, h : 64*scaleval, c : appsByTag[tag].length,
@ -105,6 +116,7 @@ let showTagMenu = (tag) => {
back : showMainMenu, back : showMainMenu,
remove: unload remove: unload
}); });
Bangle.on("lock", lockHandler);
}; };
let showMainMenu = () => { let showMainMenu = () => {
@ -127,21 +139,11 @@ let showMainMenu = () => {
back : Bangle.showClock, // button press or tap in top left shows clock now back : Bangle.showClock, // button press or tap in top left shows clock now
remove : unload remove : unload
}); });
Bangle.on("lock", lockHandler);
}; };
showMainMenu(); showMainMenu();
g.flip(); // force a render before widgets have finished drawing 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();
} }