Skip to content

Commit 916a5a9

Browse files
authored
Merge pull request #4330 from RKBoss6/gridlaunch
[New App] Grid Launcher
2 parents eda8c18 + 2d7b012 commit 916a5a9

6 files changed

Lines changed: 118 additions & 0 deletions

File tree

apps/gridlaunch/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.01: New app

apps/gridlaunch/app.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
let s = require("Storage");
3+
let settings = Object.assign(
4+
{showClocks:false,showLaunchers:false, showWidgets:true},s.readJSON("gridlaunch.settings.json")||{});
5+
6+
let launchCache = require("launch_utils").cache(settings);
7+
let apps = launchCache.apps;
8+
let chunkedApps = [];
9+
10+
for (let i = 0; i < apps.length; i += 3) {
11+
chunkedApps.push(apps.slice(i, i + 3));
12+
}
13+
if(settings.showWidgets){
14+
Bangle.loadWidgets();
15+
Bangle.drawWidgets();
16+
}
17+
E.showScroller({
18+
h : 70,
19+
c : chunkedApps.length-1,
20+
draw : (idx, r) => {
21+
if (!chunkedApps[idx]) return;
22+
23+
const iconW = 43;
24+
const third = r.w / 3;
25+
const x0 = r.x + (third * 0.5) - (iconW / 2);
26+
const x1 = r.x + (third * 1.5) - (iconW / 2);
27+
const x2 = r.x + (third * 2.5) - (iconW / 2);
28+
29+
// 2. Strict checks ensure s.read() is only executed if BOTH the app and icon exist
30+
if (chunkedApps[idx][0] && chunkedApps[idx][0].icon) {
31+
g.drawImage(s.read(chunkedApps[idx][0].icon), x0, r.y, {scale:0.9});
32+
}
33+
if (chunkedApps[idx][1] && chunkedApps[idx][1].icon) {
34+
g.drawImage(s.read(chunkedApps[idx][1].icon), x1, r.y+26, {scale:0.9});
35+
}
36+
if (chunkedApps[idx][2] && chunkedApps[idx][2].icon) {
37+
g.drawImage(s.read(chunkedApps[idx][2].icon), x2, r.y, {scale:0.9});
38+
}
39+
},
40+
select : (idx, touch) => {
41+
let hIdx = 2;
42+
if(touch.x<g.getWidth()/3*2) hIdx = 1;
43+
if(touch.x<g.getWidth()/3) hIdx = 0;
44+
45+
if (Bangle.haptic) Bangle.haptic("touch");
46+
var app = chunkedApps[idx][hIdx];
47+
if (!app) return;
48+
if (Bangle.haptic) Bangle.haptic("touch");
49+
if (!app.src || s.read(app.src)===undefined) {
50+
E.showScroller();
51+
E.showMessage(/*LANG*/"App Source\nNot found");
52+
} else {
53+
require("launch_utils").loadApp(app);
54+
}
55+
},
56+
back : Bangle.showClock,
57+
});
58+
59+

apps/gridlaunch/icon.png

2.7 KB
Loading

apps/gridlaunch/metadata.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"id": "gridlaunch",
3+
"name": "Grid Launcher",
4+
"shortName": "Grid Launch",
5+
"version": "0.01",
6+
"author": "RKBoss6",
7+
"description": "A simple grid launcher in a familiar style",
8+
"icon": "icon.png",
9+
"type": "launch",
10+
"tags": "tool,system,launcher",
11+
"supports": ["BANGLEJS2"],
12+
"screenshots": [
13+
{"url":"scr.png"}
14+
],
15+
"storage": [
16+
{"name":"gridlaunch.app.js","url":"app.js"},
17+
{"name":"gridlaunch.settings.js","url":"settings.js"}
18+
],
19+
"data": [{"name":"launch.cache.json"},{"name":"gridlaunch.settings.json"}]
20+
}

apps/gridlaunch/scr.png

5.77 KB
Loading

apps/gridlaunch/settings.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
(function(back) {
2+
let settings = Object.assign({
3+
showClocks:false,showLaunchers:false, showWidgets:true
4+
},require("Storage").readJSON("gridlaunch.settings.json")||{});
5+
6+
7+
function save() {
8+
require("Storage").write("gridlaunch.settings.json",settings);
9+
}
10+
const appMenu = {
11+
"": { "title": /*LANG*/"Grid Launch" },
12+
/*LANG*/"< Back": back,
13+
/*LANG*/"Show Clocks": {
14+
value: !!settings.showClocks,
15+
onchange: (m) => {
16+
settings.showClocks=m;
17+
save();
18+
require("launch_utils").clearCache();
19+
}
20+
},
21+
/*LANG*/"Show Launchers": {
22+
value: !!settings.showLaunchers,
23+
onchange: (m) => {
24+
settings.showLaunchers=m;
25+
save();
26+
require("launch_utils").clearCache();
27+
}
28+
},
29+
/*LANG*/"Show Widgets": {
30+
value: !!settings.showWidgets,
31+
onchange: (m) => {
32+
settings.showWidgets=m;
33+
save();
34+
}
35+
}
36+
};
37+
E.showMenu(appMenu);
38+
})

0 commit comments

Comments
 (0)