Skip to content

Open camera to take and share a photo #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gnprice opened this issue Apr 11, 2023 · 3 comments · Fixed by #70
Closed

Open camera to take and share a photo #61

gnprice opened this issue Apr 11, 2023 · 3 comments · Fixed by #70
Labels
a-compose Compose box, autocomplete, attaching files/images

Comments

@gnprice
Copy link
Member

gnprice commented Apr 11, 2023

This is the feature indicated by a "camera" icon below the compose box in the zulip-mobile RN app. It's a standard, expected feature for a messaging application on a mobile device.

Flutter has a first-party plugin for this: https://pub.dev/packages/camera and that's probably what we want to use.


Further notes on the camera plugin:

The plugin's Android implementation is being rewritten to use Android's new CameraX API.

  • Design doc gives some background:

    There are a large number of device-specific issues with the current Android camera implementation (about 30% of all filed camera issues). These issues are extremely difficult for us to tackle since they may require access to specific devices, involve hardware issues, or require undocumented or hacky workarounds.

    Android upstream has invested in solving that problem (see the photo of an automated physical-phone-with-camera test lab in the CameraX doc), and CameraX is the result.

  • Tracked as a GitHub project board; see as issue search.

    • It looks like work on implementing this project started around the beginning of 2023. Perhaps it'll be finished later in 2023?
  • So at present the plugin is less reliable on Android than one would like. But probably our best path to solve that is to just go ahead and use the first-party plugin, and wait for it to improve with the switch to CameraX.

Meanwhile on the iOS side:

  • Filtering to iOS issues: 28 open, of 66 total. See ranked by upvotes.
    • All have far fewer upvotes than the top-voted Android issues, indicating there aren’t a lot of developers running into them.
    • The top few issues don’t look too concerning: specific to uncommon use cases like taking video, or happen infrequently.
    • Some of the top issues that do look relevant: #25959 latency; #89216 a messy issue about camera orientation.
chrisbobbe added a commit to chrisbobbe/zulip-flutter that referenced this issue Apr 13, 2023
As Alex points out in discussion:
  https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/flutter.3A.20http.20.60Client.60/near/1545511

> Looks like doing so will allow connection reuse, which is a great
> performance boost, particularly with HTTP/2.

So that seems good. This will also help with file uploads (zulip#56, zulip#57,
and zulip#61) because http.Client has a `send` method --
  https://pub.dev/documentation/http/latest/http/Client/send.html
-- that we can use for requests we want more control over (in
particular, a file-upload request), and a counterpart toplevel
convenience function like `http.send` isn't offered.

See doc:
  https://pub.dev/documentation/http/latest/http/Client-class.html
chrisbobbe added a commit to chrisbobbe/zulip-flutter that referenced this issue Apr 14, 2023
As Alex points out in discussion:
  https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/flutter.3A.20http.20.60Client.60/near/1545511

> Looks like doing so will allow connection reuse, which is a great
> performance boost, particularly with HTTP/2.

So that seems good. This will also help with file uploads (zulip#56, zulip#57,
and zulip#61) because http.Client has a `send` method --
  https://pub.dev/documentation/http/latest/http/Client/send.html
-- that we can use for requests we want more control over (in
particular, a file-upload request), and a counterpart toplevel
convenience function like `http.send` isn't offered.

See doc:
  https://pub.dev/documentation/http/latest/http/Client-class.html
chrisbobbe added a commit to chrisbobbe/zulip-flutter that referenced this issue Apr 17, 2023
As Alex points out in discussion:
  https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/flutter.3A.20http.20.60Client.60/near/1545511

> Looks like doing so will allow connection reuse, which is a great
> performance boost, particularly with HTTP/2.

So that seems good. This will also help with file uploads (zulip#56, zulip#57,
and zulip#61) because http.Client has a `send` method --
  https://pub.dev/documentation/http/latest/http/Client/send.html
-- that we can use for requests we want more control over (in
particular, a file-upload request), and a counterpart toplevel
convenience function like `http.send` isn't offered.

See doc:
  https://pub.dev/documentation/http/latest/http/Client-class.html
@chrisbobbe
Copy link
Collaborator

chrisbobbe commented Apr 18, 2023

For this feature, a convenient API will let us take the user to a native camera UI, then take them back to the app with a picture or video so we can upload it.

I'm not finding an API like that in the camera library. I do see that it gives access to the camera, but in a different way: from within the app, you can call things like takePicture, startVideoRecording, and stopVideoRecording, and you can show a live preview of what the camera sees, with the CameraPreview widget. It seems like in theory we could use this to build a custom photo/video-capturing UI ourselves, but I think we should just take user to a camera UI from the platform.

At a glance, it looks like Flutter's first-party plugin image_picker looks like it has what we'd want for that. It looks like we already plan to use that for:

@chrisbobbe
Copy link
Collaborator

Hmm, ideally we'd open a platform interface that lets you choose between taking a photo and a video. image_picker doesn't yet have that option: flutter/flutter#89159

Would it be clunky to have two buttons for camera capture: one for photos, and one for videos?

Also, zulip-mobile doesn't offer uploading from captured video either, so I guess one option pending flutter/flutter#89159 is to leave video-capturing as a TODO.

@gnprice
Copy link
Member Author

gnprice commented Apr 18, 2023

It seems like in theory we could use this to build a custom photo/video-capturing UI ourselves,

Hmm, I see. Yeah, that's not the kind of API we want here. I guess image_picker is the upstream solution for the interaction we do want.

I think it's fine to not support taking a video.

chrisbobbe added a commit to chrisbobbe/zulip-flutter that referenced this issue Apr 19, 2023
So far we've used this code for the generic upload-file UI (zulip#57).
Soon we'll use it for media-library uploads (zulip#56) and camera uploads
(zulip#61).
chrisbobbe added a commit to chrisbobbe/zulip-flutter that referenced this issue Apr 19, 2023
Toward zulip#61, "Open camera to take and share a photo".
chrisbobbe added a commit to chrisbobbe/zulip-flutter that referenced this issue Apr 19, 2023
chrisbobbe added a commit to chrisbobbe/zulip-flutter that referenced this issue Apr 22, 2023
So far we've used this code for the generic upload-file UI (zulip#57).
Soon we'll use it for media-library uploads (zulip#56) and camera uploads
(zulip#61).
chrisbobbe added a commit to chrisbobbe/zulip-flutter that referenced this issue Apr 22, 2023
Toward zulip#61, "Open camera to take and share a photo".
chrisbobbe added a commit to chrisbobbe/zulip-flutter that referenced this issue Apr 22, 2023
chrisbobbe added a commit to chrisbobbe/zulip-flutter that referenced this issue Apr 28, 2023
So far we've used this code for the generic upload-file UI (zulip#57).
Soon we'll use it for media-library uploads (zulip#56) and camera uploads
(zulip#61).
chrisbobbe added a commit to chrisbobbe/zulip-flutter that referenced this issue Apr 28, 2023
Toward zulip#61, "Open camera to take and share a photo".
@gnprice gnprice added the a-compose Compose box, autocomplete, attaching files/images label May 27, 2023
@gnprice gnprice moved this to Done in Flutter app Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-compose Compose box, autocomplete, attaching files/images
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants