mirror of https://github.com/espruino/BangleApps
gbridge: Add setting to show/hide icon
parent
6783472e9a
commit
631abb812e
|
@ -95,7 +95,7 @@
|
|||
{ "id": "gbridge",
|
||||
"name": "Gadgetbridge",
|
||||
"icon": "app.png",
|
||||
"version":"0.11",
|
||||
"version":"0.12",
|
||||
"description": "The default notification handler for Gadgetbridge notifications from Android",
|
||||
"tags": "tool,system,android,widget",
|
||||
"type":"widget",
|
||||
|
@ -103,6 +103,9 @@
|
|||
{"name":"gbridge.settings.js","url":"settings.js"},
|
||||
{"name":"gbridge.img","url":"app-icon.js","evaluate":true},
|
||||
{"name":"gbridge.wid.js","url":"widget.js"}
|
||||
],
|
||||
"data": [
|
||||
{"name":"gbridge.json"}
|
||||
]
|
||||
},
|
||||
{ "id": "mclock",
|
||||
|
|
|
@ -10,3 +10,4 @@
|
|||
0.09: Update Bluetooth connection state automatically
|
||||
0.10: Make widget play well with other Gadgetbridge widgets/apps
|
||||
0.11: Report battery status on connect and at regular intervals
|
||||
0.12: Setting to show/hide icon
|
|
@ -2,10 +2,28 @@
|
|||
function gb(j) {
|
||||
Bluetooth.println(JSON.stringify(j));
|
||||
}
|
||||
|
||||
const storage = require('Storage');
|
||||
let settings = storage.readJSON("gbridge.json", true) || {};
|
||||
if (!("showIcon" in settings)) {
|
||||
settings.showIcon = true;
|
||||
}
|
||||
function updateSettings() {
|
||||
storage.write('gbridge.json', settings);
|
||||
}
|
||||
function toggleIcon() {
|
||||
settings.showIcon = !settings.showIcon;
|
||||
updateSettings();
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
}
|
||||
var mainmenu = {
|
||||
"" : { "title" : "Gadgetbridge" },
|
||||
"Connected" : { value : NRF.getSecurityStatus().connected?"Yes":"No" },
|
||||
"Show Icon" : {
|
||||
value: settings.showIcon,
|
||||
format: v => v?"Yes":"No",
|
||||
onchange: toggleIcon
|
||||
},
|
||||
"Find Phone" : function() { E.showMenu(findPhone); },
|
||||
"< Back" : back,
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
(() => {
|
||||
const storage = require('Storage');
|
||||
|
||||
const state = {
|
||||
music: "stop",
|
||||
|
@ -12,6 +13,11 @@
|
|||
scrollPos: 0
|
||||
};
|
||||
|
||||
let settings = storage.readJSON('gbridge.json',1) || {};
|
||||
if (!("showIcon" in settings)) {
|
||||
settings.showIcon = true;
|
||||
}
|
||||
|
||||
function gbSend(message) {
|
||||
Bluetooth.println("");
|
||||
Bluetooth.println(JSON.stringify(message));
|
||||
|
@ -192,10 +198,15 @@
|
|||
g.flip(); // turns screen on
|
||||
}
|
||||
|
||||
if (settings.showIcon) {
|
||||
WIDGETS["gbridgew"] = {area: "tl", width: 24, draw: draw};
|
||||
NRF.on("connect", changedConnectionState);
|
||||
NRF.on("disconnect", changedConnectionState);
|
||||
|
||||
WIDGETS["gbridgew"] = { area: "tl", width: 24, draw: draw };
|
||||
} else {
|
||||
NRF.removeListener("connect", changedConnectionState);
|
||||
NRF.removeListener("disconnect", changedConnectionState);
|
||||
delete WIDGETS["gbridgew"];
|
||||
}
|
||||
|
||||
function sendBattery() {
|
||||
gbSend({ t: "status", bat: E.getBattery() });
|
||||
|
|
Loading…
Reference in New Issue