Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Refactored Instant Upload #681

Merged
merged 9 commits into from Jun 8, 2016
Merged

Refactored Instant Upload #681

merged 9 commits into from Jun 8, 2016

Conversation

Jon-Schneider
Copy link
Contributor

@Jon-Schneider Jon-Schneider commented May 31, 2016

This Pull Request Does the Following:

  1. Moves Instant Upload Management logic out of SettingsViewController into a new InstantUpload class.
  2. Separates Background Instant Upload from Instant Upload. If Background Instant Upload is disabled and Instant Upload enabled, upload just takes place when you first open the app, the app enters the foreground, or new photos are taken while the app is running in the background.
  3. Adds a migration to add a background instant upload enabled field to the users table, used to implement the user preference for Background Instant Upload.
  4. Migrates Instant Upload to use the new PHPhotoLibrary api rather than the deprecated ALAssetLibrary API for photo access. This means Instant Upload can now work independent of whether location permission has been granted to the app or not.
  5. The user's last instant upload time is now tracked as an NSTimeInterval rather than a long representing seconds, and a DB migration has been added for this change.
  6. Deletes ManageLocation class. InstantUpload.m implements background upload by subscribing to CLLocationManager significant location change updates.

TASKS

This closes #511


BUGS / IMPROVEMENTS:

… background upload preference has now been seperated from the InstantUpload preference. Instant Upload now uses the Photos Library instead of the Assets library for photo access. Instant upload last uploaded timestamp is now stored as an NSTimeInterval rather than a long.
@Jon-Schneider Jon-Schneider changed the title Instant Upload now implemented in InstantUpload class. Instant Upload… Refactored Instant Upload May 31, 2016
@Jon-Schneider Jon-Schneider mentioned this pull request May 31, 2016
4 tasks
@Jon-Schneider
Copy link
Contributor Author

@nasli @javiergonzper

@ghost
Copy link

ghost commented Jun 1, 2016

@Jon-Schneider

Thanks a lot for your contribution!
Contributions to the core repo require a signed contributors agreement http://owncloud.org/about/contributor-agreement/

Alternatively you can add a comment here where you state that this contribution is MIT licensed.

Some more details about out pull request workflow can be found here: http://owncloud.org/code-reviews-on-github/

@nasli
Copy link
Contributor

nasli commented Jun 1, 2016

@Jon-Schneider please, check again your github email address

@nasli nasli added this to the 3.5.0-current milestone Jun 1, 2016
@Jon-Schneider
Copy link
Contributor Author

@nasli There may have been an error earlier. Both commits show as being from Jon-Schneider on my end.

@nasli
Copy link
Contributor

nasli commented Jun 1, 2016

@DeepDiver1975 could you check what is wrong? Thank you!

@Jon-Schneider
Copy link
Contributor Author

screen shot 2016-06-01 at 11 15 53 am

Clear cache button and log out account
@nasli
Copy link
Contributor

nasli commented Jun 1, 2016

@Jon-Schneider please rebase this branch

… background upload preference has now been seperated from the InstantUpload preference. Instant Upload now uses the Photos Library instead of the Assets library for photo access. Instant upload last uploaded timestamp is now stored as an NSTimeInterval rather than a long.
@Jon-Schneider
Copy link
Contributor Author

@nasli Rebased.

@ghost
Copy link

ghost commented Jun 2, 2016

@Jon-Schneider

Thanks a lot for your contribution!
Contributions to the core repo require a signed contributors agreement http://owncloud.org/about/contributor-agreement/

Alternatively you can add a comment here where you state that this contribution is MIT licensed.

Some more details about out pull request workflow can be found here: http://owncloud.org/code-reviews-on-github/


#pragma mark - Utility

- (void) showPhotoLibraryAccessPermissionDeniedAlert {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to instead of use this three methods for any alertview code use just one method like

- (void) showAlertView:(NSString*)string{
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:string message:@"" delegate:self cancelButtonTitle:NSLocalizedString(@"ok", nil) otherButtonTitles:nil, nil];
    [alertView show];
}

and called

[self showAlertView:NSLocalizedString(@"access_photos_library_not_enabled", nil)];

This would make also more easier the refactor that we plan to do it in a near future to the new UIAlertController instead of the deprecated UIAlertView.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, since you are using title and body use this method that you are not using

