photos auto backup design - Logan676/seadroid GitHub Wiki
- User choose
Backup Photos
from slide menu bar to turn on the backup function. - Popup a window to let user choose an account.
- Show library list under the selected account and let user choose a library.
- When user choose a library, popup a message to tell user that uploading task starts.
- User can navigate to UploadTaskFragment to see photos uploading status.
- have internet access
- only via wifi
- cache backup data, detect duplicate
- Create a photos
auto backup manager
to backup local photos to the cloud. - When user turns on the auto backup button, load all photos from sdcard in order to add them to
auto backup manager
. - Monitor local photos, broadcast event when local photos change. For example, when user takes new photos by camera, monitor the change, broadcast the event and auto backup the newly added photos immediately.
- When backup photos underneath, always popup to show user state messages.
- add a new package
com.seafile.seadroid2.sync
to manage backup functions - add a new class
PhotosLoader
which implementsLoaderManager
to asynchronously load local photos from sdcard - add a new class
PhotosObserver
which extendsFileObserver
to monitor file access and modification
Warning: If a FileObserver is garbage collected, it will stop sending events. To ensure you keep receiving events, you must keep a reference to the FileObserver instance from some other live object.
Note: FileObserver API is actually not recursively monitor all files and subdirectories inside the monitored directory
- add a new service
AutoBackupService
which extendsIntentService
to provide auto backup service when application starts if user turn on the auto backup photos button.
Warning: If you want to notify the user about an event that happened in the background while your app was not visible, use a Notification. Never start an Activity in response to an incoming broadcast Intent.
- add a new class
AutoBackupManager
to create and send a auto backup request to theAutoBackupService
and usePhotosBackupReceiver
which extendsBroadcastReceiver
to receive status broadcast sent byAutoBackupService
-
AutoBackupManager
works as a controller, it connect PhotosObserver, PhotosLoader and PhotosBackupReceiver together. It is also responsible to add photos to upload queue and interact with UploadingTaskFragment. And if user turn off the auto upload button, it is its duty to stop the background service. Also it writes & reads data to SharedPreference and database, interact with UI thread or more. - cache cloud repo info selected by user to local sdcard (user SharedPreference)
- cache upload photos data in local db to detect duplicate upload (use SQLite 3 databse)
- SeafilePathChooserActivity.java
- UploadTasksFragment.java
- BrowserActivity.addUploadTask()
- FileLoader.java
- Utils.getImageFoldersList()