BangleApps/apps/gbridge/settings.js

42 lines
1.1 KiB
JavaScript
Raw Normal View History

(function(back) {
function gb(j) {
Bluetooth.println(JSON.stringify(j));
}
2020-05-28 21:27:10 +00:00
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();
// need to re-layout widgets
WIDGETS["gbridgew"].reload();
g.clear();
2020-05-28 21:27:10 +00:00
Bangle.drawWidgets();
}
var mainmenu = {
"" : { "title" : "Gadgetbridge" },
"Connected" : { value : NRF.getSecurityStatus().connected?"Yes":"No" },
2020-05-28 21:27:10 +00:00
"Show Icon" : {
value: settings.showIcon,
format: v => v?"Yes":"No",
onchange: toggleIcon
},
"Find Phone" : function() { E.showMenu(findPhone); },
"< Back" : back,
};
var findPhone = {
"" : { "title" : "-- Find Phone --" },
"On" : _=>gb({t:"findPhone",n:true}),
"Off" : _=>gb({t:"findPhone",n:false}),
"< Back" : function() { E.showMenu(mainmenu); },
};
const menu = E.showMenu(mainmenu);
})