diff --git a/apps/widscrlock/ChangeLog b/apps/widscrlock/ChangeLog new file mode 100644 index 000000000..9b23d8608 --- /dev/null +++ b/apps/widscrlock/ChangeLog @@ -0,0 +1 @@ +25/Jun/2022: Added to depository. \ No newline at end of file diff --git a/apps/widscrlock/metadata.json b/apps/widscrlock/metadata.json new file mode 100644 index 000000000..15aca37a5 --- /dev/null +++ b/apps/widscrlock/metadata.json @@ -0,0 +1,14 @@ +{ "id": "widscrlock", + "name": "Screenlock Widget", + "shortName":"Screenlock", + "version":"1.0", + "description": "A widget to lock a Bangle 2 screen with a tap.", + "icon": "widget.png", + "type": "widget", + "tags": "widget, screenlock", + "supports" : ["BANGLEJS2"], + "readme": "README.md", + "storage": [ + {"name:"widscrlock.wid.js","url":"widget.js"} + ] +} \ No newline at end of file diff --git a/apps/widscrlock/widget.js b/apps/widscrlock/widget.js new file mode 100644 index 000000000..96e71076c --- /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("GBiDAkkkkiSSSUkkkkkkiSSSSSUkkkkiSSSSSSSUkkkSSSSSSSSSkkiSSSf/ySSSUkiSSf///ySAUkSSSfwAPyQASkSST+AAB+AACiSST+AAB2AACSSST+AAA2AAASSST+AAA2AAASSSf//+22wAASSSf//222wAASSSf/+A22wAASSSf/wAG2wAASSSf+wAG2wACUSST2wAG2AACkSSS22A22AASkiSQG222wAAUkiSAAG2wAACUkkSAAAAAAASkkkiSAAAAASUkkkkiSAAASUkkkkkkiSSSUkkkg=="),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..3f165fdca Binary files /dev/null and b/apps/widscrlock/widget.png differ