Tweaks to notify to allow Gadgetbridge to dismiss notifications on phone from watch
parent
f6b46395fc
commit
04b7af4a6a
|
|
@ -94,7 +94,7 @@
|
||||||
"name": "Notifications (default)",
|
"name": "Notifications (default)",
|
||||||
"shortName":"Notifications",
|
"shortName":"Notifications",
|
||||||
"icon": "notify.png",
|
"icon": "notify.png",
|
||||||
"version":"0.08",
|
"version":"0.09",
|
||||||
"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",
|
||||||
|
|
@ -107,7 +107,7 @@
|
||||||
"name": "Fullscreen Notifications",
|
"name": "Fullscreen Notifications",
|
||||||
"shortName":"Notifications",
|
"shortName":"Notifications",
|
||||||
"icon": "notify.png",
|
"icon": "notify.png",
|
||||||
"version":"0.08",
|
"version":"0.09",
|
||||||
"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",
|
||||||
|
|
@ -153,7 +153,7 @@
|
||||||
{ "id": "gbridge",
|
{ "id": "gbridge",
|
||||||
"name": "Gadgetbridge",
|
"name": "Gadgetbridge",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"version":"0.22",
|
"version":"0.23",
|
||||||
"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",
|
||||||
|
|
|
||||||
|
|
@ -22,3 +22,4 @@
|
||||||
0.20: Reduce memory usage
|
0.20: Reduce memory usage
|
||||||
0.21: Fix HRM setting
|
0.21: Fix HRM setting
|
||||||
0.22: Respect Quiet Mode
|
0.22: Respect Quiet Mode
|
||||||
|
0.23: Allow notification dismiss to remove from phone too
|
||||||
|
|
|
||||||
|
|
@ -155,6 +155,10 @@
|
||||||
switch (event.t) {
|
switch (event.t) {
|
||||||
case "notify":
|
case "notify":
|
||||||
currentNot = prettifyNotificationEvent(event);
|
currentNot = prettifyNotificationEvent(event);
|
||||||
|
currentNot.onHide = function() {
|
||||||
|
// when notification hidden, remove from phone
|
||||||
|
gbSend({ t:"notify", n:"DISMISS", id:currentNot.id });
|
||||||
|
};
|
||||||
require("notify").show(currentNot);
|
require("notify").show(currentNot);
|
||||||
if (!(require('Storage').readJSON('setting.json',1)||{}).quiet) {
|
if (!(require('Storage').readJSON('setting.json',1)||{}).quiet) {
|
||||||
Bangle.buzz();
|
Bangle.buzz();
|
||||||
|
|
|
||||||
|
|
@ -5,3 +5,4 @@
|
||||||
0.06: Support background color
|
0.06: Support background color
|
||||||
0.07: Auto-calculate height, and pad text down even when there's no title (so it stays on-screen)
|
0.07: Auto-calculate height, and pad text down even when there's no title (so it stays on-screen)
|
||||||
0.08: Don't turn on screen during Quiet Mode
|
0.08: Don't turn on screen during Quiet Mode
|
||||||
|
0.09: Add onHide callback
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
let pos = 0;
|
let pos = 0;
|
||||||
let id = null;
|
let id = null;
|
||||||
|
let hideCallback = undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fit text into area, trying to insert newlines between words
|
* Fit text into area, trying to insert newlines between words
|
||||||
|
|
@ -44,6 +45,7 @@ function fitWords(text,rows,width) {
|
||||||
render : function(y) // function callback to render
|
render : function(y) // function callback to render
|
||||||
bgColor : int/string // optional background color (default black)
|
bgColor : int/string // optional background color (default black)
|
||||||
titleBgColor : int/string // optional background color for title (default black)
|
titleBgColor : int/string // optional background color for title (default black)
|
||||||
|
onHide : function() // callback when notification is hidden
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
|
|
@ -141,7 +143,9 @@ exports.show = function(options) {
|
||||||
if (pos > -size) setTimeout(anim, 15);
|
if (pos > -size) setTimeout(anim, 15);
|
||||||
}
|
}
|
||||||
anim();
|
anim();
|
||||||
Bangle.on("touch", exports.dismiss_and_hide);
|
Bangle.on("touch", exports.hide);
|
||||||
|
if (options.onHide)
|
||||||
|
hideCallback = options.onHide;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -152,6 +156,8 @@ exports.show = function(options) {
|
||||||
exports.hide = function(options) {
|
exports.hide = function(options) {
|
||||||
options = options||{};
|
options = options||{};
|
||||||
if ("id" in options && options.id!==id) return;
|
if ("id" in options && options.id!==id) return;
|
||||||
|
if (hideCallback) hideCallback({id:id});
|
||||||
|
hideCallback = undefined;
|
||||||
id = null;
|
id = null;
|
||||||
Bangle.removeListener("touch", exports.hide);
|
Bangle.removeListener("touch", exports.hide);
|
||||||
function anim() {
|
function anim() {
|
||||||
|
|
@ -162,20 +168,3 @@ exports.hide = function(options) {
|
||||||
}
|
}
|
||||||
anim();
|
anim();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
Calls exports.hide(), but if Gadgetbridge is installed, dismiss through it
|
|
||||||
instead (which will call call exports.hide() itself).
|
|
||||||
*/
|
|
||||||
exports.dismiss_and_hide = function(options) {
|
|
||||||
options = options||{};
|
|
||||||
if (typeof(options) == "number") {
|
|
||||||
options = {};
|
|
||||||
}
|
|
||||||
if ("GB" in global) {
|
|
||||||
options["t"] = "notify-";
|
|
||||||
GB(options);
|
|
||||||
} else {
|
|
||||||
exports.hide(options);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
|
||||||
|
|
@ -6,3 +6,4 @@
|
||||||
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
|
0.07: Support background color
|
||||||
0.08: Don't turn on screen during Quiet Mode
|
0.08: Don't turn on screen during Quiet Mode
|
||||||
|
0.09: Add onHide callback
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
let oldg;
|
let oldg;
|
||||||
let id = null;
|
let id = null;
|
||||||
|
let hideCallback = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See notify/notify.js
|
* See notify/notify.js
|
||||||
|
|
@ -40,6 +41,7 @@ function fitWords(text,rows,width) {
|
||||||
render : function(y) // function callback to render
|
render : function(y) // function callback to render
|
||||||
bgColor : int/string // optional background color (default black)
|
bgColor : int/string // optional background color (default black)
|
||||||
titleBgColor : int/string // optional background color for title (default black)
|
titleBgColor : int/string // optional background color for title (default black)
|
||||||
|
onHide : function() // callback when notification is hidden
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
exports.show = function(options) {
|
exports.show = function(options) {
|
||||||
|
|
@ -65,7 +67,6 @@ exports.show = function(options) {
|
||||||
if (options.title && options.src) {
|
if (options.title && options.src) {
|
||||||
g.setColor(-1).setFontAlign(1, 1, 0).setFont("6x8", 2);
|
g.setColor(-1).setFontAlign(1, 1, 0).setFont("6x8", 2);
|
||||||
// above drawing area, but we are fullscreen
|
// above drawing area, but we are fullscreen
|
||||||
print(options.src.substring(0, 10), w-23, y-4);
|
|
||||||
g.drawString(options.src.substring(0, 10), w-16, y-4);
|
g.drawString(options.src.substring(0, 10), w-16, y-4);
|
||||||
}
|
}
|
||||||
y += 30;h -= 30;
|
y += 30;h -= 30;
|
||||||
|
|
@ -94,6 +95,8 @@ exports.show = function(options) {
|
||||||
Bangle.setLCDPower(1); // light up
|
Bangle.setLCDPower(1); // light up
|
||||||
}
|
}
|
||||||
Bangle.on("touch", exports.hide);
|
Bangle.on("touch", exports.hide);
|
||||||
|
if (options.onHide)
|
||||||
|
hideCallback = options.onHide;
|
||||||
// Create a fake graphics to hide draw attempts
|
// Create a fake graphics to hide draw attempts
|
||||||
oldg = g;
|
oldg = g;
|
||||||
g = Graphics.createArrayBuffer(8,8,1);
|
g = Graphics.createArrayBuffer(8,8,1);
|
||||||
|
|
@ -108,6 +111,8 @@ exports.show = function(options) {
|
||||||
exports.hide = function(options) {
|
exports.hide = function(options) {
|
||||||
options = options||{};
|
options = options||{};
|
||||||
if ("id" in options && options.id!==id) return;
|
if ("id" in options && options.id!==id) return;
|
||||||
|
if (hideCallback) hideCallback({id:id});
|
||||||
|
hideCallback = undefined;
|
||||||
id = null;
|
id = null;
|
||||||
if (oldg) {
|
if (oldg) {
|
||||||
g=oldg;
|
g=oldg;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue