Bookmark sync (#2090)
* Closes #919: Enable bookmarks synchronization * Add bookmarks checkbox to sync preference screenmaster
parent
4cd0d464a7
commit
fbdf60fdb9
|
@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Added
|
### Added
|
||||||
|
- #919 - Enabled bookmark synchronization
|
||||||
- #916 - Added the ability to save and delete bookmarks
|
- #916 - Added the ability to save and delete bookmarks
|
||||||
- #356 - Added the ability to delete history
|
- #356 - Added the ability to delete history
|
||||||
- #208 - Added normal browsing dark mode (advised to use attrs from now on for most referenced colors)
|
- #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
|
### Changed
|
||||||
- #1429 - Updated site permissions ui for MVP
|
- #1429 - Updated site permissions ui for MVP
|
||||||
- #1599 - Fixed a crash creating a bookmark for a custom tab
|
- #1599 - Fixed a crash creating a bookmark for a custom tab
|
||||||
### Removed
|
### Removed
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.content.Context
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import mozilla.components.browser.storage.sync.PlacesBookmarksStorage
|
||||||
import mozilla.components.browser.storage.sync.PlacesHistoryStorage
|
import mozilla.components.browser.storage.sync.PlacesHistoryStorage
|
||||||
import mozilla.components.feature.sync.BackgroundSyncManager
|
import mozilla.components.feature.sync.BackgroundSyncManager
|
||||||
import mozilla.components.feature.sync.GlobalSyncableStoreProvider
|
import mozilla.components.feature.sync.GlobalSyncableStoreProvider
|
||||||
|
@ -20,7 +21,8 @@ import mozilla.components.service.fxa.FxaAccountManager
|
||||||
*/
|
*/
|
||||||
class BackgroundServices(
|
class BackgroundServices(
|
||||||
context: Context,
|
context: Context,
|
||||||
historyStorage: PlacesHistoryStorage
|
historyStorage: PlacesHistoryStorage,
|
||||||
|
bookmarkStorage: PlacesBookmarksStorage
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
const val CLIENT_ID = "a2270f727f45f648"
|
const val CLIENT_ID = "a2270f727f45f648"
|
||||||
|
@ -35,12 +37,14 @@ class BackgroundServices(
|
||||||
private val config = Config.release(CLIENT_ID, REDIRECT_URL)
|
private val config = Config.release(CLIENT_ID, REDIRECT_URL)
|
||||||
|
|
||||||
init {
|
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("history" to historyStorage)
|
||||||
|
GlobalSyncableStoreProvider.configureStore("bookmarks" to bookmarkStorage)
|
||||||
}
|
}
|
||||||
|
|
||||||
val syncManager = BackgroundSyncManager("https://identity.mozilla.com/apps/oldsync").also {
|
val syncManager = BackgroundSyncManager("https://identity.mozilla.com/apps/oldsync").also {
|
||||||
it.addStore("history")
|
it.addStore("history")
|
||||||
|
it.addStore("bookmarks")
|
||||||
}
|
}
|
||||||
|
|
||||||
val accountManager = FxaAccountManager(context, config, scopes, syncManager).also {
|
val accountManager = FxaAccountManager(context, config, scopes, syncManager).also {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import android.content.Context
|
||||||
* Provides access to all components.
|
* Provides access to all components.
|
||||||
*/
|
*/
|
||||||
class Components(private val context: Context) {
|
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 services by lazy { Services(backgroundServices.accountManager, useCases.tabsUseCases) }
|
||||||
val core by lazy { Core(context) }
|
val core by lazy { Core(context) }
|
||||||
val search by lazy { Search(context) }
|
val search by lazy { Search(context) }
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
<string name="pref_key_account_category" translatable="false">pref_key_account_category</string>
|
<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_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_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_sign_out" translatable="false">pref_key_sign_out</string>
|
||||||
<string name="pref_key_cached_account" translatable="false">pref_key_cached_account</string>
|
<string name="pref_key_cached_account" translatable="false">pref_key_cached_account</string>
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,8 @@
|
||||||
<string name="preferences_sync_category">Choose what to sync</string>
|
<string name="preferences_sync_category">Choose what to sync</string>
|
||||||
<!-- Preference for syncing history -->
|
<!-- Preference for syncing history -->
|
||||||
<string name="preferences_sync_history">History</string>
|
<string name="preferences_sync_history">History</string>
|
||||||
|
<!-- Preference for syncing bookmarks -->
|
||||||
|
<string name="preferences_sync_bookmarks">Bookmarks</string>
|
||||||
<!-- Preference for signing out -->
|
<!-- Preference for signing out -->
|
||||||
<string name="preferences_sign_out">Sign out</string>
|
<string name="preferences_sign_out">Sign out</string>
|
||||||
<!-- Label indicating that sync is in progress -->
|
<!-- Label indicating that sync is in progress -->
|
||||||
|
|
|
@ -11,6 +11,12 @@
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/preferences_sync_category">
|
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
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_key_sync_history"
|
android:key="@string/pref_key_sync_history"
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
|
|
Loading…
Reference in New Issue