Nicer Share Pics

This commit is contained in:
Tim Zöller 2026-04-08 11:06:26 +02:00
parent 48ac2e444b
commit 07fbcf8064
5 changed files with 1045 additions and 563 deletions

View file

@ -473,7 +473,12 @@ public class ActivityPubController {
imageAttachment.put("type", "Image");
imageAttachment.put("mediaType", "image/png");
imageAttachment.put("url", imageUrl);
imageAttachment.put("name", "Activity map showing " + activity.getActivityType() + " route");
// The "name" field on an Image attachment is what Mastodon, other
// ActivityPub servers, and screen readers expose as the image
// description. Build a real prose description from the activity
// data instead of the previous "Activity map showing X route"
// placeholder. See ActivityImageService.buildImageAltText.
imageAttachment.put("name", activityImageService.buildImageAltText(activity));
noteObject.put("attachment", List.of(imageAttachment));
}

View file

@ -233,7 +233,11 @@ public class ActivityPostProcessingService {
imageAttachment.put("type", "Image");
imageAttachment.put("mediaType", "image/png");
imageAttachment.put("url", imageUrl);
imageAttachment.put("name", "Activity map showing " + activity.getActivityType() + " route");
// The "name" field on an Image attachment is what Mastodon and
// other ActivityPub servers expose as the image description /
// alt text. Build it from the same data the visual renderer
// uses so the two stay in sync.
imageAttachment.put("name", activityImageService.buildImageAltText(activity));
noteObject.put("attachment", List.of(imageAttachment));
}

View file

@ -191,8 +191,11 @@ public class OsmTileRenderer {
drawY = 0;
}
// Fill background with neutral gray
g.setColor(new Color(240, 240, 240));
// Fill the letterbox margins with the FitPub dark background so the
// square share-image map blends seamlessly into the dark stats panel.
// (Was previously a neutral light gray that produced visible bars
// around non-square routes.)
g.setColor(new Color(0x0f, 0x05, 0x20));
g.fillRect(0, 0, width, height);
// Draw scaled image centered with preserved aspect ratio