Commit 6157d6e7 authored by Ricki Hirner's avatar Ricki Hirner

Disable OpenTasks sync on account creation without CalDAV service; Account UI:...

Disable OpenTasks sync on account creation without CalDAV service; Account UI: finish activity from main thread on account deletion
parent 013729ed
......@@ -18,7 +18,7 @@ android {
defaultConfig {
applicationId "at.bitfire.davdroid"
versionCode 264
versionCode 265
buildConfigField "long", "buildTime", System.currentTimeMillis() + "L"
buildConfigField "boolean", "customCerts", "true"
......@@ -34,7 +34,7 @@ android {
flavorDimensions "distribution"
productFlavors {
standard {
versionName "2.2.3-beta1-ose"
versionName "2.2.3-beta2-ose"
}
}
......
......@@ -20,6 +20,7 @@ import at.bitfire.davdroid.model.ServiceDB
import at.bitfire.davdroid.model.ServiceDB.Services
import at.bitfire.davdroid.resource.LocalTaskList
import at.bitfire.ical4android.TaskProvider
import at.bitfire.ical4android.TaskProvider.ProviderName.OpenTasks
class PackageChangedReceiver: BroadcastReceiver() {
......@@ -46,10 +47,9 @@ class PackageChangedReceiver: BroadcastReceiver() {
val account = Account(cursor.getString(0), context.getString(R.string.account_type))
if (tasksInstalled) {
if (ContentResolver.getIsSyncable(account, TaskProvider.ProviderName.OpenTasks.authority) <= 0) {
ContentResolver.setIsSyncable(account, TaskProvider.ProviderName.OpenTasks.authority, 1)
ContentResolver.setSyncAutomatically(account, TaskProvider.ProviderName.OpenTasks.authority, true)
ContentResolver.addPeriodicSync(account, TaskProvider.ProviderName.OpenTasks.authority, Bundle(), Constants.DEFAULT_SYNC_INTERVAL)
if (ContentResolver.getIsSyncable(account, OpenTasks.authority) <= 0) {
ContentResolver.setIsSyncable(account, OpenTasks.authority, 1)
ContentResolver.addPeriodicSync(account, OpenTasks.authority, Bundle(), Constants.DEFAULT_SYNC_INTERVAL)
}
} else
ContentResolver.setIsSyncable(account, TaskProvider.ProviderName.OpenTasks.authority, 0)
......
......@@ -18,10 +18,7 @@ import android.content.pm.PackageManager
import android.database.DatabaseUtils
import android.database.sqlite.SQLiteDatabase
import android.net.Uri
import android.os.AsyncTask
import android.os.Build
import android.os.Bundle
import android.os.IBinder
import android.os.*
import android.provider.CalendarContract
import android.provider.ContactsContract
import android.view.*
......@@ -819,7 +816,9 @@ class AccountActivity: AppCompatActivity(), Toolbar.OnMenuItemClickListener, Pop
accountManager.removeAccount(account, this, { future ->
try {
if (future.result.getBoolean(AccountManager.KEY_BOOLEAN_RESULT))
finish()
Handler(Looper.getMainLooper()).post {
finish()
}
} catch(e: Exception) {
Logger.log.log(Level.SEVERE, "Couldn't remove account", e)
}
......@@ -828,7 +827,9 @@ class AccountActivity: AppCompatActivity(), Toolbar.OnMenuItemClickListener, Pop
accountManager.removeAccount(account, { future ->
try {
if (future.result)
finish()
Handler(Looper.getMainLooper()).post {
finish()
}
} catch (e: Exception) {
Logger.log.log(Level.SEVERE, "Couldn't remove account", e)
}
......
......@@ -32,7 +32,7 @@ import at.bitfire.davdroid.model.ServiceDB.*
import at.bitfire.davdroid.resource.LocalTaskList
import at.bitfire.davdroid.settings.AccountSettings
import at.bitfire.davdroid.settings.Settings
import at.bitfire.ical4android.TaskProvider
import at.bitfire.ical4android.TaskProvider.ProviderName.OpenTasks
import at.bitfire.vcard4android.GroupMethod
import com.google.android.material.snackbar.Snackbar
import kotlinx.android.synthetic.main.login_account_details.*
......@@ -180,11 +180,13 @@ class AccountDetailsFragment: Fragment() {
// enable task sync if OpenTasks is installed
// further changes will be handled by PackageChangedReceiver
if (LocalTaskList.tasksProviderAvailable(appContext)) {
ContentResolver.setIsSyncable(account, TaskProvider.ProviderName.OpenTasks.authority, 1)
accountSettings.setSyncInterval(TaskProvider.ProviderName.OpenTasks.authority, Constants.DEFAULT_SYNC_INTERVAL)
ContentResolver.setIsSyncable(account, OpenTasks.authority, 1)
accountSettings.setSyncInterval(OpenTasks.authority, Constants.DEFAULT_SYNC_INTERVAL)
}
} else
} else {
ContentResolver.setIsSyncable(account, CalendarContract.AUTHORITY, 0)
ContentResolver.setIsSyncable(account, OpenTasks.authority, 0)
}
} catch(e: InvalidAccountException) {
Logger.log.log(Level.SEVERE, "Couldn't access account settings", e)
......
Markdown is supported
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