diff --git a/apps/clkinfomsg/ChangeLog b/apps/clkinfomsg/ChangeLog new file mode 100644 index 0000000000..7b83706bf8 --- /dev/null +++ b/apps/clkinfomsg/ChangeLog @@ -0,0 +1 @@ +0.01: First release diff --git a/apps/clkinfomsg/README.md b/apps/clkinfomsg/README.md new file mode 100644 index 0000000000..90baa3d701 --- /dev/null +++ b/apps/clkinfomsg/README.md @@ -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). \ No newline at end of file diff --git a/apps/clkinfomsg/app.png b/apps/clkinfomsg/app.png new file mode 100644 index 0000000000..81a968a40b Binary files /dev/null and b/apps/clkinfomsg/app.png differ diff --git a/apps/clkinfomsg/clkinfo.js b/apps/clkinfomsg/clkinfo.js new file mode 100644 index 0000000000..d5e74d6907 --- /dev/null +++ b/apps/clkinfomsg/clkinfo.js @@ -0,0 +1,88 @@ +(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 getAllMGS = function() { + if (msgAll === undefined) { + debug("msgAll is undefined"); + msgAll = msgs.getMessages().filter(m => !['call', 'map', 'music'].includes(m.id)).map(m => m.src).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)).map(m => m.src).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)).map(m => m.src).length; + if (msgUnread === undefined) { + msgUnread = "?"; + } + msgAll = msgsNow.filter(m => !['call', 'map', 'music'].includes(m.id)).map(m => m.src).length; + if (msgAll === undefined) { + msgAll = "?"; + } + info.items[0].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 : getAllMGS(), + img : allImg() // TODO This is omited if category image is not set + }; + }, + show : function() { + Bangle.on("message", msgCounter); + }, + hide : function() { + Bangle.removeListener("message", msgCounter); + }, + run : () => { + require("messages").openGUI(); + } + } + ] + }; + return info; +}) diff --git a/apps/clkinfomsg/metadata.json b/apps/clkinfomsg/metadata.json new file mode 100644 index 0000000000..e675b69f77 --- /dev/null +++ b/apps/clkinfomsg/metadata.json @@ -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"} + ] +} diff --git a/apps/clkinfomsg/screenshot.png b/apps/clkinfomsg/screenshot.png new file mode 100644 index 0000000000..e46415ad51 Binary files /dev/null and b/apps/clkinfomsg/screenshot.png differ