Skip to content

Commit 3c2f706

Browse files
authored
Merge pull request #10002 from wmontwe/feat-change-default-sync-interval-to-15
feat(sync): change default sync interval to 15 minutes
2 parents 1784d08 + 6e57bef commit 3c2f706

File tree

6 files changed

+85
-4
lines changed

6 files changed

+85
-4
lines changed

core/android/account/src/main/kotlin/net/thunderbird/core/android/account/AccountDefaultsProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ interface AccountDefaultsProvider {
4141

4242
const val DEFAULT_STRIP_SIGNATURE = true
4343

44-
const val DEFAULT_SYNC_INTERVAL = 60
44+
const val DEFAULT_SYNC_INTERVAL = 15
4545

4646
/**
4747
* Specifies how many messages will be shown in a folder by default. This number is set

feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/domain/entity/EmailCheckFrequency.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ enum class EmailCheckFrequency(
1818
;
1919

2020
companion object {
21-
val DEFAULT = EVERY_HOUR
21+
val DEFAULT = EVERY_15_MINUTES
2222
fun all() = entries.toImmutableList()
2323

2424
fun fromMinutes(minutes: Int): EmailCheckFrequency {

legacy/core/src/main/java/com/fsck/k9/preferences/AccountSettingsDescriptions.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.fsck.k9.preferences.Settings.V;
2121
import com.fsck.k9.preferences.upgrader.AccountSettingsUpgraderTo104;
2222
import com.fsck.k9.preferences.upgrader.AccountSettingsUpgraderTo106;
23+
import com.fsck.k9.preferences.upgrader.AccountSettingsUpgraderTo107;
2324
import com.fsck.k9.preferences.upgrader.AccountSettingsUpgraderTo53;
2425
import com.fsck.k9.preferences.upgrader.AccountSettingsUpgraderTo54;
2526
import com.fsck.k9.preferences.upgrader.AccountSettingsUpgraderTo74;
@@ -80,7 +81,8 @@ class AccountSettingsDescriptions {
8081
));
8182
s.put("automaticCheckIntervalMinutes", Settings.versions(
8283
new V(1, new IntegerResourceSetting(-1, R.array.check_frequency_values)),
83-
new V(61, new IntegerResourceSetting(60, R.array.check_frequency_values))
84+
new V(61, new IntegerResourceSetting(60, R.array.check_frequency_values)),
85+
new V(107, new IntegerResourceSetting(15, R.array.check_frequency_values))
8486
));
8587
s.put("chipColor", Settings.versions(
8688
new V(1, new ColorSetting(0xFF0000FF))
@@ -324,6 +326,7 @@ class AccountSettingsDescriptions {
324326
u.put(91, new AccountSettingsUpgraderTo91());
325327
u.put(104, new AccountSettingsUpgraderTo104());
326328
u.put(106, new AccountSettingsUpgraderTo106(new ServerSettingsDtoSerializer()));
329+
u.put(107, new AccountSettingsUpgraderTo107());
327330

328331
UPGRADERS = Collections.unmodifiableMap(u);
329332
}

legacy/core/src/main/java/com/fsck/k9/preferences/Settings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Settings {
3434
*
3535
* @see SettingsExporter
3636
*/
37-
public static final int VERSION = 106;
37+
public static final int VERSION = 107;
3838

3939
static Map<String, Object> validate(int version, Map<String, TreeMap<Integer, SettingsDescription<?>>> settings,
4040
Map<String, String> importedSettings, boolean useDefaultValues) {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.fsck.k9.preferences.upgrader
2+
3+
import com.fsck.k9.preferences.SettingsUpgrader
4+
5+
/**
6+
* Upgrade account settings
7+
*
8+
* - update the automatic check interval default from 60 to 15 minutes without
9+
* overwriting user-customized values (e.g., manual, 30 min, etc.).
10+
*/
11+
class AccountSettingsUpgraderTo107 : SettingsUpgrader {
12+
override fun upgrade(settings: MutableMap<String, Any?>) {
13+
val current = settings[AUTOMATIC_CHECK_INTERVAL_MINUTES_KEY] as? Int
14+
15+
when (current) {
16+
null -> settings[AUTOMATIC_CHECK_INTERVAL_MINUTES_KEY] = NEW_CHECK_INTERVAL_MINUTES
17+
OLD_DEFAULT_CHECK_INTERVAL_MINUTES -> {
18+
settings[AUTOMATIC_CHECK_INTERVAL_MINUTES_KEY] = NEW_CHECK_INTERVAL_MINUTES
19+
}
20+
else -> {
21+
// Keep user-selected value as-is
22+
}
23+
}
24+
}
25+
26+
private companion object {
27+
const val AUTOMATIC_CHECK_INTERVAL_MINUTES_KEY = "automaticCheckIntervalMinutes"
28+
const val OLD_DEFAULT_CHECK_INTERVAL_MINUTES = 60
29+
const val NEW_CHECK_INTERVAL_MINUTES = 15
30+
}
31+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.fsck.k9.preferences.upgrader
2+
3+
import assertk.assertThat
4+
import assertk.assertions.isEqualTo
5+
import kotlin.test.Test
6+
7+
class AccountSettingsUpgraderTo107Test {
8+
9+
@Test
10+
fun `should set automaticCheckIntervalMinutes when missing`() {
11+
val settings = mutableMapOf<String, Any?>()
12+
13+
AccountSettingsUpgraderTo107().upgrade(settings)
14+
15+
assertThat(settings[AUTOMATIC_CHECK_INTERVAL_MINUTES_KEY]).isEqualTo(NEW_CHECK_INTERVAL_MINUTES)
16+
}
17+
18+
@Test
19+
fun `should change automaticCheckIntervalMinutes from old default to new default value`() {
20+
val settings = mutableMapOf<String, Any?>(
21+
AUTOMATIC_CHECK_INTERVAL_MINUTES_KEY to OLD_DEFAULT_CHECK_INTERVAL_MINUTES,
22+
)
23+
24+
AccountSettingsUpgraderTo107().upgrade(settings)
25+
26+
assertThat(settings[AUTOMATIC_CHECK_INTERVAL_MINUTES_KEY]).isEqualTo(NEW_CHECK_INTERVAL_MINUTES)
27+
}
28+
29+
@Test
30+
fun `should keep custom automaticCheckIntervalMinutes for all allowed values`() {
31+
val customValues = listOf(-1, 15, 30, 120, 180, 360, 720, 1440)
32+
33+
customValues.forEach { value ->
34+
val settings = mutableMapOf<String, Any?>(AUTOMATIC_CHECK_INTERVAL_MINUTES_KEY to value)
35+
36+
AccountSettingsUpgraderTo107().upgrade(settings)
37+
38+
assertThat(settings[AUTOMATIC_CHECK_INTERVAL_MINUTES_KEY]).isEqualTo(value)
39+
}
40+
}
41+
42+
private companion object {
43+
const val AUTOMATIC_CHECK_INTERVAL_MINUTES_KEY = "automaticCheckIntervalMinutes"
44+
const val OLD_DEFAULT_CHECK_INTERVAL_MINUTES = 60
45+
const val NEW_CHECK_INTERVAL_MINUTES = 15
46+
}
47+
}

0 commit comments

Comments
 (0)