alarm settings (incl group), drag keyboard settings fix

pull/3001/head
lauzonhomeschool 2023-06-07 23:13:06 -04:00
parent e2d8a23672
commit 4569f52692
12 changed files with 84 additions and 11 deletions

View File

@ -45,3 +45,4 @@
0.40: Use substring of message when it's longer than fits the designated menu entry. 0.40: Use substring of message when it's longer than fits the designated menu entry.
0.41: Fix a menu bug affecting alarms with empty messages. 0.41: Fix a menu bug affecting alarms with empty messages.
0.42: Fix date not getting saved in event edit menu when tapping Confirm 0.42: Fix date not getting saved in event edit menu when tapping Confirm
0.43: New settings: Show confirm, Show Overflow, Show Type.

View File

@ -13,7 +13,7 @@ It uses the [`sched` library](https://github.com/espruino/BangleApps/blob/master
- `Repeat` → Select when the alarm will fire. You can select a predefined option (_Once_, _Every Day_, _Workdays_ or _Weekends_ or you can configure the days freely) - `Repeat` → Select when the alarm will fire. You can select a predefined option (_Once_, _Every Day_, _Workdays_ or _Weekends_ or you can configure the days freely)
- `New Timer` → Configure a new timer (triggered based on amount of time elapsed in hours/minutes/seconds) - `New Timer` → Configure a new timer (triggered based on amount of time elapsed in hours/minutes/seconds)
- `New Event` → Configure a new event (triggered based on time and date) - `New Event` → Configure a new event (triggered based on time and date)
- `Repeat` → Alarm can be be fired only once or repeated (every X number of _days_, _weeks_, _months_ or _years_) - `Repeat` → Alarm can be fired only once or repeated (every X number of _days_, _weeks_, _months_ or _years_)
- `Advanced` - `Advanced`
- `Scheduler settings` → Open the [Scheduler](https://github.com/espruino/BangleApps/tree/master/apps/sched) settings page, see its [README](https://github.com/espruino/BangleApps/blob/master/apps/sched/README.md) for details - `Scheduler settings` → Open the [Scheduler](https://github.com/espruino/BangleApps/tree/master/apps/sched) settings page, see its [README](https://github.com/espruino/BangleApps/blob/master/apps/sched/README.md) for details
- `Enable All` → Enable _all_ disabled alarms & timers - `Enable All` → Enable _all_ disabled alarms & timers

View File

@ -1,6 +1,7 @@
Bangle.loadWidgets(); Bangle.loadWidgets();
Bangle.drawWidgets(); Bangle.drawWidgets();
const settings = require('Storage').readJSON('alarm.json',1)||{};
// 0 = Sunday (default), 1 = Monday // 0 = Sunday (default), 1 = Monday
const firstDayOfWeek = (require("Storage").readJSON("setting.json", true) || {}).firstDayOfWeek || 0; const firstDayOfWeek = (require("Storage").readJSON("setting.json", true) || {}).firstDayOfWeek || 0;
const WORKDAYS = 62; const WORKDAYS = 62;
@ -51,12 +52,14 @@ function getLabel(e) {
} }
function trimLabel(label, maxLength) { function trimLabel(label, maxLength) {
if(settings.showOverflow) return label;
return (label.length > maxLength return (label.length > maxLength
? label.substring(0,maxLength-3) + "..." ? label.substring(0,maxLength-3) + "..."
: label.substring(0,maxLength)); : label.substring(0,maxLength));
} }
function formatAlarmMessage(msg) { function formatAlarmProperty(msg) {
if(settings.showOverflow) return msg;
if (msg == null) { if (msg == null) {
return msg; return msg;
} else if (msg.length > 7) { } else if (msg.length > 7) {
@ -155,7 +158,7 @@ function showEditAlarmMenu(selectedAlarm, alarmIndex, withDate) {
}, },
/*LANG*/"Message": { /*LANG*/"Message": {
value: alarm.msg, value: alarm.msg,
format: formatAlarmMessage, format: formatAlarmProperty,
onchange: () => { onchange: () => {
setTimeout(() => { setTimeout(() => {
keyboard.input({text:alarm.msg}).then(result => { keyboard.input({text:alarm.msg}).then(result => {
@ -166,6 +169,19 @@ function showEditAlarmMenu(selectedAlarm, alarmIndex, withDate) {
}, 100); }, 100);
} }
}, },
/*LANG*/"Group": {
value: alarm.group,
format: formatAlarmProperty,
onchange: () => {
setTimeout(() => {
keyboard.input({text:alarm.group}).then(result => {
alarm.group = result;
prepareAlarmForSave(alarm, alarmIndex, time, date, true);
setTimeout(showEditAlarmMenu, 10, alarm, alarmIndex, withDate);
});
}, 100);
}
},
/*LANG*/"Enabled": { /*LANG*/"Enabled": {
value: alarm.on, value: alarm.on,
onchange: v => alarm.on = v onchange: v => alarm.on = v
@ -197,6 +213,10 @@ function showEditAlarmMenu(selectedAlarm, alarmIndex, withDate) {
}; };
if (!keyboard) delete menu[/*LANG*/"Message"]; if (!keyboard) delete menu[/*LANG*/"Message"];
if (!keyboard || !settings.showGroup) delete menu[/*LANG*/"Group"];
if (!(settings.showConfirm == null ? true : settings.showConfirm)) delete menu[/*LANG*/"Confirm"];
if (!(settings.showAutoSnooze == null ? true : settings.showAutoSnooze)) delete menu[/*LANG*/"Auto Snooze"];
if (!(settings.showHidden == null ? true : settings.showHidden)) delete menu[/*LANG*/"Hidden"];
if (!alarm.date) { if (!alarm.date) {
delete menu[/*LANG*/"Day"]; delete menu[/*LANG*/"Day"];
delete menu[/*LANG*/"Month"]; delete menu[/*LANG*/"Month"];
@ -387,7 +407,7 @@ function showEditTimerMenu(selectedTimer, timerIndex) {
}, },
/*LANG*/"Message": { /*LANG*/"Message": {
value: timer.msg, value: timer.msg,
format: formatAlarmMessage, format: formatAlarmProperty,
onchange: () => { onchange: () => {
setTimeout(() => { setTimeout(() => {
keyboard.input({text:timer.msg}).then(result => { keyboard.input({text:timer.msg}).then(result => {
@ -420,6 +440,8 @@ function showEditTimerMenu(selectedTimer, timerIndex) {
}; };
if (!keyboard) delete menu[/*LANG*/"Message"]; if (!keyboard) delete menu[/*LANG*/"Message"];
if (!(settings.showConfirm == null ? true : settings.showConfirm)) delete menu[/*LANG*/"Confirm"];
if (!(settings.showHidden == null ? true : settings.showHidden)) delete menu[/*LANG*/"Hidden"];
if (!isNew) { if (!isNew) {
menu[/*LANG*/"Delete"] = () => { menu[/*LANG*/"Delete"] = () => {
E.showPrompt(getLabel(timer) + "\n" + /*LANG*/"Are you sure?", { title: /*LANG*/"Delete Timer" }).then((confirm) => { E.showPrompt(getLabel(timer) + "\n" + /*LANG*/"Are you sure?", { title: /*LANG*/"Delete Timer" }).then((confirm) => {

View File

@ -2,7 +2,7 @@
"id": "alarm", "id": "alarm",
"name": "Alarms & Timers", "name": "Alarms & Timers",
"shortName": "Alarms", "shortName": "Alarms",
"version": "0.42", "version": "0.43",
"description": "Set alarms and timers on your Bangle", "description": "Set alarms and timers on your Bangle",
"icon": "app.png", "icon": "app.png",
"tags": "tool,alarm", "tags": "tool,alarm",
@ -11,7 +11,8 @@
"dependencies": { "scheduler":"type", "alarm":"widget" }, "dependencies": { "scheduler":"type", "alarm":"widget" },
"storage": [ "storage": [
{ "name": "alarm.app.js", "url": "app.js" }, { "name": "alarm.app.js", "url": "app.js" },
{ "name": "alarm.img", "url": "app-icon.js", "evaluate": true } { "name": "alarm.img", "url": "app-icon.js", "evaluate": true },
{ "name": "alarm.settings.js", "url":"settings.js" }
], ],
"screenshots": [ "screenshots": [
{ "url": "screenshot-1.png" }, { "url": "screenshot-1.png" },

47
apps/alarm/settings.js Normal file
View File

@ -0,0 +1,47 @@
(function(back) {
let settings = require('Storage').readJSON('alarm.json',1)||{};
const save = () => require('Storage').write('alarm.json', settings);
const DATE_FORMATS = ['default', 'mmdd'];
const DATE_FORMATS_LABELS = [/*LANG*/'Default', /*LANG*/'MMDD'];
const appMenu = {
'': {title: 'alarm'}, '< Back': back,
/*LANG*/'Menu Date Format': {
value: DATE_FORMATS.indexOf(settings.menuDateFormat || 'default'),
format: v => DATE_FORMATS_LABELS[v],
min: 0,
max: DATE_FORMATS.length - 1,
onchange : v => {
if(v > 0) {
settings.menuDateFormat=DATE_FORMATS[v];
} else {
delete settings.menuDateFormat;
}
save();
}
},
/*LANG*/'Show Menu Auto Snooze': {
value : settings.showAutoSnooze == null ? true : settings.showAutoSnooze,
onchange : v => { settings.showAutoSnooze=v; save();}
},
/*LANG*/'Show Menu Confirm': {
value : settings.showConfirm == null ? true : settings.showConfirm,
onchange : v => { settings.showConfirm=v; save();}
},
/*LANG*/'Show Menu Hidden': {
value : settings.showHidden == null ? true : settings.showHidden,
onchange : v => { settings.showHidden=v; save();}
},
/*LANG*/'Show Menu Group': {
value : !!settings.showGroup,
onchange : v => { settings.showGroup=v; save();}
},
/*LANG*/'Show Text Overflow': {
value : !!settings.showOverflow,
onchange : v => { settings.showOverflow=v; save();}
},
};
E.showMenu(appMenu);
});

View File

@ -7,3 +7,4 @@
0.07: Settings for display colors 0.07: Settings for display colors
0.08: Catch and discard swipe events on fw2v19 and up (as well as some cutting 0.08: Catch and discard swipe events on fw2v19 and up (as well as some cutting
edge 2v18 ones), allowing compatability with the Back Swipe app. edge 2v18 ones), allowing compatability with the Back Swipe app.
0.09: Fix colors settings, where color was stored as string instead of the expected int.

View File

@ -1,6 +1,6 @@
{ "id": "dragboard", { "id": "dragboard",
"name": "Dragboard", "name": "Dragboard",
"version":"0.08", "version":"0.09",
"description": "A library for text input via swiping keyboard", "description": "A library for text input via swiping keyboard",
"icon": "app.png", "icon": "app.png",
"type":"textinput", "type":"textinput",

View File

@ -21,7 +21,7 @@
value: settings[key] == color, value: settings[key] == color,
onchange: () => { onchange: () => {
if (color >= 0) { if (color >= 0) {
settings[key] = color; settings[key] = parseInt(color);
} else { } else {
delete settings[key]; delete settings[key];
} }

View File

@ -1,3 +1,4 @@
0.01: New App based on dragboard, but with a U shaped drag area 0.01: New App based on dragboard, but with a U shaped drag area
0.02: Catch and discard swipe events on fw2v19 and up (as well as some cutting 0.02: Catch and discard swipe events on fw2v19 and up (as well as some cutting
edge 2v18 ones), allowing compatability with the Back Swipe app. edge 2v18 ones), allowing compatability with the Back Swipe app.
0.03: Fix "Uncaught Error: Unhandled promise rejection: ReferenceError: "dragHandlerDB" is not defined"

View File

@ -148,7 +148,7 @@ exports.input = function(options) {
g.clearRect(Bangle.appRect); g.clearRect(Bangle.appRect);
resolve(text); resolve(text);
}, },
drag: dragHandlerDB drag: dragHandlerUB
}); });
Bangle.prependListener&&Bangle.prependListener('swipe', catchSwipe); // Intercept swipes on fw2v19 and later. Should not break on older firmwares. Bangle.prependListener&&Bangle.prependListener('swipe', catchSwipe); // Intercept swipes on fw2v19 and later. Should not break on older firmwares.

View File

@ -1,6 +1,6 @@
{ "id": "draguboard", { "id": "draguboard",
"name": "DragUboard", "name": "DragUboard",
"version":"0.02", "version":"0.03",
"description": "A library for text input via swiping U-shaped keyboard.", "description": "A library for text input via swiping U-shaped keyboard.",
"icon": "app.png", "icon": "app.png",
"type":"textinput", "type":"textinput",

View File

@ -21,7 +21,7 @@
value: settings[key] == color, value: settings[key] == color,
onchange: () => { onchange: () => {
if (color >= 0) { if (color >= 0) {
settings[key] = color; settings[key] = parseInt(color);
} else { } else {
delete settings[key]; delete settings[key];
} }