Skip to content

Compress images and videos before upload + new upload/preview dialog + use system camera - #6429

Merged
mahibi merged 16 commits into
masterfrom
feature/5190/imageCompression
Aug 7, 2026
Merged

Compress images and videos before upload + new upload/preview dialog + use system camera#6429
mahibi merged 16 commits into
masterfrom
feature/5190/imageCompression

Conversation

@mahibi

@mahibi mahibi commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator
  • resolve Use compression for images and files selected via gallery #5190

  • resolve replace photo camera code with intent to open system camera #2461

    Adds automatic compression of images and videos before upload in chat, replaces the old attachment picker/preview dialog with a new Compose-based
    one, and removes the app's built-in camera capture screen in favor of the system camera.

  • Compress images and videos before upload

    • New ImageCompressor/VideoCompressor utilities: images are downscaled and re-encoded as JPEG; videos are downscaled to 540p (short side) and
      transcoded via Media3 Transformer on a dedicated HandlerThread, keeping the main thread unblocked.
    • BitmapShrinker modernized to use ImageDecoder on API 28+ (single-pass decode+scale with automatic EXIF rotation for JPEG/HEIC), falling back to
      the previous BitmapFactory path on API 26/27.
    • UploadAndShareFilesWorker shows live "Compressing… X%" progress (via Transformer.getProgress()) before switching to the upload progress notification.
      --> this is just a temporary solution until in chat upload previews are implemented.
    • Fixes MIME-type resolution for file:// URIs (e.g. camera-captured photos/videos), which previously broke dialog/thumbnail detection since
      ContentResolver.getType() only handles content:// URIs.
  • New attachment preview/upload dialog

    • FileAttachmentPreviewFragment/FileAttachmentPreviewDialogCompose rewritten in Jetpack Compose, with thumbnails and per-file dimensions/size shown
      before sending.
  • Media quality setting

    • The compression toggle is now a "Sent media quality" setting under Settings, presented as a dialog with Original quality / Reduced quality
      options (previously a simple switch), persisted via AppPreferences.
  • Removed built-in camera

    • Deleted TakePhotoActivity, TakePictureViewModel, and the associated layout/drawables. Photo/video capture now goes through the system camera;
      PickImage, ConversationCreationActivity, ConversationInfoEditActivity, and ProfileActivity updated accordingly.

Assisted-by: Claude Code 2.1.199:claude-sonnet-5

🖼️ Screenshots/Videos

🏚️ Before 🏡 After
grafik grafik

Demonstration video

Screen_recording_20260803_150537.mp4

Settings

grafik grafik

TODO for followup PR's

As not to go even further off-topic with this PR it only focuses on the upload/preview dialog and not on the upload itself. So

is not part of this PR but should be a next step soon.
Although the order of the previews can be modified by drag and drop in this PR, the related code to upload and share does not yet respect this order. This must be part of a followup improvement.

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔖 Capability is checked or not needed
  • 🔙 Backport requests are created or not needed: /backport to stable-xx.x
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@mahibi mahibi self-assigned this Jul 28, 2026
@mahibi
mahibi requested a review from rapterjet2004 July 28, 2026 18:36
@mahibi mahibi added the 3. to review Waiting for reviews label Jul 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

APK file: https://github.com/nextcloud/talk-android/actions/runs/30387637532/artifacts/8699821637
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

@mahibi
mahibi force-pushed the feature/5190/imageCompression branch from cd7df8f to c950080 Compare July 28, 2026 18:44
@github-actions

Copy link
Copy Markdown
Contributor

APK file: https://github.com/nextcloud/talk-android/actions/runs/30388822788/artifacts/8700239068
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

@jancborchardt jancborchardt 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 would be nice to formulate and design it a bit less technical. Signal e.g. specifically calls it "Sent media quality" with an easy to understand "Low" and "High" setting.

I'd say we could have a single-select segmented button in the send flow with:

  • Original quality
  • Reduced quality

And last selected setting remembered. What do you think @nimishavijay

@mahibi

mahibi commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator Author

For reference: thats how signal does it in the send flow (in the left pic it is the (crossed) HD button):

grafik grafik

@mahibi
mahibi force-pushed the feature/5190/imageCompression branch from c950080 to fc85f80 Compare July 29, 2026 17:38
@github-actions

Copy link
Copy Markdown
Contributor

