0.15: Added option to hide widget when connected

pull/2011/head
Hank 2022-07-04 09:45:15 +02:00
parent 371dd94a03
commit d0a33541a5
4 changed files with 27 additions and 5 deletions

View File

@ -11,3 +11,4 @@
0.12: Prevent repeated execution of `draw()` from the current app. 0.12: Prevent repeated execution of `draw()` from the current app.
0.13: Added "connection restored" notification. Fixed restoring of the watchface. 0.13: Added "connection restored" notification. Fixed restoring of the watchface.
0.14: Added configuration option 0.14: Added configuration option
0.15: Added option to hide widget when connected

View File

@ -1,7 +1,7 @@
{ {
"id": "widbt_notify", "id": "widbt_notify",
"name": "Bluetooth Widget with Notification", "name": "Bluetooth Widget with Notification",
"version": "0.14", "version": "0.15",
"description": "Show the current Bluetooth connection status in the top right of the clock and vibrate when disconnected.", "description": "Show the current Bluetooth connection status in the top right of the clock and vibrate when disconnected.",
"icon": "widget.png", "icon": "widget.png",
"type": "widget", "type": "widget",

View File

@ -54,6 +54,13 @@
settings.buzzOnLoss = v; settings.buzzOnLoss = v;
writeSettings(); writeSettings();
} }
},
"Hide connected": {
value: (settings.hideConnected !== undefined ? settings.hideConnected : false),
onchange: v => {
settings.hideConnected = v;
writeSettings();
}
} }
}; };

View File

@ -30,18 +30,32 @@ WIDGETS.bluetooth_notify = {
buzzOnLoss = def(settings.buzzOnLoss, true); buzzOnLoss = def(settings.buzzOnLoss, true);
return buzzOnLoss; return buzzOnLoss;
}, },
readHideConnected: function() {
var hideConnected;
const SETTINGSFILE = "widbt_notify.json";
function def (value, def) {return value !== undefined ? value : def;}
var settings = require('Storage').readJSON(SETTINGSFILE, true) || {};
hideConnected = def(settings.hideConnected, true);
return hideConnected;
},
// ------------ Settings -------- // ------------ Settings --------
draw: function() { draw: function() {
if (WIDGETS.bluetooth_notify.readshowWidget()){ if (WIDGETS.bluetooth_notify.readshowWidget()){
g.reset(); g.reset();
if (NRF.getSecurityStatus().connected) { if (NRF.getSecurityStatus().connected) {
g.setColor((g.getBPP() > 8) ? "#07f" : (g.theme.dark ? "#0ff" : "#00f")); if (!WIDGETS.bluetooth_notify.readHideConnected()) {
g.setColor((g.getBPP() > 8) ? "#07f" : (g.theme.dark ? "#0ff" : "#00f"));
g.drawImage(atob("CxQBBgDgFgJgR4jZMawfAcA4D4NYybEYIwTAsBwDAA=="), 2 + this.x, 2 + this.y);
}
} else { } else {
// g.setColor(g.theme.dark ? "#666" : "#999"); // g.setColor(g.theme.dark ? "#666" : "#999");
g.setColor("#f00"); // red is easier to distinguish from blue g.setColor("#f00"); // red is easier to distinguish from blue
g.drawImage(atob("CxQBBgDgFgJgR4jZMawfAcA4D4NYybEYIwTAsBwDAA=="), 2 + this.x, 2 + this.y);
} }
g.drawImage(atob("CxQBBgDgFgJgR4jZMawfAcA4D4NYybEYIwTAsBwDAA=="), 2 + this.x, 2 + this.y);
} }
}, },