mirror of https://github.com/espruino/BangleApps
calendar: use non-dithering colors by default;
localize strings; remove unused variablespull/1126/head
parent
e67f15710d
commit
bae67ecf6d
|
@ -2429,7 +2429,7 @@
|
||||||
{
|
{
|
||||||
"id": "calendar",
|
"id": "calendar",
|
||||||
"name": "Calendar",
|
"name": "Calendar",
|
||||||
"version": "0.03",
|
"version": "0.04",
|
||||||
"description": "Simple calendar",
|
"description": "Simple calendar",
|
||||||
"icon": "calendar.png",
|
"icon": "calendar.png",
|
||||||
"screenshots": [{"url":"screenshot_calendar.png"}],
|
"screenshots": [{"url":"screenshot_calendar.png"}],
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
0.01: Basic calendar
|
0.01: Basic calendar
|
||||||
0.02: Make Bangle 2 compatible
|
0.02: Make Bangle 2 compatible
|
||||||
0.03: Add setting to start week on Sunday
|
0.03: Add setting to start week on Sunday
|
||||||
|
0.04: Add setting to switch color schemes. Default color scheme will now use colors that are not dithered on Bangle 2. Use localized names for months and days of the week (Language app needed).
|
||||||
|
|
|
@ -10,4 +10,5 @@ Basic calendar
|
||||||
## Settings
|
## Settings
|
||||||
|
|
||||||
- Starts on Sunday: whether the calendar should start on Sunday (default is Monday).
|
- Starts on Sunday: whether the calendar should start on Sunday (default is Monday).
|
||||||
|
- Non-dithering Colors: use non-dithering colors (default, recommended for Bangle 2) or the original color scheme.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1 @@
|
||||||
require("heatshrink").decompress(
|
E.toArrayBuffer(atob("MDCDAkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkgEkkkkkkkgEkkkkkkkkkkkkkPwkkkkkkkPwkkkkkkkkkkkkkPwkkkkkkkPwkkkkkkkkkgAAAPwAAAAAAAPwAAAEkkkkkCSSSPwSSSSSSSPwSSSQkkkkkCSSSPwSSSSSSSPwSSSQkkkkkCSSSPwSSSSSSSPwSSSQkkkkkCSSSPwSSSSSSSPwSSSQkkkkkCSSSQCSSSSSSSQCSSSQkkkkkCSSSSSSSSSSSSSSSSSQkkkkkCSSSSSSSSSSSSSSSSSQkkkkkCSSSSSSSSSSSSSSSSSQkkkkkCSSSSSSSSSSSSSSSSSQkkkkkP/////////////////wkkkkkP/////////////////wkkkkkP/////////////////wkkkkkP/////////////////wkkkkkP//+AB+AB+AB+AB///wkkkkkP//+AB+AB+AB+AB///wkkkkkP//+AB+AB+AB+AB///wkkkkkP//+AB+AB+AB+AB///wkkkkkP/////////////////wkkkkkP/////////////////wkkkkkP//+AB+AB+AB+AB///wkkkkkP//+AB+AB+AB+AB///wkkkkkP//+AB+AB+AB+AB///wkkkkkP//+AB+AB+AB+AB///wkkkkkP/////////////////wkkkkkP/////////////////wkkkkkP//+AB+AB+AB+AB///wkkkkkP//+AB+AB+AB+AB///wkkkkkP//+AB+AB+AB+AB///wkkkkkP//+AB+AB+AB+AB///wkkkkkP/////////////////wkkkkkP/////////////////wkkkkkP/////////////////wkkkkkP/////////////////wkkkkkh////////////////+EkkkkkkAAAAAAAAAAAAAAAAAkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkg=="))
|
||||||
atob(
|
|
||||||
"mEwxH+AH4A/ADuIUCARRDhgePCKIv13YAEDoYJFAA4RJFyQvcGBYRGy4dDy4uLCJgv/DoOBDgOBF5oRLF6IeBDgIvNCJYvQDwQuNCJovRADov/F9OsAEgv/F/4vhwIACAqYv/F/4vnd94vvX/4v/F/7vvF96//F/4v/d94v/F/4wsFxQwjFxgA/AH4A/AH4AZA=="
|
|
||||||
)
|
|
||||||
)
|
|
|
@ -1,6 +1,6 @@
|
||||||
const maxX = g.getWidth();
|
const maxX = g.getWidth();
|
||||||
const maxY = g.getHeight();
|
const maxY = g.getHeight();
|
||||||
const fontSize = g.getWidth()>200?2:1;
|
const fontSize = g.getWidth() > 200 ? 2 : 1;
|
||||||
const rowN = 7;
|
const rowN = 7;
|
||||||
const colN = 7;
|
const colN = 7;
|
||||||
const headerH = maxY / 7;
|
const headerH = maxY / 7;
|
||||||
|
@ -10,26 +10,105 @@ const color1 = "#035AA6";
|
||||||
const color2 = "#4192D9";
|
const color2 = "#4192D9";
|
||||||
const color3 = "#026873";
|
const color3 = "#026873";
|
||||||
const color4 = "#038C8C";
|
const color4 = "#038C8C";
|
||||||
const color5 = "#03A696";
|
const gray1 = "#bbbbbb";
|
||||||
const black = "#000000";
|
const black = "#000000";
|
||||||
const white = "#ffffff";
|
const white = "#ffffff";
|
||||||
const gray1 = "#444444";
|
|
||||||
const gray2 = "#888888";
|
|
||||||
const gray3 = "#bbbbbb";
|
|
||||||
const red = "#d41706";
|
const red = "#d41706";
|
||||||
|
const blue = "#0000ff";
|
||||||
|
const yellow = "#ffff00";
|
||||||
|
|
||||||
let settings = require('Storage').readJSON("calendar.json", true) || {};
|
let settings = require('Storage').readJSON("calendar.json", true) || {};
|
||||||
if (settings.startOnSun === undefined)
|
if (settings.startOnSun === undefined)
|
||||||
settings.startOnSun = false;
|
settings.startOnSun = false;
|
||||||
|
if (settings.ndColor === undefined)
|
||||||
|
settings.ndColor = true;
|
||||||
|
|
||||||
|
if (settings.ndColor === true) {
|
||||||
|
let bgColor = white;
|
||||||
|
let bgColorMonth = blue;
|
||||||
|
let bgColorDow = black;
|
||||||
|
let bgColorWeekend = yellow;
|
||||||
|
let fgOtherMonth = blue;
|
||||||
|
let fgSameMonth = black;
|
||||||
|
} else {
|
||||||
|
let bgColor = color4;
|
||||||
|
let bgColorMonth = color1;
|
||||||
|
let bgColorDow = color2;
|
||||||
|
let bgColorWeekend = color3;
|
||||||
|
let fgOtherMonth = gray1;
|
||||||
|
let fgSameMonth = white;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDowLbls(locale) {
|
||||||
|
let dowLbls;
|
||||||
|
//TODO: Find some clever way to generate this programmatically from locale lib
|
||||||
|
switch (locale) {
|
||||||
|
case "de_AT":
|
||||||
|
case "de_CH":
|
||||||
|
case "de_DE":
|
||||||
|
if (settings.startOnSun) {
|
||||||
|
dowLbls = ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"];
|
||||||
|
} else {
|
||||||
|
dowLbls = ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "nl_NL":
|
||||||
|
if (settings.startOnSun) {
|
||||||
|
dowLbls = ["zo", "ma", "di", "wo", "do", "vr", "za"];
|
||||||
|
} else {
|
||||||
|
dowLbls = ["ma", "di", "wo", "do", "vr", "za", "zo"];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "fr_BE":
|
||||||
|
case "fr_CH":
|
||||||
|
case "fr_FR":
|
||||||
|
if (settings.startOnSun) {
|
||||||
|
dowLbls = ["Di", "Lu", "Ma", "Me", "Je", "Ve", "Sa"];
|
||||||
|
} else {
|
||||||
|
dowLbls = ["Lu", "Ma", "Me", "Je", "Ve", "Sa", "Di"];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "sv_SE":
|
||||||
|
if (settings.startOnSun) {
|
||||||
|
dowLbls = ["Di", "Lu", "Ma", "Me", "Je", "Ve", "Sa"];
|
||||||
|
} else {
|
||||||
|
dowLbls = ["Lu", "Ma", "Me", "Je", "Ve", "Sa", "Di"];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "it_CH":
|
||||||
|
case "it_IT":
|
||||||
|
if (settings.startOnSun) {
|
||||||
|
dowLbls = ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa"];
|
||||||
|
} else {
|
||||||
|
dowLbls = ["Lu", "Ma", "Me", "Gi", "Ve", "Sa", "Do"];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "oc_FR":
|
||||||
|
if (settings.startOnSun) {
|
||||||
|
dowLbls = ["dg", "dl", "dm", "dc", "dj", "dv", "ds"];
|
||||||
|
} else {
|
||||||
|
dowLbls = ["dl", "dm", "dc", "dj", "dv", "ds", "dg"];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (settings.startOnSun) {
|
||||||
|
dowLbls = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
||||||
|
} else {
|
||||||
|
dowLbls = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return dowLbls;
|
||||||
|
}
|
||||||
|
|
||||||
function drawCalendar(date) {
|
function drawCalendar(date) {
|
||||||
g.setBgColor(color4);
|
g.setBgColor(bgColor);
|
||||||
g.clearRect(0, 0, maxX, maxY);
|
g.clearRect(0, 0, maxX, maxY);
|
||||||
g.setBgColor(color1);
|
g.setBgColor(bgColorMonth);
|
||||||
g.clearRect(0, 0, maxX, headerH);
|
g.clearRect(0, 0, maxX, headerH);
|
||||||
g.setBgColor(color2);
|
g.setBgColor(bgColorDow);
|
||||||
g.clearRect(0, headerH, maxX, headerH + rowH);
|
g.clearRect(0, headerH, maxX, headerH + rowH);
|
||||||
g.setBgColor(color3);
|
g.setBgColor(bgColorWeekend);
|
||||||
g.clearRect(colW * 5, headerH + rowH, maxX, maxY);
|
g.clearRect(colW * 5, headerH + rowH, maxX, maxY);
|
||||||
for (let y = headerH; y < maxY; y += rowH) {
|
for (let y = headerH; y < maxY; y += rowH) {
|
||||||
g.drawLine(0, y, maxX, y);
|
g.drawLine(0, y, maxX, y);
|
||||||
|
@ -40,24 +119,11 @@ function drawCalendar(date) {
|
||||||
|
|
||||||
const month = date.getMonth();
|
const month = date.getMonth();
|
||||||
const year = date.getFullYear();
|
const year = date.getFullYear();
|
||||||
const monthMap = {
|
const localeMonth = require('locale').month(date);
|
||||||
0: "January",
|
|
||||||
1: "February",
|
|
||||||
2: "March",
|
|
||||||
3: "April",
|
|
||||||
4: "May",
|
|
||||||
5: "June",
|
|
||||||
6: "July",
|
|
||||||
7: "August",
|
|
||||||
8: "September",
|
|
||||||
9: "October",
|
|
||||||
10: "November",
|
|
||||||
11: "December"
|
|
||||||
};
|
|
||||||
g.setFontAlign(0, 0);
|
g.setFontAlign(0, 0);
|
||||||
g.setFont("6x8", fontSize);
|
g.setFont("6x8", fontSize);
|
||||||
g.setColor(white);
|
g.setColor(white);
|
||||||
g.drawString(`${monthMap[month]} ${year}`, maxX / 2, headerH / 2);
|
g.drawString(`${localeMonth} ${year}`, maxX / 2, headerH / 2);
|
||||||
g.drawPoly([10, headerH / 2, 20, 10, 20, headerH - 10], true);
|
g.drawPoly([10, headerH / 2, 20, 10, 20, headerH - 10], true);
|
||||||
g.drawPoly(
|
g.drawPoly(
|
||||||
[maxX - 10, headerH / 2, maxX - 20, 10, maxX - 20, headerH - 10],
|
[maxX - 10, headerH / 2, maxX - 20, 10, maxX - 20, headerH - 10],
|
||||||
|
@ -65,12 +131,7 @@ function drawCalendar(date) {
|
||||||
);
|
);
|
||||||
|
|
||||||
g.setFont("6x8", fontSize);
|
g.setFont("6x8", fontSize);
|
||||||
let dowLbls;
|
let dowLbls = getDowLbls(require('locale').name);
|
||||||
if (settings.startOnSun) {
|
|
||||||
dowLbls = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
||||||
} else {
|
|
||||||
dowLbls = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"];
|
|
||||||
}
|
|
||||||
dowLbls.forEach((lbl, i) => {
|
dowLbls.forEach((lbl, i) => {
|
||||||
g.drawString(lbl, i * colW + colW / 2, headerH + rowH / 2);
|
g.drawString(lbl, i * colW + colW / 2, headerH + rowH / 2);
|
||||||
});
|
});
|
||||||
|
@ -120,14 +181,19 @@ function drawCalendar(date) {
|
||||||
today.year === year && today.month === month && today.day === day - 50;
|
today.year === year && today.month === month && today.day === day - 50;
|
||||||
if (isToday) {
|
if (isToday) {
|
||||||
g.setColor(red);
|
g.setColor(red);
|
||||||
|
let x1 = x * colW;
|
||||||
|
let y1 = y * rowH + headerH + rowH;
|
||||||
|
let x2 = x * colW + colW;
|
||||||
|
let y2 = y * rowH + headerH + rowH + rowH;
|
||||||
|
g.drawRect(x1, y1, x2, y2);
|
||||||
g.drawRect(
|
g.drawRect(
|
||||||
x * colW,
|
x1 + 1,
|
||||||
y * rowH + headerH + rowH,
|
y1 + 1,
|
||||||
x * colW + colW - 1,
|
x2 - 1,
|
||||||
y * rowH + headerH + rowH + rowH
|
y2 - 1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
g.setColor(day < 50 ? gray3 : white);
|
g.setColor(day < 50 ? fgOtherMonth : fgSameMonth);
|
||||||
g.drawString(
|
g.drawString(
|
||||||
(day > 50 ? day - 50 : day).toString(),
|
(day > 50 ? day - 50 : day).toString(),
|
||||||
x * colW + colW / 2,
|
x * colW + colW / 2,
|
||||||
|
@ -145,10 +211,10 @@ const today = {
|
||||||
};
|
};
|
||||||
drawCalendar(date);
|
drawCalendar(date);
|
||||||
clearWatch();
|
clearWatch();
|
||||||
Bangle.on("touch",area=>{
|
Bangle.on("touch", area => {
|
||||||
const month = date.getMonth();
|
const month = date.getMonth();
|
||||||
let prevMonth;
|
let prevMonth;
|
||||||
if (area==1) {
|
if (area == 1) {
|
||||||
let prevMonth = month > 0 ? month - 1 : 11;
|
let prevMonth = month > 0 ? month - 1 : 11;
|
||||||
if (prevMonth === 11) date.setFullYear(date.getFullYear() - 1);
|
if (prevMonth === 11) date.setFullYear(date.getFullYear() - 1);
|
||||||
date.setMonth(prevMonth);
|
date.setMonth(prevMonth);
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 540 B After Width: | Height: | Size: 7.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 1.1 KiB |
|
@ -1,24 +1,34 @@
|
||||||
(function(back) {
|
(function (back) {
|
||||||
var FILE = "calendar.json";
|
var FILE = "calendar.json";
|
||||||
var settings = require('Storage').readJSON(FILE, true) || {};
|
var settings = require('Storage').readJSON(FILE, true) || {};
|
||||||
if (settings.startOnSun === undefined)
|
if (settings.startOnSun === undefined)
|
||||||
settings.startOnSun = true;
|
settings.startOnSun = false;
|
||||||
|
if (settings.ndColors === undefined)
|
||||||
|
settings.ndColors = true;
|
||||||
|
|
||||||
function writeSettings() {
|
function writeSettings() {
|
||||||
require('Storage').writeJSON(FILE, settings);
|
require('Storage').writeJSON(FILE, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
E.showMenu({
|
E.showMenu({
|
||||||
"" : { "title" : "Calendar" },
|
"": { "title": "Calendar" },
|
||||||
"< Back" : () => back(),
|
"< Back": () => back(),
|
||||||
'Start on Sunday': {
|
'Start on Sunday': {
|
||||||
value: settings.startOnSun,
|
value: settings.startOnSun,
|
||||||
format: v => v?"Yes":"No",
|
format: v => v ? "Yes" : "No",
|
||||||
onchange: v => {
|
onchange: v => {
|
||||||
settings.startOnSun = v;
|
settings.startOnSun = v;
|
||||||
writeSettings();
|
writeSettings();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'Non-dithering colors': {
|
||||||
|
value: settings.ndColors,
|
||||||
|
format: v => v ? "Yes" : "No",
|
||||||
|
onchange: v => {
|
||||||
|
settings.ndColors = v;
|
||||||
|
writeSettings();
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue