Skip to content

Support gallery messages#7112

Merged
bmarty merged 27 commits into
developfrom
feature/bma/galleryMessages
Jul 3, 2026
Merged

Support gallery messages#7112
bmarty merged 27 commits into
developfrom
feature/bma/galleryMessages

Conversation

@bmarty

@bmarty bmarty commented Jun 26, 2026

Copy link
Copy Markdown
Member

Follow up for #6519

Support sending and rendering gallery messages (a message with multiple photos)

* Support gallery messages

* Address review

* Remove unused function

* Fix indent

* Add "Gallery" message prefix

* Support galleries for image editing

* Fix tapping on a tile opens the last item

* Fix overflow count

* Add caption editing to gallery messages

* Use the new gallery string for prefix

* Lock sending galleries behind a feature flag

* Fix detekts

* Fix

* Ensure image edition is saved when navigating

* Fix sending media broken on edited gallery.

* Fix tests

* Order imports

* Remove unused parameters.

* Fix copyright header of new files.

* Fix Konsist test

* Extract new previews to a dedicated file.

* Sync strings

* Remove unused import

* Update screenshots

* Trigger CI

* Remove parameters with default value.

* More cleanup

* Restore sendAsFile behavior.

* Improve Preview.

* Improve Preview.

* Improve Preview.

* Fix gallery sending cancel and retry issue

* Ensure any previous job is cancelled.

* Fix issue in summary message

* Gallery feature is disabled by default.

* Kotlin convention

* Remove useless parenthesis

* Update screenshots

* Fix test

* List -> ImmutableList

* Remove useless code.

* Render formatted caption for attachment list.

* Replace set of Booleans by an enum

* Remove unused model for individual caption in a gallery Event.

* Fix tests

* Fix tests

* Rework MediaViewer entry point.

And ensure that the clicked image from the gallery is displayed first.

* Ensure gallery item can be click in the pinned message list
Improve the gallery item click handling code.

* Improve code and fix separator color
Closes #7101

* React on attachment item click
Improve code

* Improve code and support 0 items in gallery.

* Fix click on attachment item not rendering anything.

---------

Co-authored-by: Benoit Marty <benoitm@element.io>
Co-authored-by: Benoit Marty <benoit@matrix.org>
Co-authored-by: ElementBot <android@element.io>
@bmarty bmarty added Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. PR-Wip For anything that isn't ready to ship and will be enabled at a later date labels Jun 26, 2026
@github-actions github-actions Bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Jun 26, 2026
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
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/SdXPCQ

@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.98783% with 328 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.55%. Comparing base (9e7ae34) to head (762823e).
⚠️ Report is 31 commits behind head on develop.

Files with missing lines Patch % Lines
...ctories/event/TimelineItemContentMessageFactory.kt 63.39% 8 Missing and 33 partials ⚠️
...braries/matrix/impl/media/GalleryItemInfoMapper.kt 0.00% 27 Missing ⚠️
...oid/libraries/matrix/impl/timeline/RustTimeline.kt 0.00% 18 Missing ⚠️
...s/impl/messagecomposer/MessageComposerPresenter.kt 29.16% 17 Missing ⚠️
...attachments/preview/AttachmentsPreviewPresenter.kt 86.79% 3 Missing and 11 partials ⚠️
...meline/components/event/TimelineItemGalleryView.kt 93.17% 2 Missing and 12 partials ⚠️
...droid/libraries/mediaupload/api/MediaUploadInfo.kt 22.22% 10 Missing and 4 partials ⚠️
...iewer/impl/datasource/TimelineMediaItemsFactory.kt 43.47% 10 Missing and 3 partials ⚠️
...braries/mediapickers/impl/DefaultPickerProvider.kt 0.00% 12 Missing ⚠️
...es/mediaviewer/impl/datasource/EventItemFactory.kt 87.09% 0 Missing and 12 partials ⚠️
... and 33 more
Additional details and impacted files
@@            Coverage Diff             @@
##           develop    #7112     +/-   ##
==========================================
  Coverage    80.55%   80.55%             
==========================================
  Files         2686     2701     +15     
  Lines        76357    77717   +1360     
  Branches     10271    10488    +217     
==========================================
+ Hits         61510    62606   +1096     
- Misses       10920    11059    +139     
- Partials      3927     4052    +125     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bmarty bmarty added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Jun 29, 2026
@github-actions github-actions Bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Jun 29, 2026
@bmarty bmarty marked this pull request as ready for review June 29, 2026 15:22
@bmarty bmarty requested a review from a team as a code owner June 29, 2026 15:22
@bmarty bmarty requested review from jmartinesp and removed request for a team June 29, 2026 15:22

@jmartinesp jmartinesp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've reviewed the first few classes and I've found some issues, mainly with the 'per-item media quality selector' feature, it disables some optimizations and they don't seem to work well together overall.

I'll continue testing and reviewing tomorrow.

Comment on lines -140 to -144
!isApplyingImageEdits) {
if (mediaAttachment.localMedia.info.mimeType.isMimeTypeVideo() && mediaOptimizationSelectorState.videoSizeEstimations.dataOrNull() == null) {
Timber.d("Waiting for video size estimations to be able to select the best video compression preset before pre-processing the media")
return@LaunchedEffect
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think removing this may be breaking selecting the highest preset available automatically in the 'per-media' media quality feature. e.g. your video is short, so it fits in the HS max upload size in high quality (1080p) but instead standard (720p) is selected.

Comment on lines +216 to +229
val config = MediaOptimizationConfig(
compressImages = mediaOptimizationSelectorState.isImageOptimizationEnabled
?: mediaOptimizationConfigProvider.get().compressImages,
videoCompressionPreset = mediaOptimizationSelectorState.selectedVideoPreset
?: mediaOptimizationConfigProvider.get().videoCompressionPreset,
)
preprocessMediaJob = coroutineScope.launch(dispatchers.io) {
preProcessAttachments(
attachments = attachmentsAndEdits.map { it.attachment },
mediaOptimizationConfig = config,
displayProgress = true,
sendActionState = sendActionState,
)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we need to re-run the pre-processing? Shouldn't this already have happened or be happening and we should just wait for it to finish?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It was not happening and the application was stuck when the user clicked the send buton. I will check the code again

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe some of the changes broke something related to this, or maybe there's some case we didn't realise could cause this pre-processing to be cancelled 🤔 .

@jmartinesp jmartinesp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok, here's another round of comments. I may have missed some stuff since the PR is huge, but I think once the issues with the per-item media quality feature are fixed, it should be mergeable.

@bmarty

bmarty commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

@jmartinesp I have pushed a few commits, but I'll do more user tests on my side.

@jmartinesp jmartinesp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems to work pretty well now, thanks! Great job making it work with the per-item media quality. I added a couple of nits, but nothing important.

My main concern is that some other clients (like Element Web) don't seem to support this event type and there is no fallback version. I guess that's why it's behind a FF.

@bmarty

bmarty commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

Thanks for the review @jmartinesp . I have pushed a fix and take your remark into account.

I am wondering when sendAsFile is true if you should display the media quality selection. This is a bit out of scope of this PR, just sharing this point.

@sonarqubecloud

sonarqubecloud Bot commented Jul 3, 2026

Copy link
Copy Markdown

@bmarty bmarty merged commit 8840e2f into develop Jul 3, 2026
32 of 34 checks passed
@bmarty bmarty deleted the feature/bma/galleryMessages branch July 3, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR-Wip For anything that isn't ready to ship and will be enabled at a later date

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants