From e007d05e978dc03d7ec72771894c80c7e4f04f65 Mon Sep 17 00:00:00 2001 From: Randy Heydon Date: Tue, 28 Jan 2025 20:37:58 -0500 Subject: [PATCH] calendar: read events synchronized from Gadgetbridge This is a partial fix for feature request #3707. This allows synchronized events (stored in android.calendar.json) to be shown in the app, alongside the manually entered events and alarm events that are already shown. Note only date/time and event title are currently used; other information available in the synchronized events (e.g. duration, description) are ignored. --- apps/calendar/ChangeLog | 1 + apps/calendar/calendar.js | 6 ++++++ apps/calendar/metadata.json | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/calendar/ChangeLog b/apps/calendar/ChangeLog index 9a4f81491..d737ec6d4 100644 --- a/apps/calendar/ChangeLog +++ b/apps/calendar/ChangeLog @@ -19,3 +19,4 @@ Display Widgets in menus 0.17: Load holidays before events so the latter is not overpainted 0.18: Minor code improvements +0.19: Read events synchronized from Gadgetbridge diff --git a/apps/calendar/calendar.js b/apps/calendar/calendar.js index e140ff576..da5a00a6e 100644 --- a/apps/calendar/calendar.js +++ b/apps/calendar/calendar.js @@ -60,6 +60,12 @@ const loadEvents = () => { date.setSeconds(time.s); return {date: date, msg: a.msg, type: "e"}; })); + // all events synchronized from Gadgetbridge + events = events.concat((require("Storage").readJSON("android.calendar.json",1) || []).map(a => { + // timestamp is in seconds, Date requires milliseconds + const date = new Date(a.timestamp * 1000); + return {date: date, msg: a.title, type: "e"}; + })); }; const loadSettings = () => { diff --git a/apps/calendar/metadata.json b/apps/calendar/metadata.json index 468bceabb..5f5f21b27 100644 --- a/apps/calendar/metadata.json +++ b/apps/calendar/metadata.json @@ -1,7 +1,7 @@ { "id": "calendar", "name": "Calendar", - "version": "0.18", + "version": "0.19", "description": "Monthly calendar, displays holidays uploaded from the web interface and scheduled events.", "icon": "calendar.png", "screenshots": [{"url":"screenshot_calendar.png"}],