From b81b6c2040c33031211d3a2959da06d199c86f13 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Tue, 15 Oct 2024 22:18:10 +0100 Subject: [PATCH 1/4] messagegui: option to not open the first unread message --- apps/messagegui/ChangeLog | 3 ++- apps/messagegui/app.js | 14 +++++++------- apps/messagegui/metadata.json | 2 +- apps/messages/ChangeLog | 3 ++- apps/messages/metadata.json | 2 +- apps/messages/settings.js | 5 +++++ 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/apps/messagegui/ChangeLog b/apps/messagegui/ChangeLog index f97d7b85fe..42a385b52c 100644 --- a/apps/messagegui/ChangeLog +++ b/apps/messagegui/ChangeLog @@ -109,4 +109,5 @@ 0.80: Add ability to reply to messages if a reply library is installed and the message can be replied to 0.81: Fix issue stopping Music message for being marked as read Make sure play button image is transparent - Add top-right menu to music playback to allow message to be deleted \ No newline at end of file + Add top-right menu to music playback to allow message to be deleted +0.82: Add option to not open the first unread message diff --git a/apps/messagegui/app.js b/apps/messagegui/app.js index 22f9c05790..cfc1443351 100644 --- a/apps/messagegui/app.js +++ b/apps/messagegui/app.js @@ -155,7 +155,7 @@ function showMapMessage(msg) { function back() { // mark as not new and return to menu msg.new = false; layout = undefined; - checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1,openMusic:0}); + checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:settings.showMsgIfUnread,openMusic:0}); } Bangle.setUI({mode:"updown", back: back}, back); // any input takes us back } @@ -407,7 +407,7 @@ function showMessage(msgid, persist) { msg.new = false; cancelReloadTimeout(); // don't auto-reload to clock now Bangle.messageResponse(msg,false); - checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1,openMusic:openMusic}); + checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:settings.showMsgIfUnread,openMusic:openMusic}); }; footer.push({type:"img",src:atob("PhAB4A8AAAAAAAPAfAMAAAAAD4PwHAAAAAA/H4DwAAAAAH78B8AAAAAA/+A/AAAAAAH/Af//////w/gP//////8P4D///////H/Af//////z/4D8AAAAAB+/AfAAAAAA/H4DwAAAAAPg/AcAAAAADwHwDAAAAAA4A8AAAAAAAA=="),col:"#f00",cb:negHandler}); } footer.push({fillx:1}); // push images to left/right @@ -421,7 +421,7 @@ function showMessage(msgid, persist) { Bluetooth.println(JSON.stringify(result)); replying = false; layout.render(); - checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1,openMusic:openMusic}); + checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:settings.showMsgIfUnread,openMusic:openMusic}); }) .catch(() => { replying = false; @@ -435,7 +435,7 @@ function showMessage(msgid, persist) { msg.new = false; cancelReloadTimeout(); // don't auto-reload to clock now Bangle.messageResponse(msg,true); - checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1,openMusic:openMusic}); + checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:settings.showMsgIfUnread,openMusic:openMusic}); }; footer.push({type:"img",src:atob("QRABAAAAAAAAAAOAAAAABgAAA8AAAAADgAAD4AAAAAHgAAPgAAAAAPgAA+AAAAAAfgAD4///////gAPh///////gA+D///////AD4H//////8cPgAAAAAAPw8+AAAAAAAfB/4AAAAAAA8B/gAAAAAABwB+AAAAAAADAB4AAAAAAAAABgAA=="),col:"#0f0",cb:posHandler}); } @@ -447,7 +447,7 @@ function showMessage(msgid, persist) { ]}, { type:"btn", src:require("messageicons").getImage(msg), - col:require("messageicons").getColor(msg, {settings:settings, default:g.theme.fg2}), + col:require("messageicons").getColor(msg, {settings, default:g.theme.fg2}), pad: 3, cb:()=>{ cancelReloadTimeout(); // don't auto-reload to clock now showMessageSettings(msg); @@ -538,7 +538,7 @@ function checkMessages(options) { } if (img) { var fg = g.getColor(), - col = require("messageicons").getColor(msg, {settings:settings, default:fg}); + col = require("messageicons").getColor(msg, {settings, default:fg}); g.setColor(col).drawImage(img, x+24, r.y+24, {rotate:0}) // force centering .setColor(fg); // only color the icon x += 50; @@ -594,7 +594,7 @@ setTimeout(() => { // only openMusic on launch if music is new, or state=="show" (set by messagesmusic) var musicMsg = MESSAGES.find(m => m.id === "music"); checkMessages({ - clockIfNoMsg: 0, clockIfAllRead: 0, showMsgIfUnread: 1, + clockIfNoMsg: 0, clockIfAllRead: 0, showMsgIfUnread: settings.showMsgIfUnread, openMusic: ((musicMsg&&musicMsg.new) && settings.openMusic) || (musicMsg&&musicMsg.state=="show"), dontStopBuzz: 1 }); }, 10); // if checkMessages wants to 'load', do that diff --git a/apps/messagegui/metadata.json b/apps/messagegui/metadata.json index ff8376bae9..4e3ca6057d 100644 --- a/apps/messagegui/metadata.json +++ b/apps/messagegui/metadata.json @@ -2,7 +2,7 @@ "id": "messagegui", "name": "Message UI", "shortName": "Messages", - "version": "0.81", + "version": "0.82", "description": "Default app to display notifications from iOS and Gadgetbridge/Android", "icon": "app.png", "type": "app", diff --git a/apps/messages/ChangeLog b/apps/messages/ChangeLog index 052916e640..4bd661bc67 100644 --- a/apps/messages/ChangeLog +++ b/apps/messages/ChangeLog @@ -5,4 +5,5 @@ 0.59: fixes message timeout by using setinterval, as it was intended. So the buzz is triggered every x seconds until the timeout occours. 0.60: Bump version to allow new buzz.js module to be loaded - fixes memory/performance hog when buzz called 0.61: Add repeatCalls option to allow different repeat settings for messages vs calls -0.62: Add option for driving on left (affects roundabout icons in navigation) \ No newline at end of file +0.62: Add option for driving on left (affects roundabout icons in navigation) +0.63: Add option to not open the first unread message diff --git a/apps/messages/metadata.json b/apps/messages/metadata.json index 8197081bbd..4907d496df 100644 --- a/apps/messages/metadata.json +++ b/apps/messages/metadata.json @@ -1,7 +1,7 @@ { "id": "messages", "name": "Messages", - "version": "0.62", + "version": "0.63", "description": "Library to handle, load and store message events received from Android/iOS", "icon": "app.png", "type": "module", diff --git a/apps/messages/settings.js b/apps/messages/settings.js index 1d429580c8..5cfae1d612 100644 --- a/apps/messages/settings.js +++ b/apps/messages/settings.js @@ -11,6 +11,7 @@ if (settings.unreadTimeout===undefined) settings.unreadTimeout=60; if (settings.maxMessages===undefined) settings.maxMessages=3; if (settings.iconColorMode === undefined) settings.iconColorMode = iconColorModes[0]; + if (settings.showMsgIfUnread === undefined) settings.showMsgIfUnread = 1; settings.unlockWatch=!!settings.unlockWatch; settings.openMusic=!!settings.openMusic; settings.maxUnreadTimeout=240; @@ -58,6 +59,10 @@ format: v => [/*LANG*/"Small",/*LANG*/"Medium"][v], onchange: v => updateSetting("fontSize", v) }, + /*LANG*/'Auto-Open Unread Msg': { + value: !!settings().showMsgIfUnread, + onchange: v => updateSetting("showMsgIfUnread", v) + }, /*LANG*/'Auto-Open Music': { value: !!settings().openMusic, onchange: v => updateSetting("openMusic", v) From 25495f5731ced4ca2088d3e8757039a1b2046dc9 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Wed, 23 Oct 2024 22:04:44 +0100 Subject: [PATCH 2/4] messagegui: s/openMusic:openMusic/openMusic/ --- apps/messagegui/app.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/messagegui/app.js b/apps/messagegui/app.js index cfc1443351..e64c9d9145 100644 --- a/apps/messagegui/app.js +++ b/apps/messagegui/app.js @@ -349,7 +349,7 @@ function showMessage(msgid, persist) { clearInterval(updateLabelsInterval); updateLabelsInterval=undefined; } - if (!msg) return checkMessages({clockIfNoMsg:1,clockIfAllRead:0,showMsgIfUnread:0,openMusic:openMusic}); // go home if no message found + if (!msg) return checkMessages({clockIfNoMsg:1,clockIfAllRead:0,showMsgIfUnread:0,openMusic}); // go home if no message found if (msg.id=="music") { cancelReloadTimeout(); // don't auto-reload to clock now return showMusicMessage(msg); @@ -399,7 +399,7 @@ function showMessage(msgid, persist) { layout = undefined; msg.new = false; // read mail cancelReloadTimeout(); // don't auto-reload to clock now - checkMessages({clockIfNoMsg:1,clockIfAllRead:0,showMsgIfUnread:0,openMusic:openMusic}); + checkMessages({clockIfNoMsg:1,clockIfAllRead:0,showMsgIfUnread:0,openMusic}); } var negHandler,posHandler,footer = [ ]; if (msg.negative) { @@ -407,7 +407,7 @@ function showMessage(msgid, persist) { msg.new = false; cancelReloadTimeout(); // don't auto-reload to clock now Bangle.messageResponse(msg,false); - checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:settings.showMsgIfUnread,openMusic:openMusic}); + checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:settings.showMsgIfUnread,openMusic}); }; footer.push({type:"img",src:atob("PhAB4A8AAAAAAAPAfAMAAAAAD4PwHAAAAAA/H4DwAAAAAH78B8AAAAAA/+A/AAAAAAH/Af//////w/gP//////8P4D///////H/Af//////z/4D8AAAAAB+/AfAAAAAA/H4DwAAAAAPg/AcAAAAADwHwDAAAAAA4A8AAAAAAAA=="),col:"#f00",cb:negHandler}); } footer.push({fillx:1}); // push images to left/right @@ -421,7 +421,7 @@ function showMessage(msgid, persist) { Bluetooth.println(JSON.stringify(result)); replying = false; layout.render(); - checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:settings.showMsgIfUnread,openMusic:openMusic}); + checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:settings.showMsgIfUnread,openMusic}); }) .catch(() => { replying = false; @@ -435,7 +435,7 @@ function showMessage(msgid, persist) { msg.new = false; cancelReloadTimeout(); // don't auto-reload to clock now Bangle.messageResponse(msg,true); - checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:settings.showMsgIfUnread,openMusic:openMusic}); + checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:settings.showMsgIfUnread,openMusic}); }; footer.push({type:"img",src:atob("QRABAAAAAAAAAAOAAAAABgAAA8AAAAADgAAD4AAAAAHgAAPgAAAAAPgAA+AAAAAAfgAD4///////gAPh///////gA+D///////AD4H//////8cPgAAAAAAPw8+AAAAAAAfB/4AAAAAAA8B/gAAAAAABwB+AAAAAAADAB4AAAAAAAAABgAA=="),col:"#0f0",cb:posHandler}); } From f5b3ad281051e723bd99eeab7570de6a66fd5df1 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Wed, 23 Oct 2024 22:05:21 +0100 Subject: [PATCH 3/4] messagegui: factor out common `checkMessages()` calls --- apps/messagegui/app.js | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/apps/messagegui/app.js b/apps/messagegui/app.js index e64c9d9145..5ba22dc4d3 100644 --- a/apps/messagegui/app.js +++ b/apps/messagegui/app.js @@ -196,7 +196,7 @@ function showMusicMessage(msg) { msg.new = false; layout = undefined; if (wasNew) checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:0,openMusic:0}); - else checkMessages({clockIfNoMsg:0,clockIfAllRead:0,showMsgIfUnread:0,openMusic:0}); + else returnToMain(); } function updateLabels() { trackName = reduceStringAndPad(msg.track, trackScrollOffset, 13); @@ -304,7 +304,7 @@ function showMessageSettings(msg) { menu = Object.assign(menu, { /*LANG*/"Delete" : () => { MESSAGES = MESSAGES.filter(m=>m.id!=msg.id); - checkMessages({clockIfNoMsg:0,clockIfAllRead:0,showMsgIfUnread:0,openMusic:0}); + returnToMain(); }, }); @@ -315,25 +315,25 @@ function showMessageSettings(msg) { Bangle.messageIgnore(msg); MESSAGES = MESSAGES.filter(m=>m.id!=msg.id); } - checkMessages({clockIfNoMsg:0,clockIfAllRead:0,showMsgIfUnread:0,openMusic:0}); + returnToMain(); }); }; menu = Object.assign(menu, { /*LANG*/"Mark Unread" : () => { msg.new = true; - checkMessages({clockIfNoMsg:0,clockIfAllRead:0,showMsgIfUnread:0,openMusic:0}); + returnToMain(); }, /*LANG*/"Mark all read" : () => { MESSAGES.forEach(msg => msg.new = false); - checkMessages({clockIfNoMsg:0,clockIfAllRead:0,showMsgIfUnread:0,openMusic:0}); + returnToMain(); }, /*LANG*/"Delete all messages" : () => { E.showPrompt(/*LANG*/"Are you sure?", {title:/*LANG*/"Delete All Messages"}).then(isYes => { if (isYes) { MESSAGES = []; } - checkMessages({clockIfNoMsg:0,clockIfAllRead:0,showMsgIfUnread:0,openMusic:0}); + returnToMain(); }); }, }); @@ -349,7 +349,7 @@ function showMessage(msgid, persist) { clearInterval(updateLabelsInterval); updateLabelsInterval=undefined; } - if (!msg) return checkMessages({clockIfNoMsg:1,clockIfAllRead:0,showMsgIfUnread:0,openMusic}); // go home if no message found + if (!msg) return returnToClockIfEmpty(); // go home if no message found if (msg.id=="music") { cancelReloadTimeout(); // don't auto-reload to clock now return showMusicMessage(msg); @@ -399,7 +399,7 @@ function showMessage(msgid, persist) { layout = undefined; msg.new = false; // read mail cancelReloadTimeout(); // don't auto-reload to clock now - checkMessages({clockIfNoMsg:1,clockIfAllRead:0,showMsgIfUnread:0,openMusic}); + returnToClockIfEmpty(); } var negHandler,posHandler,footer = [ ]; if (msg.negative) { @@ -407,7 +407,7 @@ function showMessage(msgid, persist) { msg.new = false; cancelReloadTimeout(); // don't auto-reload to clock now Bangle.messageResponse(msg,false); - checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:settings.showMsgIfUnread,openMusic}); + returnToCheckMessages(); }; footer.push({type:"img",src:atob("PhAB4A8AAAAAAAPAfAMAAAAAD4PwHAAAAAA/H4DwAAAAAH78B8AAAAAA/+A/AAAAAAH/Af//////w/gP//////8P4D///////H/Af//////z/4D8AAAAAB+/AfAAAAAA/H4DwAAAAAPg/AcAAAAADwHwDAAAAAA4A8AAAAAAAA=="),col:"#f00",cb:negHandler}); } footer.push({fillx:1}); // push images to left/right @@ -421,7 +421,7 @@ function showMessage(msgid, persist) { Bluetooth.println(JSON.stringify(result)); replying = false; layout.render(); - checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:settings.showMsgIfUnread,openMusic}); + returnToCheckMessages(); }) .catch(() => { replying = false; @@ -435,7 +435,7 @@ function showMessage(msgid, persist) { msg.new = false; cancelReloadTimeout(); // don't auto-reload to clock now Bangle.messageResponse(msg,true); - checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:settings.showMsgIfUnread,openMusic}); + returnToCheckMessages(); }; footer.push({type:"img",src:atob("QRABAAAAAAAAAAOAAAAABgAAA8AAAAADgAAD4AAAAAHgAAPgAAAAAPgAA+AAAAAAfgAD4///////gAPh///////gA+D///////AD4H//////8cPgAAAAAAPw8+AAAAAAAfB/4AAAAAAA8B/gAAAAAABwB+AAAAAAADAB4AAAAAAAAABgAA=="),col:"#0f0",cb:posHandler}); } @@ -570,6 +570,17 @@ function checkMessages(options) { }); } +function returnToCheckMessages(clock) { + checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:settings.showMsgIfUnread,openMusic}); +} + +function returnToMain() { + checkMessages({clockIfNoMsg:0,clockIfAllRead:0,showMsgIfUnread:0,openMusic:0}); +} + +function returnToClockIfEmpty() { + checkMessages({clockIfNoMsg:1,clockIfAllRead:0,showMsgIfUnread:0,openMusic}); +} function cancelReloadTimeout() { if (!unreadTimeout) return; From 6c42d015e77f79ad0b57df9bfc9210c2f6b2090f Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Thu, 7 Nov 2024 17:40:23 +0000 Subject: [PATCH 4/4] s/showMsgIfUnread/ignoreUnread/ --- apps/messagegui/app.js | 16 ++++++++-------- apps/messages/settings.js | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/messagegui/app.js b/apps/messagegui/app.js index 5ba22dc4d3..d99835f289 100644 --- a/apps/messagegui/app.js +++ b/apps/messagegui/app.js @@ -155,7 +155,7 @@ function showMapMessage(msg) { function back() { // mark as not new and return to menu msg.new = false; layout = undefined; - checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:settings.showMsgIfUnread,openMusic:0}); + checkMessages({clockIfNoMsg:1,clockIfAllRead:1,ignoreUnread:settings.ignoreUnread,openMusic:0}); } Bangle.setUI({mode:"updown", back: back}, back); // any input takes us back } @@ -195,7 +195,7 @@ function showMusicMessage(msg) { var wasNew = msg.new; msg.new = false; layout = undefined; - if (wasNew) checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:0,openMusic:0}); + if (wasNew) checkMessages({clockIfNoMsg:1,clockIfAllRead:1,ignoreUnread:1,openMusic:0}); else returnToMain(); } function updateLabels() { @@ -476,7 +476,7 @@ function showMessage(msgid, persist) { /* options = { clockIfNoMsg : bool clockIfAllRead : bool - showMsgIfUnread : bool + ignoreUnread : bool // don't automatically navigate to the first unread message openMusic : bool // open music if it's playing dontStopBuzz : bool // don't stuf buzzing (any time other than the first this is undefined/false) } @@ -500,7 +500,7 @@ function checkMessages(options) { // we have >0 messages var newMessages = MESSAGES.filter(m=>m.new&&m.id!="music"); // If we have a new message, show it - if (options.showMsgIfUnread && newMessages.length) { + if (!options.ignoreUnread && newMessages.length) { delete newMessages[0].show; // stop us getting stuck here if we're called a second time showMessage(newMessages[0].id, false); // buzz after showMessage, so being busy during layout doesn't affect the buzz pattern @@ -571,15 +571,15 @@ function checkMessages(options) { } function returnToCheckMessages(clock) { - checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:settings.showMsgIfUnread,openMusic}); + checkMessages({clockIfNoMsg:1,clockIfAllRead:1,ignoreUnread:settings.ignoreUnread,openMusic}); } function returnToMain() { - checkMessages({clockIfNoMsg:0,clockIfAllRead:0,showMsgIfUnread:0,openMusic:0}); + checkMessages({clockIfNoMsg:0,clockIfAllRead:0,ignoreUnread:1,openMusic:0}); } function returnToClockIfEmpty() { - checkMessages({clockIfNoMsg:1,clockIfAllRead:0,showMsgIfUnread:0,openMusic}); + checkMessages({clockIfNoMsg:1,clockIfAllRead:0,ignoreUnread:1,openMusic}); } function cancelReloadTimeout() { @@ -605,7 +605,7 @@ setTimeout(() => { // only openMusic on launch if music is new, or state=="show" (set by messagesmusic) var musicMsg = MESSAGES.find(m => m.id === "music"); checkMessages({ - clockIfNoMsg: 0, clockIfAllRead: 0, showMsgIfUnread: settings.showMsgIfUnread, + clockIfNoMsg: 0, clockIfAllRead: 0, ignoreUnread: settings.ignoreUnread, openMusic: ((musicMsg&&musicMsg.new) && settings.openMusic) || (musicMsg&&musicMsg.state=="show"), dontStopBuzz: 1 }); }, 10); // if checkMessages wants to 'load', do that diff --git a/apps/messages/settings.js b/apps/messages/settings.js index 5cfae1d612..cb4644d4a9 100644 --- a/apps/messages/settings.js +++ b/apps/messages/settings.js @@ -11,7 +11,7 @@ if (settings.unreadTimeout===undefined) settings.unreadTimeout=60; if (settings.maxMessages===undefined) settings.maxMessages=3; if (settings.iconColorMode === undefined) settings.iconColorMode = iconColorModes[0]; - if (settings.showMsgIfUnread === undefined) settings.showMsgIfUnread = 1; + if (settings.ignoreUnread === undefined) settings.ignoreUnread = 0; settings.unlockWatch=!!settings.unlockWatch; settings.openMusic=!!settings.openMusic; settings.maxUnreadTimeout=240; @@ -60,8 +60,8 @@ onchange: v => updateSetting("fontSize", v) }, /*LANG*/'Auto-Open Unread Msg': { - value: !!settings().showMsgIfUnread, - onchange: v => updateSetting("showMsgIfUnread", v) + value: !!settings().ignoreUnread, + onchange: v => updateSetting("ignoreUnread", v) }, /*LANG*/'Auto-Open Music': { value: !!settings().openMusic,