messages 0.35: Change App/Widget settings to 'App Settings' so it fits on Bangle screen
parent
7b404cb12f
commit
f848f69770
|
|
@ -57,7 +57,7 @@
|
||||||
{
|
{
|
||||||
"id": "messages",
|
"id": "messages",
|
||||||
"name": "Messages",
|
"name": "Messages",
|
||||||
"version": "0.08",
|
"version": "0.09",
|
||||||
"description": "App to display notifications from iOS and Gadgetbridge",
|
"description": "App to display notifications from iOS and Gadgetbridge",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"type": "app",
|
"type": "app",
|
||||||
|
|
|
||||||
|
|
@ -10,3 +10,4 @@
|
||||||
0.07: Added settings menu with option to choose vibrate pattern and frequency (fix #909)
|
0.07: Added settings menu with option to choose vibrate pattern and frequency (fix #909)
|
||||||
0.08: Fix rendering of long messages (fix #969)
|
0.08: Fix rendering of long messages (fix #969)
|
||||||
buzz on new message (fix #999)
|
buzz on new message (fix #999)
|
||||||
|
0.09: Message now disappears after 60s if no action taken and clock loads (fix 922)
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,17 @@ and responded to.
|
||||||
|
|
||||||
It is a replacement for the old `notify`/`gadgetbridge` apps.
|
It is a replacement for the old `notify`/`gadgetbridge` apps.
|
||||||
|
|
||||||
## Usage
|
## Settings
|
||||||
|
|
||||||
|
You can change settings by going to the global `Settings` app, then `App Settings`
|
||||||
|
and `Messages`:
|
||||||
|
|
||||||
|
* `Vibrate` - This is the pattern of buzzes that should be made when a new message 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.
|
||||||
|
If there is no user input for this amount of time then the app will exit and return
|
||||||
|
to the clock where `MESSAGES` will be shown in the Widget bar.
|
||||||
|
|
||||||
...
|
|
||||||
|
|
||||||
## Requests
|
## Requests
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,12 @@ try {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** this is a timeout if the app has started and is showing a single message
|
||||||
|
but the user hasn't seen it (eg no user input) - in which case
|
||||||
|
we should start a timeout for settings.unreadTimeout to return
|
||||||
|
to the clock. */
|
||||||
|
var unreadTimeout;
|
||||||
|
/// List of all our messages
|
||||||
var MESSAGES = require("Storage").readJSON("messages.json",1)||[];
|
var MESSAGES = require("Storage").readJSON("messages.json",1)||[];
|
||||||
if (!Array.isArray(MESSAGES)) MESSAGES=[];
|
if (!Array.isArray(MESSAGES)) MESSAGES=[];
|
||||||
var onMessagesModified = function(msg) {
|
var onMessagesModified = function(msg) {
|
||||||
|
|
@ -171,8 +176,14 @@ function showMessageSettings(msg) {
|
||||||
function showMessage(msgid) {
|
function showMessage(msgid) {
|
||||||
var msg = MESSAGES.find(m=>m.id==msgid);
|
var msg = MESSAGES.find(m=>m.id==msgid);
|
||||||
if (!msg) return checkMessages(); // go home if no message found
|
if (!msg) return checkMessages(); // go home if no message found
|
||||||
if (msg.src=="Maps") return showMapMessage(msg);
|
if (msg.src=="Maps") {
|
||||||
if (msg.id=="music") return showMusicMessage(msg);
|
cancelReloadTimeout(); // don't auto-reload to clock now
|
||||||
|
return showMapMessage(msg);
|
||||||
|
}
|
||||||
|
if (msg.id=="music") {
|
||||||
|
cancelReloadTimeout(); // don't auto-reload to clock now
|
||||||
|
return showMusicMessage(msg);
|
||||||
|
}
|
||||||
// Normal text message display
|
// Normal text message display
|
||||||
var title=msg.title, titleFont = fontLarge, lines;
|
var title=msg.title, titleFont = fontLarge, lines;
|
||||||
if (title) {
|
if (title) {
|
||||||
|
|
@ -186,14 +197,15 @@ function showMessage(msgid) {
|
||||||
}
|
}
|
||||||
var buttons = [
|
var buttons = [
|
||||||
{type:"btn", src:getBackImage(), cb:()=>{
|
{type:"btn", src:getBackImage(), cb:()=>{
|
||||||
msg.new = false; // read mail
|
msg.new = false; saveMessages(); // read mail
|
||||||
saveMessages();
|
cancelReloadTimeout(); // don't auto-reload to clock now
|
||||||
checkMessages({clockIfNoMsg:1,clockIfAllRead:0,showMsgIfUnread:1});
|
checkMessages({clockIfNoMsg:1,clockIfAllRead:0,showMsgIfUnread:1});
|
||||||
}} // back
|
}} // back
|
||||||
];
|
];
|
||||||
if (msg.positive) {
|
if (msg.positive) {
|
||||||
buttons.push({type:"btn", src:getPosImage(), cb:()=>{
|
buttons.push({type:"btn", src:getPosImage(), cb:()=>{
|
||||||
msg.new = false; saveMessages();
|
msg.new = false; saveMessages();
|
||||||
|
cancelReloadTimeout(); // don't auto-reload to clock now
|
||||||
Bangle.messageResponse(msg,true);
|
Bangle.messageResponse(msg,true);
|
||||||
checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1});
|
checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1});
|
||||||
}});
|
}});
|
||||||
|
|
@ -202,6 +214,7 @@ function showMessage(msgid) {
|
||||||
buttons.push({type:"btn", src:getNegImage(), cb:()=>{
|
buttons.push({type:"btn", src:getNegImage(), cb:()=>{
|
||||||
console.log("Response");
|
console.log("Response");
|
||||||
msg.new = false; saveMessages();
|
msg.new = false; saveMessages();
|
||||||
|
cancelReloadTimeout(); // don't auto-reload to clock now
|
||||||
Bangle.messageResponse(msg,false);
|
Bangle.messageResponse(msg,false);
|
||||||
checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1});
|
checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1});
|
||||||
}});
|
}});
|
||||||
|
|
@ -210,7 +223,10 @@ function showMessage(msgid) {
|
||||||
var body = (lines.length>4) ? lines.slice(0,4).join("\n")+"..." : lines.join("\n");
|
var body = (lines.length>4) ? lines.slice(0,4).join("\n")+"..." : lines.join("\n");
|
||||||
layout = new Layout({ type:"v", c: [
|
layout = new Layout({ type:"v", c: [
|
||||||
{type:"h", fillx:1, bgCol:colBg, c: [
|
{type:"h", fillx:1, bgCol:colBg, c: [
|
||||||
{ type:"btn", src:getMessageImage(msg), cb:()=>showMessageSettings(msg) },
|
{ type:"btn", src:getMessageImage(msg), cb:()=>{
|
||||||
|
cancelReloadTimeout(); // don't auto-reload to clock now
|
||||||
|
showMessageSettings(msg);
|
||||||
|
}},
|
||||||
{ type:"v", fillx:1, c: [
|
{ type:"v", fillx:1, c: [
|
||||||
{type:"txt", font:fontSmall, label:msg.src||"Message", bgCol:colBg, fillx:1, pad:2, halign:1 },
|
{type:"txt", font:fontSmall, label:msg.src||"Message", bgCol:colBg, fillx:1, pad:2, halign:1 },
|
||||||
title?{type:"txt", font:titleFont, label:title, bgCol:colBg, fillx:1, pad:2 }:{},
|
title?{type:"txt", font:titleFont, label:title, bgCol:colBg, fillx:1, pad:2 }:{},
|
||||||
|
|
@ -249,7 +265,8 @@ function checkMessages(options) {
|
||||||
// no new messages - go to clock?
|
// no new messages - go to clock?
|
||||||
if (options.clockIfAllRead && newMessages.length==0)
|
if (options.clockIfAllRead && newMessages.length==0)
|
||||||
return load();
|
return load();
|
||||||
|
// we don't have to time out of this screen...
|
||||||
|
cancelReloadTimeout();
|
||||||
// Otherwise show a menu
|
// Otherwise show a menu
|
||||||
E.showScroller({
|
E.showScroller({
|
||||||
h : 48,
|
h : 48,
|
||||||
|
|
@ -291,9 +308,23 @@ function checkMessages(options) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cancelReloadTimeout() {
|
||||||
|
if (!unreadTimeout) return;
|
||||||
|
clearTimeout(unreadTimeout);
|
||||||
|
unreadTimeout = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
g.clear();
|
g.clear();
|
||||||
Bangle.loadWidgets();
|
Bangle.loadWidgets();
|
||||||
Bangle.drawWidgets();
|
Bangle.drawWidgets();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
var unreadTimeoutSecs = (require('Storage').readJSON("messages.settings.json", true) || {}).unreadTimeout;
|
||||||
|
if (unreadTimeoutSecs===undefined) unreadTimeoutSecs=60;
|
||||||
|
if (unreadTimeoutSecs)
|
||||||
|
unreadTimeout = setTimeout(function() {
|
||||||
|
print("Message not seen - reloading");
|
||||||
|
load();
|
||||||
|
}, unreadTimeoutSecs*1000);
|
||||||
checkMessages({clockIfNoMsg:0,clockIfAllRead:0,showMsgIfUnread:1});
|
checkMessages({clockIfNoMsg:0,clockIfAllRead:0,showMsgIfUnread:1});
|
||||||
},10); // if checkMessages wants to 'load', do that
|
},10); // if checkMessages wants to 'load', do that
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
|
/* Push a new message onto messages queue, event is:
|
||||||
|
{t:"add",id:int, src,title,subject,body,sender,tel, important:bool} // add new
|
||||||
|
{t:"add",id:int, id:"music", state, artist, track, etc} // add new
|
||||||
|
{t:"remove-",id:int} // remove
|
||||||
|
{t:"modify",id:int, title:string} // modified
|
||||||
|
*/
|
||||||
exports.pushMessage = function(event) {
|
exports.pushMessage = function(event) {
|
||||||
/* event is:
|
|
||||||
{t:"add",id:int, src,title,subject,body,sender,tel, important:bool} // add new
|
|
||||||
{t:"add",id:int, id:"music", state, artist, track, etc} // add new
|
|
||||||
{t:"remove-",id:int} // remove
|
|
||||||
{t:"modify",id:int, title:string} // modified
|
|
||||||
*/
|
|
||||||
var messages, inApp = "undefined"!=typeof MESSAGES;
|
var messages, inApp = "undefined"!=typeof MESSAGES;
|
||||||
if (inApp)
|
if (inApp)
|
||||||
messages = MESSAGES; // we're in an app that has already loaded messages
|
messages = MESSAGES; // we're in an app that has already loaded messages
|
||||||
|
|
@ -43,6 +43,7 @@ exports.pushMessage = function(event) {
|
||||||
WIDGETS.messages.show();
|
WIDGETS.messages.show();
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
/// Remove all messages
|
||||||
exports.clearAll = function(event) {
|
exports.clearAll = function(event) {
|
||||||
var messages, inApp = "undefined"!=typeof MESSAGES;
|
var messages, inApp = "undefined"!=typeof MESSAGES;
|
||||||
if (inApp) {
|
if (inApp) {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
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.repeat===undefined) settings.repeat=4;
|
if (settings.repeat===undefined) settings.repeat=4;
|
||||||
|
if (settings.unreadTimeout===undefined) settings.unreadTimeout=60;
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
function updateSetting(setting, value) {
|
function updateSetting(setting, value) {
|
||||||
|
|
@ -30,6 +31,12 @@
|
||||||
format: v => v+"s",
|
format: v => v+"s",
|
||||||
onchange: v => updateSetting("repeat", v)
|
onchange: v => updateSetting("repeat", v)
|
||||||
},
|
},
|
||||||
|
'Unread timer': {
|
||||||
|
value: settings().unreadTimeout,
|
||||||
|
min: 0, max: 240, step : 10,
|
||||||
|
format: v => v?v+"s":"Off",
|
||||||
|
onchange: v => updateSetting("unreadTimeout", v)
|
||||||
|
},
|
||||||
};
|
};
|
||||||
E.showMenu(mainmenu);
|
E.showMenu(mainmenu);
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
WIDGETS["messages"]={area:"tl",width:0,draw:function() {
|
WIDGETS["messages"]={area:"tl",width:0,draw:function() {
|
||||||
if (!this.width) return;
|
if (!this.width) return;
|
||||||
var c = (Date.now()-this.t)/1000;
|
var c = (Date.now()-this.t)/1000;
|
||||||
|
|
@ -13,9 +12,10 @@ WIDGETS["messages"]={area:"tl",width:0,draw:function() {
|
||||||
WIDGETS["messages"].buzz(); // buzz every 4 seconds
|
WIDGETS["messages"].buzz(); // buzz every 4 seconds
|
||||||
}
|
}
|
||||||
setTimeout(()=>WIDGETS["messages"].draw(), 1000);
|
setTimeout(()=>WIDGETS["messages"].draw(), 1000);
|
||||||
},show:function() {
|
},show:function(quiet) {
|
||||||
WIDGETS["messages"].t=Date.now(); // first time
|
WIDGETS["messages"].t=Date.now(); // first time
|
||||||
WIDGETS["messages"].l=Date.now()-10000; // last buzz
|
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
|
||||||
WIDGETS["messages"].width=64;
|
WIDGETS["messages"].width=64;
|
||||||
Bangle.drawWidgets();
|
Bangle.drawWidgets();
|
||||||
Bangle.setLCDPower(1);// turns screen on
|
Bangle.setLCDPower(1);// turns screen on
|
||||||
|
|
@ -34,3 +34,10 @@ WIDGETS["messages"]={area:"tl",width:0,draw:function() {
|
||||||
}
|
}
|
||||||
b();
|
b();
|
||||||
}};
|
}};
|
||||||
|
/* We might have returned here if we were in the Messages app for a
|
||||||
|
message but then the watch was never viewed. In that case we don't
|
||||||
|
want to buzz but should still show that there are unread messages. */
|
||||||
|
if (global.MESSAGES===undefined) (function() {
|
||||||
|
var messages = require("Storage").readJSON("messages.json",1)||[];
|
||||||
|
if (messages.some(m=>m.new)) WIDGETS["messages"].show(true);
|
||||||
|
})();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue