widbt_notify: Added "connection restored" notification. Fixed restoring of the watchface.

pull/2011/head
Hank 2022-07-01 19:49:35 +02:00
parent 088cd53b9c
commit c99a0de9a9
3 changed files with 17 additions and 1 deletions

View File

@ -9,3 +9,4 @@
0.10: Bug fix
0.11: Avoid too many notifications. Change disconnected colour to red.
0.12: Prevent repeated execution of `draw()` from the current app.
0.13: Added "connection restored" notification. Fixed restoring of the watchface.

View File

@ -1,7 +1,7 @@
{
"id": "widbt_notify",
"name": "Bluetooth Widget with Notification",
"version": "0.12",
"version": "0.13",
"description": "Show the current Bluetooth connection status in the top right of the clock and vibrate when disconnected.",
"icon": "widget.png",
"type": "widget",

View File

@ -15,13 +15,28 @@ WIDGETS.bluetooth_notify = {
redrawCurrentApp: function(){
if(typeof(draw)=='function'){
g.clear();
draw();
Bangle.loadWidgets();
Bangle.drawWidgets();
}else{
load(); // fallback. This might reset some variables
}
},
connect: function() {
if(WIDGETS.bluetooth_notify.warningEnabled == 1){
E.showMessage(/*LANG*/'Connection\n restored.', 'Bluetooth');
setTimeout(()=>{WIDGETS.bluetooth_notify.redrawCurrentApp();}, 3000); // clear message - this will reload the widget, resetting 'warningEnabled'.
WIDGETS.bluetooth_notify.warningEnabled = 0;
setTimeout('WIDGETS.bluetooth_notify.warningEnabled = 1;', 30000); // don't buzz for the next 30 seconds.
var quiet = (require('Storage').readJSON('setting.json',1)||{}).quiet;
if(!quiet){
Bangle.buzz(700, 1); // buzz on connection loss
}
}
WIDGETS.bluetooth_notify.draw();
},