cleaner implementation
parent
696e97c373
commit
fc44eccb31
|
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
const ITEM_HEIGHT = 88;
|
const ITEM_HEIGHT = 88;
|
||||||
|
|
||||||
let scroller = E.showScroller({
|
E.showScroller({
|
||||||
h: ITEM_HEIGHT,
|
h: ITEM_HEIGHT,
|
||||||
c: apps.length,
|
c: apps.length,
|
||||||
draw: (idx, rect) => {
|
draw: (idx, rect) => {
|
||||||
|
|
@ -75,35 +75,14 @@
|
||||||
load(apps[idx].src);
|
load(apps[idx].src);
|
||||||
},
|
},
|
||||||
remove: () => {
|
remove: () => {
|
||||||
if (timeoutToClock) clearTimeout(timeoutToClock);
|
// Remove button handler
|
||||||
|
setWatch(() => { }, BTN1);
|
||||||
|
// Remove lock handler
|
||||||
|
Bangle.removeListener('lock');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update timeout on user interaction
|
setWatch(Bangle.showClock, BTN1, { debounce: 100 });
|
||||||
const originalDraw = scroller.draw;
|
// Add lock handler to show clock when locked
|
||||||
scroller.draw = () => {
|
Bangle.on('lock', (on) => { if (on) Bangle.showClock(); });
|
||||||
updateTimeoutToClock();
|
}
|
||||||
originalDraw();
|
|
||||||
};
|
|
||||||
|
|
||||||
// taken from Icon Launcher with minor alterations
|
|
||||||
let timeoutToClock;
|
|
||||||
const updateTimeoutToClock = function () {
|
|
||||||
if (settings.timeOut != 'Off') {
|
|
||||||
let time = parseInt(settings.timeOut); //the "s" will be trimmed by the parseInt
|
|
||||||
if (timeoutToClock) clearTimeout(timeoutToClock);
|
|
||||||
timeoutToClock = setTimeout(Bangle.showClock, time * 1000);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
updateTimeoutToClock();
|
|
||||||
|
|
||||||
if (Bangle.backHandler) clearWatch(Bangle.backHandler);
|
|
||||||
Bangle.backHandler = setWatch(Bangle.showClock, BTN1, { debounce: 100 });
|
|
||||||
} // end of app scope
|
|
||||||
|
|
||||||
// setUI now also needs to clear up our back button touch handler
|
|
||||||
Bangle.setUI = (old => function () {
|
|
||||||
if (Bangle.backHandler) clearWatch(Bangle.backHandler);
|
|
||||||
delete Bangle.backHandler;
|
|
||||||
return old.apply(this, arguments);
|
|
||||||
})(Bangle.setUI);
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "cutelauncher",
|
"id": "cutelauncher",
|
||||||
"name": "Cute Launcher",
|
"name": "Cute Launcher",
|
||||||
"version": "0.03",
|
"version": "0.04",
|
||||||
"description": "A simple launcher app for Bangle.js 2 that makes use of the full touchscreen",
|
"description": "A simple launcher app for Bangle.js 2 that makes use of the full touchscreen",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"type": "launch",
|
"type": "launch",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue