1
0
Fork 0

Merge pull request #3604 from thyttan/alarm

alarm: toggle alarms from main menu
master
Gordon Williams 2024-10-11 14:36:56 +01:00 committed by GitHub
commit 3d7c6db2af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 4 deletions

View File

@ -53,3 +53,5 @@
0.48: Use datetimeinput for Events, if available. Scroll back when getting out of group. Menu date format setting for shorter dates on current year.
0.49: fix uncaught error if no scroller (Bangle 1). Would happen when trying
to select an alarm in the main menu.
0.50: Bangle.js 2: Long touch of alarm in main menu toggle it on/off. Touching the icon on
the right will do the same.

View File

@ -20,6 +20,8 @@ It uses the [`sched` library](https://github.com/espruino/BangleApps/blob/master
- `Disable All` → Disable _all_ enabled alarms & timers
- `Delete All` → Delete _all_ alarms & timers
On Bangle.js 2 it's possible to toggle alarms, timers and events from the main menu. This is done by clicking the indicator icons of corresponding entries. Or long pressing anywhere on them.
## Creator
- [Gordon Williams](https://github.com/gfwilliams)
@ -29,6 +31,7 @@ It uses the [`sched` library](https://github.com/espruino/BangleApps/blob/master
- [Alessandro Cocco](https://github.com/alessandrococco) - New UI, full rewrite, new features
- [Sabin Iacob](https://github.com/m0n5t3r) - Auto snooze support
- [storm64](https://github.com/storm64) - Fix redrawing in submenus
- [thyttan](https://github.com/thyttan) - Toggle alarms directly from main menu.
## Attributions

View File

@ -88,13 +88,23 @@ function showMainMenu(scroll, group, scrollback) {
const getGroups = settings.showGroup && !group;
const groups = getGroups ? {} : undefined;
var showAlarm;
const getIcon = (e)=>{return e.on ? (e.timer ? iconTimerOn : iconAlarmOn) : (e.timer ? iconTimerOff : iconAlarmOff);};
alarms.forEach((e, index) => {
showAlarm = !settings.showGroup || (group ? e.group === group : !e.group);
if(showAlarm) {
menu[trimLabel(getLabel(e),40)] = {
value: e.on ? (e.timer ? iconTimerOn : iconAlarmOn) : (e.timer ? iconTimerOff : iconAlarmOff),
onchange: () => setTimeout(e.timer ? showEditTimerMenu : showEditAlarmMenu, 10, e, index, undefined, scroller?scroller.scroll:undefined, group)
const label = trimLabel(getLabel(e),40);
menu[label] = {
value: e.on,
onchange: (v, touch) => {
if (touch && (2==touch.type || 145<touch.x)) { // Long touch or touched icon.
e.on = v;
saveAndReload();
} else {
setTimeout(e.timer ? showEditTimerMenu : showEditAlarmMenu, 10, e, index, undefined, scroller?scroller.scroll:undefined, group);
}
},
format: v=>getIcon(e)
};
} else if (getGroups) {
groups[e.group] = undefined;

View File

@ -2,7 +2,7 @@
"id": "alarm",
"name": "Alarms & Timers",
"shortName": "Alarms",
"version": "0.49",
"version": "0.50",
"description": "Set alarms and timers on your Bangle",
"icon": "app.png",
"tags": "tool,alarm",