Commit b401ce62 authored by Aayush Gupta's avatar Aayush Gupta
Browse files

Merge branch '4311-recently-contacted-addressbook' into 'master'

AccountManager: on upgrade remove recently contacted address book

See merge request !42
parents af4e30e0 3f5956fd
Pipeline #183202 passed with stage
in 3 minutes and 16 seconds
......@@ -98,6 +98,8 @@ class AccountSettings(
const val SYNC_INTERVAL_MANUALLY = -1L
const val CONTACTS_APP_INTERACTION = "z-app-generated--contactsinteraction--recent/"
fun initialUserData(credentials: Credentials, baseURL: String?): Bundle {
val bundle = Bundle(2)
bundle.putString(KEY_SETTINGS_VERSION, CURRENT_VERSION.toString())
......@@ -316,6 +318,15 @@ class AccountSettings(
@Suppress("unused","FunctionName")
private fun update_10_11() {
setGroupMethod(GroupMethod.CATEGORIES)
val db = AppDatabase.getInstance(context)
val service = db.serviceDao().getByAccountAndType(account.name, Service.TYPE_CARDDAV)
if (service != null) {
for (collection in db.collectionDao().getByServiceAndSync(service.id)) {
if(collection.url.toString().contains(CONTACTS_APP_INTERACTION)) {
db.collectionDao().delete(collection)
}
}
}
}
@Suppress("unused","FunctionName")
......
......@@ -66,8 +66,12 @@ class EeloAddressBooksSyncAdapterService : SyncAdapterService() {
val remoteAddressBooks = mutableMapOf<HttpUrl, Collection>()
if (service != null)
for (collection in db.collectionDao().getByServiceAndSync(service.id))
for (collection in db.collectionDao().getByServiceAndSync(service.id)) {
if(collection.url.toString().contains(AccountSettings.CONTACTS_APP_INTERACTION)) {
db.collectionDao().delete(collection)
}
remoteAddressBooks[collection.url] = collection
}
if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
if (remoteAddressBooks.isEmpty())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment