Skip to content

refactor: extract ConjugationHandler from GeneralKeyboardIME (Part 12) - #426 - #687

Open
prince-0408 wants to merge 1 commit into
scribe-org:mainfrom
prince-0408:refactor/extract-conjugation-handler-426
Open

refactor: extract ConjugationHandler from GeneralKeyboardIME (Part 12) - #426#687
prince-0408 wants to merge 1 commit into
scribe-org:mainfrom
prince-0408:refactor/extract-conjugation-handler-426

Conversation

@prince-0408

Copy link
Copy Markdown
Collaborator

Description

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

It extracts verb conjugation state management, conjugation table layout calculation (2x1, 1x3, 3x2, 2x2), capitalization formatting, index boundary validation, and sub-view setup out of GeneralKeyboardIME.kt into a standalone helper class ConjugationHandler.

Detailed Changes Table

File / Component Changes Applied Detailed Impact
ConjugationHandler.kt Created standalone helper encapsulating conjugation state (subsequentAreaRequired, subsequentData, conjugateOutput, conjugateLabels), layout mode saving (saveConjugateModeType), capitalization formatting (applyCapitalizationToConjugations), index validation (getValidatedConjugateIndex), conjugation key press handling (handleConjugateKeys), secondary sub-view setup (setupConjugateSubView), and layout XML selection (getKeyboardLayoutForState). Extracts verb conjugation table formatting, multi-option selection sub-views, and layout grid mode calculations out of GeneralKeyboardIME.kt into a dedicated helper class.
GeneralKeyboardIME.kt Instantiated conjugationHandler and delegated conjugation state properties (subsequentAreaRequired, subsequentData) and helper methods (saveConjugateModeType, applyCapitalizationToConjugations, getValidatedConjugateIndex, returnIsSubsequentRequired, returnSubsequentData, handleConjugateKeys, setupConjugateSubView, getKeyboardLayoutForState). Removed duplicate private helper implementations and unused constants. Fulfills the core goal of #426 by decoupling verb conjugation layout and state management from GeneralKeyboardIME.kt while maintaining 100% backward compatibility for all callers.
ConjugationHandlerTest.kt Added unit tests covering capitalization formatting (applyCapitalizationToConjugations), index boundary clamping (getValidatedConjugateIndex), layout mode saving (saveConjugateModeType), and XML layout selection (getKeyboardLayoutForState). Ensures unit test coverage for verb conjugation helper logic using Robolectric and MockK.
CHANGELOG.md Added entry under ### ♻️ Code Refactoring detailing the extraction of ConjugationHandler from GeneralKeyboardIME. Satisfies ci_changelog_check workflow requirement for pull requests targeting main.

Key Benefits

  • Decoupled Conjugation & Layout Logic: Removes complex grid layout calculations (2x1, 1x3, 3x2, 2x2), verb tense capitalization rules, and multi-option selection sub-views from GeneralKeyboardIME.kt.
  • Improved Testability & Maintainability: Verb conjugation index validation, mode persistence, layout XML selection, and text capitalization can now be tested and maintained independently of IME service lifecycles.

Related Issue

Refactors part of #426

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.

1 participant