Skip to content
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

Auto Upload photos #243

Open
megabitdragon opened this issue Jul 12, 2017 · 9 comments
Open

Auto Upload photos #243

megabitdragon opened this issue Jul 12, 2017 · 9 comments
Assignees

Comments

@megabitdragon
Copy link
Member

A option to auto-upload pictures from camera should be added. This should be enabled by a switch in the settings menu. Once enabled, two more field should show up specifically, path to the upload folder and a switch that will indicate if pictures should be uploaded on cellular data or not. The images need to be added to a queue and uploaded only on WiFi if the cellular data is disabled. Otherwise the images will be uploaded automatically.

@csoni111
Copy link
Member

csoni111 commented Jul 12, 2017

When will the auto upload trigger? Does this mean that as soon as the user takes a new photo from any of the camera application available on his device, the upload shall trigger or the photo will have to be taken from inside amahi app?

@megabitdragon
Copy link
Member Author

Is should work for every camera app or at least for the default one. I think it should trigger as soon as a photo is taken. We might put a delay on place just in case the person decides to delete the picture immediately after is taken. Maybe add the image to a queue, and after a determined delay, if picture is still in the folder upload it.

@csoni111
Copy link
Member

csoni111 commented Jul 14, 2017

I see three options for achieving this:

  1. We can use FileObserver to observe a particular directory for any new file addition (recursively inside the directory listing). Then on callback, we start a background service which uploads the file to the server.

  2. Another option is to register a ACTION_MEDIA_SCANNER_SCAN_FILE Broadcast Receiver. This question can be referred for more info on this.

  3. We can also listen to Camera#ACTION_NEW_PICTURE brodcast but this may result in not getting any callbacks from non-default camera apps or if a screenshot is taken.

Having a FileObserver will allow us to extend this feature for any file and not just image/media files. Also I read somewhere that some devices do not send the MediaScanner intent properly so we might miss out on some devices.

There's already a lot of discussion about this exact feature on the owncloud/android repo. We can look over the discussion on these issues/pr #6, #1675, #95, #1059, #110, #774; to make an informed decision on what to use in our app.

@megabitdragon What do you suggest?

@megabitdragon
Copy link
Member Author

@csoni111 Shouldn't we use the camera2 api?

@csoni111
Copy link
Member

We do not want to capture image from inside our app (or do we?). What we want is to get notified whenever any new image is taken on the device using any app.

To capture an image from inside our app, there are two possibilities:

  • Using a custom made camera inside our app and camera2 apis (instead of deprecated camera apis)
  • Or calling the default camera app using an Intent with action type of MediaStore.ACTION_IMAGE_CAPTURE (this was not deprecated when the camera apis got deprecated)

This is documented here.

Now since we do not want any custom camera app, we do not require camera2 apis!

What we want is to register a Broadcast Receiver for android.hardware.action.NEW_PICTURE which is declared a Constant String ACTION_NEW_PICTURE in the Camera.class.

@megabitdragon
Copy link
Member Author

megabitdragon commented Jul 15, 2017

@csoni111 Taking photos from within the app is a story for a different day but very good suggestions. I think we should use the Broadcast Receiver and the ACTION_NEW_PICTURE. We have to keep in mind that for android N, ACTION_NEW_PICTURE was removed so we need to use this instead. Can we just use the JobScheduler as described and forget about the ACTION_NEW_PICTURE?

@csoni111
Copy link
Member

Unfortunately we cannot just rely on the JobScheduler only as it was added in api 21 (android 5.0) and is not backwards compatible through a support library.
So maybe we can take a look at this library Firebase JobDispatcher. This was developed by firebase to backport the JobScheduler till api 9.

Or we can have two separate things, the broadcast receiver for api level < 21 and JobDispatcher for api level >= 21.

@arihant-001
Copy link
Collaborator

@csoni111 can you tell me what exactly the use of pathPreference in uploadSettingsFragment?

@amahi amahi deleted a comment from adrian-vg May 9, 2018
@amahi amahi deleted a comment from arihant-001 May 9, 2018
@amahi amahi deleted a comment from adrian-vg May 9, 2018
@amahi amahi deleted a comment from adrian-vg May 9, 2018
@RGlass89
Copy link

I am sure this can be closed

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

No branches or pull requests

5 participants