(void) showAlertViewWithTitle:(NSString *)title body:(NSString *)body{ 

instead of the other two

showLocationAccessAlwaysPermissionDeniedAlert
showLocationAccessAlwaysPermissionDeniedAlert

…be newer than to be uploaded to the current datetime. This has the effect of only uploading photos taken after Instant Upload is enabled
@Jon-Schneider
Copy link
Contributor Author

@nasli Both done.

@nasli
Copy link
Contributor

nasli commented Jun 3, 2016

Great!! Nice work @Jon-Schneider!! Let's move this to ready to test @jesmrec

@Jon-Schneider
Copy link
Contributor Author

@jesmrec I'm new here. What does testing involve? How can I help move the process along?

@jesmrec
Copy link
Contributor

jesmrec commented Jun 7, 2016

@Jon-Schneider hi!!
After the developing and CR stages, a QA process is performed to assure that the solution is correct. A test plan is designed and then executed.

Today i will start with these tasks. The test plan will be uploaded to the QA repo (https://github.com/owncloud/QA) and i will link it to this PR to make easier the access. If bugs or problems are found during the process i will post or link them here, if you want to review them :) . All comments or review about the test plan will be always welcome!!!

Thank you very much for your contribution.

@jesmrec
Copy link
Contributor

jesmrec commented Jun 8, 2016

@Jon-Schneider @nasli

I have detected the following behaviour:

1.- Disable location services
2.- Install the app
3.- Enable "Instant Uploads"
4.- Enable "Background Instant Upload"
5.- Notification about location services is raised, choose "Cancel"

Actual Behaviour

If you try again to enable "Background Instant Upload", the switch button is enabled without requesting to enable location services. If you change the view and then return to settings, the switch button is disabled.

Expected behaviour

If location services are disabled in device (or for ownCloud), the option "Background Instant Upload" can not be enabled in any case without requesting it to the user.

@jesmrec
Copy link
Contributor

jesmrec commented Jun 8, 2016

@Jon-Schneider apart of the problem mentioned in my last post, it works really fine!! great job :)

@nasli
Copy link
Contributor

nasli commented Jun 8, 2016

@Jon-Schneider
Copy link
Contributor Author

Jon-Schneider commented Jun 8, 2016

I'll check it out. What should be happening if you hit the switch after location permissions have been denied is the delegate method backgroundInstantUploadPermissionLostOrDenied is called immediately and the switch is flipped back off.

…n permission, could flip the 'Background Instant Upload' Settings option to true.
@Jon-Schneider
Copy link
Contributor Author

@jesmrec @nasli Fixed.

@jesmrec
Copy link
Contributor

jesmrec commented Jun 8, 2016

@Jon-Schneider right!! now working fine. That was the only problem, so this PR is already validated and ready to be merged.

@Jon-Schneider
Copy link
Contributor Author

Jon-Schneider commented Jun 8, 2016

@nasli Am I allowed to merge this once approved by QA or does project staff prefer to do it?

@rperezb
Copy link

rperezb commented Jun 8, 2016

@Jon-Schneider in regular basis, if possible, we'd rather than the pr is merged by a different person to the one who launched the pr, so that we ensure that the pr has been reviewed, does this make sense?

Right now, there is something else that we have to take into account, @jesmrec has just noticed one, important, extra test case to check: versions upgrade. He is currently checking it.

@rperezb
Copy link

rperezb commented Jun 8, 2016

Indeed, if it's ok for you we may ping you to review pr too

@Jon-Schneider
Copy link
Contributor Author

If you wanted me to test migration in addition to @jesmrec, I did test version upgrade from latest to this PR during my own testing without issue. I haven't touched the data model since then, but if you find any edge cases let me know and I'll fix them.

@jesmrec
Copy link
Contributor

jesmrec commented Jun 8, 2016

Checks about upgrading:

  • Datatype change of timestamp_last_instant_upload from long to double in DB. Upgrade correct. 👍
  • Taking a pic in background and then, upgrading. Photo is uploaded. 👍
  • No connection + take pic (in queue) + wait to background + take pics + upgrade + take pics (to queue) + enable connection. All pics are uploaded. 👍

All OK.

@nasli
Copy link
Contributor

nasli commented Jun 8, 2016

👍 Great!! Ready!

@nasli nasli merged commit c8202f8 into owncloud:clear_cache_button Jun 8, 2016
@Jon-Schneider
Copy link
Contributor Author

@nasli Just so you know, this merge request was actually into clear_cache_button, not master, so clear_cache_button will need merged into master again.

@nasli
Copy link
Contributor

nasli commented Jun 8, 2016

@Jon-Schneider Fixed the conflicts with master and waiting for travis 👍

@nasli
Copy link
Contributor

nasli commented Jun 9, 2016

@Jon-Schneider could you launch this PR into master branch? thanks!

@Jon-Schneider
Copy link
Contributor Author

@nasli Did you mean merge this PR into master? The branch you created yesterday (#693) is able to merged with no conflicts.

@nasli
Copy link
Contributor

nasli commented Jun 9, 2016

Travis failed, and since the branch clear cache is already in master an strange behaviour happens, and not detect all the conflicts.
I mean your refactored instant upload branch send a new PR into master, and we will merge it from there

@nasli nasli mentioned this pull request Jun 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants