Skip to content

feat(chat): Add full screen in-app camera and media preview with editing - #2746

Draft
ToteMeiSter wants to merge 6 commits into
nextcloud:mainfrom
ToteMeiSter:feat/in-app-camera
Draft

ToteMeiSter wants to merge 6 commits into
nextcloud:mainfrom
ToteMeiSter:feat/in-app-camera

Conversation

@ToteMeiSter

Copy link
Copy Markdown
Contributor

Draft: tested in CI only, not on a device (no Xcode/iPhone available to the author).

Depends on #2745. The branch is stacked on it: until it is merged, the diff also shows its commit. Review only the last commit.

Refs #2744

Feature

An in-app camera replaces UIImagePickerController in the chat. The photos and videos to share are shown in a full screen preview that can be edited, before they are sent.

The same feature for Android: nextcloud/talk-android#6820 (issue nextcloud/talk-android#6815). Related: nextcloud/talk-android#6812 (video messages, shares the camera code).

Changes

One commit on top of the video message recording.

Camera (NextcloudTalk/Chat/Camera):

  • InAppCameraViewController: tap the shutter for a photo, hold it for a video (up to 300 s). Flash off/auto/on (the last mode is remembered), front/back camera.
  • Photos are taken at the full size of the camera. The microphone is only used while a video is recorded.
  • The shutter stays at the bottom edge of the device, only the icons rotate. On an iPad (the orientation lock is ignored there) the controls follow the edges of the device body. Flat on a table, the last held orientation is used.
  • Not offered during a call or without a camera.
  • CameraCaptureHelpers: shared with the video message recorder, extended by the interface orientation and the layout update when a session starts.
  • BaseChatViewController: the "Camera" action of the menu opens the in-app camera. UIImagePickerControllerDelegate, UINavigationControllerDelegate and the picker code are removed. The result goes through the upload confirmation, with the text of the input field as the caption.

Preview (built into the existing ShareConfirmationViewController, plus MediaPreviewViews.swift):

  • Full screen items, swipe between them, "2 of 5" counter, caption on top, tool bar: Add more (camera / photos / files), crop and rotate (existing TOCropViewController), draw (system QuickLook markup), remove. All existing send options stay.
  • At most 10 items at once (the photo picker limit was 20).
  • ShareItemController: an edited photo is stored as JPEG 0.95 (a PNG stays a PNG), the longest side is limited to 4096 pixels.

Tests: UnitInAppCameraTest (flash modes, file names, durations, orientation logic).
Strings: only the strings of this change (15 new, 2 plural rules). Info.plist: the camera usage description is extended. No new dependencies.

How to test

Not built or run locally. Build and unit tests: CI only. CI in the fork on the same commit: Build, SwiftLint and all 5 test jobs (main, stable23, stable32, stable33, stable34) passed, run https://github.com/ToteMeiSter/talk-ios/actions/runs/37227743324. SwiftLint: no new warnings or errors compared to main. check-localizable-plurals.sh passes.

Manual, on a device (expected results, not verified):

  1. In a conversation: "+" > "Camera". Tap the shutter: the photo opens in the full screen preview with the caption of the input field.
  2. Hold the shutter: a video is recorded (timer shown), release: the video opens in the preview.
  3. Flash modes and the camera switch work; the flash mode is kept the next time.
  4. Rotate the device (iPhone and iPad, also in split view and flat on a table): the shutter stays at the bottom edge of the device, photos and videos have the right orientation.
  5. In the preview: swipe between items, crop and rotate, draw, remove, "Add more" (camera / photo library / files). The 11th item is refused with a message.
  6. Send with and without a caption; check the uploaded photo is the edited one.
  7. Start a call, then open the camera: it is refused with a message.
  8. Share extension: select photos in another app, check the preview there (no camera in the extension).

AI disclosure

This change was prepared with AI assistance (Claude Code, model claude-opus-5-5): code reading, the implementation, the tests and this description. Commits carry Assisted-by: Claude-Code:claude-opus-5-5. The change was reviewed by the author. It was not built or tested on a device (no Xcode or iPhone available to the author).

馃 Generated with Claude Code

Let the user switch the record button of the chat input between voice and
video messages. Tapping the button toggles the mode (the choice is stored in
the user defaults), holding it records, like for voice messages: slide to cancel,
slide up to lock the recording, 60 seconds at most. Too short videos are dropped.
The front and the back camera can be switched while recording.

The video is recorded as H.264/AAC MP4 (1280x720 preset, portrait) with
AVCaptureVideoDataOutput and AVCaptureAudioDataOutput feeding an AVAssetWriter.
AVCaptureMovieFileOutput is not used: removing the video input to switch the
camera tears down its connection and ends the recording, the writer is not
part of the capture graph. The audio session is restored afterwards.

The recording is uploaded as an ordinary file. The upload path of voice
messages is shared (shareRecording), but without a temporary message and
without the voice message type. File names do not clash within one second.

The camera helpers (camera lookup, input replacement, rotation of the output,
live preview, audio session restore) live in CameraCaptureHelpers.swift.

The usage descriptions of camera and microphone mention the video recording.

Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru>
Assisted-by: Claude-Code:claude-opus-5-5
Replace UIImagePickerController in the chat with an in-app camera, and show
the photos and videos to share in a full screen preview that can be edited.

Camera (NextcloudTalk/Chat/Camera):
- Full screen camera with photo (tap) and video (hold) from one shutter
  button, flash modes (the last one is remembered), front/back camera switch.
- Photos are taken at the full size of the camera and the microphone is
  only used while a video is recorded.
- The controls follow the orientation of the device and the shutter stays at
  the bottom edge of the device, also on an iPad and when the device lies
  flat (the last held orientation is used then).
- The camera is not offered during a call or when none is available.
- The result is uploaded through the same confirmation as before, with the
  text of the input field as the caption. All of UIImagePickerController is
  removed from the chat.

Preview (ShareExtension):
- The confirmation screen shows the items in a full screen preview with a
  caption field, a counter, "Add more" (camera, photo library, files),
  crop and rotate, and drawing (QuickLook markup).
- At most 10 items can be added at once.
- An edited photo is stored as JPEG (PNG stays PNG), its longest side is
  limited to 4096 pixels.

Unit tests cover the flash modes, file names, durations and the orientation
logic of the camera.

Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru>
Assisted-by: Claude-Code:claude-opus-5-5
The preview of a video message recording is placed by a pure function in the
free space between the safe area and the recording panel: 9:16 in portrait and
16:9 in landscape, 16 pt from the edges, at most 75 % of the width. It is placed
again on rotation, when the panel of a locked recording appears and after the
camera was switched, and its frames follow the orientation of the interface.
The recorded file keeps the orientation the recording started in.

The chat is dimmed under the preview, which keeps the touches away from it, and
VoiceOver does not read the chat while recording.

Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru>
Assisted-by: Claude-Code:claude-opus-5-5
A locked video recording no longer opens the tall panel of the voice message:
it stays in the row of the inputbar, which shows the indicator and the time,
and gets a cancel button in the row and a send button over the record button.
The preview takes the freed height. Voice messages keep their panel, which
loses the pause switch that only videos needed.

Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru>
Assisted-by: Claude-Code:claude-opus-5-5
Overlays that appear while recording (pinned message, out of office) are added
below the dimming, VoiceOver gets its focus moved to the preview and does not
read the record button under the send button of a locked recording, the send
button uses the colors of the theme, the orientation of the start is read in
one way, and the test of the centering has room for rounding.

Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru>
Assisted-by: Claude-Code:claude-opus-5-5
The handler of the record button gets one branch more with the locked video
recording, which raised its cyclomatic complexity. The locking is its own
function now, and the handler is as complex as before.

Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru>
Assisted-by: Claude-Code:claude-opus-5-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant