messages 0.13: Add /*LANG*/ comments for internationalisation
+ Add 'Delete All' option to message options
+ Now update correctly when 'require("messages").clearAll()' is called
master
parent
456886c6d5
commit
25e1fc5f28
|
|
@ -77,7 +77,7 @@
|
||||||
{
|
{
|
||||||
"id": "messages",
|
"id": "messages",
|
||||||
"name": "Messages",
|
"name": "Messages",
|
||||||
"version": "0.12",
|
"version": "0.13",
|
||||||
"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",
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,6 @@
|
||||||
0.12: Extra app-specific notification icons
|
0.12: Extra app-specific notification icons
|
||||||
New animated notifcationicon (instead of large blinking 'MESSAGES')
|
New animated notifcationicon (instead of large blinking 'MESSAGES')
|
||||||
Added screenshots
|
Added screenshots
|
||||||
|
0.13: Add /*LANG*/ comments for internationalisation
|
||||||
|
Add 'Delete All' option to message options
|
||||||
|
Now update correctly when 'require("messages").clearAll()' is called
|
||||||
|
|
|
||||||
|
|
@ -52,11 +52,11 @@ 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) {
|
||||||
// TODO: if new, show this new one
|
// TODO: if new, show this new one
|
||||||
if (msg.new) {
|
if (msg && msg.new) {
|
||||||
if (WIDGETS["messages"]) WIDGETS["messages"].buzz();
|
if (WIDGETS["messages"]) WIDGETS["messages"].buzz();
|
||||||
else Bangle.buzz();
|
else Bangle.buzz();
|
||||||
}
|
}
|
||||||
showMessage(msg.id);
|
showMessage(msg&&msg.id);
|
||||||
};
|
};
|
||||||
function saveMessages() {
|
function saveMessages() {
|
||||||
require("Storage").writeJSON("messages.json",MESSAGES)
|
require("Storage").writeJSON("messages.json",MESSAGES)
|
||||||
|
|
@ -174,24 +174,33 @@ function showMusicMessage(msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function showMessageSettings(msg) {
|
function showMessageSettings(msg) {
|
||||||
E.showMenu({"":{"title":"Message"},
|
E.showMenu({"":{"title":/*LANG*/"Message"},
|
||||||
"< Back" : () => showMessage(msg.id),
|
"< Back" : () => showMessage(msg.id),
|
||||||
"Delete" : () => {
|
/*LANG*/"Delete" : () => {
|
||||||
MESSAGES = MESSAGES.filter(m=>m.id!=msg.id);
|
MESSAGES = MESSAGES.filter(m=>m.id!=msg.id);
|
||||||
saveMessages();
|
saveMessages();
|
||||||
checkMessages({clockIfNoMsg:0,clockIfAllRead:0,showMsgIfUnread:0});
|
checkMessages({clockIfNoMsg:0,clockIfAllRead:0,showMsgIfUnread:0});
|
||||||
},
|
},
|
||||||
"Mark Unread" : () => {
|
/*LANG*/"Mark Unread" : () => {
|
||||||
msg.new = true;
|
msg.new = true;
|
||||||
saveMessages();
|
saveMessages();
|
||||||
checkMessages({clockIfNoMsg:0,clockIfAllRead:0,showMsgIfUnread:0});
|
checkMessages({clockIfNoMsg:0,clockIfAllRead:0,showMsgIfUnread:0});
|
||||||
},
|
},
|
||||||
|
/*LANG*/"Delete all messages" : () => {
|
||||||
|
E.showPrompt(/*LANG*/"Are you sure?", {title:/*LANG*/"Delete All Messages"}).then(isYes => {
|
||||||
|
if (isYes) {
|
||||||
|
MESSAGES = [];
|
||||||
|
saveMessages();
|
||||||
|
}
|
||||||
|
checkMessages({clockIfNoMsg:0,clockIfAllRead:0,showMsgIfUnread:0});
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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({clockIfNoMsg:0,clockIfAllRead:0,showMsgIfUnread:0}); // go home if no message found
|
||||||
if (msg.src=="Maps") {
|
if (msg.src=="Maps") {
|
||||||
cancelReloadTimeout(); // don't auto-reload to clock now
|
cancelReloadTimeout(); // don't auto-reload to clock now
|
||||||
return showMapMessage(msg);
|
return showMapMessage(msg);
|
||||||
|
|
@ -228,7 +237,6 @@ function showMessage(msgid) {
|
||||||
}
|
}
|
||||||
if (msg.negative) {
|
if (msg.negative) {
|
||||||
buttons.push({type:"btn", src:getNegImage(), cb:()=>{
|
buttons.push({type:"btn", src:getNegImage(), cb:()=>{
|
||||||
console.log("Response");
|
|
||||||
msg.new = false; saveMessages();
|
msg.new = false; saveMessages();
|
||||||
cancelReloadTimeout(); // don't auto-reload to clock now
|
cancelReloadTimeout(); // don't auto-reload to clock now
|
||||||
Bangle.messageResponse(msg,false);
|
Bangle.messageResponse(msg,false);
|
||||||
|
|
@ -266,10 +274,10 @@ function checkMessages(options) {
|
||||||
options=options||{};
|
options=options||{};
|
||||||
// If no messages, just show 'no messages' and return
|
// If no messages, just show 'no messages' and return
|
||||||
if (!MESSAGES.length) {
|
if (!MESSAGES.length) {
|
||||||
if (!options.clockIfNoMsg) return E.showPrompt("No Messages",{
|
if (!options.clockIfNoMsg) return E.showPrompt(/*LANG*/"No Messages",{
|
||||||
title:"Messages",
|
title:/*LANG*/"Messages",
|
||||||
img:require("heatshrink").decompress(atob("kkk4UBrkc/4AC/tEqtACQkBqtUDg0VqAIGgoZFDYQIIM1sD1QAD4AIBhnqA4WrmAIBhc6BAWs8AIBhXOBAWz0AIC2YIC5wID1gkB1c6BAYFBEQPqBAYXBEQOqBAnDAIQaEnkAngaEEAPDFgo+IKA5iIOhCGIAFb7RqAIGgtUBA0VqobFgNVA")),
|
img:require("heatshrink").decompress(atob("kkk4UBrkc/4AC/tEqtACQkBqtUDg0VqAIGgoZFDYQIIM1sD1QAD4AIBhnqA4WrmAIBhc6BAWs8AIBhXOBAWz0AIC2YIC5wID1gkB1c6BAYFBEQPqBAYXBEQOqBAnDAIQaEnkAngaEEAPDFgo+IKA5iIOhCGIAFb7RqAIGgtUBA0VqobFgNVA")),
|
||||||
buttons : {"Ok":1}
|
buttons : {/*LANG*/"Ok":1}
|
||||||
}).then(() => { load() });
|
}).then(() => { load() });
|
||||||
return load();
|
return load();
|
||||||
}
|
}
|
||||||
|
|
@ -297,7 +305,7 @@ function checkMessages(options) {
|
||||||
var x = r.x+2, title = msg.title, body = msg.body;
|
var x = r.x+2, title = msg.title, body = msg.body;
|
||||||
var img = getMessageImage(msg);
|
var img = getMessageImage(msg);
|
||||||
if (msg.id=="music") {
|
if (msg.id=="music") {
|
||||||
title = msg.artist || "Music";
|
title = msg.artist || /*LANG*/"Music";
|
||||||
body = msg.track;
|
body = msg.track;
|
||||||
}
|
}
|
||||||
if (img) {
|
if (img) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue