refactor: extract KeyboardStateManager from GeneralKeyboardIME (#426) - #678
Conversation
|
Thanks for the PR, @prince-0408! Maintainers are a bit busy for the next few days. @linreal, would you have a moment to take a look again? 😊 |
andrewtavis
left a comment
There was a problem hiding this comment.
praise: All's looking good on my end as well in terms of code and functionality. Thanks, @prince-0408! And thanks for the initial review, @linreal!
Hi @andrewtavis There are a few more refactoring PRs that I think would be good to raise. If you’re okay with it, I can work on those as well and create the PRs. |
|
Sounds good, @prince-0408! Feel free to write into #426 with your ideas, if they're not already covered by what's been planned there already. |
Description
This PR is Part 7 in modularizing
GeneralKeyboardIMEfor #426.It extracts
ScribeStatetracking, state transitions, invalid command state recording, and state query helpers out ofGeneralKeyboardIME.ktinto a standalone, unit-testable helper classKeyboardStateManager.Detailed Changes Table:
KeyboardStateManager.ktcurrentState(ScribeState),invalidCommandSource(ScribeState), transition methods (moveToState,moveToIdle,setInvalidState,reset), and state query getters (isIdle,isSelectCommand,isCommandBarActive,isInvalid,isAlreadyPlural).GeneralKeyboardIME.ktinto a dedicated, unit-testable class.GeneralKeyboardIME.ktstateManagerand delegatedcurrentState&invalidCommandSourceproperties. Refactored state transition methods (moveToIdleState(),onScribeKeyOptionsClicked(),onTranslateClicked(),onConjugateClicked(),onPluralClicked(),handlePluralOrTranslateState(),handleConjugateState()) to delegate toKeyboardStateManager.GeneralKeyboardIME.ktwhile preserving 100% backward compatibility for external callers.KeyboardStateManagerTest.ktmoveToState,moveToIdle), invalid state source recording (setInvalidState), query getters (isIdle,isCommandBarActive, etc.), and state reset (reset).Key Benefits:
GeneralKeyboardIME.ktinto a single-responsibility helper class.KeyHandler,BackspaceHandler,SuggestionHandler,ClipboardHandler,KeyboardUIManager, etc.).Related Issue
Refactors part of #426