iconlaunch 0.21: Display placeholder icons at start and render line by line to the screen to make loading seem faster

master
Gordon Williams 2025-03-27 11:46:11 +00:00
parent 6132c1af92
commit 73f376e5e3
3 changed files with 24 additions and 11 deletions

View File

@ -25,4 +25,5 @@
0.18: Better performance 0.18: Better performance
0.19: Remove 'jit' keyword as 'for(..of..)' is not supported (fix #2937) 0.19: Remove 'jit' keyword as 'for(..of..)' is not supported (fix #2937)
0.20: Use '28' font if installed (2v26+) and put it inside a rounded rect in the current theme 0.20: Use '28' font if installed (2v26+) and put it inside a rounded rect in the current theme
Ensure 'oneClickExit' is the default Ensure 'oneClickExit' is the default
0.21: Display placeholder icons at start and render line by line to the screen to make loading seem faster

View File

@ -16,6 +16,22 @@
} else { // for fast-load, if we had widgets then we should hide them } else { // for fast-load, if we had widgets then we should hide them
require("widget_utils").hide(); require("widget_utils").hide();
} }
let selectedItem = -1;
const R = Bangle.appRect;
const iconSize = 48;
const appsN = Math.floor(R.w / iconSize);
const whitespace = Math.floor((R.w - appsN * iconSize) / (appsN + 1));
const iconYoffset = Math.floor(whitespace/4)-1;
const itemSize = iconSize + whitespace;
// show some grey blocks as a loading screen
g.clearRect(Bangle.appRect).setColor("#888");
for (var y=R.y+whitespace/2;y<R.h;y+=itemSize)
for (var x=R.x+whitespace/2;x<R.w;x+=itemSize)
g.drawRect(x+16,y+16,x+32,y+32);
g.flip();
let launchCache = s.readJSON("iconlaunch.cache.json", true)||{}; let launchCache = s.readJSON("iconlaunch.cache.json", true)||{};
let launchHash = s.hash(/\.info/); let launchHash = s.hash(/\.info/);
if (launchCache.hash!=launchHash) { if (launchCache.hash!=launchHash) {
@ -38,13 +54,7 @@
const ICON_MISSING = s.read("iconlaunch.na.img"); const ICON_MISSING = s.read("iconlaunch.na.img");
let count = 0; let count = 0;
let selectedItem = -1;
const R = Bangle.appRect;
const iconSize = 48;
const appsN = Math.floor(R.w / iconSize);
const whitespace = Math.floor((R.w - appsN * iconSize) / (appsN + 1));
const iconYoffset = Math.floor(whitespace/4)-1;
const itemSize = iconSize + whitespace;
launchCache.items = {}; launchCache.items = {};
for (let c of launchCache.apps){ for (let c of launchCache.apps){
@ -82,8 +92,9 @@
drawText(itemI, r.y, selectedApp); drawText(itemI, r.y, selectedApp);
texted=itemI; texted=itemI;
} }
if (firstRun) g.flip(); // at startup
}; };
let firstRun = true;
let drawText = function(i, appY, selectedApp) { let drawText = function(i, appY, selectedApp) {
const idy = (selectedItem - (selectedItem % 3)) / 3; const idy = (selectedItem - (selectedItem % 3)) / 3;
if (i != idy) return; if (i != idy) return;
@ -150,10 +161,11 @@
} }
let scroller = E.showScroller(options); let scroller = E.showScroller(options);
firstRun = false; // this stops us flipping the screen after each line we draw
let timeout; let timeout;
const updateTimeout = function(){ const updateTimeout = function(){
if (settings.timeOut!="Off"){ if (settings.timeOut!="Off"){
let time=parseInt(settings.timeOut); //the "s" will be trimmed by the parseInt let time=parseInt(settings.timeOut); //the "s" will be trimmed by the parseInt
if (timeout) clearTimeout(timeout); if (timeout) clearTimeout(timeout);
timeout = setTimeout(Bangle.showClock,time*1000); timeout = setTimeout(Bangle.showClock,time*1000);

View File

@ -2,7 +2,7 @@
"id": "iconlaunch", "id": "iconlaunch",
"name": "Icon Launcher", "name": "Icon Launcher",
"shortName" : "Icon launcher", "shortName" : "Icon launcher",
"version": "0.20", "version": "0.21",
"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",