Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 46ee17f0 authored by Ricki Hirner's avatar Ricki Hirner
Browse files

Make default sync interval a setting

parent 21fffe0b
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -11,8 +11,6 @@ object Constants {

    const val DAVDROID_GREEN_RGBA = 0xFF8bc34a.toInt()

    const val DEFAULT_SYNC_INTERVAL = 4 * 3600L    // 4 hours

    /**
     * Context label for [org.apache.commons.lang3.exception.ContextedException].
     * Context value is the [at.bitfire.davdroid.resource.LocalResource]
+4 −1
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ import at.bitfire.davdroid.model.AppDatabase
import at.bitfire.davdroid.model.Service
import at.bitfire.davdroid.resource.TaskUtils
import at.bitfire.davdroid.settings.AccountSettings
import at.bitfire.davdroid.settings.Settings
import at.bitfire.davdroid.settings.SettingsManager
import at.bitfire.ical4android.TaskProvider
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -71,7 +73,8 @@ class TasksWatcher(
                ContentResolver.setIsSyncable(account, authority, 1)
                try {
                    val settings = AccountSettings(context, account)
                    val interval = settings.getSavedTasksSyncInterval() ?: Constants.DEFAULT_SYNC_INTERVAL
                    val interval = settings.getSavedTasksSyncInterval() ?:
                            SettingsManager.getInstance(context).getLong(Settings.DEFAULT_SYNC_INTERVAL)
                    settings.setSyncInterval(authority, interval)
                } catch (e: InvalidAccountException) {
                    // account has already been removed
+1 −1
Original line number Diff line number Diff line
@@ -577,7 +577,7 @@ class AccountSettings(

        // request sync of new address book account
        ContentResolver.setIsSyncable(account, context.getString(R.string.address_books_authority), 1)
        setSyncInterval(context.getString(R.string.address_books_authority), Constants.DEFAULT_SYNC_INTERVAL)
        setSyncInterval(context.getString(R.string.address_books_authority), 4*3600)
    }

    /* Android 7.1.1 OpenTasks fix */
+3 −1
Original line number Diff line number Diff line
@@ -22,7 +22,9 @@ class DefaultsProvider(
            Pair(Settings.OVERRIDE_PROXY_PORT, 8118)
    )

    override val longDefaults = emptyMap<String, Long>()
    override val longDefaults = mapOf<String, Long>(
            Pair(Settings.DEFAULT_SYNC_INTERVAL, 4*3600)    /* 4 hours */
    )

    override val stringDefaults = mapOf(
            Pair(Settings.OVERRIDE_PROXY_HOST, "localhost")
+6 −0
Original line number Diff line number Diff line
@@ -8,6 +8,12 @@ object Settings {
    const val OVERRIDE_PROXY_HOST = "override_proxy_host"
    const val OVERRIDE_PROXY_PORT = "override_proxy_port"

    /**
     * Default sync interval (long), in seconds.
     * Used to initialize an account.
     */
    const val DEFAULT_SYNC_INTERVAL = "default_sync_interval"

    const val PREFERRED_TASKS_PROVIDER = "preferred_tasks_provider"

}
Loading