diff --git a/app/src/main/java/com/etesync/syncadapter/syncadapter/RequestSync.kt b/app/src/main/java/com/etesync/syncadapter/syncadapter/RequestSync.kt new file mode 100644 index 00000000..3c30b015 --- /dev/null +++ b/app/src/main/java/com/etesync/syncadapter/syncadapter/RequestSync.kt @@ -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) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/etesync/syncadapter/ui/AccountActivity.kt b/app/src/main/java/com/etesync/syncadapter/ui/AccountActivity.kt index b6ddb347..a581f26d 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/AccountActivity.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/AccountActivity.kt @@ -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) - } - } } } diff --git a/app/src/main/java/com/etesync/syncadapter/ui/ChangeEncryptionPasswordActivity.kt b/app/src/main/java/com/etesync/syncadapter/ui/ChangeEncryptionPasswordActivity.kt index 5c37616e..ad625b9c 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/ChangeEncryptionPasswordActivity.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/ChangeEncryptionPasswordActivity.kt @@ -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 {