diff --git a/apps/widbthide/metadata.json b/apps/widbthide/metadata.json index 587faf28f..dd0e88cbd 100644 --- a/apps/widbthide/metadata.json +++ b/apps/widbthide/metadata.json @@ -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"} + ] } diff --git a/apps/widbthide/settings.js b/apps/widbthide/settings.js deleted file mode 100644 index 0400a2eec..000000000 --- a/apps/widbthide/settings.js +++ /dev/null @@ -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(); - } - }, - }); -}) diff --git a/apps/widbthide/widget.js b/apps/widbthide/widget.js index 24779c29d..2c5e16ba1 100644 --- a/apps/widbthide/widget.js +++ b/apps/widbthide/widget.js @@ -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);