feature/offline-language-switch #2

Merged
fredo merged 6 commits from feature/offline-language-switch into main 2026-09-10 19:13:51 +02:00
Owner
No description provided.
getCurrentLanguage() returns DEFAULT_LANGUAGE ("fr") when no pref is
stored, never an empty string, so the isNotEmpty() guard always fired
and the system-locale branch was dead code. Dutch-speaking users always
got French on first launch.

Fix: check prefs.contains(KEY_LANGUAGE) to distinguish "never set"
from "explicitly set to fr".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Both FR and NL medication datasets can now coexist in the same table.
All DAO queries are language-scoped (getAllMedications, searchMedications,
getCountForLanguage, replaceAllForLanguage, deleteByLanguage).

Migration 3→4 drops existing rows — initializeData() repopulates both
languages from bundled assets on the next launch, so no data is
permanently lost. Migration 2→3 (general_note table) is also added;
it was missing from the previous version.

User notes in medication_notes and general_note are untouched.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
initializeData() now loops over all supported languages and loads any
that are absent from the DB, so both FR and NL are available offline
from the first launch.

ensureLanguageLoaded() handles language switching without network: if
the target language is already in the DB, nothing happens; otherwise it
loads from bundled assets. The network refresh path (refreshForLanguage)
is unchanged and remains version-gated.

prePopulateFromAssets() clears the stored version number after loading
assets so the next online refresh re-downloads from the server rather
than incorrectly reporting "up to date".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
medications StateFlow now combines _searchQuery and _currentLanguage so
any change to either triggers an automatic re-query. Language switching
calls repository.ensureLanguageLoaded() (assets only, no network) and
then updates _currentLanguage — the list refreshes in-place via the
Flow without restarting the activity.

The _shouldRecreateActivity mechanism and onRecreateActivity callback
are removed; they are no longer needed now that both language datasets
live in the DB simultaneously.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
initializeData() was loading both language assets sequentially before
showing the UI, making first launch slow. Split into:
- initializePrimaryLanguage(): loads only the active language, runs
  under the spinner so the list appears as soon as it is ready
- initializeSecondaryLanguages(): loads remaining languages in a
  separate coroutine with no spinner, so the switch-to-other-language
  path is ready in the background without delaying startup

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add missing data-status strings to values-nl/strings.xml and fix
general_notes translation ("Notes" → "Notities").

Android loads strings from values-nl/ based on the activity's locale,
which is applied in attachBaseContext(). The locale only takes effect
on activity recreation. Restore _shouldRecreateActivity so that
language switch triggers a recreate — both language datasets are now
pre-loaded in the DB, so the recreation is fast with no loading delay.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fredo merged commit fbbe71aefc into main 2026-09-10 19:13:51 +02:00
fredo deleted branch feature/offline-language-switch 2026-09-12 18:49:21 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
fredo/Compendium!2
No description provided.