Skip to content

Commit d353d13

Browse files
david-allisonlukstbit
authored andcommitted
feat: display user-facing FSRS version
This was causing confusion for users Fixes 18825
1 parent 105b993 commit d353d13

File tree

3 files changed

+81
-1
lines changed

3 files changed

+81
-1
lines changed

AnkiDroid/src/main/java/com/ichi2/anki/preferences/AboutFragment.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import com.ichi2.anki.BuildConfig
3434
import com.ichi2.anki.Info
3535
import com.ichi2.anki.R
3636
import com.ichi2.anki.launchCatchingTask
37+
import com.ichi2.anki.scheduling.Fsrs
3738
import com.ichi2.anki.servicelayer.DebugInfoService
3839
import com.ichi2.anki.settings.Prefs
3940
import com.ichi2.anki.showThemedToast
@@ -72,7 +73,9 @@ class AboutFragment : Fragment(R.layout.about_layout) {
7273
"(anki " + BackendBuildConfig.ANKI_DESKTOP_VERSION + " / " + BackendBuildConfig.ANKI_COMMIT_HASH.subSequence(0, 8) + ")"
7374

7475
// FSRS version text
75-
view.findViewById<TextView>(R.id.about_fsrs).text = "(FSRS ${BackendBuildConfig.FSRS_VERSION})"
76+
view.findViewById<TextView>(R.id.about_fsrs).text = Fsrs.displayVersion ?.let { version ->
77+
"($version)"
78+
} ?: ""
7679

7780
// Logo secret
7881
view
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (c) 2025 David Allison <davidallisongithub@gmail.com>
3+
*
4+
* This program is free software; you can redistribute it and/or modify it under
5+
* the terms of the GNU General Public License as published by the Free Software
6+
* Foundation; either version 3 of the License, or (at your option) any later
7+
* version.
8+
*
9+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
10+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11+
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License along with
14+
* this program. If not, see <http://www.gnu.org/licenses/>.
15+
*/
16+
17+
package com.ichi2.anki.scheduling
18+
19+
import net.ankiweb.rsdroid.BuildConfig as BackendBuildConfig
20+
21+
/**
22+
* Functionality for [FSRS](https://github.com/open-spaced-repetition/)
23+
*/
24+
object Fsrs {
25+
val version = FsrsVersion(BackendBuildConfig.FSRS_VERSION)
26+
27+
/**
28+
* A user-facing string for the FSRS version.
29+
*
30+
* The underlying library version is not typically known to Anki users
31+
*
32+
* `null` is unexpected
33+
*/
34+
val displayVersion: String?
35+
get() = version.displayString
36+
}
37+
38+
@JvmInline
39+
value class FsrsVersion(
40+
val libraryVersion: String,
41+
) {
42+
val displayString: String? get() =
43+
when (libraryVersion) {
44+
"0.6.4" -> "FSRS 4.5"
45+
"4.1.1" -> "FSRS 6"
46+
else -> null
47+
}
48+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (c) 2025 David Allison <davidallisongithub@gmail.com>
3+
*
4+
* This program is free software; you can redistribute it and/or modify it under
5+
* the terms of the GNU General Public License as published by the Free Software
6+
* Foundation; either version 3 of the License, or (at your option) any later
7+
* version.
8+
*
9+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
10+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11+
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License along with
14+
* this program. If not, see <http://www.gnu.org/licenses/>.
15+
*/
16+
17+
package com.ichi2.anki.scheduling
18+
19+
import org.hamcrest.MatcherAssert.assertThat
20+
import org.hamcrest.Matchers.not
21+
import org.hamcrest.Matchers.nullValue
22+
import org.junit.Test
23+
24+
class FsrsTest {
25+
@Test
26+
fun `FSRS version is mapped to user-facing version`() {
27+
assertThat("FSRS ${Fsrs.version.libraryVersion} should be mapped to a user-facing version", Fsrs.displayVersion, not(nullValue()))
28+
}
29+
}

0 commit comments

Comments
 (0)