NativeScript / nativescript-camera

NativeScript plugin to empower using device camera.
Apache License 2.0
92 stars 47 forks source link

Camera saving images to gallery on 3.2.1 despite saveToGallery being false #86

Open mast3rd3mon opened 6 years ago

mast3rd3mon commented 6 years ago

Android v7.0.0 Real device - LG G5 nativescript - 3.3.0 tns-core-modules - 3.3.0 tns-android - 3.3.0 nativescript-camera - 3.2.1

I request the permissions at the end of the ngOnInit(), i then click a button to call takeImage() which is as follows

takeImage() {
    cameraModule.takePicture({
        width: 100,
        height: 150,
        keepAspectRatio: true,
        saveToGallery: false
    }).then(imageAsset => {
        imageSource.fromAsset(imageAsset)
            .then(res => {
                this.displayPicture(res);
            }).then(
            () => {
                //Do code to display new elements
            })
    });
}

Currently only tested on android but not on ios

zbranzov commented 6 years ago

@mast3rd3mon saveToGallery is false by default in the plugin. So if you even skip providing it, the image should not be saved in the Gallery. Can you reproduce the issue using the demo apps in this repo? Notice that they enable saving of the images by default so you would have to turn it off manually by using the app's switch.

mast3rd3mon commented 6 years ago

If it's set to false by default, why does it always save to the gallery? It's done this since around ns v2.2.

On Fri, 2 Mar 2018, 09:58 Zdravko, notifications@github.com wrote:

@mast3rd3mon https://github.com/mast3rd3mon saveToGallery is false by default in the plugin. So if you even skip providing it, the image should not be saved in the Gallery. Can you reproduce the issue using the demo apps in this repo? Notice that they enable saving of the images by default so you would have to turn it off manually by using the app's switch.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NativeScript/nativescript-camera/issues/86#issuecomment-369877207, or mute the thread https://github.com/notifications/unsubscribe-auth/AgyKCm01FGluSMkxVvDEaShBdjz4zaDiks5taRfHgaJpZM4R7MzN .

zbranzov commented 6 years ago

@mast3rd3mon Unfortunately, we don't have similar to your device, but when tested on other android devices the image does not appear in the Gallery. I want to mention that in the latest version 4.0 we enabled saving on the device by default as it can help in certain situations.

mast3rd3mon commented 6 years ago

@zbranzov well im not sure then, but i've never known this plugin to not save to the gallery. I know it annoys me and it will also annoy our customers when they use the app

mast3rd3mon commented 6 years ago

I've just gone through and debugged (somewhat) the plugin, even if the saveToGallery property is set to false (console logged the values) the file still gets saved to the phone's gallery

Mflm commented 6 years ago

Hi

I have the same issue with a real device (Moto G5 Plus).

In the camera.android.js I changed the variable saveToGallery_1 to false and stills save it in the gallery.

mast3rd3mon commented 6 years ago

I too have tested on a Moto G5 (not the plus) and i have the same issue. I have also tested what you have and i also corrected the check that's used so its valid but it still saves to the gallery.

zbranzov commented 6 years ago

Indeed the issue is reproducible on specific devices (e.g. LG G6) maybe because of some setting or permission which will require further investigation.

lini commented 6 years ago

The nativescript-camera plugin uses a standard intent action called ACTION_IMAGE_CAPTURE in Android. This is handled by whatever camera application is installed on the device or if multiple camera apps are installed, the user will be prompted to choose one. The plugin also instructs the camera app to save the image in a predefined location instead of the default gallery. What happens next is not under our control - some camera apps only save the image in the specified location, but others also place a copy in the gallery as well.

Setting saveToGallery to true in these cases might even lead to two copies of the same image in the gallery - one from the camera app and another from the nativescript-camera plugin. Unfortunately, this is not something that can be easily fixed.

A possible solution would be to go to the gallery directory and delete the second copy of the image after it is taken. However, this is prone to many errors - e.g. different apps use different paths for storing gallery images; the wrong image could be deleted by accident. Another approach would be to command the camera module on the device directly (i.e. create a new camera app) but this is also far from an ideal solution - camera apps offer better image quality due to post-processing, advanced customization options and updates.

briosheje commented 6 years ago

@lini Thanks for the infos.

I can confirm that I'm still having feedbacks from some users having issues with the save picture module. The amount of feedbacks, however, after the latest update and after setting saveGallery to true, is DRASTICALLY reduced.

I'm still trying to figure out where the problem could effectively be since in some similar devices I'm having different results (despite similar hardwares). An interesting example, for instance, is that my nexus 5X with android 8 is suddenly working, while the same 5X, with the previous 7.x update, wasn't.

For instance, I would recommend to everyone having issues on android, to keep saveGallery always to true and, eventually, to use the gallery copy and alert users that the gallery copy is being used in the application.

Another thing which I personally would recommend is to always check for permissions: some devices seems to be often resetting permissions in my app (and I'm really not sure why), hence ALWAYS check if you have permissions, otherwise the error may simply be there, despite the user may have granted permissions.

Another curious fact is that it looks like that all the users experiencing "permissions issues" all have an antivirus or something like that installed. Even cleaners seems to be sometimes resetting app permissions, apparently.

Thanks again for the support, I will keep this issue updated if I gather any new relevant information.

jokro commented 5 years ago

I am experiencing android moto g6 still saving to gallery when the flag is set to false. So why is the bug label removed ?

jokro commented 5 years ago

Here it is written

If you want to hide your files from the Media Scanner, include an empty file named .nomedia in your external files directory (note the dot prefix in the filename). This prevents media scanner from reading your media files and providing them to other apps through the MediaStore content provider.