From 6bd3d2e599652c145f1927cdcfe67d359c939144 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Tue, 21 May 2024 21:36:37 +0100 Subject: [PATCH 1/4] promenu: fix removal of final menu item & `E.showMenu()` --- apps/promenu/ChangeLog | 2 ++ apps/promenu/bootb2.js | 10 ++++------ apps/promenu/bootb2.ts | 15 ++++++--------- apps/promenu/metadata.json | 2 +- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/apps/promenu/ChangeLog b/apps/promenu/ChangeLog index e06007c98..0cbb4fdba 100644 --- a/apps/promenu/ChangeLog +++ b/apps/promenu/ChangeLog @@ -5,3 +5,5 @@ functionality, both via `.back` and `"< Back"` items, displaying an entry and the `setUI` back widget. Fix `setUI`'s back overwrite. Add support for scroll. +0.05: Fix display of final menu item when no options are given and + handling of E.showMenu() with no arguments diff --git a/apps/promenu/bootb2.js b/apps/promenu/bootb2.js index 87d6e4a54..a41b8cb06 100644 --- a/apps/promenu/bootb2.js +++ b/apps/promenu/bootb2.js @@ -12,12 +12,10 @@ E.showMenu = function (items) { g.fillPoly(RectRnd(x1, y1, x2, y2, r)); g.setColor(255, 255, 255); }; + var options = items && items[""] || {}; + if (items) + delete items[""]; var menuItems = Object.keys(items); - var options = items[""] || {}; - if (!(options instanceof Object)) - options = {}; - if (options) - menuItems.splice(menuItems.indexOf(""), 1); var fontHeight = options.fontHeight || 25; var selected = options.scroll || options.selected || 0; var ar = Bangle.appRect; @@ -144,7 +142,7 @@ E.showMenu = function (items) { l.draw(); var back = options.back; if (!back) { - var backItem = items["< Back"]; + var backItem = items && items["< Back"]; if (typeof backItem === "function") back = backItem; else if (backItem && "back" in backItem) diff --git a/apps/promenu/bootb2.ts b/apps/promenu/bootb2.ts index c3ec89bea..abc243c45 100644 --- a/apps/promenu/bootb2.ts +++ b/apps/promenu/bootb2.ts @@ -1,6 +1,6 @@ type ActualMenuItem = Exclude; -(E.showMenu as any) = (items: Menu): MenuInstance => { +E.showMenu = (items?: Menu): MenuInstance => { const RectRnd = (x1: number, y1: number, x2: number, y2: number, r: number) => { const pp = []; pp.push(...g.quadraticBezier([x2 - r, y1, x2, y1, x2, y1 + r])); @@ -14,12 +14,9 @@ type ActualMenuItem = Exclude; g.fillPoly(RectRnd(x1, y1, x2, y2, r)); g.setColor(255, 255, 255); }; + let options = items && items[""] || {}; + if (items) delete items[""]; const menuItems = Object.keys(items); - let options = items[""] || {}; - if (!(options instanceof Object)) options = {}; - - if (options) - menuItems.splice(menuItems.indexOf(""), 1); const fontHeight = options.fontHeight||25; @@ -63,7 +60,7 @@ type ActualMenuItem = Exclude; } while (rows--) { const name = menuItems[idx]; - const item = items[name]! as ActualMenuItem; + const item = items![name]! as ActualMenuItem; const hl = (idx === selected && !selectEdit); if(g.theme.dark){ @@ -118,7 +115,7 @@ type ActualMenuItem = Exclude; g.flip(); }, select: () => { - const item = items[menuItems[selected]] as ActualMenuItem; + const item = items![menuItems[selected]] as ActualMenuItem; if (typeof item === "function") { item(); @@ -164,7 +161,7 @@ type ActualMenuItem = Exclude; let back = options.back; if (!back) { - const backItem = items["< Back"]; + const backItem = items && items["< Back"]; if (typeof backItem === "function") back = backItem; else if (backItem && "back" in backItem) diff --git a/apps/promenu/metadata.json b/apps/promenu/metadata.json index 7da6e32df..31be93940 100644 --- a/apps/promenu/metadata.json +++ b/apps/promenu/metadata.json @@ -1,7 +1,7 @@ { "id": "promenu", "name": "Pro Menu", - "version": "0.04", + "version": "0.05", "description": "Replace the built in menu function. Supports Bangle.js 1 and Bangle.js 2.", "icon": "icon.png", "type": "bootloader", From 0574647e6099060c7e67b7b189a4afad7db96bcf Mon Sep 17 00:00:00 2001 From: Vini Date: Wed, 22 May 2024 21:42:55 +0200 Subject: [PATCH 2/4] feat: remove duplicate day in calendar Remove duplicated day in calendar when format setting is 'dd MMM' --- apps/clkinfocal/ChangeLog | 3 ++- apps/clkinfocal/clkinfo.js | 2 +- apps/clkinfocal/metadata.json | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/clkinfocal/ChangeLog b/apps/clkinfocal/ChangeLog index e3c19f0ba..ccb73b648 100644 --- a/apps/clkinfocal/ChangeLog +++ b/apps/clkinfocal/ChangeLog @@ -1,4 +1,5 @@ 0.01: New App! 0.02: added settings options to change date format 0.03: Remove un-needed font requirement, now outputs transparent image -0.04: Fix image after 0.03 regression \ No newline at end of file +0.04: Fix image after 0.03 regression +0.05: Remove duplicated day in calendar when format setting is 'dd MMM' \ No newline at end of file diff --git a/apps/clkinfocal/clkinfo.js b/apps/clkinfocal/clkinfo.js index 893549399..dc93ddd0e 100644 --- a/apps/clkinfocal/clkinfo.js +++ b/apps/clkinfocal/clkinfo.js @@ -5,7 +5,7 @@ var getDateString = function(dt) { switch(settings.fmt) { case "dd MMM": - return '' + dt.getDate() + ' ' + require("locale").month(dt,1).toUpperCase(); + return require("locale").month(dt,1).toUpperCase(); case "DDD dd": return require("locale").dow(dt,1).toUpperCase() + ' ' + dt.getDate(); default: // DDD diff --git a/apps/clkinfocal/metadata.json b/apps/clkinfocal/metadata.json index 0bdcb5178..71dc811e9 100644 --- a/apps/clkinfocal/metadata.json +++ b/apps/clkinfocal/metadata.json @@ -1,6 +1,6 @@ { "id": "clkinfocal", "name": "Calendar Clockinfo", - "version":"0.04", + "version":"0.05", "description": "For clocks that display 'clockinfo' (messages that can be cycled through using the clock_info module) this displays the day of the month in the icon, and the weekday. There is also a settings menu to select the format of the text", "icon": "app.png", "screenshots": [{"url":"screenshot.png"}], From f6289804d684b976a8542b37f3af6add9dc7525d Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Fri, 24 May 2024 09:02:32 +0100 Subject: [PATCH 3/4] android 0.36: Move from wrapper function to {} and let - faster execution at boot --- apps/android/ChangeLog | 1 + apps/android/boot.js | 20 ++++++++++---------- apps/android/metadata.json | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/apps/android/ChangeLog b/apps/android/ChangeLog index 0ed05817d..c2ca9ca22 100644 --- a/apps/android/ChangeLog +++ b/apps/android/ChangeLog @@ -35,3 +35,4 @@ 0.33: Fix alarms created in Gadgetbridge not repeating 0.34: Implement API for activity tracks fetching (Recorder app logs). 0.35: Implement API to enable/disable acceleration data tracking. +0.36: Move from wrapper function to {} and let - faster execution at boot \ No newline at end of file diff --git a/apps/android/boot.js b/apps/android/boot.js index c12513141..1c585ef3d 100644 --- a/apps/android/boot.js +++ b/apps/android/boot.js @@ -1,22 +1,22 @@ /* global GB */ -(function() { - function gbSend(message) { +{ + let gbSend = function(message) { Bluetooth.println(""); Bluetooth.println(JSON.stringify(message)); } - var lastMsg; // for music messages - may not be needed now... - var actInterval; // Realtime activity reporting interval when `act` is true - var actHRMHandler; // For Realtime activity reporting - var gpsState = {}; // keep information on GPS via Gadgetbridge + let lastMsg; // for music messages - may not be needed now... + let actInterval; // Realtime activity reporting interval when `act` is true + let actHRMHandler; // For Realtime activity reporting + let gpsState = {}; // keep information on GPS via Gadgetbridge // this settings var is deleted after this executes to save memory - var settings = require("Storage").readJSON("android.settings.json",1)||{}; + let settings = require("Storage").readJSON("android.settings.json",1)||{}; //default alarm settings if (settings.rp == undefined) settings.rp = true; if (settings.as == undefined) settings.as = true; if (settings.vibrate == undefined) settings.vibrate = ".."; require('Storage').writeJSON("android.settings.json", settings); - var _GB = global.GB; + let _GB = global.GB; let fetchRecInterval; global.GB = (event) => { // feed a copy to other handlers if there were any @@ -337,7 +337,7 @@ }; // Battery monitor - function sendBattery() { gbSend({ t: "status", bat: E.getBattery(), chg: Bangle.isCharging()?1:0 }); } + let sendBattery = function() { gbSend({ t: "status", bat: E.getBattery(), chg: Bangle.isCharging()?1:0 }); } Bangle.on("charging", sendBattery); NRF.on("connect", () => setTimeout(function() { sendBattery(); @@ -432,4 +432,4 @@ // remove settings object so it's not taking up RAM delete settings; -})(); +} diff --git a/apps/android/metadata.json b/apps/android/metadata.json index 95fd60854..7768efb6c 100644 --- a/apps/android/metadata.json +++ b/apps/android/metadata.json @@ -2,7 +2,7 @@ "id": "android", "name": "Android Integration", "shortName": "Android", - "version": "0.35", + "version": "0.36", "description": "Display notifications/music/etc sent from the Gadgetbridge app on Android. This replaces the old 'Gadgetbridge' Bangle.js widget.", "icon": "app.png", "tags": "tool,system,messages,notifications,gadgetbridge", From e856e381fad97cea0c88acd5cbb78c448c1abe0b Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Fri, 24 May 2024 09:10:51 +0100 Subject: [PATCH 4/4] android: Allow `calendar-` to take an array of items to remove --- apps/android/ChangeLog | 3 ++- apps/android/boot.js | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/android/ChangeLog b/apps/android/ChangeLog index c2ca9ca22..11c78588a 100644 --- a/apps/android/ChangeLog +++ b/apps/android/ChangeLog @@ -35,4 +35,5 @@ 0.33: Fix alarms created in Gadgetbridge not repeating 0.34: Implement API for activity tracks fetching (Recorder app logs). 0.35: Implement API to enable/disable acceleration data tracking. -0.36: Move from wrapper function to {} and let - faster execution at boot \ No newline at end of file +0.36: Move from wrapper function to {} and let - faster execution at boot + Allow `calendar-` to take an array of items to remove \ No newline at end of file diff --git a/apps/android/boot.js b/apps/android/boot.js index 1c585ef3d..729ed2b47 100644 --- a/apps/android/boot.js +++ b/apps/android/boot.js @@ -122,7 +122,10 @@ var cal = require("Storage").readJSON("android.calendar.json",true); //if any of those happen we are out of sync! if (!cal || !Array.isArray(cal)) cal = []; - cal = cal.filter(e=>e.id!=event.id); + if (Array.isArray(event.id)) + cal = cal.filter(e=>!event.id.includes(e.id)); + else + cal = cal.filter(e=>e.id!=event.id); require("Storage").writeJSON("android.calendar.json", cal); }, //triggered by GB, send all ids