1
0
Fork 0

widbthide: remove settings & update metadata

master
Iakov Davydov 2022-05-18 19:18:42 +02:00
parent 19ab79e5d1
commit 9f3ed84d6c
3 changed files with 11 additions and 50 deletions

View File

@ -1,15 +1,13 @@
{
"id": "widbt",
"name": "Bluetooth Widget",
"version": "0.09",
"description": "Show the current Bluetooth connection status in the top right of the clock",
"id": "widbthide",
"name": "Bluetooth Widget (hides when no connection)",
"version": "0.01",
"description": "Shows Bluetooth icon (when connected) in the top right of the clock",
"icon": "widget.png",
"type": "widget",
"tags": "widget,bluetooth",
"supports": ["BANGLEJS","BANGLEJS2"],
"storage": [
{"name":"widbt.wid.js","url":"widget.js"},
{"name":"widbt.settings.js","url":"settings.js"}
],
"data": [{"name":"widbt.json"}]
{"name":"widbt.wid.js","url":"widget.js"}
]
}

View File

@ -1,22 +0,0 @@
(function(back) {
var FILE = "widbt.json";
var settings = require('Storage').readJSON(FILE, true) || {};
function writeSettings() {
require('Storage').writeJSON(FILE, settings);
}
E.showMenu({
"" : { "title" : "Bluetooth Widget" },
"< Back" : () => back(),
'No conn. widget': {
value: !!settings.hideDisconnected,
format: v => v?"Hide":"Show",
onchange: v => {
settings.hideDisconnected = v;
writeSettings();
if (WIDGETS.bluetooth) WIDGETS.bluetooth.changed();
}
},
});
})

View File

@ -2,27 +2,12 @@ WIDGETS["bluetooth"]={area:"tr",draw:function() {
if (WIDGETS.bluetooth.width==0)
return;
g.reset();
if (NRF.getSecurityStatus().connected)
g.setColor((g.getBPP()>8) ? "#07f" : (g.theme.dark ? "#0ff" : "#00f"));
else
g.setColor(g.theme.dark ? "#666" : "#999");
g.setColor((g.getBPP()>8) ? "#07f" : (g.theme.dark ? "#0ff" : "#00f"));
g.drawImage(atob("CxQBBgDgFgJgR4jZMawfAcA4D4NYybEYIwTAsBwDAA=="),2+this.x,2+this.y);
},getWidth:function(){
if (!NRF.getSecurityStatus().connected) {
const settings = require('Storage').readJSON("widbt.json", true) || {};
if (settings.hideDisconnected)
return 0;
}
return 15;
},changed:function() {
const newWidth = WIDGETS.bluetooth.getWidth();
if (WIDGETS.bluetooth.width != newWidth) {
WIDGETS.bluetooth.width = newWidth;
Bangle.drawWidgets();
} else {
WIDGETS.bluetooth.draw();
}
}};
WIDGETS.bluetooth.width = WIDGETS.bluetooth.getWidth();
WIDGET.bluetooth.width = NRF.getSecurityStatus().connected?15:0;
Bangle.drawWidgets();
},width:NRF.getSecurityStatus().connected?15:0
};
NRF.on('connect',WIDGETS.bluetooth.changed);
NRF.on('disconnect',WIDGETS.bluetooth.changed);