APK file: https://github.com/nextcloud/talk-android/actions/runs/30476294926/artifacts/8734032240
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

@nimishavijay

Copy link
Copy Markdown
Member

If we are able to have a fullscreen preview of the image before sending like in whatsapp,telegram, signal, etc, the HD/SD icon-only button is pretty standard. if that is not possible then the radio-style buttons in the current UI make sense :)

@mahibi mahibi added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Jul 30, 2026
@mahibi mahibi changed the title Compress images and videos before upload Compress images and videos before upload + new upload dialog + use system camera Jul 31, 2026
@mahibi
mahibi force-pushed the feature/5190/imageCompression branch from fc85f80 to b50fd6b Compare July 31, 2026 15:07
@github-actions

Copy link
Copy Markdown
Contributor

APK file: https://github.com/nextcloud/talk-android/actions/runs/30641574479/artifacts/8797835298
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

@mahibi mahibi changed the title Compress images and videos before upload + new upload dialog + use system camera Compress images and videos before upload + new upload/preview dialog + use system camera Jul 31, 2026
@mahibi
mahibi force-pushed the feature/5190/imageCompression branch 2 times, most recently from 19383a8 to 9267408 Compare July 31, 2026 18:44
@github-actions

Copy link
Copy Markdown
Contributor

APK file: https://github.com/nextcloud/talk-android/actions/runs/30656399981/artifacts/8803577048
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

@mahibi

mahibi commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator Author

@jancborchardt @nimishavijay which solution of the HQ selection do you prefer? Do you have more feedback for this current state?:

HQ_button HQ_text HQ_segmentedButton

@jancborchardt jancborchardt 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.

@mahibi I’d say the last one with the toggle on the bottom that has actual text. Makes it very clear every time.
It’s best to do it clear & safe in the beginning, we can still make it more obscure later if we notice it’s too much. Important is also that the last preference is remembered.

(Another option to merge the approaches and save space could of course be to have the icon in the top right, but then make it open a menu with 2 entries which have clear wording "Original quality" and "Reduced quality".)

@mahibi

mahibi commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator Author

@mahibi I’d say the last one with the toggle on the bottom that has actual text. Makes it very clear every time.

alright thanks for the quick feedback.
For the "remember" behavior: The default can be set in the settings. This will be the state that will be set whenever the dialog is opened. Same behavior as for other messengers.

@mahibi
mahibi force-pushed the feature/5190/imageCompression branch from 9267408 to 7431a45 Compare August 3, 2026 11:02
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

APK file: https://github.com/nextcloud/talk-android/actions/runs/30807911255/artifacts/8854216608
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

@mahibi mahibi added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Aug 3, 2026
@mahibi
mahibi requested a review from jancborchardt August 3, 2026 13:38

@rapterjet2004 rapterjet2004 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you remove HighQualityIcons.kt and replace it with the xml equivalent? Found here.

https://fonts.google.com/icons?selected=Material+Symbols+Outlined:high_quality:FILL@0;wght@400;GRAD@0;opsz@24&icon.query=hq&icon.size=24&icon.color=%23222222&icon.platform=android

Which can be used in Compose with painterResource. That way all the resources are in one place. If we keep them in code in it might be a pain to track them all later.

@mahibi
mahibi force-pushed the feature/5190/imageCompression branch from 63aeda9 to ef3749f Compare August 7, 2026 09:12
@mahibi

mahibi commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

Can you remove HighQualityIcons.kt and replace it with the xml equivalent? Found here.

https://fonts.google.com/icons?selected=Material+Symbols+Outlined:high_quality:FILL@0;wght@400;GRAD@0;opsz@24&icon.query=hq&icon.size=24&icon.color=%23222222&icon.platform=android

Which can be used in Compose with painterResource. That way all the resources are in one place. If we keep them in code in it might be a pain to track them all later.

Done 👍 . I was thinking "let's use the compose equivalent from now on" (but yeah, should have chosen a better place to save it of course) but it seems the official documentation from google still recommends to just download the XML:

...we recommend using Google Font Icons and download the XML file from the Android Tab to create an up-to-date Material Symbols style Icon.

https://developer.android.com/develop/ui/compose/graphics/images/material

@mahibi
mahibi requested a review from rapterjet2004 August 7, 2026 09:24
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

APK file: https://github.com/nextcloud/talk-android/actions/runs/31164884771/artifacts/8988875188
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

