Merge pull request #1164 from sphrases/master

Widget autohide widget
master
Gordon Williams 2022-01-04 10:08:55 +00:00 committed by GitHub
commit 166f619dae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 77 additions and 0 deletions

View File

@ -5098,6 +5098,21 @@
{"name":"ltherm.img","url":"icon.js","evaluate":true}
]
},
{
"id": "widviztime",
"name": "Widget Autohide Widget",
"shortName": "Viz Time Widget",
"version": "0.01",
"description": "The widgets will be shown for four seconds after the device is unlocked.",
"icon": "eye.png",
"type": "widget",
"tags": "widget",
"readme":"README.md",
"supports": ["BANGLEJS","BANGLEJS2"],
"storage": [
{"name":"widviztime.wid.js","url":"widget.js"}
]
},
{
"id": "supf",
"name": "Simple Clock with Date",

View File

@ -0,0 +1,8 @@
# Widget Autohide Widget
This widget is forked from the "Widget Visibility Widget"
It should make widgets completely hidden (except for 4 seconds after the watch is unlocked)
Additional features that I want to implement:
- Only show widgets when in app launcher
- Make timeout adjustable
- Disable widgets completely

View File

@ -0,0 +1 @@
0.01: New Widget, forked from widviz

BIN
apps/widviztime/eye.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

53
apps/widviztime/widget.js Normal file
View File

@ -0,0 +1,53 @@
(() => {
var saved = null;
function hide() {
if (!Bangle.isLCDOn() || saved) return;
saved = [];
for (var wd of WIDGETS) {
saved.push({
d: wd.draw,
a: wd.area
});
wd.draw = () => {};
wd.area = "";
}
g.setColor(0, 0, 0);
g.fillRect(0, 0, g.getWidth(), 23);
}
function reveal() {
if (!Bangle.isLCDOn() || !saved) return;
for (var wd of WIDGETS) {
var o = saved.shift();
wd.draw = o.d;
wd.area = o.a;
}
Bangle.drawWidgets();
saved = null;
}
function draw() {
g.setColor(0x07ff);
g.drawImage(atob("GBgBAAAAAAAAAAAAAAAAAH4AAf+AB4HgDgBwHDw4OH4cMOcMYMMGYMMGMOcMOH4cHDw4DgBwB4HgAf+AAH4AAAAAAAAAAAAAAAAA"), this.x, this.y);
}
WIDGETS.viz = {
area: "tl",
width: 24,
draw: draw
};
Bangle.on('lock', (locked) => {
if (!locked) {
reveal();
setTimeout(function() {
hide();
}, 4000);
}
});
})();