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 @@ -46,6 +46,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
- 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.
- Persistent personal dictionary with in-app word management, 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 @@ -81,7 +81,7 @@ Exit criterion: correction remains usable in common editable applications even w

- [x] Grammalecte rule-category settings
- [x] Dictionary choice: all variants / classic / 1990 reform
- [ ] Personal dictionary
- [x] Personal dictionary
- [ ] Reset-to-default controls
- [ ] Import/export of non-sensitive preferences
- [ ] Clear status screen for native spell-checker and IME activation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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.GrammalectePersonalDictionaryPreferences
import fr.grammalecteandroid.engine.GrammalecteQuickJsEngine
import fr.grammalecteandroid.engine.GrammalecteRulePreferences
import org.junit.Assert.assertEquals
Expand Down Expand Up @@ -226,6 +227,57 @@ class GrammalecteEngineInstrumentedTest {
}
}

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

val preferences =
GrammalectePersonalDictionaryPreferences(context)

val personalWord =
"grammalecteandroidique"

preferences.reset()

val engine =
GrammalecteQuickJsEngine(context)

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

try {
assertFalse(
"Expected personal word to be unknown initially",
isValid(),
)

preferences.replace(
listOf(personalWord),
)

assertTrue(
"Expected existing engine to load stored personal word",
isValid(),
)

preferences.reset()

assertFalse(
"Expected existing engine to remove cleared personal word",
isValid(),
)
} 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 @@ -31,4 +31,25 @@ class RuleSettingsManifestTest {
activity.exported,
)
}

@Suppress("DEPRECATION")
@Test
fun personalDictionaryActivityIsInternal() {
val context =
ApplicationProvider.getApplicationContext<Context>()

val activity =
context.packageManager.getActivityInfo(
ComponentName(
context,
PersonalDictionaryActivity::class.java,
),
PackageManager.GET_META_DATA,
)

assertFalse(
"Personal dictionary activity must not be exported",
activity.exported,
)
}
}
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
android:name=".RuleSettingsActivity"
android:exported="false" />

<activity
android:name=".PersonalDictionaryActivity"
android:exported="false" />

<activity
android:name=".MainActivity"
android:exported="true">
Expand Down
Loading
Loading