messages 0.46: Add 'Vibrate Timer' option to set how long to vibrate for, and fix Repeat:off

+      Fix message removal from widget bar (previously caused exception as .hide has been removed)
pull/2048/head^2
Gordon Williams 2022-07-15 12:10:52 +01:00
parent 85abda3ba5
commit 6ca63def2f
6 changed files with 32 additions and 22 deletions

View File

@ -58,3 +58,5 @@
0.43: Add new Icons (Airbnb, warnwetter)
0.44: Separate buzz pattern for incoming calls
0.45: Added new app colors and icons
0.46: Add 'Vibrate Timer' option to set how long to vibrate for, and fix Repeat:off
Fix message removal from widget bar (previously caused exception as .hide has been removed)

View File

@ -14,7 +14,9 @@ and `Messages`:
* `Vibrate` - This is the pattern of buzzes that should be made when a new message is received
* `Vibrate for calls` - This is the pattern of buzzes that should be made when an incoming call is received
* `Repeat` - How often should buzzes repeat - the default of 4 means the Bangle will buzz every 4 seconds
* `Unread Timer` - When a new message is received we go into the Messages app.
* `Vibrate Timer` - When a new message is received when in a non-clock app, we display the message icon and
buzz every `Repeat` seconds. This is how long we continue to do that.
* `Unread Timer` - When a new message is received when showing the clock we go into the Messages app.
If there is no user input for this amount of time then the app will exit and return
to the clock where a ringing bell will be shown in the Widget bar.
* `Min Font` - The minimum font size used when displaying messages on the screen. A bigger font

View File

@ -40,12 +40,12 @@ exports.pushMessage = function(event) {
require("Storage").writeJSON("messages.json",messages);
// if in app, process immediately
if (inApp) return onMessagesModified(mIdx<0 ? {id:event.id} : messages[mIdx]);
// if we've removed the last new message, hide the widget
if (event.t=="remove" && !messages.some(m=>m.new)) {
if (global.WIDGETS && WIDGETS.messages) WIDGETS.messages.hide();
// update the widget icons shown
if (global.WIDGETS && WIDGETS.messages) WIDGETS.messages.update(messages,true);
// if no new messages now, make sure we don't load the messages app
if (exports.messageTimeout && !messages.some(m=>m.new))
clearTimeout(exports.messageTimeout);
if (event.t=="remove" && exports.messageTimeout && !messages.some(m=>m.new)) {
clearTimeout(exports.messageTimeout);
delete exports.messageTimeout;
}
// ok, saved now
if (event.id=="music" && Bangle.CLOCK && messages[mIdx].new && openMusic()) {

View File

@ -1,7 +1,7 @@
{
"id": "messages",
"name": "Messages",
"version": "0.45",
"version": "0.46",
"description": "App to display notifications from iOS and Gadgetbridge/Android",
"icon": "app.png",
"type": "app",

View File

@ -4,6 +4,7 @@
if (settings.vibrate===undefined) settings.vibrate=":";
if (settings.vibrateCalls===undefined) settings.vibrateCalls=":";
if (settings.repeat===undefined) settings.repeat=4;
if (settings.vibrateTimeout===undefined) settings.vibrateTimeout=60;
if (settings.unreadTimeout===undefined) settings.unreadTimeout=60;
if (settings.maxMessages===undefined) settings.maxMessages=3;
settings.unlockWatch=!!settings.unlockWatch;
@ -29,6 +30,12 @@
format: v => v?v+"s":/*LANG*/"Off",
onchange: v => updateSetting("repeat", v)
},
/*LANG*/'Vibrate timer': {
value: settings().vibrateTimeout,
min: 0, max: settings().maxUnreadTimeout, step : 10,
format: v => v?v+"s":/*LANG*/"Off",
onchange: v => updateSetting("vibrateTimeout", v)
},
/*LANG*/'Unread timer': {
value: settings().unreadTimeout,
min: 0, max: settings().maxUnreadTimeout, step : 10,

View File

@ -20,8 +20,7 @@ draw:function(recall) {
Bangle.removeListener('touch', this.touch);
if (!this.width) return;
var c = (Date.now()-this.t)/1000;
let settings = require('Storage').readJSON("messages.settings.json", true) || {};
if (settings.flash===undefined) settings.flash = true;
let settings = Object.assign({flash:true, maxMessages:3, repeat:4, vibrateTimeout:60},require('Storage').readJSON("messages.settings.json", true) || {});
if (recall !== true || settings.flash) {
var msgsShown = E.clip(this.msgs.length, 0, settings.maxMessages);
g.reset().clearRect(this.x, this.y, this.x+this.width, this.y+23);
@ -39,28 +38,28 @@ draw:function(recall) {
g.drawImage(i == (settings.maxMessages - 1) && msgs.length > settings.maxMessages ? atob("GBgBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH4H4H4H4H4H4H4H4H4H4H4H4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") : require("messages").getMessageImage(msg), this.x + i * this.iconwidth, this.y - 1);
}
}
if (settings.repeat===undefined) settings.repeat = 4;
if (c<120 && (Date.now()-this.l)>settings.repeat*1000) {
if (c<settings.vibrateTimeout && // not going on too long...
(settings.repeat || c<1) && // repeated, or no repeat and first attempt
(Date.now()-this.l)>settings.repeat*1000) { // the period between vibrations
this.l = Date.now();
WIDGETS["messages"].buzz(); // buzz every 4 seconds
}
WIDGETS["messages"].i=setTimeout(()=>WIDGETS["messages"].draw(true), 1000);
if (process.env.HWVERSION>1) Bangle.on('touch', this.touch);
},update:function(rawMsgs, quiet) {
const settings = require('Storage').readJSON("messages.settings.json", true) || {};
msgs = filterMessages(rawMsgs);
if (msgs.length === 0) {
delete WIDGETS["messages"].t;
delete WIDGETS["messages"].l;
const settings = Object.assign({maxMessages:3},require('Storage').readJSON("messages.settings.json", true) || {});
this.msgs = filterMessages(rawMsgs);
if (this.msgs.length === 0) {
delete this.t;
delete this.l;
} else {
WIDGETS["messages"].t=Date.now(); // first time
WIDGETS["messages"].l=Date.now()-10000; // last buzz
if (quiet) WIDGETS["messages"].t -= 500000; // if quiet, set last time in the past so there is no buzzing
this.t=Date.now(); // first time
this.l=Date.now()-10000; // last buzz
if (quiet) this.t -= 500000; // if quiet, set last time in the past so there is no buzzing
}
WIDGETS["messages"].width=this.iconwidth * E.clip(msgs.length, 0, settings.maxMessages);
WIDGETS["messages"].msgs = msgs;
this.width=this.iconwidth * E.clip(this.msgs.length, 0, settings.maxMessages);
Bangle.drawWidgets();
},buzz:function(msgSrc) {
},buzz:function(msgSrc) {
if ((require('Storage').readJSON('setting.json',1)||{}).quiet) return; // never buzz during Quiet Mode
var pattern;
if (msgSrc != undefined && msgSrc.toLowerCase() == "phone") {