massages: Add option to disable icon flashing

Update ChangeLog, metadata.json, README.md and settigns.js:
 - Add option to toggle icon flashing.
Update widget.js:
 - Add option to toggle icon flashing.
 - Correct clearRect y2 value.
 - Moved icon 1px up to be more centered.
pull/1664/head
storm64 2022-04-07 01:30:39 +02:00
parent 3c28c0c9c9
commit 1d23c4f2e4
5 changed files with 16 additions and 5 deletions

View File

@ -43,3 +43,4 @@
0.28: Option to auto-unlock the watch when a new message arrives
0.29: Fix message list overwrites on Bangle.js 1 (fix #1642)
0.30: Add new Icons (Youtube, Twitch, MS TODO, Teams, Snapchat, Signal, Post & DHL, Nina, Lieferando, Kalender, Discord, Corona Warn, Bibel)
0.31: Option to disable icon flashing

View File

@ -21,6 +21,7 @@ is chosen if there isn't much message text, but this specifies the smallest the
it starts getting clipped.
* `Auto-Open Music` - Should the app automatically open when the phone starts playing music?
* `Unlock Watch` - Should the app unlock the watch when a new message arrives, so you can touch the buttons at the bottom of the app?
* `Flash Icon` - Toggle flashing of the widget icon.
## New Messages

View File

@ -1,7 +1,7 @@
{
"id": "messages",
"name": "Messages",
"version": "0.30",
"version": "0.31",
"description": "App to display notifications from iOS and Gadgetbridge/Android",
"icon": "app.png",
"type": "app",

View File

@ -7,6 +7,7 @@
settings.unlockWatch=!!settings.unlockWatch;
settings.openMusic=!!settings.openMusic;
settings.maxUnreadTimeout=240;
if (settings.flash===undefined) settings.flash=true;
return settings;
}
function updateSetting(setting, value) {
@ -47,6 +48,11 @@
format: v => v?/*LANG*/'Yes':/*LANG*/'No',
onchange: v => updateSetting("unlockWatch", v)
},
/*LANG*/'Flash Icon': {
value: !!settings().flash,
format: v => v?/*LANG*/'Yes':/*LANG*/'No',
onchange: v => updateSetting("flash", v)
},
};
E.showMenu(mainmenu);
})

View File

@ -1,5 +1,5 @@
WIDGETS["messages"]={area:"tl", width:0, iconwidth:24,
draw:function() {
draw:function(recall) {
// If we had a setTimeout queued from the last time we were called, remove it
if (WIDGETS["messages"].i) {
clearTimeout(WIDGETS["messages"].i);
@ -8,15 +8,18 @@ draw:function() {
Bangle.removeListener('touch', this.touch);
if (!this.width) return;
var c = (Date.now()-this.t)/1000;
g.reset().clearRect(this.x, this.y, this.x+this.width, this.y+this.iconwidth);
g.drawImage((c&1) ? atob("GBiBAAAAAAAAAAAAAAAAAAAAAB//+DAADDAADDAADDwAPD8A/DOBzDDn/DA//DAHvDAPvjAPvjAPvjAPvh///gf/vAAD+AAB8AAAAA==") : atob("GBiBAAAAAAAAAAAAAAAAAAAAAB//+D///D///A//8CP/xDj/HD48DD+B8D/D+D/3vD/vvj/vvj/vvj/vvh/v/gfnvAAD+AAB8AAAAA=="), this.x, this.y);
let settings = require('Storage').readJSON("messages.settings.json", true) || {};
if (settings.flash===undefined) settings.flash = true;
if (recall !== true || settings.flash) {
g.reset().clearRect(this.x, this.y, this.x+this.width, this.y+23);
g.drawImage(settings.flash && (c&1) ? atob("GBiBAAAAAAAAAAAAAAAAAAAAAB//+DAADDAADDAADDwAPD8A/DOBzDDn/DA//DAHvDAPvjAPvjAPvjAPvh///gf/vAAD+AAB8AAAAA==") : atob("GBiBAAAAAAAAAAAAAAAAAAAAAB//+D///D///A//8CP/xDj/HD48DD+B8D/D+D/3vD/vvj/vvj/vvj/vvh/v/gfnvAAD+AAB8AAAAA=="), this.x, this.y-1);
}
if (settings.repeat===undefined) settings.repeat = 4;
if (c<120 && (Date.now()-this.l)>settings.repeat*1000) {
this.l = Date.now();
WIDGETS["messages"].buzz(); // buzz every 4 seconds
}
WIDGETS["messages"].i=setTimeout(()=>WIDGETS["messages"].draw(), 1000);
WIDGETS["messages"].i=setTimeout(()=>WIDGETS["messages"].draw(true), 1000);
if (process.env.HWVERSION>1) Bangle.on('touch', this.touch);
},show:function(quiet) {
WIDGETS["messages"].t=Date.now(); // first time