Downloaded or deleted dictionary is only used after the app process restarts

Chiusa
#761 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
android, kotlin
Ambito
mobile

Direzione di ricerca

Start with downloadDictionary() and DownloadableDictionaryRow in DictionaryUtils.kt, then the installed-dictionary delete button in DictionaryDialog.kt. Compare them with the NewDictionaryDialog add-from-file path, which already sends DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION, and trace how that broadcast reaches LatinIME.resetSuggestMainDict(). Done means a downloaded or deleted main dictionary takes effect in the same process, which you can check by typing English words without force-stopping the app.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug
After downloading a main dictionary in Settings → Languages & Layouts → Dictionaries → → Download, the keyboard keeps working without it until the app process restarts (force stop / reinstall). Deleting a dictionary there has the same problem: the keyboard keeps using the old one.

We noticed it with German + English (US) via multilingual typing. After downloading the English main dictionary, the keyboard still didn't know English words, and autocorrect turned "weather" into "Werther". The log showed only main:de loaded. After restarting the process, main:en_us was loaded and "weather" was kept.

Cause (from reading the code)

  • downloadDictionary() in DictionaryUtils.kt and the delete buttons (DownloadableDictionaryRow in DictionaryUtils.kt, installed dictionary row in DictionaryDialog.kt) don't send DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION. Adding a dictionary from a file (NewDictionaryDialog) does.
  • Without the broadcast, the keyboard only reaches resetDictionaryFacilitatorIfNecessary() (the pref pref_dict_download_link_* changed). That calls resetDictionaries(..., forceReloadMainDictionary = false, ...), which keeps the existing main dictionary of an already existing dictionary group. The log shows resetDictionaries, force reloading main dictionary: false.

Fix that works for us
Send the broadcast after a successful download and after deleting. It triggers LatinIME.resetSuggestMainDict(), which reloads with forceReloadMainDictionary = true:

context.sendBroadcast(Intent(DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION))

Tested: download → used right away; delete → gone right away; same process, no restart.

To Reproduce

  1. Use the keyboard once so its process is running.
  2. Settings → Languages & Layouts → Dictionaries → English (US) → download "Main dictionary: English (US) (legacy)".
  3. Type English words in a text field: no English suggestions/corrections until the app is force stopped.

Expected behavior
A downloaded or deleted dictionary takes effect right away.

App version & Flavor
Found in GlassType, my fork based on LeanType 4.3.0 (d634e26), standard flavor. The code is unchanged in current main (0e673e1).

Device Info

  • Model: Samsung Galaxy Z Fold 3 (SM-F926B) and Galaxy S23 Ultra (SM-S918B)
  • OS version: Android 15 / Android 17
Lingua principale
Kotlin
Stelle
1k
Fork
59
Merge medio
14h 9m
PR unite (30g)
56

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di LeanBitLab/LeanType

Tutte le issue di LeanBitLab/LeanType

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.