Skip to content

Commit fea818e

Browse files
BrayanDSOmikehardy
authored andcommitted
refactor: reorder CollectionPreferences
1 parent 72ea925 commit fea818e

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

AnkiDroid/src/main/java/com/ichi2/anki/utils/CollectionPreferences.kt

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import kotlin.time.toDuration
3030
* @see [anki.config.Preferences]
3131
*/
3232
object CollectionPreferences {
33+
// region Reviewing
3334
suspend fun getShowRemainingDueCounts(): Boolean = withCol { getPreferences() }.reviewing.showRemainingDueCounts
3435

3536
suspend fun setShowRemainingDueCounts(value: Boolean) {
@@ -42,6 +43,8 @@ object CollectionPreferences {
4243
Timber.i("Set showRemainingDueCounts to %b", value)
4344
}
4445

46+
suspend fun getHidePlayAudioButtons(): Boolean = withCol { getPreferences() }.reviewing.hideAudioPlayButtons
47+
4548
suspend fun setHideAudioPlayButtons(value: Boolean) {
4649
val prefs = withCol { getPreferences() }
4750
val newPrefs =
@@ -54,8 +57,6 @@ object CollectionPreferences {
5457

5558
suspend fun getShowIntervalOnButtons(): Boolean = withCol { getPreferences() }.reviewing.showIntervalsOnButtons
5659

57-
suspend fun getHidePlayAudioButtons(): Boolean = withCol { getPreferences() }.reviewing.hideAudioPlayButtons
58-
5960
suspend fun setShowIntervalsOnButtons(value: Boolean) {
6061
val prefs = withCol { getPreferences() }
6162
val newPrefs =
@@ -66,31 +67,34 @@ object CollectionPreferences {
6667
Timber.i("Set showIntervalsOnButtons to %b", value)
6768
}
6869

69-
suspend fun getLearnAheadLimit(): Duration = withCol { getPreferences() }.scheduling.learnAheadSecs.toDuration(DurationUnit.SECONDS)
70+
suspend fun getTimeboxTimeLimit(): Duration = withCol { getPreferences() }.reviewing.timeLimitSecs.toDuration(DurationUnit.SECONDS)
7071

71-
suspend fun setLearnAheadLimit(limit: Duration) {
72+
suspend fun setTimeboxTimeLimit(limit: Duration) {
7273
val prefs = withCol { getPreferences() }
7374
val newPrefs =
7475
prefs.copy {
75-
scheduling = prefs.scheduling.copy { learnAheadSecs = limit.toInt(DurationUnit.SECONDS) }
76+
reviewing = prefs.reviewing.copy { timeLimitSecs = limit.toInt(DurationUnit.SECONDS) }
7677
}
77-
7878
undoableOp { setPreferences(newPrefs) }
79-
Timber.i("set learn ahead limit: '%d'", limit.toInt(DurationUnit.SECONDS))
79+
Timber.i("Set timeLimitSecs to %d", limit.toInt(DurationUnit.SECONDS))
8080
}
81+
//endregion
8182

82-
suspend fun getTimeboxTimeLimit(): Duration = withCol { getPreferences() }.reviewing.timeLimitSecs.toDuration(DurationUnit.SECONDS)
83+
//region Scheduling
84+
suspend fun getLearnAheadLimit(): Duration = withCol { getPreferences() }.scheduling.learnAheadSecs.toDuration(DurationUnit.SECONDS)
8385

84-
suspend fun setTimeboxTimeLimit(limit: Duration) {
86+
suspend fun setLearnAheadLimit(limit: Duration) {
8587
val prefs = withCol { getPreferences() }
8688
val newPrefs =
8789
prefs.copy {
88-
reviewing = prefs.reviewing.copy { timeLimitSecs = limit.toInt(DurationUnit.SECONDS) }
90+
scheduling = prefs.scheduling.copy { learnAheadSecs = limit.toInt(DurationUnit.SECONDS) }
8991
}
92+
9093
undoableOp { setPreferences(newPrefs) }
91-
Timber.i("Set timeLimitSecs to %d", limit.toInt(DurationUnit.SECONDS))
94+
Timber.i("set learn ahead limit: '%d'", limit.toInt(DurationUnit.SECONDS))
9295
}
9396

9497
@VisibleForTesting
9598
suspend fun getDayOffset(): Int = withCol { getPreferences() }.scheduling.rollover
99+
//endregion
96100
}

0 commit comments

Comments
 (0)