Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/quicklaunch/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
0.14: Extension: Don't go down a path if nothing waits at the end. Revisit the current intersection instead.
0.15: Extension: Compatibility with "Fastload Utils" app history feature.
0.16: Snappier. Fewer storage interactions.
0.17: Make use of the launch_utils module to use fastloading when we can.
4 changes: 2 additions & 2 deletions apps/quicklaunch/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
else if (!storage.read(settings[trace+"app"].src)) {
E.showMessage(settings[trace+"app"].src+"\n"+/*LANG*/"was not found"+".", "Quick Launch");
settings[trace+"app"] = {"name":"(none)"}; // reset entry.
} else load(settings[trace+"app"].src);
} else require("launch_utils").loadApp(settings[trace+"app"]);
}
};

Expand Down Expand Up @@ -79,7 +79,7 @@
const updateTimeoutToClock = function(){
let time = 1500; // milliseconds
if (timeoutToClock) clearTimeout(timeoutToClock);
timeoutToClock = setTimeout(load,time);
timeoutToClock = setTimeout(Bangle.showClock,time);
};
updateTimeoutToClock();

Expand Down
2 changes: 1 addition & 1 deletion apps/quicklaunch/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
settings[trace+"app"] = {"name":"(none)"}; // reset entry.
storage.write("quicklaunch.json", settings);
setTimeout(load, 2000);
} else {load(settings[trace+"app"].src);}
} else {require("launch_utils").loadApp(settings[trace+"app"]);}
}
};

Expand Down
6 changes: 4 additions & 2 deletions apps/quicklaunch/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "quicklaunch",
"name": "Quick Launch",
"icon": "app.png",
"version": "0.16",
"version": "0.17",
"author": "frigis1",
"description": "Tap or swipe left/right/up/down on your clock face to launch up to five apps of your choice. Configurations can be accessed through Settings->Apps.",
"type": "bootloader",
Expand All @@ -12,7 +12,9 @@
"storage": [
{"name": "quicklaunch.settings.js", "url": "settings.js"},
{"name": "quicklaunch.boot.js", "url": "boot.js"},
{"name": "quicklaunch.app.js", "url": "app.js"}
{"name": "quicklaunch.app.js", "url": "app.js"},
{"name": "launch_utils", "url": "../../modules/launch_utils.js"},
{"name": "RAM", "url": "setup.js"}
],
"data": [{"name": "quicklaunch.json"}]
}
35 changes: 6 additions & 29 deletions apps/quicklaunch/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,10 @@ for (let c of ["lapp","rapp","uapp","dapp","tapp"]){ // l=left, r=right, u=up, d
if (!settings[c]) settings[c] = {"name":""};
}

// Convert settings object from before v0.12 to v0.12.
for (let c of ["leftapp","rightapp","upapp","downapp","tapapp"]){
if (settings[c]) {
let cNew = c.substring(0,1)+"app";
settings[cNew] = settings[c];
delete settings[c];
if (settings[cNew].name=="(none)") settings[cNew].name = "";

if (settings[cNew].name=="Quick Launch Extension"){
settings[cNew].name = "Extension";
for (let d of ["extleftapp","extrightapp","extupapp","extdownapp","exttapapp"]){
if (settings[d]) {
let dNew = cNew.substring(0,1)+d.substring(3,4)+"app";
settings[dNew] = settings[d];
delete settings[d];
if (settings[dNew].name=="(none)") settings[dNew].name = "";
}
}
}
storage.writeJSON("quicklaunch.json",settings);
}
}
for (let d of ["extleftapp","extrightapp","extupapp","extdownapp","exttapapp"]){
if (settings[d]) delete settings[d];
}


var apps = storage.list(/\.info$/).map(app=>{var a=storage.readJSON(app,1);return a&&{name:a.name,type:a.type,sortorder:a.sortorder,src:a.src};}).filter(app=>app && (app.type=="app" || app.type=="launch" || app.type=="clock" || !app.type));
var launchCache = require("launch_utils").cache({showClocks:true,showLaunchers:true});
//launchCache = require("launch_utils").cacheWidgetsCheck(launchCache.apps);
var apps = launchCache.apps;

// Add psuedo app to trigger Bangle.showLauncher later
apps.push({
Expand All @@ -49,7 +25,8 @@ let extension = {
"name": "Extension",
"type": "app",
"sortorder": -11,
"src": "quicklaunch.app.js"
"src": "quicklaunch.app.js",
"wid": true // // Hack: Fool launch_utils that extension screen uses widgets. This way we get the fastest possibe loading in whichever environment we find ourselves.
};
apps.push(extension);

Expand Down Expand Up @@ -105,7 +82,7 @@ function showMainMenu() {
// If no app is selected the name is an empty string, but we want to display "(none)".
let appName = settings[key].name==""?"(none)":settings[key].name;
mainmenu[entry+ ": "+appName] = function() {showSubMenu(keyCurrent);};
}
}

return E.showMenu(mainmenu);
}
Expand Down
45 changes: 45 additions & 0 deletions apps/quicklaunch/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
()=>{
var storage = require("Storage");
var settings = Object.assign(storage.readJSON("quicklaunch.json", true) || {});

// Convert settings object from before v0.12 to v0.12.
for (let c of ["leftapp","rightapp","upapp","downapp","tapapp"]){
if (settings[c]) {
let cNew = c.substring(0,1)+"app";
settings[cNew] = settings[c];
delete settings[c];
if (settings[cNew].name=="(none)") settings[cNew].name = "";

if (settings[cNew].name=="Quick Launch Extension"){
settings[cNew].name = "Extension";
for (let d of ["extleftapp","extrightapp","extupapp","extdownapp","exttapapp"]){
if (settings[d]) {
let dNew = cNew.substring(0,1)+d.substring(3,4)+"app";
settings[dNew] = settings[d];
delete settings[d];
if (settings[dNew].name=="(none)") settings[dNew].name = "";
}
}
}
storage.writeJSON("quicklaunch.json",settings);
}
}
for (let d of ["extleftapp","extrightapp","extupapp","extdownapp","exttapapp"]){
if (settings[d]) delete settings[d];
}

var launchCache = require("launch_utils").cache({showClocks:true,showLaunchers:true});
var apps = launchCache.apps;
launchCache = require("launch_utils").cacheWidgetsCheck(launchCache.apps);

// Add required launch_utils properties to settings object from versions older than 0.17
//delete settings.trace;
var settingsKeys = Object.keys(settings);
settingsKeys.forEach(key => {
let name = settings[key].name;
let app = apps.find(app=>app.name === name);
print(app)
if (app) settings[key].wid = app.wid;
});
storage.writeJSON("quicklaunch.json",settings);
}()
27 changes: 15 additions & 12 deletions modules/launch_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,7 @@ exports.cache = function(settings) {
/** Call with app object from .cache() */
exports.loadApp = function(app) {
if (!app.src) return E.showMessage(/*LANG*/ "App Source\nNot found"); // sanity check
if (app.wid===undefined) { // If we hadn't stored whether the app uses widgets before, check now
let s = require("Storage");
let src = s.read(app.src)
app.wid = (src!==undefined)&&src.includes("Bangle.loadWidgets");
// Now update the launch cache to save having to do this again
let launchCache = s.readJSON("launch.cache.json", true)||{};
let a = launchCache.apps.find(a=>a.src===app.src);
if (a) {
a.wid = app.wid;
require("Storage").writeJSON("launch.cache.json", launchCache);
}
}
if (app.wid===undefined) exports.cacheWidgetsCheck([app]); // If we hadn't stored whether the app uses widgets before, check now
// TODO: If there's a load screen boot app, we could call it? Or maybe Bangle.load should do that?
if (app.wid || global.WIDGETS===undefined) Bangle.load(app.src) // if app uses widgets or we don't have any, we can fast load into it
else if (Object.keys(WIDGETS).every(w=>!!WIDGETS[w].remove)) { // are widgets unloadable? !! needed before 2v29 fw
Expand All @@ -72,6 +61,20 @@ exports.loadApp = function(app) {
} else load(app.src); // otherwise default to slow load
};

exports.cacheWidgetsCheck = function(apps) {
let s = require("Storage");
let launchCache = s.readJSON("launch.cache.json", true)||{};
apps.forEach(app => {
let src = s.read(app.src)
app.wid = (src!==undefined)&&src.includes("Bangle.loadWidgets");
// Now update the launch cache to save having to do this again
let a = launchCache.apps.find(a=>a.src===app.src);
if (a) a.wid = app.wid;
});
s.writeJSON("launch.cache.json", launchCache);
return launchCache
}

/** delete the cache app list */
exports.clearCache = function() {
require("Storage").erase("launch.cache.json"); // delete the cache app list
Expand Down
Loading