gbridge: 0.19: Support for call incoming/start/end
parent
28c7cfc3fa
commit
0e2f33d656
|
|
@ -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",
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
var currentSteps = 0, lastSentSteps=0;
|
var currentSteps = 0, lastSentSteps=0;
|
||||||
var activityInterval;
|
var activityInterval;
|
||||||
var hrmTimeout;
|
var hrmTimeout;
|
||||||
|
|
||||||
function settings() {
|
function settings() {
|
||||||
let settings = require('Storage').readJSON("gbridge.json", true) || {};
|
let settings = require('Storage').readJSON("gbridge.json", true) || {};
|
||||||
if (!("showIcon" in settings)) {
|
if (!("showIcon" in settings)) {
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,7 +160,7 @@
|
||||||
setTimeout(_=>Bangle.beep(), 1000);
|
setTimeout(_=>Bangle.beep(), 1000);
|
||||||
},2000);
|
},2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleActivityEvent(event) {
|
function handleActivityEvent(event) {
|
||||||
var s = settings();
|
var s = settings();
|
||||||
// handle setting activity interval
|
// handle setting activity interval
|
||||||
|
|
@ -251,7 +263,7 @@
|
||||||
function sendBattery() {
|
function sendBattery() {
|
||||||
gbSend({ t: "status", bat: E.getBattery() });
|
gbSend({ t: "status", bat: E.getBattery() });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send a summary of activity to Gadgetbridge
|
// Send a summary of activity to Gadgetbridge
|
||||||
function sendActivity(hrm) {
|
function sendActivity(hrm) {
|
||||||
var steps = currentSteps - lastSentSteps;
|
var steps = currentSteps - lastSentSteps;
|
||||||
|
|
@ -279,7 +291,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
handleActivityEvent({}); // kicks off activity reporting
|
handleActivityEvent({}); // kicks off activity reporting
|
||||||
|
|
||||||
// Finally add widget
|
// Finally add widget
|
||||||
WIDGETS["gbridgew"] = {area: "tl", width: 24, draw: draw, reload: reload};
|
WIDGETS["gbridgew"] = {area: "tl", width: 24, draw: draw, reload: reload};
|
||||||
reload();
|
reload();
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue