Skip to content

Commit

Permalink
Merge branch 'dtlaunch' into app-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
thyttan committed Nov 7, 2024
2 parents a081f6d + de28353 commit a0e7fe9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
1 change: 1 addition & 0 deletions apps/dtlaunch/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ when moving pages. Add caching for faster startups.
0.24: Add buzz-on-interaction setting
0.25: Minor code improvements
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.
38 changes: 32 additions & 6 deletions apps/dtlaunch/app-b2.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@
s.writeJSON("launch.cache.json", launchCache);
}
let apps = launchCache.apps;
for (let i = 0; i < 4; i++) { // Initially only load icons for the current page.
let page = (global.dtlaunch&&dtlaunch.HandlePagePersist()) ??
(parseInt(s.read("dtlaunch.page")) ?? 0);

const INIT_PAGE_APP_ZEROTH = page*4;
const INIT_PAGE_APP_LAST = Math.min(page*5-1, apps.length-1)
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)
apps[i].icon = s.read(apps[i].icon); // should just be a link to a memory area
}
Expand All @@ -43,7 +48,6 @@
let maxPage = Npages-1;
let selected = -1;
//let oldselected = -1;
let page = 0;
const XOFF = 24;
const YOFF = 30;

Expand Down Expand Up @@ -99,13 +103,32 @@

Bangle.drawWidgets(); // To immediately update widget field to follow current theme - remove leftovers if previous app set custom theme.
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 >= INIT_PAGE_APP_ZEROTH && i <= INIT_PAGE_APP_LAST) continue;
if (apps[i].icon)
apps[i].icon = s.read(apps[i].icon); // should just be a link to a memory area
}

if (!global.dtlaunch) {
global.dtlaunch = {};
dtlaunch.HandlePagePersist = (page) => {
// Function for persisting the active page when leaving dtlaunch.
if (page===undefined) {return dtlaunch.page||0;}

if (!dtlaunch.killHandler) { // Only register kill listener once.
dtlaunch.killHandler = () => {
s.write("dtlaunch.page", dtlaunch.page.toString());
};
E.on("kill", dtlaunch.killHandler); // This is intentionally left around after fastloading into other apps. I.e. not removed in uiRemove.
}

dtlaunch.page = page;
};
dtlaunch.HandlePagePersist(page);
}

let swipeListenerDt = function(dirLeftRight, dirUpDown){
updateTimeoutToClock();
selected = -1;
Expand Down Expand Up @@ -142,6 +165,7 @@
drawIcon(page,selected,false);
} else {
buzzLong();
dtlaunch.HandlePagePersist(page);
load(apps[page*4+i].src);
}
}
Expand All @@ -162,7 +186,10 @@
back : Bangle.showClock,
swipe : swipeListenerDt,
touch : touchListenerDt,
remove : ()=>{if (timeoutToClock) clearTimeout(timeoutToClock);}
remove : ()=>{
if (timeoutToClock) {clearTimeout(timeoutToClock);}
dtlaunch.HandlePagePersist(page);
}
});

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

} // end of app scope

2 changes: 1 addition & 1 deletion apps/dtlaunch/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "dtlaunch",
"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.",
"screenshots": [{"url":"shot1.png"},{"url":"shot2.png"},{"url":"shot3.png"}],
"icon": "icon.png",
Expand Down

0 comments on commit a0e7fe9

Please sign in to comment.