messages 0.16: Fix text wrapping so it fits the screen even if title is big (fix #1147)

master
Gordon Williams 2022-01-04 14:27:23 +00:00
parent c06afa1132
commit 128f2d4e66
3 changed files with 5 additions and 3 deletions

View File

@ -77,7 +77,7 @@
{ {
"id": "messages", "id": "messages",
"name": "Messages", "name": "Messages",
"version": "0.15", "version": "0.16",
"description": "App to display notifications from iOS and Gadgetbridge", "description": "App to display notifications from iOS and Gadgetbridge",
"icon": "app.png", "icon": "app.png",
"type": "app", "type": "app",

View File

@ -22,3 +22,4 @@
Now update correctly when 'require("messages").clearAll()' is called Now update correctly when 'require("messages").clearAll()' is called
0.14: Hide widget when all unread notifications are dismissed from phone 0.14: Hide widget when all unread notifications are dismissed from phone
0.15: Don't buzz when Quiet Mode is active 0.15: Don't buzz when Quiet Mode is active
0.16: Fix text wrapping so it fits the screen even if title is big (fix #1147)

View File

@ -243,7 +243,8 @@ function showMessage(msgid) {
checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1}); checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1});
}}); }});
} }
lines = g.wrapString(msg.body, g.getWidth()-10); var bodyFont = fontMedium;
lines = g.setFont(bodyFont).wrapString(msg.body, g.getWidth()-10);
var body = (lines.length>4) ? lines.slice(0,4).join("\n")+"..." : lines.join("\n"); var body = (lines.length>4) ? lines.slice(0,4).join("\n")+"..." : lines.join("\n");
layout = new Layout({ type:"v", c: [ layout = new Layout({ type:"v", c: [
{type:"h", fillx:1, bgCol:colBg, c: [ {type:"h", fillx:1, bgCol:colBg, c: [
@ -256,7 +257,7 @@ function showMessage(msgid) {
title?{type:"txt", font:titleFont, label:title, bgCol:colBg, fillx:1, pad:2 }:{}, title?{type:"txt", font:titleFont, label:title, bgCol:colBg, fillx:1, pad:2 }:{},
]}, ]},
]}, ]},
{type:"txt", font:fontMedium, label:body, fillx:1, filly:1, pad:2 }, {type:"txt", font:bodyFont, label:body, fillx:1, filly:1, pad:2 },
{type:"h",fillx:1, c: buttons} {type:"h",fillx:1, c: buttons}
]}); ]});
g.clearRect(Bangle.appRect); g.clearRect(Bangle.appRect);