Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use formatted captions for images and video #3864

Merged
merged 5 commits into from
Nov 13, 2024

Conversation

jmartinesp
Copy link
Member

Content

This PR has the following changes:

  • Parse the caption and formattedCaption in the same way as we do for text messages.
  • Allow opening links from the caption UI text component.
  • Split the onClick action for timeline items between those whose onClick action should be triggered by the whole message bubble and those who should trigger it only from certain UI elements (as the image/video preview in the timeline).

Note there's no way to send captions as either markdown or HTML at the moment from the app, so either you send these from some other client or you'd only be able to test this by sending a URL as part of the plain text caption.

This PR can be reviewed commit-by-commit.

Motivation and context

Fixes #3850.

Screenshots / GIFs

No changes in screenshots, I hope.

Tests

  • Send an image/video with an URL in the caption and some other text.
  • Make sure the link in the caption is later clickable in the timeline item.
  • Clicking on the image/video preview should open the viewer.
  • Clicking on the text part that has no URL shouldn't do anything.
  • Clicking on the URL should open it.
  • Clicking on any other timeline items should have the same effect as before this patch.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 14

Checklist

  • Changes have been tested on an Android device or Android emulator with API 23
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • Pull request includes a sign off
  • You've made a self review of your PR

…`Charsequence?`, parse the formatted caption body as we do for text message bodies
… the click action should be triggered at the message bubble level or when some internal content is tapped instead.
…content of the timeline item depending on `TimelineItem.isWholeContentClickable`.
@jmartinesp jmartinesp added the PR-Bugfix For bug fix label Nov 13, 2024
@jmartinesp jmartinesp requested a review from a team as a code owner November 13, 2024 12:45
@jmartinesp jmartinesp requested review from bmarty and removed request for a team November 13, 2024 12:45
Copy link
Contributor

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/wnTS7B

Copy link

codecov bot commented Nov 13, 2024

Codecov Report

Attention: Patch coverage is 68.11594% with 22 lines in your changes missing coverage. Please review.

Project coverage is 82.84%. Comparing base (a9c74e9) to head (9ae4f4a).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
...ctories/event/TimelineItemContentMessageFactory.kt 0.00% 1 Missing and 6 partials ⚠️
...imeline/components/TimelineItemGroupedEventsRow.kt 20.00% 4 Missing ⚠️
...tures/messages/impl/timeline/model/TimelineItem.kt 40.00% 0 Missing and 3 partials ⚠️
...e/components/event/TimelineItemEventContentView.kt 77.77% 2 Missing ⚠️
...timeline/components/event/TimelineItemImageView.kt 60.00% 1 Missing and 1 partial ⚠️
...timeline/components/event/TimelineItemVideoView.kt 60.00% 1 Missing and 1 partial ⚠️
...ssages/impl/timeline/components/TimelineItemRow.kt 80.00% 0 Missing and 1 partial ⚠️
...meline/components/event/TimelineItemStickerView.kt 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3864      +/-   ##
===========================================
- Coverage    82.86%   82.84%   -0.02%     
===========================================
  Files         1783     1783              
  Lines        44995    45014      +19     
  Branches      5302     5312      +10     
===========================================
+ Hits         37283    37294      +11     
+ Misses        5864     5861       -3     
- Partials      1848     1859      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jmartinesp
Copy link
Member Author

This is complemented by matrix-org/matrix-rust-sdk#4261, which allows generating HTML formatted body from the caption, which is now used as markdown instead of plain text.

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@jmartinesp jmartinesp merged commit a132be2 into develop Nov 13, 2024
25 of 29 checks passed
@jmartinesp jmartinesp deleted the jme/fix/parse-and-linkify-media-captions branch November 13, 2024 19:25
@jmartinesp jmartinesp mentioned this pull request Nov 13, 2024
@cyrneko
Copy link

cyrneko commented Nov 14, 2024

glad to see the fix has landed, thank you! <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Bugfix For bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

URLs are not clickable in media captions
3 participants