From f78818ae00ba483dbca2aee1baa99e5cb0e283fb Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Thu, 19 Oct 2023 20:00:54 +0200 Subject: [PATCH] calendar: re-add ndColors setting --- apps/calendar/ChangeLog | 1 - apps/calendar/README.md | 4 ++++ apps/calendar/calendar.js | 8 ++++++-- apps/calendar/settings.js | 16 +++++++++++++++- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/apps/calendar/ChangeLog b/apps/calendar/ChangeLog index 206b3080e..6edb54f65 100644 --- a/apps/calendar/ChangeLog +++ b/apps/calendar/ChangeLog @@ -16,5 +16,4 @@ 0.14: Add support for holidays 0.15: Edit holidays on device in settings 0.16: Add menu to fast open settings to edit holidays - Drop "B2 Colors" setting, use theme dark indicator instead Display Widgets in menus diff --git a/apps/calendar/README.md b/apps/calendar/README.md index 03a151bf5..7fa7bea1c 100644 --- a/apps/calendar/README.md +++ b/apps/calendar/README.md @@ -11,3 +11,7 @@ Monthly calendar, displays holidays uploaded from the web interface and schedule - Touch to display events for current month - Press the button (button 3 on Bangle.js 1) to exit - Holidays have same color as weekends and can be edited with the 'Download'-interface, e.g. by uploading an iCalendar file. + +## Settings + +B2 Colors: use non-dithering colors (default, recommended for Bangle 2) or the original color scheme. diff --git a/apps/calendar/calendar.js b/apps/calendar/calendar.js index 4d0db5867..d0cc87cfa 100644 --- a/apps/calendar/calendar.js +++ b/apps/calendar/calendar.js @@ -55,7 +55,11 @@ const loadEvents = () => { }); }; -if (!g.theme.dark) { +if (settings.ndColors === undefined) { + settings.ndColors = !g.theme.dark; +} + +if (settings.ndColors === true) { bgColor = white; bgColorMonth = blue; bgColorDow = black; @@ -100,7 +104,7 @@ const drawEvent = function(ev, curDay, x1, y1, x2, y2) { g.setColor(bgOtherEvent).fillRect(x1+1, y1+1, x2-1, y2-1); break; } -} +}; const drawCalendar = function(date) { g.setBgColor(bgColor); diff --git a/apps/calendar/settings.js b/apps/calendar/settings.js index 18c2e6ec9..38896362b 100644 --- a/apps/calendar/settings.js +++ b/apps/calendar/settings.js @@ -3,12 +3,19 @@ const HOLIDAY_FILE = "calendar.days.json"; var settings = require('Storage').readJSON(FILE, true) || {}; if (settings.ndColors === undefined) + if (process.env.HWVERSION == 2) { + settings.ndColors = true; + } else { + settings.ndColors = false; + } + if (settings.ndColors === undefined) { if (process.env.HWVERSION == 2) { settings.ndColors = true; } else { settings.ndColors = false; } - const holidays = require("Storage").readJSON(HOLIDAY_FILE,1).sort((a,b) => new Date(a.date) - new Date(b.date)) || []; + } + const holidays = (require("Storage").readJSON(HOLIDAY_FILE,1)||[]).sort((a,b) => new Date(a.date) - new Date(b.date)) || []; function writeSettings() { require('Storage').writeJSON(FILE, settings); @@ -132,6 +139,13 @@ E.showMenu({ "": { "title": "Calendar" }, "< Back": () => back(), + 'B2 Colors': { + value: settings.ndColors, + onchange: v => { + settings.ndColors = v; + writeSettings(); + } + }, /*LANG*/"Edit Holidays": () => editdates(), /*LANG*/"Add Holiday": () => { holidays.push({