Skip to content

Commit 73f376e

Browse files
committed
iconlaunch 0.21: Display placeholder icons at start and render line by line to the screen to make loading seem faster
1 parent 6132c1a commit 73f376e

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

apps/iconlaunch/ChangeLog

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

apps/iconlaunch/app.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@
1616
} else { // for fast-load, if we had widgets then we should hide them
1717
require("widget_utils").hide();
1818
}
19+
20+
let selectedItem = -1;
21+
const R = Bangle.appRect;
22+
const iconSize = 48;
23+
const appsN = Math.floor(R.w / iconSize);
24+
const whitespace = Math.floor((R.w - appsN * iconSize) / (appsN + 1));
25+
const iconYoffset = Math.floor(whitespace/4)-1;
26+
const itemSize = iconSize + whitespace;
27+
28+
// show some grey blocks as a loading screen
29+
g.clearRect(Bangle.appRect).setColor("#888");
30+
for (var y=R.y+whitespace/2;y<R.h;y+=itemSize)
31+
for (var x=R.x+whitespace/2;x<R.w;x+=itemSize)
32+
g.drawRect(x+16,y+16,x+32,y+32);
33+
g.flip();
34+
1935
let launchCache = s.readJSON("iconlaunch.cache.json", true)||{};
2036
let launchHash = s.hash(/\.info/);
2137
if (launchCache.hash!=launchHash) {
@@ -38,13 +54,7 @@
3854
const ICON_MISSING = s.read("iconlaunch.na.img");
3955
let count = 0;
4056

41-
let selectedItem = -1;
42-
const R = Bangle.appRect;
43-
const iconSize = 48;
44-
const appsN = Math.floor(R.w / iconSize);
45-
const whitespace = Math.floor((R.w - appsN * iconSize) / (appsN + 1));
46-
const iconYoffset = Math.floor(whitespace/4)-1;
47-
const itemSize = iconSize + whitespace;
57+
4858

4959
launchCache.items = {};
5060
for (let c of launchCache.apps){
@@ -82,8 +92,9 @@
8292
drawText(itemI, r.y, selectedApp);
8393
texted=itemI;
8494
}
95+
if (firstRun) g.flip(); // at startup
8596
};
86-
97+
let firstRun = true;
8798
let drawText = function(i, appY, selectedApp) {
8899
const idy = (selectedItem - (selectedItem % 3)) / 3;
89100
if (i != idy) return;
@@ -150,10 +161,11 @@
150161
}
151162

152163
let scroller = E.showScroller(options);
164+
firstRun = false; // this stops us flipping the screen after each line we draw
153165

154166
let timeout;
155167
const updateTimeout = function(){
156-
if (settings.timeOut!="Off"){
168+
if (settings.timeOut!="Off"){
157169
let time=parseInt(settings.timeOut); //the "s" will be trimmed by the parseInt
158170
if (timeout) clearTimeout(timeout);
159171
timeout = setTimeout(Bangle.showClock,time*1000);

apps/iconlaunch/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "iconlaunch",
33
"name": "Icon Launcher",
44
"shortName" : "Icon launcher",
5-
"version": "0.20",
5+
"version": "0.21",
66
"icon": "app.png",
77
"description": "A launcher inspired by smartphones, with an icon-only scrollable menu.",
88
"tags": "tool,system,launcher",

0 commit comments

Comments
 (0)