diff --git a/apps.json b/apps.json index dbbe95edb..d392ea240 100644 --- a/apps.json +++ b/apps.json @@ -94,7 +94,7 @@ "name": "Notifications (default)", "shortName":"Notifications", "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", "tags": "widget", "type": "notify", @@ -107,7 +107,7 @@ "name": "Fullscreen Notifications", "shortName":"Notifications", "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.", "tags": "widget", "type": "notify", @@ -153,7 +153,7 @@ { "id": "gbridge", "name": "Gadgetbridge", "icon": "app.png", - "version":"0.22", + "version":"0.23", "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 f4837d60a..6e1c5b468 100644 --- a/apps/gbridge/ChangeLog +++ b/apps/gbridge/ChangeLog @@ -22,3 +22,4 @@ 0.20: Reduce memory usage 0.21: Fix HRM setting 0.22: Respect Quiet Mode +0.23: Allow notification dismiss to remove from phone too diff --git a/apps/gbridge/widget.js b/apps/gbridge/widget.js index 70abfd610..2c61e61fa 100644 --- a/apps/gbridge/widget.js +++ b/apps/gbridge/widget.js @@ -155,6 +155,10 @@ switch (event.t) { case "notify": currentNot = prettifyNotificationEvent(event); + currentNot.onHide = function() { + // when notification hidden, remove from phone + gbSend({ t:"notify", n:"DISMISS", id:currentNot.id }); + }; require("notify").show(currentNot); if (!(require('Storage').readJSON('setting.json',1)||{}).quiet) { Bangle.buzz(); diff --git a/apps/notify/ChangeLog b/apps/notify/ChangeLog index 2b7a4f990..291f32a5a 100644 --- a/apps/notify/ChangeLog +++ b/apps/notify/ChangeLog @@ -5,3 +5,4 @@ 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.08: Don't turn on screen during Quiet Mode +0.09: Add onHide callback diff --git a/apps/notify/notify.js b/apps/notify/notify.js index 230cf9d10..68bc1a954 100644 --- a/apps/notify/notify.js +++ b/apps/notify/notify.js @@ -1,5 +1,6 @@ let pos = 0; let id = null; +let hideCallback = undefined; /** * 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 bgColor : int/string // optional background color (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); } 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) { options = options||{}; if ("id" in options && options.id!==id) return; + if (hideCallback) hideCallback({id:id}); + hideCallback = undefined; id = null; Bangle.removeListener("touch", exports.hide); function anim() { @@ -162,20 +168,3 @@ exports.hide = function(options) { } 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); - } -}; diff --git a/apps/notifyfs/ChangeLog b/apps/notifyfs/ChangeLog index 974e138f7..18adecb4f 100644 --- a/apps/notifyfs/ChangeLog +++ b/apps/notifyfs/ChangeLog @@ -6,3 +6,4 @@ 0.06: Adjust position of notification src text and notifications without title 0.07: Support background color 0.08: Don't turn on screen during Quiet Mode +0.09: Add onHide callback diff --git a/apps/notifyfs/notify.js b/apps/notifyfs/notify.js index 07801cedb..b6b8dc43b 100644 --- a/apps/notifyfs/notify.js +++ b/apps/notifyfs/notify.js @@ -1,5 +1,6 @@ let oldg; let id = null; +let hideCallback = null; /** * See notify/notify.js @@ -40,6 +41,7 @@ function fitWords(text,rows,width) { 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) + onHide : function() // callback when notification is hidden } */ exports.show = function(options) { @@ -65,7 +67,6 @@ exports.show = function(options) { if (options.title && options.src) { g.setColor(-1).setFontAlign(1, 1, 0).setFont("6x8", 2); // 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); } y += 30;h -= 30; @@ -94,6 +95,8 @@ exports.show = function(options) { Bangle.setLCDPower(1); // light up } Bangle.on("touch", exports.hide); + if (options.onHide) + hideCallback = options.onHide; // Create a fake graphics to hide draw attempts oldg = g; g = Graphics.createArrayBuffer(8,8,1); @@ -108,6 +111,8 @@ exports.show = function(options) { exports.hide = function(options) { options = options||{}; if ("id" in options && options.id!==id) return; + if (hideCallback) hideCallback({id:id}); + hideCallback = undefined; id = null; if (oldg) { g=oldg;