gbridge: Handle notify- events

So dismissing notifications on the phone also clears them on the watch
master
Richard de Boer 2020-07-07 20:53:00 +02:00
parent 9c55b47263
commit a5f3118859
3 changed files with 22 additions and 14 deletions

View File

@ -121,7 +121,7 @@
{ "id": "gbridge", { "id": "gbridge",
"name": "Gadgetbridge", "name": "Gadgetbridge",
"icon": "app.png", "icon": "app.png",
"version":"0.15", "version":"0.16",
"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",
"type":"widget", "type":"widget",

View File

@ -14,3 +14,4 @@
0.13: Modified to use the 'notify' library 0.13: Modified to use the 'notify' library
0.14: Added 'find' event handling 0.14: Added 'find' event handling
0.15: Don't keep LCD on while playing music 0.15: Don't keep LCD on while playing music
0.16: Handle dismissing notifications on the phone

View File

@ -25,13 +25,19 @@
} }
function handleNotificationEvent(event) { function handleNotificationEvent(event) {
if (event.t === "notify") {
require("notify").show(event); require("notify").show(event);
Bangle.buzz(); Bangle.buzz();
} else { // notify-
require("notify").hide(event);
}
} }
function updateMusic(options){ function updateMusic(options){
if (state.music === "play") { if (state.music === "play") {
require("notify").show(Object.assign({size:40, render:y => { require("notify").show(Object.assign({
size:40, id:"music",
render:y => {
g.setColor(-1); g.setColor(-1);
g.drawImage(require("heatshrink").decompress(atob("jEYwILI/EAv/8gP/ARcMgOAASN8h+A/kfwP8n4CD/E/gHgjg/HA=")), 8, y + 8); g.drawImage(require("heatshrink").decompress(atob("jEYwILI/EAv/8gP/ARcMgOAASN8h+A/kfwP8n4CD/E/gHgjg/HA=")), 8, y + 8);
g.setFontAlign(-1, -1); g.setFontAlign(-1, -1);
@ -42,7 +48,7 @@
} }
if (state.music === "pause") { if (state.music === "pause") {
require("notify").hide(); require("notify").hide("music");
} }
} }
function handleMusicStateUpdate(event) { function handleMusicStateUpdate(event) {
@ -59,7 +65,7 @@
function handleCallEvent(event) { function handleCallEvent(event) {
if (event.cmd === "accept") { if (event.cmd === "accept") {
require("notify").show({ require("notify").show({
size: 55, title: event.name, size: 55, title: event.name, id: "call",
body: event.number, icon:require("heatshrink").decompress(atob("jEYwIMJj4CCwACJh4CCCIMOAQMGAQMHAQMDAQMBCIMB4PwgHz/EAn4CBj4CBg4CBgACCAAw="))}); body: event.number, icon:require("heatshrink").decompress(atob("jEYwIMJj4CCwACJh4CCCIMOAQMGAQMHAQMDAQMBCIMB4PwgHz/EAn4CBj4CBg4CBgACCAAw="))});
Bangle.buzz(); Bangle.buzz();
} }
@ -81,6 +87,7 @@
global.GB = (event) => { global.GB = (event) => {
switch (event.t) { switch (event.t) {
case "notify": case "notify":
case "notify-":
handleNotificationEvent(event); handleNotificationEvent(event);
break; break;
case "musicinfo": case "musicinfo":