@mahibi
mahibi force-pushed the feature/5190/imageCompression branch from ef3749f to 42b18dd Compare August 7, 2026 09:26
mahibi added 16 commits August 7, 2026 11:26
Adds an optional compression step to the chat attachment upload flow,
covering both gallery-picked and camera-captured photos/videos.

  - Add ImageCompressor/VideoCompressor utilities: images are downscaled
    and re-encoded as JPEG; videos are downscaled to 540p short side and
    transcoded via Media3 Transformer on a dedicated HandlerThread so the
    main thread is never blocked.
  - Migrate the file attachment preview dialog to Jetpack Compose, adding
    thumbnails, per-file dimensions/size preview, and a "Compress images
    and videos" checkbox that updates the preview live.
  - Persist the compression choice as a user preference (default on),
    with a toggle in Settings.
  - Extend the existing upload notification to also show live progress
    ("Compressing… X%") while a video is being transcoded, by polling
    Transformer.getProgress(), before it turns into the upload progress
    notification.
  - Modernize BitmapShrinker to use ImageDecoder on API 28+ (single-pass
    decode+scale, automatic EXIF rotation for JPEG/HEIC), falling back to
    the previous BitmapFactory-based path on API 26/27.
  - Fix MIME-type resolution for file:// URIs (e.g. camera-captured
    photos/videos), which previously failed dialog/thumbnail detection
    since ContentResolver.getType() only handles content:// URIs.

Assisted-by: Claude Code 2.1.199:claude-sonnet-5

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Assisted-by: Claude Code 2.1.199:claude-sonnet-5

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Assisted-by: Claude Code 2.1.199:claude-sonnet-5

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Assisted-by: Claude Code 2.1.199:claude-sonnet-5

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Assisted-by: Claude Code 2.1.199:claude-sonnet-5

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Assisted-by: Claude Code 2.1.199:claude-sonnet-5

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Assisted-by: Claude Code 2.1.199:claude-sonnet-5

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
  Release the ExoPlayer's hardware decoder on ON_STOP (e.g. when the
  system camera launches on top to record), not just on dispose, to
  avoid contending with the camera's hardware encoder for codec
  resources.

Assisted-by: Claude Code 2.1.199:claude-sonnet-5

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
…see the chip

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
..so the chips are visible

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
For now the official recommendation from google is
"we recommend downloading Vector Drawable XML files from the "Android" tab on Google Fonts to get the latest Material Symbols."

https://developer.android.com/reference/kotlin/androidx/compose/material/icons/package-summary

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
@mahibi
mahibi force-pushed the feature/5190/imageCompression branch from 42b18dd to 79901ba Compare August 7, 2026 09:26
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

APK file: https://github.com/nextcloud/talk-android/actions/runs/31165927913/artifacts/8989198806
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

@mahibi
mahibi merged commit cb2177e into master Aug 7, 2026
16 of 22 checks passed
@mahibi
mahibi deleted the feature/5190/imageCompression branch August 7, 2026 10:35
@RoboPolaris

RoboPolaris commented Aug 7, 2026

Copy link
Copy Markdown

A great first step — thank you so much! This is a really important improvement for using Talk as an everyday messenger.

A few things that would make the experience even better:

  1. Visible compression progress
    It would be very helpful to have a clear visual indicator while a video is being compressed. At the moment, there is no %-display to see in my version and therefore it is not obvious that a compression process is running.

  2. Video preview in received messages
    When receiving a video, it would be great to see a muted preview directly in the chat without having to open the player first.

  3. Better fullscreen video player
    The player would benefit from a proper fullscreen option, automatic fitting to the screen, and automatic rotation/orientation handling.

  4. Higher video quality or selectable presets
    540p is quite low for normal everyday videos. 720p or 1080p (like Telegram) would be much more useful. Ideally with selectable presets (which would be better than any other messanger) such as:

    • Data saver: 540p
    • Standard: 720p
    • High quality: 1080p
    • Original
  5. Higher image resolution
    768 px is also quite low for photos. In my opinion, the short side should be at least 1080 px, while still keeping the option to send the original file.

Overall, this is a fantastic and very important step. With a little more flexibility in media quality and a few improvements to the video experience, Talk could become much more suitable as a real replacement for mainstream family and friends messengers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews AI assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use compression for images and files selected via gallery replace photo camera code with intent to open system camera

6 participants