From ebf27aa14f73d3eaa7162f884da5c45ee2815818 Mon Sep 17 00:00:00 2001 From: Rarder44 Date: Wed, 12 Apr 2023 17:43:12 +0200 Subject: [PATCH 1/9] fix for #2689 commented out of the old code (it could be useful during the re-implementation of the music interface) --- apps/messages_light/messages_light.app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/messages_light/messages_light.app.js b/apps/messages_light/messages_light.app.js index 40f94dd0f..efb07f097 100644 --- a/apps/messages_light/messages_light.app.js +++ b/apps/messages_light/messages_light.app.js @@ -467,7 +467,7 @@ const updateTimeout = function(){ if (settings.timeOut!="Off"){ removeTimeout(); if( callInProgress) return; //c'รจ una chiamata in corso -> no timeout - if( music!=undefined && EventQueue.length==0 ) return; //ho aperto l'interfaccia della musica e non ho messaggi davanti -> no timeout + //if( typeof music !== 'undefined' && EventQueue.length==0 ) return; //ho aperto l'interfaccia della musica e non ho messaggi davanti -> no timeout let time=parseInt(settings.timeOut); //the "s" will be trimmed by the parseInt From ecd7ba57c16b58cd5787532e61a49816c85bd775 Mon Sep 17 00:00:00 2001 From: Rarder44 Date: Thu, 13 Apr 2023 18:37:27 +0200 Subject: [PATCH 2/9] [messages_light] changelog and metadata --- apps/messages_light/ChangeLog | 3 ++- apps/messages_light/metadata.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/messages_light/ChangeLog b/apps/messages_light/ChangeLog index 23d9ba053..e4e91cb3f 100644 --- a/apps/messages_light/ChangeLog +++ b/apps/messages_light/ChangeLog @@ -6,4 +6,5 @@ removed lib no longer used 1.3: icon changed 1.4: new management of events implemented; removed code no longer used (from now the music will be managed by the Messagesgui app) -1.5: Fix graphic bug; View via popup while there are other open apps \ No newline at end of file +1.5: Fix graphic bug; View via popup while there are other open apps +1.6: fix for #2689; ( white screen ) \ No newline at end of file diff --git a/apps/messages_light/metadata.json b/apps/messages_light/metadata.json index eeab7d9f4..f5f883ae2 100644 --- a/apps/messages_light/metadata.json +++ b/apps/messages_light/metadata.json @@ -1,7 +1,7 @@ { "id": "messages_light", "name": "Messages Light", - "version": "1.5", + "version": "1.6", "description": "A light implementation of messages App (display notifications from iOS and Gadgetbridge/Android)", "icon": "app.png", "type": "app", From 9ece2165e430dc839f61c6f97c49c48ff81f03af Mon Sep 17 00:00:00 2001 From: Christian Mauderer Date: Sun, 16 Apr 2023 14:24:13 +0200 Subject: [PATCH 3/9] widalarmeta: Selectable font. Optional hour padding. Allow to select between segment, teletext and bitmap font. Allow to disable the hour padding. FIXME --- apps/widalarmeta/ChangeLog | 1 + apps/widalarmeta/metadata.json | 2 +- apps/widalarmeta/settings.js | 18 ++++++++++++++++++ apps/widalarmeta/widget.js | 30 ++++++++++++++++++++++-------- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/apps/widalarmeta/ChangeLog b/apps/widalarmeta/ChangeLog index 2b74766c8..f412fc45f 100644 --- a/apps/widalarmeta/ChangeLog +++ b/apps/widalarmeta/ChangeLog @@ -9,3 +9,4 @@ 0.06: Remember next alarm to reduce calculation amount Redraw only every hour when no alarm in next 24h 0.07: Fix when no alarms are present +0.08: Selectable font. Allow to disable hour padding. diff --git a/apps/widalarmeta/metadata.json b/apps/widalarmeta/metadata.json index 6b3d8978b..5bb7f7795 100644 --- a/apps/widalarmeta/metadata.json +++ b/apps/widalarmeta/metadata.json @@ -2,7 +2,7 @@ "id": "widalarmeta", "name": "Alarm & Timer ETA", "shortName": "Alarm ETA", - "version": "0.07", + "version": "0.08", "description": "A widget that displays the time to the next Alarm or Timer in hours and minutes, maximum 24h (configurable).", "icon": "widget.png", "type": "widget", diff --git a/apps/widalarmeta/settings.js b/apps/widalarmeta/settings.js index db9243ae0..b9fa062b3 100644 --- a/apps/widalarmeta/settings.js +++ b/apps/widalarmeta/settings.js @@ -4,7 +4,9 @@ const settings = Object.assign({ maxhours: 24, drawBell: false, + padHours: true, showSeconds: 0, // 0=never, 1=only when display is unlocked, 2=for less than a minute + font: 0, // 0=segment style font, 1=teletest font, 2=4x5 }, require("Storage").readJSON(CONFIGFILE,1) || {}); function writeSettings() { @@ -40,5 +42,21 @@ writeSettings(); } }, + /*LANG*/'Pad hours': { + value: !!settings.padHours, + onchange: v => { + settings.padHours = v; + writeSettings(); + } + }, + /*LANG*/'Font': { + value: settings.font, + min: 0, max: 2, + format: v => [/*LANG*/"Segment", /*LANG*/"Teletext", /*LANG*/"4x5"][v || 0], + onchange: v => { + settings.font = v; + writeSettings(); + } + }, }); }); diff --git a/apps/widalarmeta/widget.js b/apps/widalarmeta/widget.js index 0104eb3b1..77b7ebb88 100644 --- a/apps/widalarmeta/widget.js +++ b/apps/widalarmeta/widget.js @@ -1,9 +1,13 @@ (() => { require("Font5x9Numeric7Seg").add(Graphics); + require("FontTeletext5x9Ascii").add(Graphics); + require("Font4x5").add(Graphics); const config = Object.assign({ maxhours: 24, drawBell: false, + padHours: true, showSeconds: 0, // 0=never, 1=only when display is unlocked, 2=for less than a minute + font: 0, // 0=segment style font, 1=teletest font, 2=4x5 }, require("Storage").readJSON("widalarmeta.json",1) || {}); function getNextAlarm(date) { @@ -46,20 +50,30 @@ drawSeconds = (config.showSeconds & 0b01 && !Bangle.isLocked()) || (config.showSeconds & 0b10 && next <= 1000*60); g.reset(); // reset the graphics context to defaults (color/font/etc) - g.setFontAlign(0,0); // center fonts + g.setFontAlign(-1,0); // center font in y direction g.clearRect(this.x, this.y, this.x+this.width-1, this.y+23); - var text = hours.padStart(2, '0') + ":" + minutes.padStart(2, '0'); + var text = ""; + if (config.padHours) { + text += hours.padStart(2, '0'); + } else { + text += hours; + } + text += ":" + minutes.padStart(2, '0'); if (drawSeconds) { text += ":" + seconds.padStart(2, '0'); } - g.setFont("5x9Numeric7Seg:1x2"); - g.drawString(text, this.x+this.width/2, this.y+12); - - calcWidth = 5*5+2; - if (drawSeconds) { - calcWidth += 3*5; + if (config.font == 1) { + g.setFont("Teletext5x9Ascii:1x2"); + } else if (config.font == 2) { + g.setFont("4x5"); + } else { + // Default to this if no other font is set. + g.setFont("5x9Numeric7Seg:1x2"); } + g.drawString(text, this.x+1, this.y+12); + + calcWidth = g.stringWidth(text) + 2; // One pixel on each side this.bellVisible = false; } else if (config.drawBell && this.numActiveAlarms > 0) { calcWidth = 24; From ac219f241f476c12b93018fa20572a9e857eb6b1 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Sun, 16 Apr 2023 21:04:13 +0100 Subject: [PATCH 4/9] clkinfo stopw: add option for format --- apps/clkinfostopw/ChangeLog | 2 +- apps/clkinfostopw/clkinfo.ts | 10 ++++++++-- apps/clkinfostopw/metadata.json | 3 ++- apps/clkinfostopw/settings.ts | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 apps/clkinfostopw/settings.ts diff --git a/apps/clkinfostopw/ChangeLog b/apps/clkinfostopw/ChangeLog index 9ef47266a..2626fb51e 100644 --- a/apps/clkinfostopw/ChangeLog +++ b/apps/clkinfostopw/ChangeLog @@ -1,2 +1,2 @@ 0.01: New clkinfo! -0.02: changed format to h:mm:ss, to reduce size of text string +0.02: Added format option, reduced battery usage diff --git a/apps/clkinfostopw/clkinfo.ts b/apps/clkinfostopw/clkinfo.ts index 900ecaeba..fa4309bb4 100644 --- a/apps/clkinfostopw/clkinfo.ts +++ b/apps/clkinfostopw/clkinfo.ts @@ -2,6 +2,8 @@ let durationOnPause = "---"; let redrawInterval: number | undefined; let startTime: number | undefined; + let { format = StopWatchFormat.HMS }: StopWatchSettings + = require("Storage").readJSON("clkinfostopw.setting.json", true) || {}; const unqueueRedraw = () => { if (redrawInterval) clearInterval(redrawInterval); @@ -25,12 +27,16 @@ seconds %= 60; if (mins < 60) - return `${pad2(mins)}m${pad2(seconds)}s`; + return format === StopWatchFormat.HMS + ? `${pad2(mins)}m${pad2(seconds)}s` + : `${mins.toFixed(0)}:${pad2(seconds)}`; let hours = mins / 60; mins %= 60; - return `${Math.round(hours)}h${pad2(mins)}m${pad2(seconds)}s`; + return format === StopWatchFormat.HMS + ? `${hours.toFixed(0)}h${pad2(mins)}m${pad2(seconds)}s` + : `${hours.toFixed(0)}:${pad2(mins)}:${pad2(seconds)}`; }; const img = () => atob("GBiBAAAAAAB+AAB+AAAAAAB+AAH/sAOB8AcA4A4YcAwYMBgYGBgYGBg8GBg8GBgYGBgAGAwAMA4AcAcA4AOBwAH/gAB+AAAAAAAAAA=="); diff --git a/apps/clkinfostopw/metadata.json b/apps/clkinfostopw/metadata.json index a1a5ebbfe..654493e64 100644 --- a/apps/clkinfostopw/metadata.json +++ b/apps/clkinfostopw/metadata.json @@ -10,6 +10,7 @@ "readme":"README.md", "allow_emulator": true, "storage": [ - {"name":"stopw.clkinfo.js","url":"clkinfo.js"} + {"name":"stopw.clkinfo.js","url":"clkinfo.js"}, + {"name":"stopw.settings.js","url":"settings.js"} ] } diff --git a/apps/clkinfostopw/settings.ts b/apps/clkinfostopw/settings.ts new file mode 100644 index 000000000..352c02677 --- /dev/null +++ b/apps/clkinfostopw/settings.ts @@ -0,0 +1,32 @@ +const enum StopWatchFormat { + HMS, + Colon, +} +type StopWatchSettings = { + format: StopWatchFormat, +}; + +((back: () => void) => { + const SETTINGS_FILE = "clkinfostopw.setting.json"; + + const storage = require("Storage"); + const settings: StopWatchSettings = storage.readJSON(SETTINGS_FILE, true) || {}; + settings.format ??= StopWatchFormat.HMS; + + const save = () => { + storage.writeJSON(SETTINGS_FILE, settings) + }; + + E.showMenu({ + "": { "title": "stopwatch" }, + "< Back": back, + "Format": { + value: settings.format, + format: () => settings.format == StopWatchFormat.HMS ? "12h34m56s" : "12:34:56", + onchange: () => { + settings.format = (settings.format + 1) % 2; + save(); + }, + }, + }); +}) From 2443000117344325f4f48c759053e6799f257107 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Sun, 16 Apr 2023 21:05:04 +0100 Subject: [PATCH 5/9] clkinfo stopw: drop interval to 1s --- apps/clkinfostopw/clkinfo.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/clkinfostopw/clkinfo.ts b/apps/clkinfostopw/clkinfo.ts index fa4309bb4..39a0637bc 100644 --- a/apps/clkinfostopw/clkinfo.ts +++ b/apps/clkinfostopw/clkinfo.ts @@ -12,7 +12,7 @@ const queueRedraw = function(this: ClockInfo.MenuItem) { unqueueRedraw(); - redrawInterval = setInterval(() => this.emit('redraw'), 100); + redrawInterval = setInterval(() => this.emit('redraw'), 1000); }; const pad2 = (s: number) => ('0' + s.toFixed(0)).slice(-2); From efd6ec5083b98715c222666c26e03ef52fece63c Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Sun, 16 Apr 2023 21:06:05 +0100 Subject: [PATCH 6/9] clkinfo stopw: fix redrawing when paused --- apps/clkinfostopw/clkinfo.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/clkinfostopw/clkinfo.ts b/apps/clkinfostopw/clkinfo.ts index 39a0637bc..6051e106e 100644 --- a/apps/clkinfostopw/clkinfo.ts +++ b/apps/clkinfostopw/clkinfo.ts @@ -53,7 +53,13 @@ : durationOnPause, img: img(), }), - show: queueRedraw, + show: function(this: ClockInfo.MenuItem) { + if(startTime){ // only queue if active + queueRedraw.call(this); + }else{ + this.emit('redraw') + } + }, hide: unqueueRedraw, run: function() { // tapped if (startTime) { From 1ac5942a931441f2160412fc52c76ecffaa82262 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Sun, 16 Apr 2023 21:06:23 +0100 Subject: [PATCH 7/9] clkinfo stopw: regenerate JS --- apps/clkinfostopw/clkinfo.js | 20 ++++++++++++++++---- apps/clkinfostopw/settings.js | 23 +++++++++++++++++++++++ 2 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 apps/clkinfostopw/settings.js diff --git a/apps/clkinfostopw/clkinfo.js b/apps/clkinfostopw/clkinfo.js index 0073543b4..e89c18505 100644 --- a/apps/clkinfostopw/clkinfo.js +++ b/apps/clkinfostopw/clkinfo.js @@ -3,6 +3,7 @@ var durationOnPause = "---"; var redrawInterval; var startTime; + var _a = (require("Storage").readJSON("clkinfostopw.setting.json", true) || {}).format, format = _a === void 0 ? 0 : _a; var unqueueRedraw = function () { if (redrawInterval) clearInterval(redrawInterval); @@ -11,7 +12,7 @@ var queueRedraw = function () { var _this = this; unqueueRedraw(); - redrawInterval = setInterval(function () { return _this.emit('redraw'); }, 100); + redrawInterval = setInterval(function () { return _this.emit('redraw'); }, 1000); }; var pad2 = function (s) { return ('0' + s.toFixed(0)).slice(-2); }; var duration = function (start) { @@ -21,10 +22,14 @@ var mins = seconds / 60; seconds %= 60; if (mins < 60) - return "".concat(mins.toFixed(0)+":").concat(pad2(seconds)); + return format === 0 + ? "".concat(pad2(mins), "m").concat(pad2(seconds), "s") + : "".concat(mins.toFixed(0), ":").concat(pad2(seconds)); var hours = mins / 60; mins %= 60; - return "".concat(hours.toFixed(0)+":").concat(pad2(mins)).concat(pad2(seconds)); + return format === 0 + ? "".concat(hours.toFixed(0), "h").concat(pad2(mins), "m").concat(pad2(seconds), "s") + : "".concat(hours.toFixed(0), ":").concat(pad2(mins), ":").concat(pad2(seconds)); }; var img = function () { return atob("GBiBAAAAAAB+AAB+AAAAAAB+AAH/sAOB8AcA4A4YcAwYMBgYGBgYGBg8GBg8GBgYGBgAGAwAMA4AcAcA4AOBwAH/gAB+AAAAAAAAAA=="); }; return { @@ -39,7 +44,14 @@ : durationOnPause, img: img(), }); }, - show: queueRedraw, + show: function () { + if (startTime) { + queueRedraw.call(this); + } + else { + this.emit('redraw'); + } + }, hide: unqueueRedraw, run: function () { if (startTime) { diff --git a/apps/clkinfostopw/settings.js b/apps/clkinfostopw/settings.js new file mode 100644 index 000000000..89b234f3b --- /dev/null +++ b/apps/clkinfostopw/settings.js @@ -0,0 +1,23 @@ +"use strict"; +(function (back) { + var _a; + var SETTINGS_FILE = "clkinfostopw.setting.json"; + var storage = require("Storage"); + var settings = storage.readJSON(SETTINGS_FILE, true) || {}; + (_a = settings.format) !== null && _a !== void 0 ? _a : (settings.format = 0); + var save = function () { + storage.writeJSON(SETTINGS_FILE, settings); + }; + E.showMenu({ + "": { "title": "stopwatch" }, + "< Back": back, + "Format": { + value: settings.format, + format: function () { return settings.format == 0 ? "12h34m56s" : "12:34:56"; }, + onchange: function () { + settings.format = (settings.format + 1) % 2; + save(); + }, + }, + }); +}); From 685aedad41519be25c47d269bf8a8e3d481ca434 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Mon, 17 Apr 2023 08:52:10 +0100 Subject: [PATCH 8/9] clkinfo stopw: better settings --- apps/clkinfostopw/settings.js | 8 +++++--- apps/clkinfostopw/settings.ts | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/clkinfostopw/settings.js b/apps/clkinfostopw/settings.js index 89b234f3b..df51cd705 100644 --- a/apps/clkinfostopw/settings.js +++ b/apps/clkinfostopw/settings.js @@ -13,9 +13,11 @@ "< Back": back, "Format": { value: settings.format, - format: function () { return settings.format == 0 ? "12h34m56s" : "12:34:56"; }, - onchange: function () { - settings.format = (settings.format + 1) % 2; + min: 0, + max: 1, + format: function (v) { return v === 0 ? "12m34s" : "12:34"; }, + onchange: function (v) { + settings.format = v; save(); }, }, diff --git a/apps/clkinfostopw/settings.ts b/apps/clkinfostopw/settings.ts index 352c02677..3d7ff5c05 100644 --- a/apps/clkinfostopw/settings.ts +++ b/apps/clkinfostopw/settings.ts @@ -22,9 +22,11 @@ type StopWatchSettings = { "< Back": back, "Format": { value: settings.format, - format: () => settings.format == StopWatchFormat.HMS ? "12h34m56s" : "12:34:56", - onchange: () => { - settings.format = (settings.format + 1) % 2; + min: StopWatchFormat.HMS, + max: StopWatchFormat.Colon, + format: v => v === StopWatchFormat.HMS ? "12m34s" : "12:34", + onchange: v => { + settings.format = v; save(); }, }, From 9767eb6594de573432daa259e1fa308cb7f7db0c Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Mon, 17 Apr 2023 12:02:31 +0100 Subject: [PATCH 9/9] typescript: drop "use strict" generation --- apps/btadv/app.js | 1 - apps/clkinfostopw/clkinfo.js | 1 - apps/clkinfostopw/settings.js | 1 - apps/widChargingStatus/widget.js | 1 - apps/widbtstates/widget.js | 1 - tsconfig.json | 10 +++++++++- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/btadv/app.js b/apps/btadv/app.js index ced701d79..67899370e 100644 --- a/apps/btadv/app.js +++ b/apps/btadv/app.js @@ -1,4 +1,3 @@ -"use strict"; var __assign = Object.assign; var Layout = require("Layout"); Bangle.loadWidgets(); diff --git a/apps/clkinfostopw/clkinfo.js b/apps/clkinfostopw/clkinfo.js index e89c18505..84d7dfecc 100644 --- a/apps/clkinfostopw/clkinfo.js +++ b/apps/clkinfostopw/clkinfo.js @@ -1,4 +1,3 @@ -"use strict"; (function () { var durationOnPause = "---"; var redrawInterval; diff --git a/apps/clkinfostopw/settings.js b/apps/clkinfostopw/settings.js index df51cd705..86bf09cdd 100644 --- a/apps/clkinfostopw/settings.js +++ b/apps/clkinfostopw/settings.js @@ -1,4 +1,3 @@ -"use strict"; (function (back) { var _a; var SETTINGS_FILE = "clkinfostopw.setting.json"; diff --git a/apps/widChargingStatus/widget.js b/apps/widChargingStatus/widget.js index 46119cc5c..628fac043 100644 --- a/apps/widChargingStatus/widget.js +++ b/apps/widChargingStatus/widget.js @@ -1,4 +1,3 @@ -"use strict"; (function () { var icon = require('heatshrink').decompress(atob('ikggMAiEAgYIBmEAg4EB+EAh0AgPggEeCAIEBnwQBAgP+gEP//x///j//8f//k///H//4BYOP/4lBv4bDvwEB4EAvAEBwEAuA7DCAI7BgAQBhEAA')); var iconWidth = 18; diff --git a/apps/widbtstates/widget.js b/apps/widbtstates/widget.js index 1d32e1bc4..e80da4082 100644 --- a/apps/widbtstates/widget.js +++ b/apps/widbtstates/widget.js @@ -1,4 +1,3 @@ -"use strict"; (function () { "ram"; var _a; diff --git a/tsconfig.json b/tsconfig.json index a383f7346..1158f887e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,6 +15,7 @@ "declaration": false, "emitDeclarationOnly": false, "removeComments": true, + "noImplicitUseStrict": true, // disable "use strict" "newLine": "lf", "noEmitHelpers": true, // we link to specific banglejs implementations @@ -35,7 +36,14 @@ "noImplicitOverride": true, "exactOptionalPropertyTypes": true, "useUnknownInCatchVariables": true, - "strict": true, + //"strict": true, // can't have this with noImplicitUseStrict, instead: + "strictNullChecks": true, + "strictBindCallApply": true, + "strictFunctionTypes": true, + "strictPropertyInitialization": true, + "noImplicitAny": true, + "noImplicitThis": true, + "useUnknownInCatchVariables": true, // simple type checking "noUnusedLocals": true,