mirror of https://github.com/espruino/BangleApps
Bangle2 version of dtlaunch
parent
829e25991d
commit
f0782fef61
12
apps.json
12
apps.json
|
@ -2733,7 +2733,7 @@
|
|||
"id": "multiclock",
|
||||
"name": "Multi Clock",
|
||||
"version": "0.09",
|
||||
"description": "Clock with multiple faces. Switch between faces with BTN1 & BTN3 or swipe left-right. For best display set theme Background 2 to cyan or some other bright colour in settings.",
|
||||
"description": "Clock with multiple faces. Switch between faces with BTN1 & BTN3 (Bangle 2 touch top-right, bottom right). For best display set theme Background 2 to cyan or some other bright colour in settings.",
|
||||
"screenshots": [{"url":"screen-ana.png"},{"url":"screen-big.png"},{"url":"screen-td.png"},{"url":"screen-nifty.png"},{"url":"screen-word.png"},{"url":"screen-sec.png"}],
|
||||
"icon": "multiclock.png",
|
||||
"type": "clock",
|
||||
|
@ -3130,15 +3130,17 @@
|
|||
{
|
||||
"id": "dtlaunch",
|
||||
"name": "Desktop Launcher",
|
||||
"version": "0.04",
|
||||
"description": "Desktop style App Launcher with six apps per page - fast access if you have lots of apps installed.",
|
||||
"version": "0.05",
|
||||
"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",
|
||||
"type": "launch",
|
||||
"tags": "tool,system,launcher",
|
||||
"supports": ["BANGLEJS"],
|
||||
"supports": ["BANGLEJS","BANGLEJS2"],
|
||||
"readme": "README.md",
|
||||
"storage": [
|
||||
{"name":"dtlaunch.app.js","url":"app.js"},
|
||||
{"name":"dtlaunch.app.js","url":"app-b1.js", "supports": ["BANGLEJS"]},
|
||||
{"name":"dtlaunch.app.js","url":"app-b2.js", "supports": ["BANGLEJS2"]},
|
||||
{"name":"dtlaunch.img","url":"app-icon.js","evaluate":true}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
0.02: Multiple pages
|
||||
0.03: cycle thru pages
|
||||
0.04: reset to clock after 2 mins of inactivity
|
||||
0.05: add Bangle 2 version
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||

|
||||
|
||||
In the picture above, the Settings app is selected.
|
||||
## Controls
|
||||
## Controls- Bangle
|
||||
|
||||
**BTN1** - move backward through app icons on a page
|
||||
|
||||
|
@ -14,3 +14,11 @@ In the picture above, the Settings app is selected.
|
|||
**Swipe Left** - move to next page of app icons
|
||||
|
||||
**Swipe Right** - move to previous page of app icons
|
||||
|
||||
## Controls- Bangle 2
|
||||
|
||||
**Touch** - icon to select, scond touch launches app
|
||||
|
||||
**Swipe Left** - move to next page of app icons
|
||||
|
||||
**Swipe Right** - move to previous page of app icons
|
|
@ -0,0 +1,105 @@
|
|||
/* Desktop launcher
|
||||
*
|
||||
*/
|
||||
|
||||
var s = require("Storage");
|
||||
var apps = s.list(/\.info$/).map(app=>{var a=s.readJSON(app,1);return a&&{name:a.name,type:a.type,icon:a.icon,sortorder:a.sortorder,src:a.src};}).filter(app=>app && (app.type=="app" || app.type=="clock" || !app.type));
|
||||
apps.sort((a,b)=>{
|
||||
var n=(0|a.sortorder)-(0|b.sortorder);
|
||||
if (n) return n; // do sortorder first
|
||||
if (a.name<b.name) return -1;
|
||||
if (a.name>b.name) return 1;
|
||||
return 0;
|
||||
});
|
||||
apps.forEach(app=>{
|
||||
if (app.icon)
|
||||
app.icon = s.read(app.icon); // should just be a link to a memory area
|
||||
});
|
||||
|
||||
var Napps = apps.length;
|
||||
var Npages = Math.ceil(Napps/4);
|
||||
var maxPage = Npages-1;
|
||||
var selected = -1;
|
||||
var oldselected = -1;
|
||||
var page = 0;
|
||||
const XOFF = 24;
|
||||
const YOFF = 30;
|
||||
|
||||
function draw_icon(p,n,selected) {
|
||||
var x = (n%2)*72+XOFF;
|
||||
var y = n>1?72+YOFF:YOFF;
|
||||
(selected?g.setColor(g.theme.fgH):g.setColor(g.theme.bg)).fillRect(x+10,y+2,x+60,y+52);
|
||||
g.clearRect(x+12,y+4,x+59,y+51);
|
||||
g.setColor(g.theme.fg);
|
||||
try{g.drawImage(apps[p*4+n].icon,x+12,y+4);} catch(e){}
|
||||
g.setFontAlign(0,-1,0).setFont("6x8",1);
|
||||
var txt = apps[p*4+n].name.split(" ");
|
||||
for (var i = 0; i < txt.length; i++) {
|
||||
txt[i] = txt[i].trim();
|
||||
g.drawString(txt[i],x+36,y+54+i*8);
|
||||
}
|
||||
}
|
||||
|
||||
function drawPage(p){
|
||||
g.reset();
|
||||
g.clearRect(0,24,175,175);
|
||||
var O = 88+YOFF/2-12*(Npages/2);
|
||||
for (var j=0;j<Npages;j++){
|
||||
var y = O+j*12;
|
||||
g.setColor(g.theme.fg);
|
||||
if (j==page) g.fillCircle(XOFF/2,y,4);
|
||||
else g.drawCircle(XOFF/2,y,4);
|
||||
}
|
||||
for (var i=0;i<4;i++) {
|
||||
if (!apps[p*4+i]) return i;
|
||||
draw_icon(p,i,selected==i);
|
||||
}
|
||||
g.flip();
|
||||
}
|
||||
|
||||
Bangle.on("swipe",(dir)=>{
|
||||
selected = 0;
|
||||
oldselected=-1;
|
||||
if (dir<0){
|
||||
++page; if (page>maxPage) page=0;
|
||||
drawPage(page);
|
||||
} else {
|
||||
--page; if (page<0) page=maxPage;
|
||||
drawPage(page);
|
||||
}
|
||||
});
|
||||
|
||||
function isTouched(p,n){
|
||||
if (n<0 || n>3) return false;
|
||||
var x1 = (n%2)*72+XOFF; var y1 = n>1?72+YOFF:YOFF;
|
||||
var x2 = x1+71; var y2 = y1+81;
|
||||
return (p.x>x1 && p.y>y1 && p.x<x2 && p.y<y2);
|
||||
}
|
||||
|
||||
Bangle.on("touch",(_,p)=>{
|
||||
var i;
|
||||
for (i=0;i<4;i++){
|
||||
if((page*4+i)<Napps){
|
||||
if (isTouched(p,i)) {
|
||||
draw_icon(page,i,true);
|
||||
if (selected>=0) {
|
||||
if (selected!=i){
|
||||
draw_icon(page,selected,false);
|
||||
} else {
|
||||
load(apps[page*4+i].src);
|
||||
}
|
||||
}
|
||||
selected=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((i==4 || (page*4+i)>Napps) && selected>=0) {
|
||||
draw_icon(page,selected,false);
|
||||
selected=-1;
|
||||
}
|
||||
});
|
||||
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
drawPage(0);
|
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
Loading…
Reference in New Issue