Skip to content

Commit

Permalink
calendar: re-add ndColors setting
Browse files Browse the repository at this point in the history
  • Loading branch information
nxdefiant committed Oct 19, 2023
1 parent aac0314 commit f78818a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
1 change: 0 additions & 1 deletion apps/calendar/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions apps/calendar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
8 changes: 6 additions & 2 deletions apps/calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
16 changes: 15 additions & 1 deletion apps/calendar/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit f78818a

Please sign in to comment.