Andreas Rozek 2022-01-12 10:08:49 +01:00
commit 84a403a24f
8 changed files with 90 additions and 24 deletions

View File

@ -77,7 +77,7 @@
{
"id": "messages",
"name": "Messages",
"version": "0.17",
"version": "0.18",
"description": "App to display notifications from iOS and Gadgetbridge",
"icon": "app.png",
"type": "app",
@ -2095,12 +2095,13 @@
"id": "devstopwatch",
"name": "Dev Stopwatch",
"shortName": "Dev Stopwatch",
"version": "0.03",
"version": "0.04",
"description": "Stopwatch with 5 laps supported (cyclically replaced)",
"icon": "app.png",
"tags": "stopwatch,chrono,timer,chronometer",
"supports": ["BANGLEJS","BANGLEJS2"],
"screenshots": [{"url":"bangle1-dev-stopwatch-screenshot.png"}],
"screenshots": [{"url":"bangle1-dev-stopwatch-screenshot.png"},{"url":"bangle2-dev-stopwatch-screenshot.png"}],
"readme": "README.md",
"allow_emulator": true,
"storage": [
{"name":"devstopwatch.app.js","url":"app.js"},

View File

@ -1,3 +1,8 @@
0.01: App created
0.02: Persist state to storage to enable stopwatch to continue in the background
0.03: Modified to use setUI, theme and different screens
0.04: *bugfix* stopwatch broken with v0.03 setUI
realigned quick n dirty screen positions
help adjusted to fit bangle1 & bangle2 screen-size with widgets
fixed bangle2 colors for chrono and last lap highlight
added screen for bangle2 and a small README

View File

@ -0,0 +1,18 @@
# dev stop watch
stores state at kill
## Bangle 1
![](bangle1-dev-stopwatch-screenshot.png)
* BTN1: start/lap
* BTN2: launcher
* BTN3: reset
## Bangle 2
![](bangle2-dev-stopwatch-screenshot.png)
* TAP top right: start/lap
* TAP bottom right: reset
* Use BTN to get to launcher

View File

@ -3,11 +3,11 @@ const EMPTY_H = '00:00:000';
const MAX_LAPS = 6;
const XY_CENTER = g.getWidth() / 2;
const big = g.getWidth()>200;
const Y_CHRONO = 40;
const Y_HEADER = big?80:60;
const Y_LAPS = big?125:90;
const Y_CHRONO = big?40:30;
const Y_HEADER = big?95:65;
const Y_LAPS = big?125:80;
const H_LAPS = big?15:8;
const Y_BTN3 = big?225:165;
const Y_HELP = big?225:135;
const FONT = '6x8';
const CHRONO = '/* C H R O N O */';
@ -27,18 +27,17 @@ var state = require("Storage").readJSON("devstopwatch.state.json",1) || {
// Show launcher when button pressed
Bangle.setUI("clockupdown", btn=>{
if (btn==0) {
reset = false;
if (state.started) {
changeLap();
} else {
if (!reset) {
chronoInterval = setInterval(chronometer, 10);
}
switch (btn) {
case -1:
if (state.started) {
changeLap();
} else {
chronoInterval = setInterval(chronometer, 10);
}
break;
case 1: resetChrono(); break;
default: Bangle.showLauncher(); break; //launcher handeled by ROM
}
}
if (btn==1) resetChrono();
});
function resetChrono() {
@ -105,6 +104,7 @@ function printChrono() {
var print = '';
g.setColor(g.theme.fg);
g.setFont(FONT, big?2:1);
print = CHRONO;
g.drawString(print, XY_CENTER, Y_CHRONO, true);
@ -124,7 +124,8 @@ function printChrono() {
let suffix = ' ';
if (state.currentLapIndex === i) {
let suffix = '*';
g.setColor("#f70");
if (process.env.HWVERSION==2) g.setColor("#0ee");
else g.setColor("#f70");
}
const lapLine = `L${i - 1} ${state.laps[i]} ${suffix}\n`;
@ -133,8 +134,17 @@ function printChrono() {
g.setColor(g.theme.fg);
g.setFont(FONT, 1);
print = 'Press 3 to reset';
g.drawString(print, XY_CENTER, Y_BTN3, true);
//help for model 2 or 1
if (process.env.HWVERSION==2) {
print = /*LANG*/'TAP right top/bottom';
g.drawString(print, XY_CENTER, Y_HELP, true);
print = /*LANG*/'start&lap/reset, BTN1: EXIT';
g.drawString(print, XY_CENTER, Y_HELP+10, true);
}
else {
print = /*LANG*/'BTNs 1:startlap 2:exit 3:reset';
g.drawString(print, XY_CENTER, Y_HELP, true);
}
g.flip();
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -24,3 +24,6 @@
0.15: Don't buzz when Quiet Mode is active
0.16: Fix text wrapping so it fits the screen even if title is big (fix #1147)
0.17: Fix: Get dynamic dimensions of notify icon, fixed notification font
0.18: Use app-specific icon colors
Spread message action buttons out
Back button now goes back to list of messages

View File

@ -101,6 +101,31 @@ function getMessageImage(msg) {
if (msg.id=="back") return getBackImage();
return getNotificationImage();
}
function getMessageImageCol(msg,def) {
return {
// generic colors, using B2-safe colors
"calendar": "#f00",
"mail": "#ff0",
"music": "#f0f",
"phone": "#0f0",
"sms message": "#0ff",
// brands, according to https://www.schemecolor.com/?s (picking one for multicolored logos)
// all dithered on B2, but we only use the color for the icons. (Could maybe pick the closest 3-bit color for B2?)
"facebook": "#4267b2",
"gmail": "#ea4335",
"google home": "#fbbc05",
"hangouts": "#1ba261",
"instagram": "#dd2a7b",
"messenger": "#0078ff",
"outlook mail": "#0072c6",
"skype": "#00aff0",
"slack": "#e51670",
"telegram": "#0088cc",
"twitter": "#1da1f2",
"whatsapp": "#4fce5d",
"wordfeud": "#dcc8bd",
}[(msg.src||"").toLowerCase()]||(def !== undefined?def:g.theme.fg);
}
function showMapMessage(msg) {
var m;
@ -224,10 +249,11 @@ function showMessage(msgid) {
{type:"btn", src:getBackImage(), cb:()=>{
msg.new = false; saveMessages(); // read mail
cancelReloadTimeout(); // don't auto-reload to clock now
checkMessages({clockIfNoMsg:1,clockIfAllRead:0,showMsgIfUnread:1});
checkMessages({clockIfNoMsg:1,clockIfAllRead:0,showMsgIfUnread:0});
}} // back
];
if (msg.positive) {
buttons.push({fillx:1});
buttons.push({type:"btn", src:getPosImage(), cb:()=>{
msg.new = false; saveMessages();
cancelReloadTimeout(); // don't auto-reload to clock now
@ -236,6 +262,7 @@ function showMessage(msgid) {
}});
}
if (msg.negative) {
buttons.push({fillx:1});
buttons.push({type:"btn", src:getNegImage(), cb:()=>{
msg.new = false; saveMessages();
cancelReloadTimeout(); // don't auto-reload to clock now
@ -248,7 +275,7 @@ function showMessage(msgid) {
var body = (lines.length>4) ? lines.slice(0,4).join("\n")+"..." : lines.join("\n");
layout = new Layout({ type:"v", c: [
{type:"h", fillx:1, bgCol:colBg, c: [
{ type:"btn", src:getMessageImage(msg), pad: 3, cb:()=>{
{ type:"btn", src:getMessageImage(msg), col:getMessageImageCol(msg), pad: 3, cb:()=>{
cancelReloadTimeout(); // don't auto-reload to clock now
showMessageSettings(msg);
}},
@ -310,7 +337,9 @@ function checkMessages(options) {
body = msg.track;
}
if (img) {
g.drawImage(img, x+24, r.y+24, {rotate:0}); // force centering
var fg = g.getColor();
g.setColor(getMessageImageCol(msg,fg)).drawImage(img, x+24, r.y+24, {rotate:0}) // force centering
.setColor(fg); // only color the icon
x += 50;
}
var m = msg.title+"\n"+msg.body;