Skip to content

Commit

Permalink
clkinfomsg: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkrz committed Sep 25, 2024
1 parent 4689f45 commit f4109eb
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/clkinfomsg/ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.01: First release
18 changes: 18 additions & 0 deletions apps/clkinfomsg/README.md
Original file line number Diff line number Diff line change
@@ -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 added apps/clkinfomsg/app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions apps/clkinfomsg/clkinfo.js
Original file line number Diff line number Diff line change
@@ -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;
})
15 changes: 15 additions & 0 deletions apps/clkinfomsg/metadata.json
Original file line number Diff line number Diff line change
@@ -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 added apps/clkinfomsg/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f4109eb

Please sign in to comment.