From fbdf60fdb941d72f564823d40a2facc70531c4ea Mon Sep 17 00:00:00 2001 From: Grisha Kruglov Date: Fri, 26 Apr 2019 14:20:13 -0700 Subject: [PATCH] Bookmark sync (#2090) * Closes #919: Enable bookmarks synchronization * Add bookmarks checkbox to sync preference screen --- CHANGELOG.md | 3 ++- .../org/mozilla/fenix/components/BackgroundServices.kt | 8 ++++++-- .../main/java/org/mozilla/fenix/components/Components.kt | 2 +- app/src/main/res/values/preference_keys.xml | 1 + app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/account_settings_preferences.xml | 6 ++++++ 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f04671e02..aab718fcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 \ No newline at end of file +### Removed diff --git a/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt b/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt index 425e6161e..218ebe2c0 100644 --- a/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt +++ b/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt @@ -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 { diff --git a/app/src/main/java/org/mozilla/fenix/components/Components.kt b/app/src/main/java/org/mozilla/fenix/components/Components.kt index c28cadb3f..1c5c8a843 100644 --- a/app/src/main/java/org/mozilla/fenix/components/Components.kt +++ b/app/src/main/java/org/mozilla/fenix/components/Components.kt @@ -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) } diff --git a/app/src/main/res/values/preference_keys.xml b/app/src/main/res/values/preference_keys.xml index a38ad6fb6..c7062a4b3 100644 --- a/app/src/main/res/values/preference_keys.xml +++ b/app/src/main/res/values/preference_keys.xml @@ -32,6 +32,7 @@ pref_key_account_category pref_key_sync_now pref_key_sync_history + pref_key_sync_bookmarks pref_key_sign_out pref_key_cached_account diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 93b1737be..003bf6592 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -143,6 +143,8 @@ Choose what to sync History + + Bookmarks Sign out diff --git a/app/src/main/res/xml/account_settings_preferences.xml b/app/src/main/res/xml/account_settings_preferences.xml index 02a87c14e..ffbecf820 100644 --- a/app/src/main/res/xml/account_settings_preferences.xml +++ b/app/src/main/res/xml/account_settings_preferences.xml @@ -11,6 +11,12 @@ + +