Skip to content

refactor: extract SuggestionUIHandler from GeneralKeyboardIME (Part 11) (#426) - #685

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

refactor: extract SuggestionUIHandler from GeneralKeyboardIME (Part 11) (#426)#685
prince-0408 wants to merge 1 commit into
scribe-org:mainfrom
prince-0408:refactor/extract-suggestion-ui-handler-426

Conversation

@prince-0408

Copy link
Copy Markdown
Collaborator

Description

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

It extracts auto-suggestion layout rendering, button styling, visibility toggling (between command buttons, gender suggestions, and emoji recommendations), and autocomplete button click handlers out of GeneralKeyboardIME.kt into a standalone helper class SuggestionUIHandler.

Detailed Changes Table

File / Component Changes Applied Detailed Impact
SuggestionUIHandler.kt Created standalone helper class encapsulating auto-suggest dispatcher (updateAutoSuggestText), single/dual suggestion button styling (handleSingleType, handleMultipleNounFormats), word prediction updates (handleWordSuggestions), and autocomplete completions (updateAutocompleteSuggestions, clearAutocomplete). Extracts ~430 lines of UI rendering and button styling logic out of GeneralKeyboardIME.kt into a focused helper component.
SuggestionUIHandlerTest.kt Added Robolectric unit tests verifying state updates, auto-suggest toggling, and autocomplete clearing. Ensures test coverage and regression prevention for SuggestionUIHandler.
GeneralKeyboardIME.kt Instantiated suggestionUIHandler and delegated updateAutoSuggestText, updateAutocompleteSuggestions, and clearAutocomplete to it. Removed private helper methods and unused extension functions. Reduces GeneralKeyboardIME.kt size by ~400 lines (from 2,061 lines down to 1,662 lines) while maintaining 100% backward compatibility.

Key Benefits

  • Decoupled Suggestion UI Architecture: Separates UI layout rendering, button styling, and click listeners from the core IME service lifecycle.
  • Dedicated Test Coverage: Added SuggestionUIHandlerTest.kt testing layout toggles and state synchronization.

Related Issue

Refactors part of #426

@prince-0408
prince-0408 force-pushed the refactor/extract-suggestion-ui-handler-426 branch from 8254a45 to 74bf7dc Compare August 24, 2026 19:48
@prince-0408
prince-0408 force-pushed the refactor/extract-suggestion-ui-handler-426 branch from 74bf7dc to e5ec7f6 Compare August 24, 2026 19:51
@andrewtavis

Copy link
Copy Markdown
Member

Thanks for the PR, @prince-0408! We'll get this PR in soon after bringing in the autosuggestion PRs 😊

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