From adc59dcc164dd1feb1be1feedac1d2279b66cc55 Mon Sep 17 00:00:00 2001 From: Rarder44 Date: Fri, 4 Nov 2022 15:57:14 +0100 Subject: [PATCH] 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 --- apps/iconlaunch/ChangeLog | 4 ++++ apps/iconlaunch/app.js | 22 ++++++++++++++++++---- apps/iconlaunch/metadata.json | 3 ++- apps/iconlaunch/settings.js | 25 +++++++++++++++++++------ 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/apps/iconlaunch/ChangeLog b/apps/iconlaunch/ChangeLog index eca18b06c..c71da1467 100644 --- a/apps/iconlaunch/ChangeLog +++ b/apps/iconlaunch/ChangeLog @@ -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 diff --git a/apps/iconlaunch/app.js b/apps/iconlaunch/app.js index 8d2f1ec4c..479956019 100644 --- a/apps/iconlaunch/app.js +++ b/apps/iconlaunch/app.js @@ -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); } diff --git a/apps/iconlaunch/metadata.json b/apps/iconlaunch/metadata.json index e310ede4d..13e7aee08 100644 --- a/apps/iconlaunch/metadata.json +++ b/apps/iconlaunch/metadata.json @@ -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" } diff --git a/apps/iconlaunch/settings.js b/apps/iconlaunch/settings.js index 49a49f700..f4c0599f7 100644 --- a/apps/iconlaunch/settings.js +++ b/apps/iconlaunch/settings.js @@ -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); });