Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
- Reproducible Android application compatibility matrix with a helper for collecting device, Android and application-version metadata.
- Grammalecte rule-option engine API exposing upstream rule groups, French labels, current/default states, option updates and reset support.
- Persistent in-app Grammalecte rule settings shared by the native spell checker, PROCESS_TEXT workflow and correction IME.
- Persistent dictionary selection between all variants, classic orthography and the 1990 reform, shared by all correction modes.

### Changed

Expand Down
2 changes: 1 addition & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Exit criterion: correction remains usable in common editable applications even w
## Phase 3 — User controls

- [x] Grammalecte rule-category settings
- [ ] Dictionary choice: all variants / classic / 1990 reform
- [x] Dictionary choice: all variants / classic / 1990 reform
- [ ] Personal dictionary
- [ ] Reset-to-default controls
- [ ] Import/export of non-sensitive preferences
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import android.content.Context
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import fr.grammalecteandroid.core.IssueKind
import fr.grammalecteandroid.engine.GrammalecteDictionary
import fr.grammalecteandroid.engine.GrammalecteDictionaryPreferences
import fr.grammalecteandroid.engine.GrammalecteQuickJsEngine
import fr.grammalecteandroid.engine.GrammalecteRulePreferences
import org.junit.Assert.assertEquals
Expand Down Expand Up @@ -147,6 +149,83 @@ class GrammalecteEngineInstrumentedTest {
}
}

@Test
fun existingEngineRefreshesStoredDictionarySelection() {
val context =
ApplicationProvider.getApplicationContext<Context>()

val preferences =
GrammalecteDictionaryPreferences(context)

preferences.reset()

val engine =
GrammalecteQuickJsEngine(context)

fun isValid(word: String): Boolean =
engine
.checkWord(
word = word,
localeTag = "fr-FR",
suggestionLimit = 5,
).valid

try {
assertTrue(
"Expected classic spelling to be valid by default",
isValid("coût"),
)

assertTrue(
"Expected reformed spelling to be valid by default",
isValid("cout"),
)

preferences.select(
GrammalecteDictionary.CLASSIC,
)

assertTrue(
"Expected classic spelling after selecting classic dictionary",
isValid("coût"),
)

assertFalse(
"Expected reformed spelling to be rejected by classic dictionary",
isValid("cout"),
)

preferences.select(
GrammalecteDictionary.REFORM_1990,
)

assertFalse(
"Expected classic spelling to be rejected by reformed dictionary",
isValid("coût"),
)

assertTrue(
"Expected reformed spelling after selecting reform dictionary",
isValid("cout"),
)

preferences.reset()

assertTrue(
"Expected classic spelling after restoring all variants",
isValid("coût"),
)

assertTrue(
"Expected reformed spelling after restoring all variants",
isValid("cout"),
)
} finally {
preferences.reset()
engine.close()
}
}

private fun withEngine(block: (GrammalecteQuickJsEngine) -> Unit) {
val context =
ApplicationProvider.getApplicationContext<Context>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,14 @@ class MainActivity :

content.addView(
createCard(
title = "Règles de correction",
title = "Réglages de correction",
description =
"Activez ou désactivez les catégories et contrôles " +
"Choisissez le dictionnaire et les contrôles " +
"Grammalecte utilisés dans les analyses.",
statusView = null,
actions =
listOf(
"Configurer les règles" to {
"Configurer" to {
startActivity(
Intent(
this@MainActivity,
Expand Down
Loading
Loading