1
0
Fork 0

Bookmark sync (#2090)

* Closes #919: Enable bookmarks synchronization

* Add bookmarks checkbox to sync preference screen
master
Grisha Kruglov 2019-04-26 14:20:13 -07:00 committed by Colin Lee
parent 4cd0d464a7
commit fbdf60fdb9
6 changed files with 18 additions and 4 deletions

View File

@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- #919 - Enabled bookmark synchronization
- #916 - Added the ability to save and delete bookmarks
- #356 - Added the ability to delete history
- #208 - Added normal browsing dark mode (advised to use attrs from now on for most referenced colors)
@ -43,4 +44,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- #1429 - Updated site permissions ui for MVP
- #1599 - Fixed a crash creating a bookmark for a custom tab
### Removed
### Removed

View File

@ -8,6 +8,7 @@ import android.content.Context
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import mozilla.components.browser.storage.sync.PlacesBookmarksStorage
import mozilla.components.browser.storage.sync.PlacesHistoryStorage
import mozilla.components.feature.sync.BackgroundSyncManager
import mozilla.components.feature.sync.GlobalSyncableStoreProvider
@ -20,7 +21,8 @@ import mozilla.components.service.fxa.FxaAccountManager
*/
class BackgroundServices(
context: Context,
historyStorage: PlacesHistoryStorage
historyStorage: PlacesHistoryStorage,
bookmarkStorage: PlacesBookmarksStorage
) {
companion object {
const val CLIENT_ID = "a2270f727f45f648"
@ -35,12 +37,14 @@ class BackgroundServices(
private val config = Config.release(CLIENT_ID, REDIRECT_URL)
init {
// Make the "history" store accessible to workers spawned by the sync manager.
// Make the "history" and "bookmark" stores accessible to workers spawned by the sync manager.
GlobalSyncableStoreProvider.configureStore("history" to historyStorage)
GlobalSyncableStoreProvider.configureStore("bookmarks" to bookmarkStorage)
}
val syncManager = BackgroundSyncManager("https://identity.mozilla.com/apps/oldsync").also {
it.addStore("history")
it.addStore("bookmarks")
}
val accountManager = FxaAccountManager(context, config, scopes, syncManager).also {

View File

@ -10,7 +10,7 @@ import android.content.Context
* Provides access to all components.
*/
class Components(private val context: Context) {
val backgroundServices by lazy { BackgroundServices(context, core.historyStorage) }
val backgroundServices by lazy { BackgroundServices(context, core.historyStorage, core.bookmarksStorage) }
val services by lazy { Services(backgroundServices.accountManager, useCases.tabsUseCases) }
val core by lazy { Core(context) }
val search by lazy { Search(context) }

View File

@ -32,6 +32,7 @@
<string name="pref_key_account_category" translatable="false">pref_key_account_category</string>
<string name="pref_key_sync_now" translatable="false">pref_key_sync_now</string>
<string name="pref_key_sync_history" translatable="false">pref_key_sync_history</string>
<string name="pref_key_sync_bookmarks" translatable="false">pref_key_sync_bookmarks</string>
<string name="pref_key_sign_out" translatable="false">pref_key_sign_out</string>
<string name="pref_key_cached_account" translatable="false">pref_key_cached_account</string>

View File

@ -143,6 +143,8 @@
<string name="preferences_sync_category">Choose what to sync</string>
<!-- Preference for syncing history -->
<string name="preferences_sync_history">History</string>
<!-- Preference for syncing bookmarks -->
<string name="preferences_sync_bookmarks">Bookmarks</string>
<!-- Preference for signing out -->
<string name="preferences_sign_out">Sign out</string>
<!-- Label indicating that sync is in progress -->

View File

@ -11,6 +11,12 @@
<PreferenceCategory
android:title="@string/preferences_sync_category">
<CheckBoxPreference
android:key="@string/pref_key_sync_bookmarks"
android:defaultValue="true"
android:enabled="false"
android:title="@string/preferences_sync_bookmarks" />
<CheckBoxPreference
android:key="@string/pref_key_sync_history"
android:defaultValue="true"