File tree Expand file tree Collapse file tree 3 files changed +81
-1
lines changed
test/java/com/ichi2/anki/scheduling Expand file tree Collapse file tree 3 files changed +81
-1
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ import com.ichi2.anki.BuildConfig
3434import com.ichi2.anki.Info
3535import com.ichi2.anki.R
3636import com.ichi2.anki.launchCatchingTask
37+ import com.ichi2.anki.scheduling.Fsrs
3738import com.ichi2.anki.servicelayer.DebugInfoService
3839import com.ichi2.anki.settings.Prefs
3940import 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
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments