mirror of
https://github.com/etesync/android
synced 2025-01-25 15:10:55 +00:00
Unify the sync interval settings across journal types.
This commit is contained in:
parent
b765f177c7
commit
c6472fe220
@ -22,6 +22,7 @@ import androidx.loader.content.Loader
|
|||||||
import androidx.preference.*
|
import androidx.preference.*
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
import at.bitfire.ical4android.TaskProvider
|
||||||
import com.etesync.syncadapter.*
|
import com.etesync.syncadapter.*
|
||||||
import com.etesync.syncadapter.Constants.KEY_ACCOUNT
|
import com.etesync.syncadapter.Constants.KEY_ACCOUNT
|
||||||
import com.etesync.syncadapter.R
|
import com.etesync.syncadapter.R
|
||||||
@ -107,41 +108,25 @@ class AccountSettingsActivity : BaseActivity() {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
// category: synchronization
|
val prefSync = findPreference("sync_interval") as ListPreference
|
||||||
val prefSyncContacts = findPreference("sync_interval_contacts") as ListPreference
|
val syncInterval = settings.getSyncInterval(CalendarContract.AUTHORITY) // Calendar is the baseline interval
|
||||||
val syncIntervalContacts = settings.getSyncInterval(App.addressBooksAuthority)
|
if (syncInterval != null) {
|
||||||
if (syncIntervalContacts != null) {
|
prefSync.value = syncInterval.toString()
|
||||||
prefSyncContacts.value = syncIntervalContacts.toString()
|
if (syncInterval == AccountSettings.SYNC_INTERVAL_MANUALLY)
|
||||||
if (syncIntervalContacts == AccountSettings.SYNC_INTERVAL_MANUALLY)
|
prefSync.setSummary(R.string.settings_sync_summary_manually)
|
||||||
prefSyncContacts.setSummary(R.string.settings_sync_summary_manually)
|
|
||||||
else
|
else
|
||||||
prefSyncContacts.summary = getString(R.string.settings_sync_summary_periodically, prefSyncContacts.entry)
|
prefSync.summary = getString(R.string.settings_sync_summary_periodically, prefSync.entry)
|
||||||
prefSyncContacts.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
prefSync.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
||||||
settings.setSyncInterval(App.addressBooksAuthority, java.lang.Long.parseLong(newValue as String))
|
val newInterval = java.lang.Long.parseLong(newValue as String)
|
||||||
|
settings.setSyncInterval(App.addressBooksAuthority, newInterval)
|
||||||
|
settings.setSyncInterval(CalendarContract.AUTHORITY, newInterval)
|
||||||
|
settings.setSyncInterval(TaskProvider.ProviderName.OpenTasks.authority, newInterval)
|
||||||
loaderManager.restartLoader(0, arguments, this@AccountSettingsFragment)
|
loaderManager.restartLoader(0, arguments, this@AccountSettingsFragment)
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
prefSyncContacts.isEnabled = false
|
prefSync.isEnabled = false
|
||||||
prefSyncContacts.setSummary(R.string.settings_sync_summary_not_available)
|
prefSync.setSummary(R.string.settings_sync_summary_not_available)
|
||||||
}
|
|
||||||
|
|
||||||
val prefSyncCalendars = findPreference("sync_interval_calendars") as ListPreference
|
|
||||||
val syncIntervalCalendars = settings.getSyncInterval(CalendarContract.AUTHORITY)
|
|
||||||
if (syncIntervalCalendars != null) {
|
|
||||||
prefSyncCalendars.value = syncIntervalCalendars.toString()
|
|
||||||
if (syncIntervalCalendars == AccountSettings.SYNC_INTERVAL_MANUALLY)
|
|
||||||
prefSyncCalendars.setSummary(R.string.settings_sync_summary_manually)
|
|
||||||
else
|
|
||||||
prefSyncCalendars.summary = getString(R.string.settings_sync_summary_periodically, prefSyncCalendars.entry)
|
|
||||||
prefSyncCalendars.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
|
||||||
settings.setSyncInterval(CalendarContract.AUTHORITY, java.lang.Long.parseLong(newValue as String))
|
|
||||||
loaderManager.restartLoader(0, arguments, this@AccountSettingsFragment)
|
|
||||||
false
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
prefSyncCalendars.isEnabled = false
|
|
||||||
prefSyncCalendars.setSummary(R.string.settings_sync_summary_not_available)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val prefWifiOnly = findPreference("sync_wifi_only") as SwitchPreferenceCompat
|
val prefWifiOnly = findPreference("sync_wifi_only") as SwitchPreferenceCompat
|
||||||
|
@ -238,11 +238,10 @@
|
|||||||
<string name="settings_encryption_password_summary">Change your encryption password</string>
|
<string name="settings_encryption_password_summary">Change your encryption password</string>
|
||||||
<string name="settings_enter_encryption_password">Enter your encryption password:</string>
|
<string name="settings_enter_encryption_password">Enter your encryption password:</string>
|
||||||
<string name="settings_sync">Synchronization</string>
|
<string name="settings_sync">Synchronization</string>
|
||||||
<string name="settings_sync_interval_contacts">Contacts sync. interval</string>
|
<string name="settings_sync_interval">Sync interval</string>
|
||||||
<string name="settings_sync_summary_manually">Only manually</string>
|
<string name="settings_sync_summary_manually">Only manually</string>
|
||||||
<string name="settings_sync_summary_periodically" tools:ignore="PluralsCandidate">%s and immediately on local changes</string>
|
<string name="settings_sync_summary_periodically" tools:ignore="PluralsCandidate">%s and immediately on local changes</string>
|
||||||
<string name="settings_sync_summary_not_available">Not available</string>
|
<string name="settings_sync_summary_not_available">Not available</string>
|
||||||
<string name="settings_sync_interval_calendars">Calendars sync. interval</string>
|
|
||||||
<string-array name="settings_sync_interval_seconds" translateable="false">
|
<string-array name="settings_sync_interval_seconds" translateable="false">
|
||||||
<item>-1</item>
|
<item>-1</item>
|
||||||
<item>300</item>
|
<item>300</item>
|
||||||
|
@ -39,16 +39,9 @@
|
|||||||
android:dialogTitle="@string/settings_enter_password" />
|
android:dialogTitle="@string/settings_enter_password" />
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="sync_interval_contacts"
|
android:key="sync_interval"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:title="@string/settings_sync_interval_contacts"
|
android:title="@string/settings_sync_interval"
|
||||||
android:entries="@array/settings_sync_interval_names"
|
|
||||||
android:entryValues="@array/settings_sync_interval_seconds" />
|
|
||||||
|
|
||||||
<ListPreference
|
|
||||||
android:key="sync_interval_calendars"
|
|
||||||
android:persistent="false"
|
|
||||||
android:title="@string/settings_sync_interval_calendars"
|
|
||||||
android:entries="@array/settings_sync_interval_names"
|
android:entries="@array/settings_sync_interval_names"
|
||||||
android:entryValues="@array/settings_sync_interval_seconds" />
|
android:entryValues="@array/settings_sync_interval_seconds" />
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user