Skip to content

refactor: extract KeyboardDataHandler from GeneralKeyboardIME (Part 8) - #679

Merged
andrewtavis merged 2 commits into
scribe-org:mainfrom
prince-0408:refactor/keyboard-data-handler-426
Aug 23, 2026
Merged

refactor: extract KeyboardDataHandler from GeneralKeyboardIME (Part 8)#679
andrewtavis merged 2 commits into
scribe-org:mainfrom
prince-0408:refactor/keyboard-data-handler-426

Conversation

@prince-0408

Copy link
Copy Markdown
Collaborator

Description

This PR is Part 8 in modularizing GeneralKeyboardIME for #426.

It extracts database manager initializations, data contract loading, dictionary queries, translations, plurals, and autocompletion queries out of GeneralKeyboardIME.kt into a standalone helper class KeyboardDataHandler.

Detailed Changes Table:

File / Component Changes Applied Detailed Impact
KeyboardDataHandler.kt Created standalone helper encapsulating DatabaseManagers, AutocompletionDataManager, dictionary data contracts (dataContract, emojiKeywords, pluralWords, nounKeywords, suggestionWords, caseAnnotation, conjugateOutput, conjugateLabels), and query methods (loadLanguageData, getAutocompletions, getPluralRepresentation, getTranslation, queryConjugateData). Extracts database management and query handling out of GeneralKeyboardIME.kt into a dedicated helper class.
GeneralKeyboardIME.kt Instantiated dataHandler and delegated database data properties (dataContract, emojiKeywords, pluralWords, nounKeywords, suggestionWords, caseAnnotation, conjugateOutput, conjugateLabels, dbManagers, autocompletionManager). Refactored data loading & query methods (loadLanguageData, getAutocompletions, getPluralRepresentation, getTranslation) to delegate to KeyboardDataHandler. Fulfills the core goal of #426 by decoupling database access from GeneralKeyboardIME.kt while maintaining 100% backward compatibility for all callers.
KeyboardDataHandlerTest.kt Added unit tests covering initial uninitialized state, autocompletion exception handling, and plural representation lookups (handling null, empty, and ALREADY_PLURAL_MSG). Ensures unit test coverage for database helper logic.

Key Benefits:

  • Decoupled Database Architecture: Removes direct DatabaseManagers access and dictionary contract handling from GeneralKeyboardIME.kt.
  • Improved Testability & Maintainability: Database querying and dictionary loading can now be tested and maintained independently of IME service lifecycles.
  • Zero Behavioral / API Breakage: Preserves exact query responses and retains property delegation for zero breaking changes across existing helpers (KeyHandler, BackspaceHandler, SuggestionHandler, AutocompletionHandler, KeyboardUIManager, etc.).

Related Issue

Refactors part of #426

@andrewtavis

Copy link
Copy Markdown
Member

Thanks for the PR, @prince-0408! Similarly, @linreal, if you'd have a moment to check it'd be great, but I can also take a look over the weekend at some point 😊

@prince-0408

Copy link
Copy Markdown
Collaborator Author

Thanks for the PR, @prince-0408! Similarly, @linreal, if you'd have a moment to check it'd be great, but I can also take a look over the weekend at some point 😊

Thanks @andrewtavis! Take your time, no rush at all. Have a great weekend! 😊

@andrewtavis andrewtavis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Checking this with @angrezichatterbox now, @prince-0408 😊 All's looking good for us! Thanks so much for your continued work on refactoring :)

@andrewtavis
andrewtavis merged commit 0be9455 into scribe-org:main Aug 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants