diff --git a/apps/widbt_notify/ChangeLog b/apps/widbt_notify/ChangeLog index a9b23f438..8f1dab908 100644 --- a/apps/widbt_notify/ChangeLog +++ b/apps/widbt_notify/ChangeLog @@ -10,4 +10,5 @@ 0.11: Avoid too many notifications. Change disconnected colour to red. 0.12: Prevent repeated execution of `draw()` from the current app. 0.13: Added "connection restored" notification. Fixed restoring of the watchface. -0.14: Added configuration option \ No newline at end of file +0.14: Added configuration option +0.15: Added option to hide widget when connected \ No newline at end of file diff --git a/apps/widbt_notify/metadata.json b/apps/widbt_notify/metadata.json index d6dffc858..566a51b57 100644 --- a/apps/widbt_notify/metadata.json +++ b/apps/widbt_notify/metadata.json @@ -1,7 +1,7 @@ { "id": "widbt_notify", "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.", "icon": "widget.png", "type": "widget", diff --git a/apps/widbt_notify/settings.js b/apps/widbt_notify/settings.js index ad0a65a5f..1e0d5036b 100644 --- a/apps/widbt_notify/settings.js +++ b/apps/widbt_notify/settings.js @@ -54,7 +54,14 @@ settings.buzzOnLoss = v; writeSettings(); } - } + }, + "Hide connected": { + value: (settings.hideConnected !== undefined ? settings.hideConnected : false), + onchange: v => { + settings.hideConnected = v; + writeSettings(); + } + } }; E.showMenu(mainmenu); diff --git a/apps/widbt_notify/widget.js b/apps/widbt_notify/widget.js index 09ff83d72..de2baa3cf 100644 --- a/apps/widbt_notify/widget.js +++ b/apps/widbt_notify/widget.js @@ -30,18 +30,32 @@ WIDGETS.bluetooth_notify = { buzzOnLoss = def(settings.buzzOnLoss, true); 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 -------- draw: function() { if (WIDGETS.bluetooth_notify.readshowWidget()){ g.reset(); 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 { // g.setColor(g.theme.dark ? "#666" : "#999"); 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); } },