Merge pull request #3642 from thyttan/dtlaunch
dtlaunch: remember page between dtlaunch instancesmaster
commit
f16f521482
|
|
@ -31,3 +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: 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,7 +34,17 @@
|
||||||
s.writeJSON("launch.cache.json", launchCache);
|
s.writeJSON("launch.cache.json", launchCache);
|
||||||
}
|
}
|
||||||
let apps = launchCache.apps;
|
let apps = launchCache.apps;
|
||||||
for (let i = 0; i < 4; i++) { // Initially only load icons for the current page.
|
let page = 0;
|
||||||
|
let initPageAppZeroth = 0;
|
||||||
|
let initPageAppLast = 3;
|
||||||
|
if (settings.rememberPage) {
|
||||||
|
page = (global.dtlaunch&&global.dtlaunch.handlePagePersist()) ??
|
||||||
|
(parseInt(s.read("dtlaunch.page")) ?? 0);
|
||||||
|
initPageAppZeroth = page*4;
|
||||||
|
initPageAppLast = Math.min(page*4+3, apps.length-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = initPageAppZeroth; i <= initPageAppLast; 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
|
||||||
}
|
}
|
||||||
|
|
@ -43,7 +54,6 @@
|
||||||
let maxPage = Npages-1;
|
let maxPage = Npages-1;
|
||||||
let selected = -1;
|
let selected = -1;
|
||||||
//let oldselected = -1;
|
//let oldselected = -1;
|
||||||
let page = 0;
|
|
||||||
const XOFF = 24;
|
const XOFF = 24;
|
||||||
const YOFF = 30;
|
const YOFF = 30;
|
||||||
|
|
||||||
|
|
@ -99,13 +109,32 @@
|
||||||
|
|
||||||
Bangle.drawWidgets(); // To immediately update widget field to follow current theme - remove leftovers if previous app set custom theme.
|
Bangle.drawWidgets(); // To immediately update widget field to follow current theme - remove leftovers if previous app set custom theme.
|
||||||
Bangle.loadWidgets();
|
Bangle.loadWidgets();
|
||||||
drawPage(0);
|
drawPage(page);
|
||||||
|
|
||||||
for (let i = 4; 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 >= 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!global.dtlaunch) {
|
||||||
|
global.dtlaunch = {};
|
||||||
|
global.dtlaunch.handlePagePersist = function(page) {
|
||||||
|
// Function for persisting the active page when leaving dtlaunch.
|
||||||
|
if (page===undefined) {return this.page||0;}
|
||||||
|
|
||||||
|
if (!this.killHandler) { // Only register kill listener once.
|
||||||
|
this.killHandler = () => {
|
||||||
|
s.write("dtlaunch.page", this.page.toString());
|
||||||
|
};
|
||||||
|
E.on("kill", this.killHandler); // This is intentionally left around after fastloading into other apps. I.e. not removed in uiRemove.
|
||||||
|
}
|
||||||
|
|
||||||
|
this.page = page;
|
||||||
|
};
|
||||||
|
global.dtlaunch.handlePagePersist(page);
|
||||||
|
}
|
||||||
|
|
||||||
let swipeListenerDt = function(dirLeftRight, dirUpDown){
|
let swipeListenerDt = function(dirLeftRight, dirUpDown){
|
||||||
updateTimeoutToClock();
|
updateTimeoutToClock();
|
||||||
selected = -1;
|
selected = -1;
|
||||||
|
|
@ -142,6 +171,7 @@
|
||||||
drawIcon(page,selected,false);
|
drawIcon(page,selected,false);
|
||||||
} else {
|
} else {
|
||||||
buzzLong();
|
buzzLong();
|
||||||
|
global.dtlaunch.handlePagePersist(page);
|
||||||
load(apps[page*4+i].src);
|
load(apps[page*4+i].src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -162,7 +192,10 @@
|
||||||
back : Bangle.showClock,
|
back : Bangle.showClock,
|
||||||
swipe : swipeListenerDt,
|
swipe : swipeListenerDt,
|
||||||
touch : touchListenerDt,
|
touch : touchListenerDt,
|
||||||
remove : ()=>{if (timeoutToClock) clearTimeout(timeoutToClock);}
|
remove : ()=>{
|
||||||
|
if (timeoutToClock) {clearTimeout(timeoutToClock);}
|
||||||
|
global.dtlaunch.handlePagePersist(page);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// taken from Icon Launcher with minor alterations
|
// taken from Icon Launcher with minor alterations
|
||||||
|
|
@ -177,4 +210,3 @@
|
||||||
updateTimeoutToClock();
|
updateTimeoutToClock();
|
||||||
|
|
||||||
} // end of app scope
|
} // end of app scope
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "dtlaunch",
|
"id": "dtlaunch",
|
||||||
"name": "Desktop Launcher",
|
"name": "Desktop Launcher",
|
||||||
"version": "0.26",
|
"version": "0.27",
|
||||||
"description": "Desktop style App Launcher with six (four for Bangle 2) apps per page - fast access if you have lots of apps installed.",
|
"description": "Desktop style App Launcher with six (four for Bangle 2) apps per page - fast access if you have lots of apps installed.",
|
||||||
"screenshots": [{"url":"shot1.png"},{"url":"shot2.png"},{"url":"shot3.png"}],
|
"screenshots": [{"url":"shot1.png"},{"url":"shot2.png"},{"url":"shot3.png"}],
|
||||||
"icon": "icon.png",
|
"icon": "icon.png",
|
||||||
|
|
|
||||||
|
|
@ -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