xamarin / XamarinCommunityToolkit

The Xamarin Community Toolkit is a collection of Animations, Behaviors, Converters, and Effects for mobile development with Xamarin.Forms. It simplifies and demonstrates common developer tasks building iOS, Android, and UWP apps with Xamarin.Forms.
MIT License
1.58k stars 471 forks source link

[CameraView] Add options to give users control over where to save a file and save to gallery #657

Open jfversluis opened 3 years ago

jfversluis commented 3 years ago

See my comment on a PR below. I think the way SavePhotoToFile is implemented today is not great. To have not any breaking changes I have opted to take out the functionality right now and implement it the right way a little later on.

This implementation, I think, ideally would look like how James does it with the MediaPlugin.

A note for future me, or whoever will work on this: have a good look at the iOS implementation. A return; is now always hit, that is why the image is not saved in the gallery right now


OK think we should make it more like the MediaPlugin with the options object: https://github.com/jamesmontemagno/MediaPlugin#saving-photovideo-to-camera-rollgallery

Not sure if I/we can make that happen for v1, in which case I propose to still do the rename of CameraCaptureOptions and remove this SavePhotoToFile property and implement it this way later so we don't have to introduce any breaking changes by then. Thoughts?

Originally posted by @jfversluis in https://github.com/xamarin/XamarinCommunityToolkit/issues/629#issuecomment-737976992

VPRoss commented 3 years ago

Is there a working sample anywhere of a Xamarin.Forms app using CameraView and saving an image .. at all? execution currently just seems to dead-end in CameraView.Shutter() - the toolkit sample itself just crashes shortly after attempting to take a photo.

michaldivis commented 3 years ago

I've been working on a CameraView sample, however, I wasn't able to make it work on iOS yet (the preview works but the ShutterCommand doesn't fire the MediaCaptured event and I have no idea why). Works fine on Android.

VPRoss commented 3 years ago

That was my experience as well ... except since I was working exclusively in iOS I never saw it work at all. Good to know it works on Android since I could maybe progress the development there, but I really need it on iOS. I was excited to see the CameraView addition to the toolkit but I'm at a bit of a stone wall right now.

michaldivis commented 3 years ago

@VPRoss same here. I was really excited about the CameraView, because I could finally ditch the old way of opening a camera intent every time user wants to take a photo (which is about 5 times per user in my app). I've been tinkering with the CameraView some more yesterday getting mixed results. For example: The imageSource you get via the MediaCaptured event displays correctly on an Android emulator, but doesn't seem to work on a physical device. It's like the imageSource is empty for some reason. What's even more confusing is that this problem seems to occur only when using the back camera on the physical device, when I switch to the selfie camera the preview imageSource suddenly works.

I really hope the CameraView gets more attention and improvement soon.

jfversluis commented 3 years ago

I really hope the CameraView gets more attention and improvement soon.

If its something that you have knowledge about and need there is of course always the possibility to start fixing some things yourself :)

I really love CameraView myself as well so I'll see if we can give it some more love

michaldivis commented 3 years ago

@jfversluis I'm not very familiar with the platform specific side of Xamarin, but I'll take a look and see if I can give it love.

VPRoss commented 3 years ago

@jfversluis I'm also almost entirely a "Forms" developer - have done some "Classic" back in the day on iOS. Still, it's a good opportunity to stretch those learning muscles and maybe help fix something for the community at the same time :)

jfversluis commented 3 years ago

No worries, it's no obligation at all, but indeed a good way to see what's going on under the hood and help yourself and the community at the same time. Let us know if you need anything!

VPRoss commented 3 years ago

@jfversluis just more of your awesome YouTube vids :)

jfversluis commented 3 years ago

Awww thank you! :D Very much appreciate it! Those will definitely come!

haavamoa commented 3 years ago

I absolutely love this and I am right now implementing this to one of our production apps. One very important feature with the camera for this production app is that it should not (at any given point of time) save this photo on the users device. This is because the photo is sensitive and the byte array should be saved to the server.

I was just about to start diving into the Android and iOS OS to see if it saves the photo, but when I saw this feature request I realized that it would be easier to straight up ask you guys. :) Can you confirm that the current implementation does not save the photo anywhere on the phone both for iOS and Android? :) We're using Xamarin Community Toolkit 1.0.2.