refactor: extract ShiftHandler from GeneralKeyboardIME (Part 13) - #426 - #688
Conversation
|
@prince-0408 Does ShiftHandler accept an injectable time source for the double-tap logic, or is it calling System.currentTimeMillis() directly? Injecting a clock would keep those timing tests deterministic. |
At present Providing the possibility of injecting I will change |
|
Would you be able to fix the merge conflicts, @prince-0408? Would be great if we could then finalize this and maybe @Roniscend could do a quick review 😊 |
3d01faf to
6b5cbf4
Compare
|
After merging of part 12 there are some merge conflicts here can you look into it @prince-0408 |
Thank you for pointing this out @Roniscend. I will check on the merge conflicts and resolve them shortly. |
| class ShiftHandler( | ||
| private val ime: GeneralKeyboardIME, | ||
| ) { | ||
| var lastShiftPressTS: Long = 0L |
There was a problem hiding this comment.
Caps lock engages spuriously, handler keeps its own lastShiftPressTS while KeyHandler.resetShiftIfNeeded resets the IME's original field, so double-tap latches caps lock instead of one-char shift
|
|
||
| class ShiftHandlerTest { | ||
| @Test | ||
| fun initialLastShiftPressTS_isZero() { |
There was a problem hiding this comment.
New tests assert on local variables without ever instantiating ShiftHandler, so they'd pass even with finding 1's bug still present.
|
After these changes , this pr will also be good to merge |
|
@andrewtavis Requesting a final review from you and then this pr will be good to merge |
andrewtavis
left a comment
There was a problem hiding this comment.
praise: Functionality and code wise this looks great, @prince-0408! Thanks for the work, and thanks for the review, @Roniscend! 😊
Description
This PR is Part 13 in modularizing GeneralKeyboardIME for #426.
It extracts shift key state machine management (
SHIFT_OFF➔SHIFT_ON_ONE_CHAR➔SHIFT_ON_PERMANENT), caps lock double-tap timing logic (lastShiftPressTS,shiftPermToggleSpeed), and keyboard mode switching (handleKeyboardLetters,handleModeChange) out ofGeneralKeyboardIME.ktinto a standalone helper classShiftHandler.Detailed Changes Table
ShiftHandler.ktlastShiftPressTS,shiftPermToggleSpeed), shift state cycling (handleKeyboardLetters), and layout mode switching between letter keyboard and symbol keyboard pages (handleModeChange).GeneralKeyboardIME.ktinto a dedicated helper class.GeneralKeyboardIME.ktshiftHandlerand delegated shift and mode switching methods (handleKeyboardLetters,handleModeChange). SimplifiedKEYCODE_SHIFTkey handling in event listener and updatedgetPrimarySymbolKeyboardLayoutXML()tointernalvisibility.GeneralKeyboardIME.ktwhile maintaining 100% backward compatibility for all callers.ShiftHandlerTest.ktlastShiftPressTS) and double-tap caps lock lock timing logic.CHANGELOG.md### ♻️ Code Refactoringdetailing the extraction ofShiftHandlerfromGeneralKeyboardIME.ci_changelog_checkworkflow requirement for pull requests targetingmain.Key Benefits
GeneralKeyboardIME.kt.GeneralKeyboardIME.kt.Related Issue
Refactors part of #426