messages: Handle text with images in messages list by just displaying the first line

master
Gordon Williams 2023-11-17 16:18:53 +00:00
parent 8f67f1a8d8
commit 9aefeb9fe6
3 changed files with 11 additions and 6 deletions

View File

@ -101,3 +101,4 @@
0.72: Nav message updastes don't automatically launch navigation menu unless they're new 0.72: Nav message updastes don't automatically launch navigation menu unless they're new
0.73: Add sharp left+right nav icons 0.73: Add sharp left+right nav icons
0.74: Add option for driving on left (affects roundabout icons in navigation) 0.74: Add option for driving on left (affects roundabout icons in navigation)
0.75: Handle text with images in messages list by just displaying the first line

View File

@ -446,7 +446,7 @@ function checkMessages(options) {
if (options.clockIfAllRead && newMessages.length==0) if (options.clockIfAllRead && newMessages.length==0)
return load(); return load();
active = "list"; active = "list";
// Otherwise show a menu // Otherwise show a list of messages
E.showScroller({ E.showScroller({
h : 48, h : 48,
c : Math.max(MESSAGES.length,3), // workaround for 2v10.219 firmware (min 3 not needed for 2v11) c : Math.max(MESSAGES.length,3), // workaround for 2v10.219 firmware (min 3 not needed for 2v11)
@ -469,16 +469,20 @@ function checkMessages(options) {
.setColor(fg); // only color the icon .setColor(fg); // only color the icon
x += 50; x += 50;
} }
var m = msg.title+"\n"+msg.body, longBody=false;
if (title) g.setFontAlign(-1,-1).setFont(fontBig).drawString(title, x,r.y+2); if (title) g.setFontAlign(-1,-1).setFont(fontBig).drawString(title, x,r.y+2);
var longBody = false;
if (body) { if (body) {
g.setFontAlign(-1,-1).setFont("6x8"); g.setFontAlign(-1,-1).setFont("6x8");
// if the body includes an image, it probably won't be small enough to allow>1 line
var maxLines = 3;
if (body.includes("\0")) maxLines=1;
var l = g.wrapString(body, r.w-(x+14)); var l = g.wrapString(body, r.w-(x+14));
if (l.length>3) { if (l.length>maxLines) {
l = l.slice(0,3); l = l.slice(0,maxLines);
l[l.length-1]+="..."; l[l.length-1]+="...";
} }
longBody = l.length>2; longBody = l.length>2;
// draw the body
g.drawString(l.join("\n"), x+10,r.y+20); g.drawString(l.join("\n"), x+10,r.y+20);
} }
if (!longBody && msg.src) g.setFontAlign(1,1).setFont("6x8").drawString(msg.src, r.x+r.w-2, r.y+r.h-2); if (!longBody && msg.src) g.setFontAlign(1,1).setFont("6x8").drawString(msg.src, r.x+r.w-2, r.y+r.h-2);

View File

@ -2,7 +2,7 @@
"id": "messagegui", "id": "messagegui",
"name": "Message UI", "name": "Message UI",
"shortName": "Messages", "shortName": "Messages",
"version": "0.74", "version": "0.75",
"description": "Default app to display notifications from iOS and Gadgetbridge/Android", "description": "Default app to display notifications from iOS and Gadgetbridge/Android",
"icon": "app.png", "icon": "app.png",
"type": "app", "type": "app",