[calclock] Version 0.02

More compact rendering & App icon
pull/2106/head
Leon Matthes 2022-08-30 11:01:01 +02:00
parent 6e909eeeeb
commit 0038c25df9
9 changed files with 38 additions and 18 deletions

View File

@ -1 +1,2 @@
0.01: Initial version 0.01: Initial version
0.02: More compact rendering & app icon

View File

@ -4,3 +4,6 @@ This clock shows a chronological view of your current and future events.
It uses events synced from Gadgetbridge to achieve this. It uses events synced from Gadgetbridge to achieve this.
The current time and date is highlighted in cyan. The current time and date is highlighted in cyan.
## Screenshot
![](screenshot.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -0,0 +1 @@
require("heatshrink").decompress(atob("mEwwgpm5gAB4AVRhgWCAAQWWDCARC/4ACJR4uB54WDAAP8DBotFGIgXLFwv4GAouQC4gwMLooXF/gXJOowXGJBIXBCIgXQxgXLMAIXXMAmIC5OIx4XJhH/wAXIxnIC78IxGIHoIABI44MBC4wQBEQIDB5gXGPAJgEC6IxBC5oABC4wwDa4YTCxAWD5nPDAzvGFYgAB5AXWJBK+GcAq5CGBIuBC5X4GBIJBdoQXB/GIx4CDPJAuEC5JoCDAgWBFwYXJxCBIFwYXKYwoACCwZ3IPQoWIC5YABGYIABCwpHKAQYMBCwwX/C5QAMC8R3/R/4XNhAXNwAXHgGIABgWIAFwA=="))

View File

@ -19,7 +19,7 @@ function zp(str) {
return ("0"+str).substr(-2); return ("0"+str).substr(-2);
} }
function drawEvent(event, y) { function drawEventHeader(event, y) {
g.setFont("Vector", 24); g.setFont("Vector", 24);
var time = isActive(event) ? new Date() : new Date(event.timestamp * 1000); var time = isActive(event) ? new Date() : new Date(event.timestamp * 1000);
@ -27,24 +27,41 @@ function drawEvent(event, y) {
g.drawString(timeStr, 5, y); g.drawString(timeStr, 5, y);
y += 24; y += 24;
g.setFont("6x15", 1); g.setFont("12x20", 1);
if (isActive(event)) { if (isActive(event)) {
g.drawString(require("locale").date(time,1),15*timeStr.length,y-15); g.drawString(zp(time.getDate())+". " + require("locale").month(time,1),15*timeStr.length,y-21);
} else { } else {
var offset = 0-time.getTimezoneOffset()/1440; var offset = 0-time.getTimezoneOffset()/1440;
var days = Math.floor((time.getTime()/1000)/86400+offset)-Math.floor(getTime()/86400+offset); var days = Math.floor((time.getTime()/1000)/86400+offset)-Math.floor(getTime()/86400+offset);
if(days > 0) { if(days > 0) {
var daysStr = days===1?/*LANG*/"tomorrow":/*LANG*/"in "+days+/*LANG*/" days"; var daysStr = days===1?/*LANG*/"tomorrow":/*LANG*/"in "+days+/*LANG*/" days";
g.drawString(daysStr,15*timeStr.length,y-15); g.drawString(daysStr,15*timeStr.length,y-21);
} }
} }
return y;
}
function drawEventBody(event, y) {
g.setFont("12x20", 1); g.setFont("12x20", 1);
var lines = g.wrapString(event.title, g.getWidth()-10); var lines = g.wrapString(event.title, g.getWidth()-10);
if (lines.length > 2) {
lines = lines.slice(0,2);
lines[1] = lines[1].slice(0,-3)+"...";
}
g.drawString(lines.join('\n'), 5, y); g.drawString(lines.join('\n'), 5, y);
y += 20 * lines.length; y+=20 * lines.length;
y += 5; if(event.location) {
g.drawImage(atob("DBSBAA8D/H/nDuB+B+B+B3Dn/j/B+A8A8AYAYAYAAAAAAA=="),5,y);
g.drawString(event.location, 20, y);
y+=20;
}
y+=5;
return y;
}
function drawEvent(event, y) {
y = drawEventHeader(event, y);
y = drawEventBody(event, y);
return y; return y;
} }
@ -58,8 +75,9 @@ function drawCurrentEvents(y) {
if(current.length === 0) { if(current.length === 0) {
y = drawEvent({timestamp: getTime(), durationInSeconds: 100}, y); y = drawEvent({timestamp: getTime(), durationInSeconds: 100}, y);
} else { } else {
y = drawEventHeader(current[0], y);
for (var e of current) { for (var e of current) {
y = drawEvent(e, y); y = drawEventBody(e, y);
} }
} }
curEventHeight = y - curEventHeight; curEventHeight = y - curEventHeight;
@ -67,7 +85,7 @@ function drawCurrentEvents(y) {
} }
function drawFutureEvents(y) { function drawFutureEvents(y) {
g.setColor("#fff"); g.setColor(g.theme.fg);
for (var e of next) { for (var e of next) {
y = drawEvent(e, y); y = drawEvent(e, y);
if(y>g.getHeight())break; if(y>g.getHeight())break;
@ -92,12 +110,7 @@ function redraw() {
} }
} }
// ------------------ DEBUG -----------------
// calendar[2].timestamp = getTime();
// Clear the screen once, at startup
g.clear(); g.clear();
// draw immediately at first
fullRedraw(); fullRedraw();
var minuteInterval = setInterval(redraw, 60 * 1000); var minuteInterval = setInterval(redraw, 60 * 1000);

BIN
apps/calclock/calclock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
apps/calclock/location.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 B

View File

@ -2,14 +2,16 @@
"id": "calclock", "id": "calclock",
"name": "Calendar Clock", "name": "Calendar Clock",
"shortName": "CalClock", "shortName": "CalClock",
"version": "0.01", "version": "0.02",
"description": "Show the current and upcoming events synchronized from Gadgetbridge", "description": "Show the current and upcoming events synchronized from Gadgetbridge",
"icon": "app.png", "icon": "calclock.png",
"type": "clock", "type": "clock",
"tags": "clock agenda", "tags": "clock agenda",
"supports": ["BANGLEJS2"], "supports": ["BANGLEJS2"],
"readme": "README.md", "readme": "README.md",
"storage": [ "storage": [
{"name":"calclock.app.js","url":"app.js"} {"name":"calclock.app.js","url":"calclock.js"},
] {"name":"calclock.img","url":"calclock-icon.js","evaluate":true}
],
"screenshots": [{"url":"screenshot.png"}]
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB