Merge pull request #1998 from CarlR9/master

Screenlock Widget
master
Gordon Williams 2022-06-27 12:20:39 +01:00 committed by GitHub
commit 29d8fd6f6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 55 additions and 0 deletions

View File

@ -0,0 +1,2 @@
0.01: 25/Jun/2022 Added Screenlock widget to depository.
0.02: 26/Jun/2022 Tidied up graphics. Fixed versioning style...

View File

@ -0,0 +1,3 @@
A Bangle 2 widget to lock the screen.
Tap on the widget's lock icon to lock and darken the touch-screen as happens with the LCD timeout.

View File

@ -0,0 +1,14 @@
{ "id": "widscrlock",
"name": "Screenlock Widget",
"shortName":"Screenlock",
"version":"0.02",
"description": "Lock a Bangle 2 screen by tapping a widget.",
"icon": "widget.png",
"type": "widget",
"tags": "widget, screenlock",
"supports" : ["BANGLEJS2"],
"readme": "README.md",
"storage": [
{"name":"widscrlock.wid.js","url":"widget.js"}
]
}

36
apps/widscrlock/widget.js Normal file
View File

@ -0,0 +1,36 @@
// Screenlock Widget
(() => {
var widX = 0;
var widY = 0;
function draw() {
// Draw icon.
g.reset();
widX = this.x;
widY = this.y;
g.drawImage(atob("GBiDAkkkkiSSSUkkkkkkiSSSSSUkkkkiSSf/ySSUkkkSSf///ySSkkiST/ySf+SQUkiST+SST+SAUkSSfySSSfwACkSSfySSSewACiSSfySSSWwAASSSfySSSGwAASSSfySSQGwAASST///+222AASST///2222AASST//+A222AASST//wAG22AASST/+AAA22AASST/2wAG22AAUST+22A222ACkiT222A222ACkiSG22A22wAUkkQA22222ACkkkiAG222wAUkkkkSAAAAASkkkkkkSQACSkkkg=="),widX,widY);
}
// add widget.
WIDGETS.widscrlock={
area:"tr",
width: 24,
draw:draw // Draw widget.
};
setInterval(()=>WIDGETS.widscrlock.draw(), 60000);
function restoreTimeout(){
// Restore LCDTimeout settings.
Bangle.setLCDTimeout(options.lockTimeout / 1000);
}
var options = [];
Bangle.on('touch', function(button, xy) {
if(xy.x>=widX && xy.x<=widX+23 && xy.y>=widY && xy.y<=widY+23) {
options = Bangle.getOptions(); // Store current Timeout settings.
Bangle.setLCDTimeout(0.1); // Lock screen.
setTimeout(restoreTimeout, 1000);
}
});
})();

BIN
apps/widscrlock/widget.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB