1
0
mirror of https://github.com/etesync/android synced 2025-04-05 01:06:03 +00:00

Request sync after encryption password change.

This is because we need the journals to be up to date with the newly
added key, or otherwise there could be issues when editing them.
This commit is contained in:
Tom Hacohen 2019-03-11 18:14:22 +00:00
parent 45ba7ad5b9
commit b382b8515c
3 changed files with 24 additions and 11 deletions

View File

@ -0,0 +1,20 @@
package com.etesync.syncadapter.syncadapter
import android.accounts.Account
import android.content.ContentResolver
import android.os.Bundle
import android.provider.CalendarContract
import at.bitfire.ical4android.TaskProvider
import com.etesync.syncadapter.App
fun requestSync(account: Account?) {
val authorities = arrayOf(App.addressBooksAuthority, CalendarContract.AUTHORITY, TaskProvider.ProviderName.OpenTasks.authority)
for (authority in authorities) {
val extras = Bundle()
extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true) // manual sync
extras.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true) // run immediately (don't queue)
ContentResolver.requestSync(account, authority, extras)
}
}

View File

@ -35,6 +35,7 @@ import com.etesync.syncadapter.model.JournalEntity
import com.etesync.syncadapter.model.ServiceEntity
import com.etesync.syncadapter.resource.LocalAddressBook
import com.etesync.syncadapter.resource.LocalCalendar
import com.etesync.syncadapter.syncadapter.requestSync
import com.etesync.syncadapter.ui.setup.SetupUserInfoFragment
import com.etesync.syncadapter.utils.HintManager
import com.etesync.syncadapter.utils.ShowcaseBuilder
@ -440,17 +441,6 @@ class AccountActivity : BaseActivity(), Toolbar.OnMenuItemClickListener, PopupMe
companion object {
val EXTRA_ACCOUNT = "account"
private val HINT_VIEW_COLLECTION = "ViewCollection"
protected fun requestSync(account: Account?) {
val authorities = arrayOf(App.addressBooksAuthority, CalendarContract.AUTHORITY, TaskProvider.ProviderName.OpenTasks.authority)
for (authority in authorities) {
val extras = Bundle()
extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true) // manual sync
extras.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true) // run immediately (don't queue)
ContentResolver.requestSync(account, authority, extras)
}
}
}
}

View File

@ -23,6 +23,7 @@ import com.etesync.syncadapter.R
import com.etesync.syncadapter.journalmanager.Crypto
import com.etesync.syncadapter.journalmanager.JournalManager
import com.etesync.syncadapter.journalmanager.UserInfoManager
import com.etesync.syncadapter.syncadapter.requestSync
import okhttp3.HttpUrl
import org.jetbrains.anko.doAsync
import org.jetbrains.anko.uiThread
@ -131,6 +132,8 @@ open class ChangeEncryptionPasswordActivity : BaseActivity() {
.setPositiveButton(android.R.string.ok) { _, _ ->
this@ChangeEncryptionPasswordActivity.finish()
}.show()
requestSync(account)
}
} catch (e: Exception) {
uiThread {