From 0e2f33d656ed6687e54a80b3682ce4139b77a1df Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 11 Feb 2021 09:45:50 +0000 Subject: [PATCH] gbridge: 0.19: Support for call incoming/start/end --- apps.json | 6 +++--- apps/gbridge/ChangeLog | 1 + apps/gbridge/widget.js | 24 ++++++++++++++++++------ apps/notify/ChangeLog | 1 + apps/notify/notify.js | 8 +++++--- apps/notifyfs/ChangeLog | 1 + apps/notifyfs/notify.js | 8 +++++--- 7 files changed, 34 insertions(+), 15 deletions(-) diff --git a/apps.json b/apps.json index 40d3ea45c..de96afe4f 100644 --- a/apps.json +++ b/apps.json @@ -80,7 +80,7 @@ "name": "Notifications (default)", "shortName":"Notifications", "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", "tags": "widget", "type": "notify", @@ -93,7 +93,7 @@ "name": "Fullscreen Notifications", "shortName":"Notifications", "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.", "tags": "widget", "type": "notify", @@ -139,7 +139,7 @@ { "id": "gbridge", "name": "Gadgetbridge", "icon": "app.png", - "version":"0.18", + "version":"0.19", "description": "The default notification handler for Gadgetbridge notifications from Android", "tags": "tool,system,android,widget", "readme": "README.md", diff --git a/apps/gbridge/ChangeLog b/apps/gbridge/ChangeLog index bec2d305a..da163e466 100644 --- a/apps/gbridge/ChangeLog +++ b/apps/gbridge/ChangeLog @@ -18,3 +18,4 @@ Nicer display of alarm clock notifications 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.19: Support for call incoming/start/end diff --git a/apps/gbridge/widget.js b/apps/gbridge/widget.js index d616e8816..d611e6686 100644 --- a/apps/gbridge/widget.js +++ b/apps/gbridge/widget.js @@ -15,7 +15,7 @@ var currentSteps = 0, lastSentSteps=0; var activityInterval; var hrmTimeout; - + function settings() { let settings = require('Storage').readJSON("gbridge.json", true) || {}; if (!("showIcon" in settings)) { @@ -129,11 +129,23 @@ } function handleCallEvent(event) { - if (event.cmd === "accept") { + var callIcon = require("heatshrink").decompress(atob("jEYwIMJj4CCwACJh4CCCIMOAQMGAQMHAQMDAQMBCIMB4PwgHz/EAn4CBj4CBg4CBgACCAAw=")); + if (event.cmd === "incoming") { require("notify").show({ size: 55, title: event.name, id: "call", - body: event.number, icon:require("heatshrink").decompress(atob("jEYwIMJj4CCwACJh4CCCIMOAQMGAQMHAQMDAQMBCIMB4PwgHz/EAn4CBj4CBg4CBgACCAAw="))}); + body: event.number, icon:callIcon}); 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); } } @@ -148,7 +160,7 @@ setTimeout(_=>Bangle.beep(), 1000); },2000); } - + function handleActivityEvent(event) { var s = settings(); // handle setting activity interval @@ -251,7 +263,7 @@ function sendBattery() { gbSend({ t: "status", bat: E.getBattery() }); } - + // Send a summary of activity to Gadgetbridge function sendActivity(hrm) { var steps = currentSteps - lastSentSteps; @@ -279,7 +291,7 @@ } }); handleActivityEvent({}); // kicks off activity reporting - + // Finally add widget WIDGETS["gbridgew"] = {area: "tl", width: 24, draw: draw, reload: reload}; reload(); diff --git a/apps/notify/ChangeLog b/apps/notify/ChangeLog index a1e8e4418..c823f9033 100644 --- a/apps/notify/ChangeLog +++ b/apps/notify/ChangeLog @@ -2,3 +2,4 @@ 0.02: Add notification ID option 0.03: Pass `area{x,y,w,h}` to render callback instead of just `y` 0.05: Adjust position of notification src text +0.06: Support background color diff --git a/apps/notify/notify.js b/apps/notify/notify.js index 6f5261de1..b18826d24 100644 --- a/apps/notify/notify.js +++ b/apps/notify/notify.js @@ -41,7 +41,9 @@ function fitWords(text,rows,width) { src : string // optional source name body : string // optional body text 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 g.setClipRect(x,y, r,b); // clear area - g.setColor(0).fillRect(x,y, r,b); + g.setColor(options.bgColor||0).fillRect(x,y, r,b); // bottom border g.setColor(0x39C7).fillRect(0,b-1, r,b); b -= 2;h -= 2; // title bar 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; g.setColor(-1).setFontAlign(-1, -1, 0).setFont("6x8", 2); g.drawString(title.trim().substring(0, 13), x+25,y+3); diff --git a/apps/notifyfs/ChangeLog b/apps/notifyfs/ChangeLog index 16bc0ebb3..d4ea69cc8 100644 --- a/apps/notifyfs/ChangeLog +++ b/apps/notifyfs/ChangeLog @@ -4,3 +4,4 @@ 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.06: Adjust position of notification src text and notifications without title +0.07: Support background color diff --git a/apps/notifyfs/notify.js b/apps/notifyfs/notify.js index 2c622f624..0b73ad2d2 100644 --- a/apps/notifyfs/notify.js +++ b/apps/notifyfs/notify.js @@ -37,7 +37,9 @@ function fitWords(text,rows,width) { src : string // optional source name body : string // optional body text 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) { @@ -53,11 +55,11 @@ exports.show = function(options) { w = 240, h = size; // clear screen - g.clear(1); + g.setColor(options.bgColor||0).fillRect(0,0,g.getWidth(),g.getHeight()); // top bar if (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.drawString(title.trim().substring(0, 13), x+5, y+3); if (options.title && options.src) {