Commit Graph

75 Commits

Author SHA1 Message Date
Benoit Marty
b3ec256dfa 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
1292da2a72 Copyright: Add Element Creations Ltd. copyright 2025-11-10 11:05:05 +01:00
Benoit Marty
b748fcc631 Copyright: Add final period 2025-11-10 10:13:41 +01:00
Benoit Marty
0a0224b586 Copyright: run command uv run license-editor --repository ../element-x-android 2025-11-10 10:09:26 +01:00
Benoit Marty
826cacf209 Remove @Inject, not necessary anymore when class is annotated with @ContributesBinding 2025-10-22 18:52:37 +02:00
Benoit Marty
c242ad98a7 Remove unused dependency on javax.inject:javax.inject 2025-10-02 10:25:54 +02:00
Benoit Marty
629fc552e5 Use DependencyHandlerScope.testCommonDependencies() 2025-09-16 14:38:31 +02:00
Jorge Martín
e06bacbff3 Redo DI gradle setup code 2025-09-04 16:49:20 +02:00
Jorge Martín
fc3153bd26 Fix lint issues and restore commented out code 2025-09-04 16:49:18 +02:00
Jorge Martín
92a4b8b66b Start migrating Anvil KSP to Metro 2025-09-04 16:48:34 +02:00
Jorge Martin Espinosa
8c1c0b63bd 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
d9dde270b2 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
a170d80cb3 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
Jorge Martin Espinosa
6c184076a9 Calculate video output size taking into account portrait mode (#5068) 2025-07-23 14:19:08 +02:00
Jorge Martin Espinosa
b219c05d06 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
2c325df32f Replace video transcoder with Media3 Transformer (#5018) 2025-07-15 11:08:56 +02:00
Jorge Martin Espinosa
fb318ad6fe Keep video rotation metadata when transcoding (#5008) 2025-07-10 15:02:42 +00:00
Benoit Marty
aeb750439c Fix test regression on API 33. 2025-06-30 17:01:01 +02:00
Jorge Martin Espinosa
58a3ea8b1f 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
Jorge Martin Espinosa
3d64afa937 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
fe5d9b4308 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
Jorge Martin Espinosa
f72fb9650b 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
05fc76822a 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
22bb8796ef Delete temporary created files. 2024-11-08 10:11:06 +01:00
Benoit Marty
be42821352 Add a log when deleting a file. 2024-11-08 10:11:06 +01:00
Jorge Martin Espinosa
e841faa737 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
1b6a759847 Fix test. 2024-10-31 18:05:13 +01:00
Benoit Marty
7d54cb8f63 Rename file. 2024-10-31 18:01:56 +01:00
Benoit Marty
26d8b74255 Compress png file and generate png thumbnail for png files.
Fix tests
2024-10-31 15:51:45 +01:00
Benoit Marty
9f0461166e Optimize media: Compress Png to Png. 2024-10-31 11:04:11 +01:00
Benoit Marty
ea73ee0481 Optimize media: always compress video to have maximum 1080 at the greatest size. 2024-10-31 10:53:44 +01:00
Benoit Marty
7c4f389d0b Fix test. 2024-10-28 13:52:53 +01:00
Benoit Marty
2531ccf8e9 Add media upload setting.
Compress media regarding the settings.
Image compression change quality to 78%
Video compression change size to 720 x 48
2024-10-28 10:56:58 +01:00
Jorge Martin Espinosa
2efdb3ae45 Centralise the DI code generation logic (#3562)
* Create Anvil extension helper

* Use the helper everywhere
2024-09-30 12:20:28 +00:00
Benoit Marty
2b016227e9 Migrate license to AGPL.
Run script `uv run license-editor --repository ../element-x-android`
2024-09-06 17:19:19 +02:00
Jorge Martin Espinosa
950e502ca6 Improve screenshot testing with ComposablePreviewScanner (#3125)
* Use ComposablePreviewScanner to rework how screenshot testing works
* Add test sharding
* Update screenshots
* Fixes for Element Gallery

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
Co-authored-by: Benoit Marty <benoit@matrix.org>
2024-07-03 13:05:06 +02:00
Jorge Martin Espinosa
801f0b955d Notifications: simplify the flow by removing persistence (#2924)
* Notifications: simplify the flow by removing persistence. 
* Bump of minSdk to `24` (Android 7).
* Add migration to remove `notification.bin` file
2024-05-29 08:03:23 +00:00
Benoit Marty
378692f743 Fix moar ktlint issues 2024-01-11 10:02:10 +01:00
renovate[bot]
7e9cda3aa9 Update plugin ktlint to v12.1.0 (#2200)
* Update plugin ktlint to v12.1.0

* Run `./gradlew ktlintFormat` and fix some issues manually.

* Fix other issues reproted by Ktlint

* Limit false positives, KtLint removes unnecessary curly brace in String templates.

* Remove useless Unit

* Minor improvements over ktlint changes

* Restore `AlertDialogContent` behaviour

* Update screenshots

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Benoit Marty <benoit@matrix.org>
Co-authored-by: Jorge Martín <jorgem@element.io>
Co-authored-by: ElementBot <benoitm+elementbot@element.io>
2024-01-10 16:22:24 +01:00
Benoit Marty
3d963df4fe Move files to correct package. 2023-12-19 11:07:12 +01:00
Benoit Marty
e156cf0515 Restore test for image sending, now that computing Thumbnail can fail. 2023-12-19 11:05:40 +01:00
Benoit Marty
4cd3faf936 ThumbnailUtils.createImageThumbnail can throw IOException, and we can ignore it. 2023-12-19 10:47:31 +01:00
Benoit Marty
0f7af2b7fc blurhash cannot be null here 2023-12-19 10:43:28 +01:00
Benoit Marty
55ce9068ef Providing a thumbnail when sending a media is now optional. 2023-12-19 10:41:44 +01:00
Benoit Marty
955b315597 Cleanup 2023-11-29 17:27:16 +01:00
Benoit Marty
8bf5d5eee8 Disable failing tests for AndroidMediaPreProcessor 2023-11-29 17:03:27 +01:00
Benoit Marty
fcd8b86c64 Add tests for AndroidMediaPreProcessor 2023-11-29 17:03:27 +01:00
Benoit Marty
475bf376f9 Provide CoroutineDispatchers to ImageCompressor 2023-11-29 17:02:38 +01:00
Benoit Marty
04be1f0385 Use kotlin.time.Duration instead of java.time.Duration. Also use Duration in TimelineItemVideoContent, like in TimelineItemAudioContent and TimelineItemVoiceContent 2023-11-27 21:58:58 +01:00
jonnyandrew
5c582bba1b Record and send voice messages (#1596)
---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
2023-10-23 17:28:00 +00:00