Skip to content

Commit a0e7fe9

Browse files
author
thyttan
committed
Merge branch 'dtlaunch' into app-loader
2 parents a081f6d + de28353 commit a0e7fe9

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

apps/dtlaunch/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ when moving pages. Add caching for faster startups.
3131
0.24: Add buzz-on-interaction setting
3232
0.25: Minor code improvements
3333
0.26: Bangle 2: Postpone loading icons that are not needed initially.
34+
0.27: Bangle 2: Remember and present the last open page between instances of dtlaunch.

apps/dtlaunch/app-b2.js

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@
3333
s.writeJSON("launch.cache.json", launchCache);
3434
}
3535
let apps = launchCache.apps;
36-
for (let i = 0; i < 4; i++) { // Initially only load icons for the current page.
36+
let page = (global.dtlaunch&&dtlaunch.HandlePagePersist()) ??
37+
(parseInt(s.read("dtlaunch.page")) ?? 0);
38+
39+
const INIT_PAGE_APP_ZEROTH = page*4;
40+
const INIT_PAGE_APP_LAST = Math.min(page*5-1, apps.length-1)
41+
for (let i = INIT_PAGE_APP_ZEROTH; i <= INIT_PAGE_APP_LAST; i++) { // Initially only load icons for the current page.
3742
if (apps[i].icon)
3843
apps[i].icon = s.read(apps[i].icon); // should just be a link to a memory area
3944
}
@@ -43,7 +48,6 @@
4348
let maxPage = Npages-1;
4449
let selected = -1;
4550
//let oldselected = -1;
46-
let page = 0;
4751
const XOFF = 24;
4852
const YOFF = 30;
4953

@@ -99,13 +103,32 @@
99103

100104
Bangle.drawWidgets(); // To immediately update widget field to follow current theme - remove leftovers if previous app set custom theme.
101105
Bangle.loadWidgets();
102-
drawPage(0);
106+
drawPage(page);
103107

104-
for (let i = 4; i < apps.length; i++) { // Load the rest of the app icons that were not initially.
108+
for (let i = 0; i < apps.length; i++) { // Load the rest of the app icons that were not initially.
109+
if (i >= INIT_PAGE_APP_ZEROTH && i <= INIT_PAGE_APP_LAST) continue;
105110
if (apps[i].icon)
106111
apps[i].icon = s.read(apps[i].icon); // should just be a link to a memory area
107112
}
108113

114+
if (!global.dtlaunch) {
115+
global.dtlaunch = {};
116+
dtlaunch.HandlePagePersist = (page) => {
117+
// Function for persisting the active page when leaving dtlaunch.
118+
if (page===undefined) {return dtlaunch.page||0;}
119+
120+
if (!dtlaunch.killHandler) { // Only register kill listener once.
121+
dtlaunch.killHandler = () => {
122+
s.write("dtlaunch.page", dtlaunch.page.toString());
123+
};
124+
E.on("kill", dtlaunch.killHandler); // This is intentionally left around after fastloading into other apps. I.e. not removed in uiRemove.
125+
}
126+
127+
dtlaunch.page = page;
128+
};
129+
dtlaunch.HandlePagePersist(page);
130+
}
131+
109132
let swipeListenerDt = function(dirLeftRight, dirUpDown){
110133
updateTimeoutToClock();
111134
selected = -1;
@@ -142,6 +165,7 @@
142165
drawIcon(page,selected,false);
143166
} else {
144167
buzzLong();
168+
dtlaunch.HandlePagePersist(page);
145169
load(apps[page*4+i].src);
146170
}
147171
}
@@ -162,7 +186,10 @@
162186
back : Bangle.showClock,
163187
swipe : swipeListenerDt,
164188
touch : touchListenerDt,
165-
remove : ()=>{if (timeoutToClock) clearTimeout(timeoutToClock);}
189+
remove : ()=>{
190+
if (timeoutToClock) {clearTimeout(timeoutToClock);}
191+
dtlaunch.HandlePagePersist(page);
192+
}
166193
});
167194

168195
// taken from Icon Launcher with minor alterations
@@ -177,4 +204,3 @@
177204
updateTimeoutToClock();
178205

179206
} // end of app scope
180-

apps/dtlaunch/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "dtlaunch",
33
"name": "Desktop Launcher",
4-
"version": "0.26",
4+
"version": "0.27",
55
"description": "Desktop style App Launcher with six (four for Bangle 2) apps per page - fast access if you have lots of apps installed.",
66
"screenshots": [{"url":"shot1.png"},{"url":"shot2.png"},{"url":"shot3.png"}],
77
"icon": "icon.png",

0 commit comments

Comments
 (0)