Skip to content

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

Open
mahibi wants to merge 15 commits into
masterfrom
feature/5190/imageCompression
Open

Compress images and videos before upload + new upload/preview dialog + use system camera#6429
mahibi wants to merge 15 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 added 6 commits August 3, 2026 10:02
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>
@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 added 4 commits August 3, 2026 13:01
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>
@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 added 4 commits August 3, 2026 14:35
  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>
@mahibi mahibi added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Aug 3, 2026
..so the chips are visible

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
@mahibi
mahibi force-pushed the feature/5190/imageCompression branch from 93371fe to 63aeda9 Compare August 3, 2026 13:20
@mahibi mahibi added this to the 25.0.0 milestone Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

APK file: https://github.com/nextcloud/talk-android/actions/runs/30817504366/artifacts/8857588809
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 requested a review from jancborchardt August 3, 2026 13:38
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

4 participants