Skip to content

Commit

Permalink
Merge pull request #3001 from lauzonhomeschool/alarm_type_and_settings
Browse files Browse the repository at this point in the history
Alarm type and settings; fix drag keyboards colors settings
  • Loading branch information
gfwilliams authored Sep 19, 2023
2 parents abc6b67 + 2c6209e commit eab1c32
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 12 deletions.
1 change: 1 addition & 0 deletions apps/alarm/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@
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.42: Fix date not getting saved in event edit menu when tapping Confirm
0.43: New settings: Show confirm, Show Overflow, Show Type.
2 changes: 1 addition & 1 deletion apps/alarm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
- `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)
- `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`
- `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
Expand Down
32 changes: 29 additions & 3 deletions apps/alarm/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Bangle.loadWidgets();
Bangle.drawWidgets();

const settings = Object.assign({
showConfirm : true,
showAutoSnooze : true,
showHidden : true
}, require('Storage').readJSON('alarm.json',1)||{});
// 0 = Sunday (default), 1 = Monday
const firstDayOfWeek = (require("Storage").readJSON("setting.json", true) || {}).firstDayOfWeek || 0;
const WORKDAYS = 62;
Expand Down Expand Up @@ -51,12 +56,14 @@ function getLabel(e) {
}

function trimLabel(label, maxLength) {
if(settings.showOverflow) return label;
return (label.length > maxLength
? label.substring(0,maxLength-3) + "..."
: label.substring(0,maxLength));
}

function formatAlarmMessage(msg) {
function formatAlarmProperty(msg) {
if(settings.showOverflow) return msg;
if (msg == null) {
return msg;
} else if (msg.length > 7) {
Expand Down Expand Up @@ -155,7 +162,7 @@ function showEditAlarmMenu(selectedAlarm, alarmIndex, withDate) {
},
/*LANG*/"Message": {
value: alarm.msg,
format: formatAlarmMessage,
format: formatAlarmProperty,
onchange: () => {
setTimeout(() => {
keyboard.input({text:alarm.msg}).then(result => {
Expand All @@ -166,6 +173,19 @@ function showEditAlarmMenu(selectedAlarm, alarmIndex, withDate) {
}, 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": {
value: alarm.on,
onchange: v => alarm.on = v
Expand Down Expand Up @@ -197,6 +217,10 @@ function showEditAlarmMenu(selectedAlarm, alarmIndex, withDate) {
};

if (!keyboard) delete menu[/*LANG*/"Message"];
if (!keyboard || !settings.showGroup) delete menu[/*LANG*/"Group"];
if (!settings.showConfirm) delete menu[/*LANG*/"Confirm"];
if (!settings.showAutoSnooze) delete menu[/*LANG*/"Auto Snooze"];
if (!settings.showHidden) delete menu[/*LANG*/"Hidden"];
if (!alarm.date) {
delete menu[/*LANG*/"Day"];
delete menu[/*LANG*/"Month"];
Expand Down Expand Up @@ -387,7 +411,7 @@ function showEditTimerMenu(selectedTimer, timerIndex) {
},
/*LANG*/"Message": {
value: timer.msg,
format: formatAlarmMessage,
format: formatAlarmProperty,
onchange: () => {
setTimeout(() => {
keyboard.input({text:timer.msg}).then(result => {
Expand Down Expand Up @@ -420,6 +444,8 @@ function showEditTimerMenu(selectedTimer, timerIndex) {
};

if (!keyboard) delete menu[/*LANG*/"Message"];
if (!settings.showConfirm) delete menu[/*LANG*/"Confirm"];
if (!settings.showHidden) delete menu[/*LANG*/"Hidden"];
if (!isNew) {
menu[/*LANG*/"Delete"] = () => {
E.showPrompt(getLabel(timer) + "\n" + /*LANG*/"Are you sure?", { title: /*LANG*/"Delete Timer" }).then((confirm) => {
Expand Down
8 changes: 5 additions & 3 deletions apps/alarm/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "alarm",
"name": "Alarms & Timers",
"shortName": "Alarms",
"version": "0.42",
"version": "0.43",
"description": "Set alarms and timers on your Bangle",
"icon": "app.png",
"tags": "tool,alarm",
Expand All @@ -11,7 +11,8 @@
"dependencies": { "scheduler":"type", "alarm":"widget" },
"storage": [
{ "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": [
{ "url": "screenshot-1.png" },
Expand All @@ -25,5 +26,6 @@
{ "url": "screenshot-9.png" },
{ "url": "screenshot-10.png" },
{ "url": "screenshot-11.png" }
]
],
"data":[ {"name":"alarm.settings.json"} ]
}
51 changes: 51 additions & 0 deletions apps/alarm/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
(function(back) {
let settings = Object.assign({
showConfirm : true,
showAutoSnooze : true,
showHidden : true
}, 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,
onchange : v => { settings.showAutoSnooze=v; save();}
},
/*LANG*/'Show Menu Confirm': {
value : !!settings.showConfirm,
onchange : v => { settings.showConfirm=v; save();}
},
/*LANG*/'Show Menu Hidden': {
value : !!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);
});
1 change: 1 addition & 0 deletions apps/dragboard/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
0.07: Settings for display colors
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.
0.09: Fix colors settings, where color was stored as string instead of the expected int.
2 changes: 1 addition & 1 deletion apps/dragboard/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ "id": "dragboard",
"name": "Dragboard",
"version":"0.08",
"version":"0.09",
"description": "A library for text input via swiping keyboard",
"icon": "app.png",
"type":"textinput",
Expand Down
2 changes: 1 addition & 1 deletion apps/dragboard/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
value: settings[key] == color,
onchange: () => {
if (color >= 0) {
settings[key] = color;
settings[key] = parseInt(color);
} else {
delete settings[key];
}
Expand Down
1 change: 1 addition & 0 deletions apps/draguboard/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
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
edge 2v18 ones), allowing compatability with the Back Swipe app.
0.03: Fix "Uncaught Error: Unhandled promise rejection: ReferenceError: "dragHandlerDB" is not defined"
2 changes: 1 addition & 1 deletion apps/draguboard/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ exports.input = function(options) {
g.clearRect(Bangle.appRect);
resolve(text);
},
drag: dragHandlerDB
drag: dragHandlerUB
});
Bangle.prependListener&&Bangle.prependListener('swipe', catchSwipe); // Intercept swipes on fw2v19 and later. Should not break on older firmwares.

Expand Down
2 changes: 1 addition & 1 deletion apps/draguboard/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ "id": "draguboard",
"name": "DragUboard",
"version":"0.02",
"version":"0.03",
"description": "A library for text input via swiping U-shaped keyboard.",
"icon": "app.png",
"type":"textinput",
Expand Down
2 changes: 1 addition & 1 deletion apps/draguboard/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
value: settings[key] == color,
onchange: () => {
if (color >= 0) {
settings[key] = color;
settings[key] = parseInt(color);
} else {
delete settings[key];
}
Expand Down

0 comments on commit eab1c32

Please sign in to comment.