Commit graph

110 commits

Author SHA1 Message Date
Gianluca Iavicoli
523ede744a
Fix portrait image metadata when uploading without media optimization (#6362)
* fix(media): preserve image orientation metadata without optimization

* style: linting
2026-04-08 11:01:54 +02:00
Jorge Martin Espinosa
23f105442e
Remove all video metadata (#6224)
Use `InAppMp4Muxer` with a custom metadata provider that removes all metadata entries
2026-02-18 16:51:44 +00:00
Jorge Martin Espinosa
8e3e0951e7
Use the right video preset when sharing videos (#5892) 2025-12-16 16:40:44 +01:00
Benoit Marty
24e3705671 run command ./gradlew ktlintFormat :) 2025-12-04 10:18:19 +01:00
Benoit Marty
8285478688 API modules do not need to setup dependency injection.
Move the implementation to the impl modules.
2025-11-12 19:05:39 +01:00
Benoit Marty
eb31505dc7 Copyright: Add Element Creations Ltd. copyright 2025-11-10 11:05:05 +01:00
Benoit Marty
f86431e663 Copyright: Add final period 2025-11-10 10:13:41 +01:00
Benoit Marty
c4e0370f41 Copyright: run command uv run license-editor --repository ../element-x-android 2025-11-10 10:09:26 +01:00
Benoit Marty
263e761907 Remove @Inject, not necessary anymore when class is annotated with @ContributesBinding 2025-10-22 18:52:37 +02:00
Benoit Marty
b6d23b2508 Remove unused dependency on javax.inject:javax.inject 2025-10-02 10:25:54 +02:00
renovate[bot]
5b9ce7a210
Update metro to v0.6.7 (#5416)
* Update metro to v0.6.7

* Replace `@Inject` with `@AssistedInject` where needed

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jorge Martín <jorgem@element.io>
2025-09-26 08:16:36 +00:00
Benoit Marty
a575019760 Use DependencyHandlerScope.testCommonDependencies() 2025-09-16 14:38:31 +02:00
Jorge Martín
4ab62a6a38 Redo DI gradle setup code 2025-09-04 16:49:20 +02:00
Jorge Martín
29a97fc0d9 Fix lint issues and restore commented out code 2025-09-04 16:49:18 +02:00
Jorge Martín
b76a71ebf5 Start migrating Anvil KSP to Metro 2025-09-04 16:48:34 +02:00
Jorge Martin Espinosa
fa755e5b75
Use variable bitrate mode when transcoding to ensure compatibility with old devices (#5223)
* Use variable bitrate mode when transcoding

This should be compatible with more devices that may lack the needed codecs to properly encode using constant bitrate mode (CBR).

* Fix video output size (again)
2025-08-26 10:41:07 +02:00
Jorge Martin Espinosa
6e6440940f
Add extra logs for sending media (#5218)
* Add extra logs for sending media

We have some issues with stuck media uploads that could use some logs to understand where the process gets stuck.

* Fix mocks for test
2025-08-26 07:02:15 +00:00
Jorge Martin Espinosa
35928e3630
Threads - first iteration (#5165)
* Initial threads support: parse `ThreadSummary`.

Replace several `isThreaded` values with `EventThreadInfo`, which contains the info about the event either being the root of a thread or part of it.

* Add `Threaded` timeline mode

* Add a `liveTimeline` parameter to `TimelineController`'s  constructor. This way we can customise which timeline will be used as the 'live' one. Also add `@LiveTimeline` DI qualifier for the actual live timeline of the room.

* Create `ThreadedMessagesNode`. Allow opening a thread in a separate screen.

* Add the callbacks for the list menu actions - even if they're the wrong ones and will send the data to the room instead

* Send attachments and location in threads

* Fix polls in threads, add support for sending voice messages in threads

* Display thread summaries only when the feature flag is enabled

* Use 'Reply' instead of 'Reply in thread' when in threaded timeline mode

* Remove incorrect usage of `Timeline` in `MessageComposerPresenter`. This led to replies to threaded events not appearing as actual replies.

---------

Co-authored-by: ElementBot <android@element.io>
2025-08-19 13:35:48 +00:00
renovate[bot]
90ad9616c0
Update dependency org.matrix.rustcomponents:sdk-android to v25.8.18 (#5182)
* Update dependency org.matrix.rustcomponents:sdk-android to v25.8.18

* Fix broken API changes:
- The send queue usage is now mandatory.
- The media upload progress now comes back in the send queue state (this still hasn't been applied to the UI in the timeline).

* Update screenshots
---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jorge Martín <jorgem@element.io>
Co-authored-by: ElementBot <android@element.io>
2025-08-18 16:41:14 +02:00
Jorge Martin Espinosa
adc61b3826
Add media file limit size warning and media quality selection (#5131)
* Add `VideoCompressorPreset` enum

This represents the different compression presets used for processing videos before uploading them

* Add `VideoCompressorHelper` util class to calculate the scaled output size of the video given an input size and its optimal bitrate

Also add `MediaOptimizationConfig` which will be used to decide how to apply compression in `MediaPreProcessor`

* Add `RustMatrixClient.getMaxFileUploadSize()` function and `MaxUploadSizeProvider` so we can import only this functionality into other components

* Try preloading the max file upload size the first time we get network connectivity - it's a best effort

This should help ensure we'll have this value available later, even if we still need to load it asynchronously.

* Split the `compressMedia` preference into `compressImages` and `compressMediaPreset`

* Modify the media processing parts to use the new classes and utils

* Add `MediaOptimizationSelectorPresenter`, which will retrieve the compression values and the max file upload size, also estimating the compressed video file sizes if needed.

* Add a feature flag to allow selecting the media upload quality per upload

* Integrate the previous changes with the attachments preview screen

Add strings from localazy too.

* Adapt the rest of the app calls to upload media to using the media optimization configs

* Allow modifying the default compression values in advanced settings, based on the feature flag value

* Pass the `fileSize` in `MediaUploadInfo` too, to be able to check it against the `maxUploadSize`

* Update screenshots

---------

Co-authored-by: ElementBot <android@element.io>
2025-08-11 17:22:46 +02:00
renovate[bot]
040fde7f22
Update dependency org.matrix.rustcomponents:sdk-android to v25.7.23 (#5073)
* Update dependency org.matrix.rustcomponents:sdk-android to v25.7.23

* Adapt to SDK changes:

- Add 'creator' role, adapt existing logic to it.
- Remove `ReplyParameters`, replace with `EventId` where possible.
- Fix changes in OIDC auth methods.
- Add more join rules.

* Make sure both creators and users with power level >= 150 are displayed as 'owners' in the room member list.

* Don't close the roles and permissions screen if the user is a creator

* Use `MediaPreviewValue.DEFAULT` for `MediaPreviewConfig.DEFAULT` too

* Improve APIs around checking roles and power levels:
    - Ensure `RoomInfo.RoomPowerLevels.users` can't be directly used to check power levels since it can't check the power levels for creators.
    - Add a few helper functions to handle actions that relied on the previous `users` property, and docs to explain their usages.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jorge Martín <jorgem@element.io>
2025-07-24 11:58:30 +02:00
Jorge Martin Espinosa
33aa7a914f
Calculate video output size taking into account portrait mode (#5068) 2025-07-23 14:19:08 +02:00
Jorge Martin Espinosa
d53457ec66
Make sure we clean up the pre-processed and uploaded media (#5039)
* Add `MediaSender.cleanUp()` and `MediaPreProcessor.cleanUp()` methods: this will remove the temporary files created when pre-processing media before sending them.

* Make sure we clean up also the previous temporary media.

* Fix the condition for the custom back handler in the attachments preview screen

* Tests: check the clean up is performed when needed
2025-07-23 08:55:20 +02:00
Jorge Martin Espinosa
e8154ec19d
Replace video transcoder with Media3 Transformer (#5018) 2025-07-15 11:08:56 +02:00
Jorge Martin Espinosa
9994562e60
Keep video rotation metadata when transcoding (#5008) 2025-07-10 15:02:42 +00:00
Benoit Marty
06a551c388 Fix test regression on API 33. 2025-06-30 17:01:01 +02:00
Jorge Martin Espinosa
efdc10e60a
Add catchingExceptions method to replace runCatching (#4797)
- Add `runCatchingExceptions` and `mapCatchingExceptions` to replace `runCatching` and `mapCatching`.
- Make `tryOrNull { ... }` catch only exceptions too.
- Apply the changes to the whole project.
- Add new Rust fakes for tests to handle the code that's now unblocked - previously it just threw an `UnsatisfiedLinkError` which we ignored.
- Add a new `detekt-rules` project with a `RunCatchingRule` to prevent `runCatching` and `mapCatching` usages.
2025-06-04 09:02:26 +02:00
Benoit Marty
4572419ed2
Stronger lambda error (#4771)
* Make sure lambdaError() make the test fail in all circumstances.

* Fix existing errors on tests.

* Uniformize the way we are creating class under test.

* Cleanup

* Fix typo

* Fix failing test after rebase.
2025-05-27 15:32:09 +00:00
Benoit Marty
8d115213cc
Reduce API of JoinedRoom, caller must use the Timeline API from liveTimeline instead. (#4731)
This removes lots of boilerplate code.
2025-05-20 09:07:43 +02:00
Jorge Martin Espinosa
c9ec26f87c
When transcoding a video fails, send it as a file (#4257)
- If the video can't be transcoded it will be uploaded as a file instead.
- If the video already has the right format and dimensions, don't transcode it.
- Update the dimensions to 720p max when enabling media compression and 1080p otherwise, matching Element X iOS.
2025-05-13 11:04:51 +00:00
Jorge Martin Espinosa
619aa6f2de
Split MatrixRoom into BaseRoom and JoinedRoom (#4561)
`JoinedRoom` will now contain both a mandatory live timeline reference and all the functionality associated to it.

`BaseRoom` on the other hand will contain only functionality that's shared for both joined and not joined rooms.

`NotJoinedRoom` is a wrapper around `RoomPreviewInfo` data and a possible local `BaseRoom`, if it exists.

The `RustRoomFactory` cache is now gone since the persistent event cache should have the same effect.
2025-04-23 15:53:40 +02:00
Jorge Martin Espinosa
f9c00ac99d
Send SVG images as files (#4595)
Since Android doesn't have support for SVG files we can't create a thumbnail or get the dimensions and other metadata needed for the `m.image` message type, so we need to send them as plain files
2025-04-15 17:05:09 +02:00
renovate[bot]
b9385ce382
fix(deps): update dependency org.matrix.rustcomponents:sdk-android to v25.4.7 (#4548)
* fix(deps): update dependency org.matrix.rustcomponents:sdk-android to v25.4.8

* Fix API breaks:

- Add `ReplyParameters` class and parameters to send functions.
- Remove outdated OIDC related values.
- Stop pre-processing the timeline to add the timeline start item, this is already done by the SDK.

* Use the new function to reply to messages in a quick reply from a notification, however:

1. We don't have the thread id value at the moment since the SDK does not provide it yet.
2. The replied to event id wasn't being passed from the notification info.

* Remove also timeline start virtual item for DMs, since this wasn't present before either

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jorge Martín <jorgem@element.io>
2025-04-08 14:21:49 +02:00
Jorge Martin Espinosa
65ce91a8fb
Close the media preview screen ASAP with sending queue enabled (#4089)
* Close the attachment preview screen ASAP when sending media with the send queue is enabled

* When the send queue FF is not enabled make sure to dismiss the screen after the media has been sent

* Make sure we get a scaled thumbnail from videos too, not only for images

* Unify several state holders into `SendActionState`.

* Fix lint issues, add `Flow.firstInstanceOf` extension fun

* Update screenshots

---------

Co-authored-by: ElementBot <android@element.io>
2025-01-08 15:49:17 +00:00
Benoit Marty
97f3be3dc5 Apply dual licenses: AGPL + Element Commercial to file headers.
2 replace all actions have been performed:
- "SPDX-License-Identifier: AGPL-3.0-only" to "SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial"
- "Please see LICENSE in the repository root for full details." to "Please see LICENSE files in the repository root for full details."
2025-01-07 10:05:04 +01:00
Benoit Marty
008a554ca6 Remove default parameter values.
This improve code coverage since some default value was never used.
2024-11-26 09:18:11 +01:00
Benoit Marty
b9caede2d3 Remove blank line 2024-11-26 09:17:39 +01:00
Benoit Marty
c1507fb24e Pre-process media during the attachment preview 2024-11-25 17:11:31 +01:00
Benoit Marty
4a5259f1d9 Fix tests 2024-11-21 09:45:27 +01:00
Benoit Marty
042d079b0a Allow caption for audio and file.
Need to preview all the attachments now, to be able to type a caption.
2024-11-21 09:45:26 +01:00
Benoit Marty
585b6a94f3 Delete temporary created files. 2024-11-08 10:11:06 +01:00
Benoit Marty
0c841442d9 Add a log when deleting a file. 2024-11-08 10:11:06 +01:00
Benoit Marty
58a0875c5d Do not delete the original file when sending a media. Fixes #3800. 2024-11-08 10:11:06 +01:00
Benoit Marty
13ec1838c0 MediaPreProcessor: remove default value of parameter deleteOriginal. No functional change here. 2024-11-08 10:11:06 +01:00
Benoit Marty
223eae9602 Send caption with media 2024-11-04 14:24:39 +01:00
Jorge Martin Espinosa
f7861acd7f
Remove all GPS metadata from images uploaded as media (#3781)
Previously a minimal set of tags were removed, but we should make sure every single one of them is removed.
2024-11-04 10:31:55 +01:00
Benoit Marty
1061ea0679 Fix test. 2024-10-31 18:05:13 +01:00
Benoit Marty
48133dcca4 Rename file. 2024-10-31 18:01:56 +01:00
Benoit Marty
74037514c0 Compress png file and generate png thumbnail for png files.
Fix tests
2024-10-31 15:51:45 +01:00
Benoit Marty
1c7b3df10e Optimize media: Compress Png to Png. 2024-10-31 11:04:11 +01:00