Merge pull request #2209 from halemmerich/iconlaunch

Iconlaunch - Back to slow loading apps
master
Gordon Williams 2022-10-31 11:36:13 +00:00 committed by GitHub
commit 481d1deda8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 30 deletions

View File

@ -6,3 +6,4 @@
0.06: Cache apps for faster start 0.06: Cache apps for faster start
0.07: Read app icons on demand 0.07: Read app icons on demand
Add swipe-to-exit Add swipe-to-exit
0.08: Only use fast loading for switching to clock to prevent problems in full screen apps

View File

@ -13,4 +13,4 @@ The app uses `E.showScroller`'s code in the app but not the function itself beca
### Fastload option ### Fastload option
Fastload clears up the memory used by the launcher and directly evals the code of the app to load. This means if widgets are loaded (fullscreen option) it is possible that widgets stay loaded in apps not expecting that and the widgets may draw over the app. Fastload clears up the memory used by the launcher and directly evals the code of the clock to load.

View File

@ -11,10 +11,10 @@
launchCache = { launchCache = {
hash : launchHash, hash : launchHash,
apps : s.list(/\.info$/) apps : s.list(/\.info$/)
.map(app=>{var a=s.readJSON(app,1);return a&&{name:a.name,type:a.type,icon:a.icon,sortorder:a.sortorder,src:a.src};}) .map(app=>{let a=s.readJSON(app,1);return a&&{name:a.name,type:a.type,icon:a.icon,sortorder:a.sortorder,src:a.src};})
.filter(app=>app && (app.type=="app" || (app.type=="clock" && settings.showClocks) || !app.type)) .filter(app=>app && (app.type=="app" || (app.type=="clock" && settings.showClocks) || !app.type))
.sort((a,b)=>{ .sort((a,b)=>{
var n=(0|a.sortorder)-(0|b.sortorder); let n=(0|a.sortorder)-(0|b.sortorder);
if (n) return n; // do sortorder first if (n) return n; // do sortorder first
if (a.name<b.name) return -1; if (a.name<b.name) return -1;
if (a.name>b.name) return 1; if (a.name>b.name) return 1;
@ -54,7 +54,7 @@
drawText(itemI); drawText(itemI);
}; };
let drawItemAuto = function(i) { let drawItemAuto = function(i) {
var y = idxToY(i); let y = idxToY(i);
g.reset().setClipRect(R.x, y, R.x2, y + itemSize); g.reset().setClipRect(R.x, y, R.x2, y + itemSize);
drawItem(i, { drawItem(i, {
x: R.x, x: R.x,
@ -86,7 +86,7 @@
const appId = id * appsN + iconN; const appId = id * appsN + iconN;
if( settings.direct && launchCache.apps[appId]) if( settings.direct && launchCache.apps[appId])
{ {
loadApp(launchCache.apps[appId].src); load(launchCache.apps[appId].src);
return; return;
} }
if (appId == selectedItem && launchCache.apps[appId]) { if (appId == selectedItem && launchCache.apps[appId]) {
@ -94,7 +94,7 @@
if (!app.src || s.read(app.src) === undefined) { if (!app.src || s.read(app.src) === undefined) {
E.showMessage( /*LANG*/ "App Source\nNot found"); E.showMessage( /*LANG*/ "App Source\nNot found");
} else { } else {
loadApp(app.src); load(app.src);
} }
} }
selectedItem = appId; selectedItem = appId;
@ -109,9 +109,9 @@
let drawItems = function() { let drawItems = function() {
g.reset().clearRect(R.x, R.y, R.x2, R.y2); g.reset().clearRect(R.x, R.y, R.x2, R.y2);
g.setClipRect(R.x, R.y, R.x2, R.y2); g.setClipRect(R.x, R.y, R.x2, R.y2);
var a = YtoIdx(R.y); let a = YtoIdx(R.y);
var b = Math.min(YtoIdx(R.y2), 99); let b = Math.min(YtoIdx(R.y2), 99);
for (var i = a; i <= b; i++) for (let i = a; i <= b; i++)
drawItem(i, { drawItem(i, {
x: R.x, x: R.x,
y: idxToY(i), y: idxToY(i),
@ -168,25 +168,20 @@
} }
g.setClipRect(0, 0, g.getWidth() - 1, g.getHeight() - 1); g.setClipRect(0, 0, g.getWidth() - 1, g.getHeight() - 1);
}; };
Bangle.setUI({ let mode = {
mode: "custom", mode: "custom",
drag: onDrag, drag: onDrag,
touch: (_, e) => { touch: (_, e) => {
if (e.y < R.y - 4) return; if (e.y < R.y - 4) return;
var i = YtoIdx(e.y); let i = YtoIdx(e.y);
selectItem(i, e); selectItem(i, e);
}, },
swipe: (h,_) => { if(settings.swipeExit && h==1) { returnToClock(); } }, swipe: (h,_) => { if(settings.swipeExit && h==1) { returnToClock(); } },
});
const returnToClock = function() {
loadApp(".bootcde");
}; };
let watch;
let loadApp; const returnToClock = function() {
if (settings.fastload){ if (settings.fastload == true){
loadApp = function(name) {
Bangle.setUI(); Bangle.setUI();
if (watch) clearWatch(watch);
delete launchCache; delete launchCache;
delete launchHash; delete launchHash;
delete drawItemAuto; delete drawItemAuto;
@ -199,16 +194,14 @@
delete idxToY; delete idxToY;
delete YtoIdx; delete YtoIdx;
delete settings; delete settings;
setTimeout(eval, 0, s.read(name)); setTimeout(eval, 0, s.read(".bootcde"));
return; } else {
}; load();
} else {
loadApp = function(name) {
load(name);
} }
} };
if (settings.oneClickExit) { if (settings.oneClickExit) mode.btn = returnToClock;
watch = setWatch(returnToClock, BTN1);
} Bangle.setUI(mode);
} }

View File

@ -2,7 +2,7 @@
"id": "iconlaunch", "id": "iconlaunch",
"name": "Icon Launcher", "name": "Icon Launcher",
"shortName" : "Icon launcher", "shortName" : "Icon launcher",
"version": "0.07", "version": "0.08",
"icon": "app.png", "icon": "app.png",
"description": "A launcher inspired by smartphones, with an icon-only scrollable menu.", "description": "A launcher inspired by smartphones, with an icon-only scrollable menu.",
"tags": "tool,system,launcher", "tags": "tool,system,launcher",