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>
This commit is contained in:
Jorge Martin Espinosa 2025-08-11 17:22:46 +02:00 committed by GitHub
parent ffe183c952
commit a170d80cb3
174 changed files with 2152 additions and 340 deletions

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:724df787c6c033c40967bfc62de74e71613ef8221bfc18a9859fcc0b5fb9a8ca
size 394854
oid sha256:27cf5dae58f473d3fd9554b159aa925596c6316934ad4bb47069d5829fd0b28c
size 400237

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b9faa86b429960368f6df670817c8d7236434d83b6154f295e1100003838ae80
size 83633

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a4b9d7cfa35310566401bc031a2554e49ea71820b3050abc449f91fad3ad892a
size 394573
oid sha256:3aefd14cc6e89b89e0965042b69e4d005a3c243e02c27d7d16296d314ad0e377
size 399961

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3ccf51958e5757064087f6a589032b7bb25b30827ecfc7864f157a6da689a67c
size 51024
oid sha256:bb7b368caebda5198bf2c523318ae349f010b89da011bf649d25374cba32318c
size 59517

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:724df787c6c033c40967bfc62de74e71613ef8221bfc18a9859fcc0b5fb9a8ca
size 394854
oid sha256:27cf5dae58f473d3fd9554b159aa925596c6316934ad4bb47069d5829fd0b28c
size 400237

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:15782147de5dc2fda9d77f75694bba22d9998db5c245969baa192e87543387cf
size 50991
oid sha256:599542430fa68487a2114228f79e6d1c91f2ad3e495c6e969ba08d43de66ed49
size 59330

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9476e888ecf6ac7d374d146a8aa5bfa3ed66b0c4b722d46052b56d177a543733
size 89112
oid sha256:ab0aac7e1228338e9f5c1b5e1a939ae13e9af6b8128b2508d0d37756b3baee34
size 86550

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:36aa7ce68da79c229612156d1870c904a87482b64bc9eb262d2c52c1e813d31d
size 390438
oid sha256:ca6f96cb449f902205bb7eac111e98dbde38b0043640cd2264ecabed605ee758
size 395882

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:724df787c6c033c40967bfc62de74e71613ef8221bfc18a9859fcc0b5fb9a8ca
size 394854
oid sha256:27cf5dae58f473d3fd9554b159aa925596c6316934ad4bb47069d5829fd0b28c
size 400237

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:01a9e0fac77cb3d1b1915407f59c44a1a9aa870033eb14e7cf3b2ae51e403c76
size 72954

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:52ec4658e2f4f4d07f1ad9ea16ac288ca9fa49440656a4590f686ea17e9ea309
size 406043

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9677ef17b1c00248df44354599debe4af0f21998b3e0797a9e701d39d48abecc
size 56820

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f6184dbd6c3511f0d8a703bd86c1c85b77efbabcdbe0e116f4ce034a392f410e
size 54474

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:bd8d14ba4e202190b47fed580cf35c568c03d1aaaf8971b274a4ba9949176c9b
size 52870

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:aa743f37c2131ff63979836259ae9290c9937f23f4341e52e14418e3c23010bc
size 55003

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2945a3dfc8090c03755a8fefdf37b20e235a35fcb48ff5efce216100679999bd
size 49823

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5507dc3686ec765a56caca94180a8650a316744f6bf419a0c916229c1f973da7
size 47562