diff --git a/app/src/main/kotlin/at/bitfire/davdroid/repository/AccountRepository.kt b/app/src/main/kotlin/at/bitfire/davdroid/repository/AccountRepository.kt index e1a896b49..87e5e5e62 100644 --- a/app/src/main/kotlin/at/bitfire/davdroid/repository/AccountRepository.kt +++ b/app/src/main/kotlin/at/bitfire/davdroid/repository/AccountRepository.kt @@ -85,6 +85,7 @@ class AccountRepository @Inject constructor( val defaultSyncInterval = settingsManager.getLong(Settings.DEFAULT_SYNC_INTERVAL) // Configure CardDAV service + val addrBookAuthority = context.getString(R.string.address_books_authority) if (config.cardDAV != null) { // insert CardDAV service val id = insertService(accountName, Service.TYPE_CARDDAV, config.cardDAV) @@ -94,6 +95,9 @@ class AccountRepository @Inject constructor( // start CardDAV service detection (refresh collections) RefreshCollectionsWorker.enqueue(context, id) + + // set default sync interval for address books + accountSettings.setSyncInterval(addrBookAuthority, defaultSyncInterval) } // Configure CalDAV service diff --git a/app/src/main/kotlin/at/bitfire/davdroid/settings/AccountSettings.kt b/app/src/main/kotlin/at/bitfire/davdroid/settings/AccountSettings.kt index c67eeab4a..c077904fd 100644 --- a/app/src/main/kotlin/at/bitfire/davdroid/settings/AccountSettings.kt +++ b/app/src/main/kotlin/at/bitfire/davdroid/settings/AccountSettings.kt @@ -217,11 +217,14 @@ class AccountSettings( * @return sync interval in seconds; *[SYNC_INTERVAL_MANUALLY]* if manual sync; *null* if not set */ fun getSyncInterval(authority: String): Long? { - if (ContentResolver.getIsSyncable(account, authority) <= 0) + val addrBookAuthority = context.getString(R.string.address_books_authority) + + if (ContentResolver.getIsSyncable(account, authority) <= 0 + && authority != addrBookAuthority) return null val key = when { - authority == context.getString(R.string.address_books_authority) -> + authority == addrBookAuthority -> KEY_SYNC_INTERVAL_ADDRESSBOOKS authority == CalendarContract.AUTHORITY -> KEY_SYNC_INTERVAL_CALENDARS