BangleApps/apps/notify
Eric Willisson c3e91b4a30 Adds support for dismissing Gadgetbridge notifications through notify app.
Most of the support was already there, so this is just a few small steps:
- notify.js gets a dismiss_and_hide() exported function that can send the "notify-" event to Gadgetbridge, if installed
- dismiss_and_hide() is called when the Bangle.js screen is touched, instead of just hide()
- Gadgetbridge's widget.js saves "notify"-type events to a variable
- Gadgetbridge's widget.js sends a DISMISS action back to the Android app on "notify-" events, using the saved event data

Note that this is a limited implementation. For example, only the most recent notfication is saved (when a new one comes in, the old one is overridden in the variable), so it will be dismissed on the phone. A more advanced implementation might make it possible to choose which notification to dismiss.

From my own testing, this does properly count as a "swipe-away" style dismiss event in Android, so apps that react to notifications being swiped away will be triggered as expected.
2021-07-09 14:56:19 -04:00
..
ChangeLog notify,notifyfs: don't turn on screen during Quiet Mode 2021-03-25 23:53:51 +01:00
README.md notify,notifyfs: don't turn on screen during Quiet Mode 2021-03-25 23:53:51 +01:00
notify.js Adds support for dismissing Gadgetbridge notifications through notify app. 2021-07-09 14:56:19 -04:00
notify.png Added notification widget 2020-06-04 14:49:35 +01:00

README.md

Notifications (default)

A handler for displaying notifications that displays them in a bar at the top of the screen

This is not an app, but instead it is a library that can be used by other applications or widgets to display messages.

Usage

options = {
  on : bool, // turn screen on, default true (But not if Quiet Mode is enabled)
  size : int, // height of notification, default is fit to height (80 max)  
  title : string, // optional title
  id // optional notification ID, used with hide()
  src : string, // optional source name
  body : string, // optional body text
  icon : string, // optional icon (image string)
  render function(area) {} // function callback to render in area{x,y,w,h}
};
// eg... show notification
require("notify").show({title:"Test", body:"Hello"});
// or display lots of text, with a phone icon
require("notify").show({
  title:"Hello",
  src:"Test",
  body:"This is a really really really long bit of text that has to be wrapped",
  icon:require("heatshrink").decompress(atob("jEYxH+ACcejwUUAAYWVjESCqoABCqoYNCpQXLCxgXJQowtTA4ZbSZiwW/C4gWWjAXVZwIuVWhxFIC6z6OLpIXSCywXYDAIWVAAYXTA=="))
});
// remove it (can also be removed by tapping)
require("notify").hide();

// Use ID to only hide a specific notification if it is still visible
require("notify").show({id:1, title:"Test", body:"Some Alert"});
require("notify").show({id:"msg", title:"Message", body:"Incoming Message"}); // replaces Test Alert
require("notify").hide({id:1}); // does nothing, because the Test Alert was already replaced
require("notify").hide({id:"msg"}); // hides Message
require("notify").hide(); // hides current notification, whatever it was