Skip to content

refactor: standardize conjugate label language checks using ScribeLan… - #690

Open
akkicodes-dev wants to merge 2 commits into
scribe-org:mainfrom
akkicodes-dev:refactor/426-conjugate-labels-scribelanguage
Open

refactor: standardize conjugate label language checks using ScribeLan…#690
akkicodes-dev wants to merge 2 commits into
scribe-org:mainfrom
akkicodes-dev:refactor/426-conjugate-labels-scribelanguage

Conversation

@akkicodes-dev

Copy link
Copy Markdown

Summary

Standardizes conjugate label mode switching logic to use the ScribeLanguage enum instead of raw string comparisons, following the same pattern established in #672 and #673.

Changes

  • KeyboardUIManager.kt: Replaced hardcoded string checks (language == "English", language in listOf("Russian", "Swedish")) with ScribeLanguage.fromDisplayName() enum comparisons for conjugate grid layout selection (2x2/3x2)
  • ConjugateViewModel.kt: Replaced duplicated hardcoded language alias list (listOf("EN", "FR", "DE", "IT", "PT", "RU", "ES", "SV"), used in 2 places) with ScribeLanguage.entries.map { it.isoCode } as a single source of truth

Testing

  • ./gradlew lintKotlin detekt — passed
  • Added 6 new unit tests in KeyboardUIManagerTest.kt covering grid layout selection for English/Russian/Swedish/German, sub-selection priority, and unknown-language fallback
  • Added 3 new unit tests in ConjugateViewModelTest.kt verifying the enum-derived alias list matches the previous hardcoded list exactly
  • ./gradlew testKeyboardsDebugUnitTest testConjugateDebugUnitTest — all tests pass (BUILD SUCCESSFUL)
  • Note: physical device testing wasn't available for this PR, so verification relies on comprehensive unit test coverage of the changed logic instead

Note

Parts of this PR were AI-assisted (Antigravity); all changes were manually reviewed line-by-line, verified via local build/lint/test, and cross-checked against the codebase before submission.

Part of #426. Follows the pattern from #672 / #673.

@Roniscend

Roniscend commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

The language list code is repeated in two places and could be combined into one, and it'd be good to add a test for what happens if an unrecognized language is passed in.

@akkicodes-dev

Copy link
Copy Markdown
Author

Thanks for the feedback @Roniscend! I've made both changes:

  1. Extracted the duplicated ScribeLanguage.entries.map { it.isoCode } into a single SUPPORTED_ALIASES constant in a companion object — both getDownloadedLanguages() and performSearch() now reference it.
  2. Added edge-case tests for unrecognized language handling in ConjugateViewModelTest.kt (unrecognized DB files, format edge cases, and deserialization of unrecognized aliases). The KeyboardUIManagerTest.kt already had updateUI_UnknownLanguageString_FallsBackSafelyWithoutCrashing covering the UI-layer case.

All lint/detekt checks and unit tests pass. Let me know if this looks good!

@angrezichatterbox angrezichatterbox added the refactor Refactor code to improve quality label Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Refactor code to improve quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants