diff --git a/apps/widscrlock/ChangeLog b/apps/widscrlock/ChangeLog new file mode 100644 index 000000000..e6d9f3512 --- /dev/null +++ b/apps/widscrlock/ChangeLog @@ -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... diff --git a/apps/widscrlock/README.md b/apps/widscrlock/README.md new file mode 100644 index 000000000..043bfbf40 --- /dev/null +++ b/apps/widscrlock/README.md @@ -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. diff --git a/apps/widscrlock/metadata.json b/apps/widscrlock/metadata.json new file mode 100644 index 000000000..9ff76b910 --- /dev/null +++ b/apps/widscrlock/metadata.json @@ -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"} + ] +} diff --git a/apps/widscrlock/widget.js b/apps/widscrlock/widget.js new file mode 100644 index 000000000..27ba2df07 --- /dev/null +++ b/apps/widscrlock/widget.js @@ -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); + } + }); +})(); diff --git a/apps/widscrlock/widget.png b/apps/widscrlock/widget.png new file mode 100644 index 000000000..76c490785 Binary files /dev/null and b/apps/widscrlock/widget.png differ