-
Notifications
You must be signed in to change notification settings - Fork 131
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
Implement MSC2530: render caption for image and video if available and add white backround to images in timeline. #2570
Implement MSC2530: render caption for image and video if available and add white backround to images in timeline. #2570
Conversation
Signed-off-by: Marco Antonio Alvarez <surakin@gmail.com>
Signed-off-by: Marco Antonio Alvarez <surakin@gmail.com>
added video captions Signed-off-by: Marco Antonio Alvarez <surakin@gmail.com>
Signed-off-by: Marco Antonio Alvarez <surakin@gmail.com>
Signed-off-by: Marco Antonio Alvarez <surakin@gmail.com>
Signed-off-by: Marco Antonio Alvarez <surakin@gmail.com>
Signed-off-by: Marco Antonio Alvarez <surakin@gmail.com>
Implement MSC2530
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
This does look better :D |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2570 +/- ##
===========================================
+ Coverage 73.14% 73.16% +0.01%
===========================================
Files 1408 1410 +2
Lines 34095 34183 +88
Branches 6617 6638 +21
===========================================
+ Hits 24939 25009 +70
- Misses 5699 5709 +10
- Partials 3457 3465 +8 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, some remarks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suspicious change, as if a filter was applied to the image
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only alpha being 0.8f
instead of 1f
. Otherwise the image itself might not be distinguishable from the blurhash behind it (this happened with a mostly black image I was testing).
AsyncImage( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.then(if (isLoaded) Modifier.background(Color.White) else Modifier), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this has been reported internally, but I am pretty sure adding a white bg can cause more troubles than fixes (rendering in Dark theme for instance), but let's see.
FTR last time I checked, Element Web does not add white BG to images.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FTR last time I checked, Element Web does not add white BG to images.
Yes, but Matthew said it was a mistake. i.e. png images with no background and black letters were impossible to read in dark mode.
Is the white background the cause of these strange artifacts on the border/corners?
Sadly, I think that's the case...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
png images with no background and black letters
OK, so with a white background, how a png image with no background and white letters will render?
I'd say this is the problem for only a minority of files, probably built just to make applications fail (not only Element).
Adding a background to image with transparency is like not supporting image with transparency, this is a shame. I still believe we should not add a white background. This degrades the user experience (stickers, etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might be right. If the users find it annoying we can always remove this white background.
This degrades the user experience (stickers, etc.)
Stickers use a different view, so they won't have this problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but Matthew said it was a mistake. i.e. png images with no background and black letters were impossible to read in dark mode.
Could we only add the background if we detect that the image is both transparent, and has a specific contrast ratio relative to the app colour scheme?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To check if an image is transparent we'd have to load it twice in memory if I'm not mistaken, which isn't really efficient, or add some transformation when Coil loads them, but it seems like it could affect animated images (GIFs, WebP...), so I don't think it's something we want to invest too much time on.
content.formatted?.body?.takeIf { content.formatted.format == MessageFormat.HTML } ?: SpannedString(content.caption) | ||
} | ||
Box { | ||
EditorStyledText( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to provide a LocalContentColor, as per this place, this will fix the fact that color of caption is not the same for my captions and for other people captions. (see the recorded screenshot)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
@Composable | ||
internal fun TimelineImageWithCaptionRowPreview() = ElementPreview { | ||
Column { | ||
sequenceOf(false, true).forEach { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe name it
for clarity:
sequenceOf(false, true).forEach { | |
sequenceOf(false, true).forEach { isMine -> |
(do not apply suggestion, it will not compile!)
Note that this is not done everywhere, so maybe an opportunity to replace all occurences of isMine = it
in the codebase :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my comment about the difference between the caption colors.
Quality Gate passedIssues Measures |
(updating the title for further reference when searching for this PR) |
Type of change
Content
Based on #2522 (thanks @surakin!) .
filename != null && body != filename
.You can review only my commits, starting from 6cfe0c8.
Motivation and context
Closes #2521.
Screenshots / GIFs
Tests
You'll need a room where images or videos with captions have been sent.
Tested devices
Checklist