mirror of https://github.com/espruino/BangleApps
Merge pull request #3587 from kamilkrz/newapp/msgclkinf
clkinfomsg: clockinfo for displaying messages countpull/3600/head
commit
68191d9ec8
|
@ -0,0 +1 @@
|
|||
0.01: First release
|
|
@ -0,0 +1,18 @@
|
|||
# Messages Clockinfo
|
||||
|
||||
A simple messages counter for clockinfo enabled watchfaces
|
||||
|
||||
## Usage
|
||||
|
||||
You can choose between read and unread counter.
|
||||
Tap to go to messages UI.
|
||||
|
||||
## Todo / Known Issues
|
||||
|
||||
* GB triggers for message read on phone are not handled
|
||||
* Icons are not consistent
|
||||
* Maybe use messageicons for handling icon from last notification
|
||||
|
||||
## Attributions
|
||||
|
||||
All icons used in this app are from [icons8](https://icons8.com).
|
Binary file not shown.
After Width: | Height: | Size: 326 B |
|
@ -0,0 +1,84 @@
|
|||
(function() {
|
||||
|
||||
var unreadImg = function() {
|
||||
return atob("GBiBAAAAAAAAAAAAAB//+D///D///D///D///D///D///D5mfD5mfD///D///D///D///D///D///B//+APgAAOAAAOAAAAAAAAAAA==");
|
||||
}
|
||||
var allImg = function() {
|
||||
return atob("GBiBAAAAAAAAAAB+AAD/AAPDwA8A8B4AeDgAHDgAHDwAPD8A/D/D/D/n/D///D///D///D///D///D///B//+AAAAAAAAAAAAAAAAA==");
|
||||
}
|
||||
|
||||
var debug = function(o) {
|
||||
//console.log(o);
|
||||
}
|
||||
var msgUnread;
|
||||
var msgAll;
|
||||
var msgs = require("messages");
|
||||
|
||||
var getAllMSGs = function() {
|
||||
if (msgAll === undefined) {
|
||||
debug("msgAll is undefined");
|
||||
msgAll = msgs.getMessages().filter(m => !['call', 'map', 'music'].includes(m.id)).length;
|
||||
}
|
||||
return msgAll;
|
||||
}
|
||||
|
||||
|
||||
var getUnreadMGS = function() {
|
||||
if (msgUnread === undefined) {
|
||||
debug("msgUnread is undefined");
|
||||
msgUnread = msgs.getMessages().filter(m => m.new && !['call', 'map', 'music'].includes(m.id)).length;
|
||||
}
|
||||
return msgUnread;
|
||||
}
|
||||
|
||||
var msgCounter = function(type, msg) {
|
||||
var msgsNow = msgs.getMessages(msg);
|
||||
msgUnread = msgsNow.filter(m => m.new && !['call', 'map', 'music'].includes(m.id)).length;
|
||||
msgAll = msgsNow.filter(m => !['call', 'map', 'music'].includes(m.id)).length;
|
||||
//TODO find nicer way to redraw current shown CI counter
|
||||
info.items[0].emit("redraw");
|
||||
info.items[1].emit("redraw");
|
||||
}
|
||||
|
||||
var info = {
|
||||
name: "Messages",
|
||||
img: unreadImg(),
|
||||
items: [
|
||||
{ name : "Unread",
|
||||
get : () => {
|
||||
return {
|
||||
text : getUnreadMGS(),
|
||||
img : unreadImg()
|
||||
};
|
||||
},
|
||||
show : function() {
|
||||
Bangle.on("message", msgCounter);
|
||||
},
|
||||
hide : function() {
|
||||
Bangle.removeListener("message", msgCounter);
|
||||
},
|
||||
run : () => {
|
||||
require("messages").openGUI();
|
||||
}
|
||||
},
|
||||
{ name : "All",
|
||||
get : () => {
|
||||
return {
|
||||
text : getAllMSGs(),
|
||||
img : allImg()
|
||||
};
|
||||
},
|
||||
show : function() {
|
||||
Bangle.on("message", msgCounter);
|
||||
},
|
||||
hide : function() {
|
||||
Bangle.removeListener("message", msgCounter);
|
||||
},
|
||||
run : () => {
|
||||
require("messages").openGUI();
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
return info;
|
||||
})
|
|
@ -0,0 +1,15 @@
|
|||
{ "id": "clkinfomsg",
|
||||
"name": "Messages Clockinfo",
|
||||
"version":"0.01",
|
||||
"description": "For clocks that display 'clockinfo', this displays the messages count",
|
||||
"icon": "app.png",
|
||||
"type": "clkinfo",
|
||||
"screenshots": [{"url":"screenshot.png"}],
|
||||
"readme":"README.md",
|
||||
"tags": "clkinfo",
|
||||
"supports" : ["BANGLEJS2"],
|
||||
"dependencies" : { "messages":"app" },
|
||||
"storage": [
|
||||
{"name":"clkinfomsg.clkinfo.js","url":"clkinfo.js"}
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
Loading…
Reference in New Issue