mirror of https://github.com/espruino/BangleApps
dtlaunch: remember page becomes a setting
parent
7e637130a2
commit
4ed499c36d
|
@ -31,4 +31,4 @@ when moving pages. Add caching for faster startups.
|
||||||
0.24: Add buzz-on-interaction setting
|
0.24: Add buzz-on-interaction setting
|
||||||
0.25: Minor code improvements
|
0.25: Minor code improvements
|
||||||
0.26: Bangle 2: Postpone loading icons that are not needed initially.
|
0.26: Bangle 2: Postpone loading icons that are not needed initially.
|
||||||
0.27: Bangle 2: Remember and present the last open page between instances of dtlaunch.
|
0.27: Bangle 2: Add setting to remember and present the last open page between instances of dtlaunch.
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
swipeExit: false,
|
swipeExit: false,
|
||||||
timeOut: "Off",
|
timeOut: "Off",
|
||||||
interactionBuzz: false,
|
interactionBuzz: false,
|
||||||
|
rememberPage: false,
|
||||||
}, require('Storage').readJSON("dtlaunch.json", true) || {});
|
}, require('Storage').readJSON("dtlaunch.json", true) || {});
|
||||||
|
|
||||||
let s = require("Storage");
|
let s = require("Storage");
|
||||||
|
@ -33,12 +34,17 @@
|
||||||
s.writeJSON("launch.cache.json", launchCache);
|
s.writeJSON("launch.cache.json", launchCache);
|
||||||
}
|
}
|
||||||
let apps = launchCache.apps;
|
let apps = launchCache.apps;
|
||||||
let page = (global.dtlaunch&&dtlaunch.handlePagePersist()) ??
|
let page = 0;
|
||||||
|
let initPageAppZeroth = 0;
|
||||||
|
let initPageAppLast = 3;
|
||||||
|
if (settings.rememberPage) {
|
||||||
|
page = (global.dtlaunch&&dtlaunch.handlePagePersist()) ??
|
||||||
(parseInt(s.read("dtlaunch.page")) ?? 0);
|
(parseInt(s.read("dtlaunch.page")) ?? 0);
|
||||||
|
initPageAppZeroth = page*4;
|
||||||
|
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?
|
||||||
|
}
|
||||||
|
|
||||||
const INIT_PAGE_APP_ZEROTH = page*4;
|
for (let i = initPageAppZeroth; i <= initPageAppLast; i++) { // Initially only load icons for the current page.
|
||||||
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?
|
|
||||||
for (let i = INIT_PAGE_APP_ZEROTH; i <= INIT_PAGE_APP_LAST; i++) { // Initially only load icons for the current page.
|
|
||||||
if (apps[i].icon)
|
if (apps[i].icon)
|
||||||
apps[i].icon = s.read(apps[i].icon); // should just be a link to a memory area
|
apps[i].icon = s.read(apps[i].icon); // should just be a link to a memory area
|
||||||
}
|
}
|
||||||
|
@ -106,7 +112,7 @@
|
||||||
drawPage(page);
|
drawPage(page);
|
||||||
|
|
||||||
for (let i = 0; i < apps.length; i++) { // Load the rest of the app icons that were not initially.
|
for (let i = 0; i < apps.length; i++) { // Load the rest of the app icons that were not initially.
|
||||||
if (i >= INIT_PAGE_APP_ZEROTH && i <= INIT_PAGE_APP_LAST) continue;
|
if (i >= initPageAppZeroth && i <= initPageAppLast) continue;
|
||||||
if (apps[i].icon)
|
if (apps[i].icon)
|
||||||
apps[i].icon = s.read(apps[i].icon); // should just be a link to a memory area
|
apps[i].icon = s.read(apps[i].icon); // should just be a link to a memory area
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
swipeExit: false,
|
swipeExit: false,
|
||||||
timeOut: "Off",
|
timeOut: "Off",
|
||||||
interactionBuzz: false,
|
interactionBuzz: false,
|
||||||
|
rememberPage: false,
|
||||||
}, require('Storage').readJSON(FILE, true) || {});
|
}, require('Storage').readJSON(FILE, true) || {});
|
||||||
|
|
||||||
function writeSettings() {
|
function writeSettings() {
|
||||||
|
@ -64,5 +65,12 @@
|
||||||
writeSettings();
|
writeSettings();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/*LANG*/'Remember Page': {
|
||||||
|
value: settings.rememberPage,
|
||||||
|
onchange: v => {
|
||||||
|
settings.rememberPage = v;
|
||||||
|
writeSettings();
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue