calendar: re-add ndColors setting

pull/3051/head
Erik Andresen 2023-10-19 20:00:54 +02:00
parent aac031489c
commit f78818ae00
4 changed files with 25 additions and 4 deletions

View File

@ -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

View File

@ -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.

View File

@ -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);

View File

@ -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({