gbridge: 0.19: Support for call incoming/start/end

master
Gordon Williams 2021-02-11 09:45:50 +00:00
parent 28c7cfc3fa
commit 0e2f33d656
7 changed files with 34 additions and 15 deletions

View File

@ -80,7 +80,7 @@
"name": "Notifications (default)", "name": "Notifications (default)",
"shortName":"Notifications", "shortName":"Notifications",
"icon": "notify.png", "icon": "notify.png",
"version":"0.05", "version":"0.06",
"description": "A handler for displaying notifications that displays them in a bar at the top of the screen", "description": "A handler for displaying notifications that displays them in a bar at the top of the screen",
"tags": "widget", "tags": "widget",
"type": "notify", "type": "notify",
@ -93,7 +93,7 @@
"name": "Fullscreen Notifications", "name": "Fullscreen Notifications",
"shortName":"Notifications", "shortName":"Notifications",
"icon": "notify.png", "icon": "notify.png",
"version":"0.06", "version":"0.07",
"description": "A handler for displaying notifications that displays them fullscreen. This may not fully restore the screen after on some apps. See `Notifications (default)` for more information about the notifications library.", "description": "A handler for displaying notifications that displays them fullscreen. This may not fully restore the screen after on some apps. See `Notifications (default)` for more information about the notifications library.",
"tags": "widget", "tags": "widget",
"type": "notify", "type": "notify",
@ -139,7 +139,7 @@
{ "id": "gbridge", { "id": "gbridge",
"name": "Gadgetbridge", "name": "Gadgetbridge",
"icon": "app.png", "icon": "app.png",
"version":"0.18", "version":"0.19",
"description": "The default notification handler for Gadgetbridge notifications from Android", "description": "The default notification handler for Gadgetbridge notifications from Android",
"tags": "tool,system,android,widget", "tags": "tool,system,android,widget",
"readme": "README.md", "readme": "README.md",

View File

@ -18,3 +18,4 @@
Nicer display of alarm clock notifications Nicer display of alarm clock notifications
0.17: Modified music notification for updated 'notify' library 0.17: Modified music notification for updated 'notify' library
0.18: Added reporting of step count and HRM (new Gadgetbridges can now log this) 0.18: Added reporting of step count and HRM (new Gadgetbridges can now log this)
0.19: Support for call incoming/start/end

View File

@ -129,11 +129,23 @@
} }
function handleCallEvent(event) { function handleCallEvent(event) {
if (event.cmd === "accept") { var callIcon = require("heatshrink").decompress(atob("jEYwIMJj4CCwACJh4CCCIMOAQMGAQMHAQMDAQMBCIMB4PwgHz/EAn4CBj4CBg4CBgACCAAw="));
if (event.cmd === "incoming") {
require("notify").show({ require("notify").show({
size: 55, title: event.name, id: "call", size: 55, title: event.name, id: "call",
body: event.number, icon:require("heatshrink").decompress(atob("jEYwIMJj4CCwACJh4CCCIMOAQMGAQMHAQMDAQMBCIMB4PwgHz/EAn4CBj4CBg4CBgACCAAw="))}); body: event.number, icon:callIcon});
Bangle.buzz(); Bangle.buzz();
} else if (event.cmd === "start") {
require("notify").show({
size: 55, title: event.name, id: "call", bgColor : "#008000", titleBgColor : "#00C000",
body: "In progress: "+event.number, icon:callIcon});
} else if (event.cmd === "end") {
require("notify").show({
size: 55, title: event.name, id: "call", bgColor : "#800000", titleBgColor : "#C00000",
body: "Ended: "+event.number, icon:callIcon});
setTimeout(function() {
require("notify").hide({ id: "call" });
}, 2000);
} }
} }

View File

@ -2,3 +2,4 @@
0.02: Add notification ID option 0.02: Add notification ID option
0.03: Pass `area{x,y,w,h}` to render callback instead of just `y` 0.03: Pass `area{x,y,w,h}` to render callback instead of just `y`
0.05: Adjust position of notification src text 0.05: Adjust position of notification src text
0.06: Support background color

View File

@ -41,7 +41,9 @@ function fitWords(text,rows,width) {
src : string // optional source name src : string // optional source name
body : string // optional body text body : string // optional body text
icon : string // optional icon (image string) icon : string // optional icon (image string)
render function(y) // function callback to render render : function(y) // function callback to render
bgColor : int/string // optional background color (default black)
titleBgColor : int/string // optional background color for title (default black)
} }
*/ */
/* /*
@ -83,13 +85,13 @@ exports.show = function(options) {
b = y+h-1, r = x+w-1; // bottom,right b = y+h-1, r = x+w-1; // bottom,right
g.setClipRect(x,y, r,b); g.setClipRect(x,y, r,b);
// clear area // clear area
g.setColor(0).fillRect(x,y, r,b); g.setColor(options.bgColor||0).fillRect(x,y, r,b);
// bottom border // bottom border
g.setColor(0x39C7).fillRect(0,b-1, r,b); g.setColor(0x39C7).fillRect(0,b-1, r,b);
b -= 2;h -= 2; b -= 2;h -= 2;
// title bar // title bar
if (options.title || options.src) { if (options.title || options.src) {
g.setColor(0x39C7).fillRect(x,y, r,y+20); g.setColor(options.titleBgColor||0x39C7).fillRect(x,y, r,y+20);
const title = options.title||options.src; const title = options.title||options.src;
g.setColor(-1).setFontAlign(-1, -1, 0).setFont("6x8", 2); g.setColor(-1).setFontAlign(-1, -1, 0).setFont("6x8", 2);
g.drawString(title.trim().substring(0, 13), x+25,y+3); g.drawString(title.trim().substring(0, 13), x+25,y+3);

View File

@ -4,3 +4,4 @@
0.04: Pass `area{x,y,w,h}` to render callback instead of just `y` 0.04: Pass `area{x,y,w,h}` to render callback instead of just `y`
0.05: Fix `g` corruption issue if .hide gets called twice 0.05: Fix `g` corruption issue if .hide gets called twice
0.06: Adjust position of notification src text and notifications without title 0.06: Adjust position of notification src text and notifications without title
0.07: Support background color

View File

@ -37,7 +37,9 @@ function fitWords(text,rows,width) {
src : string // optional source name src : string // optional source name
body : string // optional body text body : string // optional body text
icon : string // optional icon (image string) icon : string // optional icon (image string)
render function(y) // function callback to render render : function(y) // function callback to render
bgColor : int/string // optional background color (default black)
titleBgColor : int/string // optional background color for title (default black)
} }
*/ */
exports.show = function(options) { exports.show = function(options) {
@ -53,11 +55,11 @@ exports.show = function(options) {
w = 240, w = 240,
h = size; h = size;
// clear screen // clear screen
g.clear(1); g.setColor(options.bgColor||0).fillRect(0,0,g.getWidth(),g.getHeight());
// top bar // top bar
if (options.title||options.src) { if (options.title||options.src) {
const title = options.title || options.src const title = options.title || options.src
g.setColor(0x39C7).fillRect(x, y, x+w-1, y+30); g.setColor(options.titleBgColor||0x39C7).fillRect(x, y, x+w-1, y+30);
g.setColor(-1).setFontAlign(-1, -1, 0).setFont("6x8", 3); g.setColor(-1).setFontAlign(-1, -1, 0).setFont("6x8", 3);
g.drawString(title.trim().substring(0, 13), x+5, y+3); g.drawString(title.trim().substring(0, 13), x+5, y+3);
if (options.title && options.src) { if (options.title && options.src) {