Skip to content

Commit ec84a7a

Browse files
author
thyttan
committed
dtlaunch: remember page becomes a setting
1 parent 18975d4 commit ec84a7a

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

apps/dtlaunch/ChangeLog

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +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.
34+
0.27: Bangle 2: Add setting to remember and present the last open page between instances of dtlaunch.

apps/dtlaunch/app-b2.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
swipeExit: false,
1212
timeOut: "Off",
1313
interactionBuzz: false,
14+
rememberPage: false,
1415
}, require('Storage').readJSON("dtlaunch.json", true) || {});
1516

1617
let s = require("Storage");
@@ -33,12 +34,17 @@
3334
s.writeJSON("launch.cache.json", launchCache);
3435
}
3536
let apps = launchCache.apps;
36-
let page = (global.dtlaunch&&dtlaunch.handlePagePersist()) ??
37-
(parseInt(s.read("dtlaunch.page")) ?? 0);
37+
let page = 0;
38+
let initPageAppZeroth = 0;
39+
let initPageAppLast = 3;
40+
if (settings.rememberPage) {
41+
page = (global.dtlaunch&&dtlaunch.handlePagePersist()) ??
42+
(parseInt(s.read("dtlaunch.page")) ?? 0);
43+
initPageAppZeroth = page*4;
44+
initPageAppLast = (page*4+3<apps.length-1)?page*4+3:apps.length-1;//Math.min(page*4+3, apps.length-1); // FIXME:What is fastest?
45+
}
3846

39-
const INIT_PAGE_APP_ZEROTH = page*4;
40-
const INIT_PAGE_APP_LAST = (page*4+3<apps.length-1)?page*4+3:apps.length-1;//Math.min(page*4+3, apps.length-1); // FIXME:What is fastest?
41-
for (let i = INIT_PAGE_APP_ZEROTH; i <= INIT_PAGE_APP_LAST; i++) { // Initially only load icons for the current page.
47+
for (let i = initPageAppZeroth; i <= initPageAppLast; i++) { // Initially only load icons for the current page.
4248
if (apps[i].icon)
4349
apps[i].icon = s.read(apps[i].icon); // should just be a link to a memory area
4450
}
@@ -106,7 +112,7 @@
106112
drawPage(page);
107113

108114
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;
115+
if (i >= initPageAppZeroth && i <= initPageAppLast) continue;
110116
if (apps[i].icon)
111117
apps[i].icon = s.read(apps[i].icon); // should just be a link to a memory area
112118
}

apps/dtlaunch/settings-b2.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
swipeExit: false,
99
timeOut: "Off",
1010
interactionBuzz: false,
11+
rememberPage: false,
1112
}, require('Storage').readJSON(FILE, true) || {});
1213

1314
function writeSettings() {
@@ -64,5 +65,12 @@
6465
writeSettings();
6566
}
6667
},
68+
/*LANG*/'Remember Page': {
69+
value: settings.rememberPage,
70+
onchange: v => {
71+
settings.rememberPage = v;
72+
writeSettings();
73+
}
74+
},
6775
});
6876
})

0 commit comments

Comments
 (0)