diff --git a/apps.json b/apps.json index 0c197fa2b..cd5bf3489 100644 --- a/apps.json +++ b/apps.json @@ -94,7 +94,7 @@ "name": "Notifications (default)", "shortName":"Notifications", "icon": "notify.png", - "version":"0.09", + "version":"0.10", "description": "A handler for displaying notifications that displays them in a bar at the top of the screen", "tags": "widget", "type": "notify", @@ -107,9 +107,9 @@ "name": "Fullscreen Notifications", "shortName":"Notifications", "icon": "notify.png", - "version":"0.10", + "version":"0.11", "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,b2", "type": "notify", "storage": [ {"name":"notify","url":"notify.js"} @@ -155,7 +155,7 @@ "icon": "app.png", "version":"0.24", "description": "The default notification handler for Gadgetbridge notifications from Android", - "tags": "tool,system,android,widget", + "tags": "tool,system,android,widget,b2", "readme": "README.md", "type":"widget", "dependencies": { "notify":"type" }, diff --git a/apps/notify/ChangeLog b/apps/notify/ChangeLog index 291f32a5a..d1826f57e 100644 --- a/apps/notify/ChangeLog +++ b/apps/notify/ChangeLog @@ -6,3 +6,4 @@ 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 +0.10: Improvements to help notifications work with themes diff --git a/apps/notify/README.md b/apps/notify/README.md index 11c493102..f186aaab2 100644 --- a/apps/notify/README.md +++ b/apps/notify/README.md @@ -5,6 +5,10 @@ A handler for displaying notifications that displays them in a bar at the top of This is not an app, but instead it is a library that can be used by other applications or widgets to display messages. +**Note:** There are other implementations of this library available such +as `notifyfs` (Fullscreen Notifications). These can be used in the exact +same way from code, but they look different to the user. + ## Usage ```JS diff --git a/apps/notify/notify.js b/apps/notify/notify.js index 68bc1a954..4448de73b 100644 --- a/apps/notify/notify.js +++ b/apps/notify/notify.js @@ -96,15 +96,17 @@ exports.show = function(options) { b = y+h-1, r = x+w-1; // bottom,right g.setClipRect(x,y, r,b); // clear area - g.setColor(options.bgColor||0).fillRect(x,y, r,b); + g.reset(); + if (options.bgColor!==undefined) g.setColor(options.bgColor); + g.clearRect(x,y, r,b); // bottom border - g.setColor(0x39C7).fillRect(0,b-1, r,b); + g.setColor("#333").fillRect(0,b-1, r,b); b -= 2;h -= 2; // title bar if (options.title || options.src) { g.setColor(options.titleBgColor||0x39C7).fillRect(x,y, r,y+20); const title = options.title||options.src; - g.setColor(-1).setFontAlign(-1, -1, 0).setFont("6x8", 2); + g.setColor(g.theme.fg).setFontAlign(-1, -1, 0).setFont("6x8", 2); g.drawString(title.trim().substring(0, 13), x+25,y+3); if (options.title && options.src) { g.setFont("6x8", 1).setFontAlign(1, 1, 0); @@ -122,7 +124,7 @@ exports.show = function(options) { } // body text if (options.body) { - g.setColor(-1).setFont("6x8", 1).setFontAlign(-1, -1, 0).drawString(text, x+6,y+4); + g.setColor(g.theme.fg).setFont("6x8", 1).setFontAlign(-1, -1, 0).drawString(text, x+6,y+4); } if (options.render) { diff --git a/apps/notifyfs/ChangeLog b/apps/notifyfs/ChangeLog index ace651a0d..1c39bcbd5 100644 --- a/apps/notifyfs/ChangeLog +++ b/apps/notifyfs/ChangeLog @@ -8,3 +8,4 @@ 0.08: Don't turn on screen during Quiet Mode 0.09: Add onHide callback 0.10: Ensure dismissing a notification dismissal doesn't enter launcher if in clock mode +0.11: Improvements to help notifications work with themes, Bangle.js 2 support diff --git a/apps/notifyfs/notify.js b/apps/notifyfs/notify.js index cd8d108d5..a45d889f0 100644 --- a/apps/notifyfs/notify.js +++ b/apps/notifyfs/notify.js @@ -50,22 +50,24 @@ exports.show = function(options) { if (options.on===undefined) options.on=true; id = ("id" in options)?options.id:null; let size = options.size||120; - if (size>120) {size=120} - Bangle.setLCDMode("direct"); + if (size>120) size=120; + try { Bangle.setLCDMode("direct"); } catch(e) {} // not supported/needed on Bangle.js 2 let x = 0, y = 40, - w = 240, + w = g.getWidth(), h = size; // clear screen - g.setColor(options.bgColor||0).fillRect(0,0,g.getWidth(),g.getHeight()); + g.reset(); + if (options.bgColor!==undefined) g.setColor(options.bgColor); + g.clearRect(0,0,g.getWidth(),g.getHeight()); // top bar if (options.title||options.src) { - const title = options.title || options.src - g.setColor(options.titleBgColor||0x39C7).fillRect(x, y, x+w-1, y+30); - g.setColor(-1).setFontAlign(-1, -1, 0).setFont("6x8", 3); + const title = options.title || options.src; + g.setColor(options.titleBgColor||"#333").fillRect(x, y, x+w-1, y+30); + g.setColor(g.theme.fg).setFontAlign(-1, -1, 0).setFont("6x8", 3); g.drawString(title.trim().substring(0, 13), x+5, y+3); if (options.title && options.src) { - g.setColor(-1).setFontAlign(1, 1, 0).setFont("6x8", 2); + g.setColor(g.theme.fg).setFontAlign(1, 1, 0).setFont("6x8", 2); // above drawing area, but we are fullscreen g.drawString(options.src.substring(0, 10), w-16, y-4); } @@ -73,8 +75,8 @@ exports.show = function(options) { } if (options.icon) { let i = options.icon, iw,ih; - if ("string"==typeof i) {iw=i.charCodeAt(0); ih=i.charCodeAt(1)} - else {iw=i[0]; ih=i[1]} + if ("string"==typeof i) {iw=i.charCodeAt(0); ih=i.charCodeAt(1);} + else {iw=i[0]; ih=i[1];} const iy=y ? (y+4) : (h-ih)/2; // show below title bar if present, otherwise center vertically g.drawImage(i, x+4,iy); x += iw+4;w -= iw+4; @@ -84,16 +86,13 @@ exports.show = function(options) { const maxRows = Math.floor((h-4)/16), // font=2*(6x8) maxChars = Math.floor((w-4)/12), text=fitWords(options.body, maxRows, maxChars); - g.setColor(-1).setFont("6x8", 2).setFontAlign(-1, -1, 0).drawString(text, x+4, y+4); + g.setColor(g.theme.fg).setFont("6x8", 2).setFontAlign(-1, -1, 0).drawString(text, x+4, y+4); } - if (options.render) { - const area={x:x, y:y, w:w, h:h} - options.render(area); - } - if (options.on && !(require('Storage').readJSON('setting.json',1)||{}).quiet) { + if (options.render) + options.render({x:x, y:y, w:w, h:h}); + if (options.on && !(require('Storage').readJSON('setting.json',1)||{}).quiet) Bangle.setLCDPower(1); // light up - } Bangle.on("touch", exports.hide); if (options.onHide) hideCallback = options.onHide;