Merge pull request #2005 from myxor/message_buzz_pattern_for_calls

Messages: Separate buzz pattern for incoming calls
master
Gordon Williams 2022-07-07 10:27:58 +01:00 committed by GitHub
commit 970de6bf9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 16 additions and 6 deletions

View File

@ -56,3 +56,4 @@
0.41: Add notification icons in the widget 0.41: Add notification icons in the widget
0.42: Fix messages ignoring "Vibrate: Off" setting 0.42: Fix messages ignoring "Vibrate: Off" setting
0.43: Add new Icons (Airbnb, warnwetter) 0.43: Add new Icons (Airbnb, warnwetter)
0.44: Separate buzz pattern for incoming calls

View File

@ -12,6 +12,7 @@ You can change settings by going to the global `Settings` app, then `App Setting
and `Messages`: and `Messages`:
* `Vibrate` - This is the pattern of buzzes that should be made when a new message is received * `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 * `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. * `Unread Timer` - When a new message is received we go into the Messages app.
If there is no user input for this amount of time then the app will exit and return If there is no user input for this amount of time then the app will exit and return

View File

@ -54,7 +54,7 @@ var onMessagesModified = function(msg) {
// TODO: if new, show this new one // TODO: if new, show this new one
if (msg && msg.id!=="music" && msg.new && active!="map" && if (msg && msg.id!=="music" && msg.new && active!="map" &&
!((require('Storage').readJSON('setting.json', 1) || {}).quiet)) { !((require('Storage').readJSON('setting.json', 1) || {}).quiet)) {
if (WIDGETS["messages"]) WIDGETS["messages"].buzz(); if (WIDGETS["messages"]) WIDGETS["messages"].buzz(msg.src);
else Bangle.buzz(); else Bangle.buzz();
} }
if (msg && msg.id=="music") { if (msg && msg.id=="music") {

View File

@ -70,7 +70,7 @@ exports.pushMessage = function(event) {
} }
// first, buzz // first, buzz
if (!quiet && loadMessages && global.WIDGETS && WIDGETS.messages){ if (!quiet && loadMessages && global.WIDGETS && WIDGETS.messages){
WIDGETS.messages.buzz(); WIDGETS.messages.buzz(event.src);
if(unlockWatch != false){ if(unlockWatch != false){
Bangle.setLocked(false); Bangle.setLocked(false);
Bangle.setLCDPower(1); // turn screen on Bangle.setLCDPower(1); // turn screen on

View File

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

View File

@ -2,6 +2,7 @@
function settings() { function settings() {
let settings = require('Storage').readJSON("messages.settings.json", true) || {}; let settings = require('Storage').readJSON("messages.settings.json", true) || {};
if (settings.vibrate===undefined) settings.vibrate=":"; if (settings.vibrate===undefined) settings.vibrate=":";
if (settings.vibrateCalls===undefined) settings.vibrateCalls=":";
if (settings.repeat===undefined) settings.repeat=4; if (settings.repeat===undefined) settings.repeat=4;
if (settings.unreadTimeout===undefined) settings.unreadTimeout=60; if (settings.unreadTimeout===undefined) settings.unreadTimeout=60;
if (settings.maxMessages===undefined) settings.maxMessages=3; if (settings.maxMessages===undefined) settings.maxMessages=3;
@ -21,6 +22,7 @@
"" : { "title" : /*LANG*/"Messages" }, "" : { "title" : /*LANG*/"Messages" },
"< Back" : back, "< Back" : back,
/*LANG*/'Vibrate': require("buzz_menu").pattern(settings().vibrate, v => updateSetting("vibrate", v)), /*LANG*/'Vibrate': require("buzz_menu").pattern(settings().vibrate, v => updateSetting("vibrate", v)),
/*LANG*/'Vibrate for calls': require("buzz_menu").pattern(settings().vibrateCalls, v => updateSetting("vibrateCalls", v)),
/*LANG*/'Repeat': { /*LANG*/'Repeat': {
value: settings().repeat, value: settings().repeat,
min: 0, max: 10, min: 0, max: 10,
@ -62,4 +64,4 @@
} }
}; };
E.showMenu(mainmenu); E.showMenu(mainmenu);
}) });

View File

@ -60,9 +60,15 @@ draw:function(recall) {
WIDGETS["messages"].width=this.iconwidth * E.clip(msgs.length, 0, settings.maxMessages); WIDGETS["messages"].width=this.iconwidth * E.clip(msgs.length, 0, settings.maxMessages);
WIDGETS["messages"].msgs = msgs; WIDGETS["messages"].msgs = msgs;
Bangle.drawWidgets(); Bangle.drawWidgets();
},buzz:function() { },buzz:function(msgSrc) {
if ((require('Storage').readJSON('setting.json',1)||{}).quiet) return; // never buzz during Quiet Mode if ((require('Storage').readJSON('setting.json',1)||{}).quiet) return; // never buzz during Quiet Mode
var pattern = (require('Storage').readJSON("messages.settings.json", true) || {}).vibrate; var pattern;
if (msgSrc != undefined && msgSrc.toLowerCase() == "phone") {
// special vibration pattern for incoming calls
pattern = (require('Storage').readJSON("messages.settings.json", true) || {}).vibrateCalls;
} else {
pattern = (require('Storage').readJSON("messages.settings.json", true) || {}).vibrate;
}
if (pattern === undefined) { pattern = ":"; } // pattern may be "", so we can't use || ":" here if (pattern === undefined) { pattern = ":"; } // pattern may be "", so we can't use || ":" here
require("buzz").pattern(pattern); require("buzz").pattern(pattern);
},touch:function(b,c) { },touch:function(b,c) {