This PR refactors camera upload and the account storage. To be more precise, it does two things:
- It refactors the account storage. Instead of storing accounts in an SQL table, they are now stored in an Android-provided storage API. This is only done to allow us to do thing number 2.
- refactor camera upload. this changes most of the internal structure of the camera upload procedure. I tried to keep the UI as unchanged as possible, though.
The patches have more detailed explanations in their individual commit messages.
They should hopefully address the following issues:
issue #277 (Camera upload function dumps all subdir files into single dir)
issue #301 (Inconsistency in camera upload sync)
issue #311 (second suggestion: target repo sub directories)
issue #336 (file duplication when doing a full resync)
issue #375 (Picture upload not acting as service?)
issue #423 (Pictures never upload) [maybe. not sure what's going on there]
Some further notes:
- This patch set includes the patches from PR #422 as the same files are touched and thus to avoid merge conflicts.
- Originally I also wanted to refactor the TransferService into a SyncAdapter. However this patchset took much longer than expected so I postponed the TransferService refactoring for a later time.
- The Java 7 patch is not necessary, just a convenience. I can remove it, if you want to stay compatible with Java 6.
- Due to the large number of changes, there might well be bugs remaining. ;) I've tested this patchset for some days in the emulator and on an Android 5.1 phone and will amend commits if I find more issues.
- Please be especially aware of Shibboleth accounts and SeafilePro features. I had to touch code for both, but was not able to test the changes.
- To the best of my (and AndroidStudio's) knowledge this should all be compatible with API level 8. However I didn't do any tests on an API 8 device.
While this PR adds a feature or two, the main reason for its existence is to bring more stability to camera upload mechanism. So, to avoid replacing 5 old bugs with 10 new ones, this PR will need some thorough testing. Especially on
- phones with Android 4.x or 2.x
- non-standard camera apps
[EDIT: I realized maybe I should write a couple of lines on the user-visible changes of this PR. Here it goes:]
Accounts
- Accounts can now be created/removed via Android Settings -> Account. It uses the same activities and should behave pretty much the same.
- The "Pick type of Seafile server" dialog had to be refactored into an Activity with a list. Actually I'm not quite happy with that and I think the old Dialog looked slightly better (building Android UIs is still new to me). Unfortunately I couldn't figure out a way to get the old Dialog working reliably, as I had to move it out of AccountsManager into the SeafileAuthenticatorActivity.
- Accounts are now stored seperately from all other SQL tables. This means that they will survive the cleaning of all app data (which is probably more useful to developers than anyone else ;)
Camera upload
- In Android Settings -> Account -> Seafile one can now see the timestamp of the last successfull camera upload sync. Also the user can manually trigger a sync there.
- The directory chooser for picking local directories to upload is gone. It has been replaced with a list of media albums (basically the same list the Android gallery shows). If people had previously configured manually a list directories, after this patch the settings will revert back to the "Auto sync" setting.
- The sync will now skip files that are already on the server and have the same file name and size.
- The sync will now place image properly in subfolders on the server. The folders are named after the gallery albums (internally called "buckets").
- As a target, subdirectories of repositories are now also possible.
- Monitoring of the media store will now start at phone boot and after an APK upgrade.
- Resyncs will happen regularily (about every 24h, scheduled by the Android OS)
- In case of network errors, Android does an automatic retry with exponential backoff
- Hard errors during sync (remote repo gone, auth error) are now made visible to the user as a notification.
Migration
- Accounts are migrated.
- Default account is not migrated (due to settings refactoring). So the user has to select her preferred account once after upgrade.
- Camera settings are migrated, except the "custom local folder" setting. That one will revert back to "auto select folders".
- Camera sync will resync everything after upgrade. As the target folders are now different (in most cases "Camera" instead of "Camera Uploads") this will cause a full reupload of all local images.
I'll be happy to address any upcoming bugs, issues and questions.