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