changed the launch.json file name in iconlaunch.json ( launch.cache.json -> iconlaunch.cache.json)

used Object.assing for the settings
 fix cache not deleted when "showClocks" options is changed
 added timeOut to return to the clock
pull/2227/head
Rarder44 2022-11-04 15:57:14 +01:00
parent ba028e1f58
commit adc59dcc16
4 changed files with 43 additions and 11 deletions

View File

@ -8,3 +8,7 @@
Add swipe-to-exit
0.08: Only use fast loading for switching to clock to prevent problems in full screen apps
0.09: Remove fast load option since clocks containing Bangle.loadWidgets are now always normally loaded
0.10: changed the launch.json file name in iconlaunch.json ( launch.cache.json -> iconlaunch.cache.json)
used Object.assing for the settings
fix cache not deleted when "showClocks" options is changed
added timeOut to return to the clock

View File

@ -1,12 +1,21 @@
{
const s = require("Storage");
const settings = s.readJSON("launch.json", true) || { showClocks: true, fullscreen: false,direct:false,swipeExit:false,oneClickExit:false};
const settings = Object.assign({
showClocks: true,
fullscreen: false,
direct: false,
oneClickExit: false,
swipeExit: false,
timeOut:"Off"
}, s.readJSON("iconlaunch.json", true) || {});
console.log(settings);
if (!settings.fullscreen) {
Bangle.loadWidgets();
Bangle.drawWidgets();
}
let launchCache = s.readJSON("launch.cache.json", true)||{};
let launchHash = require("Storage").hash(/\.info/);
let launchCache = s.readJSON("iconlaunch.cache.json", true)||{};
let launchHash = s.hash(/\.info/);
if (launchCache.hash!=launchHash) {
launchCache = {
hash : launchHash,
@ -20,7 +29,7 @@
if (a.name>b.name) return 1;
return 0;
}) };
s.writeJSON("launch.cache.json", launchCache);
s.writeJSON("iconlaunch.cache.json", launchCache);
}
let scroll = 0;
let selectedItem = -1;
@ -198,6 +207,11 @@
if (settings.oneClickExit) mode.btn = returnToClock;
if (settings.timeOut!="Off"){
let time=parseInt(settings.timeOut); //the "s" will be trimmed by the parseInt
setTimeout(returnToClock,time*1000);
}
Bangle.setUI(mode);
}

View File

@ -2,7 +2,7 @@
"id": "iconlaunch",
"name": "Icon Launcher",
"shortName" : "Icon launcher",
"version": "0.09",
"version": "0.10",
"icon": "app.png",
"description": "A launcher inspired by smartphones, with an icon-only scrollable menu.",
"tags": "tool,system,launcher",
@ -12,6 +12,7 @@
{ "name": "iconlaunch.app.js", "url": "app.js" },
{ "name": "iconlaunch.settings.js", "url": "settings.js" }
],
"data": [{"name":"iconlaunch.json"},{"name":"iconlaunch.cache.json"}],
"screenshots": [{ "url": "screenshot1.png" }, { "url": "screenshot2.png" }],
"readme": "README.md"
}

View File

@ -1,24 +1,29 @@
// make sure to enclose the function in parentheses
(function(back) {
const s = require("Storage");
let settings = Object.assign({
showClocks: true,
fullscreen: false,
direct: false,
oneClickExit: false,
swipeExit: false
}, require("Storage").readJSON("launch.json", true) || {});
swipeExit: false,
timeOut:"Off"
}, s.readJSON("iconlaunch.json", true) || {});
let fonts = g.getFonts();
function save(key, value) {
settings[key] = value;
require("Storage").write("launch.json",settings);
s.write("iconlaunch.json",settings);
}
const timeOutChoices = [/*LANG*/"Off", "10s", "15s", "20s", "30s"];
const appMenu = {
"": { "title": /*LANG*/"Launcher" },
/*LANG*/"< Back": back,
/*LANG*/"Show Clocks": {
value: settings.showClocks == true,
onchange: (m) => { save("showClocks", m) }
onchange: (m) => {
save("showClocks", m);
s.erase("iconlaunch.cache.json"); //delete the cache app list
}
},
/*LANG*/"Fullscreen": {
value: settings.fullscreen == true,
@ -35,7 +40,15 @@
/*LANG*/"Swipe exit": {
value: settings.swipeExit == true,
onchange: m => { save("swipeExit", m) }
}
},
/*LANG*/'Time Out': {
value: timeOutChoices.indexOf(settings.timeOut),
min: 0, max: timeOutChoices.length-1,
format: v => timeOutChoices[v],
onchange: m => {
save("timeOut", timeOutChoices[m]);
}
},
};
E.showMenu(appMenu);
});