Skip to content

refactor: extract KeyboardThemeManager from GeneralKeyboardIME (Part 9) - #426 - #682

Open
prince-0408 wants to merge 1 commit into
scribe-org:mainfrom
prince-0408:refactor/keyboard-theme-manager-426
Open

refactor: extract KeyboardThemeManager from GeneralKeyboardIME (Part 9) - #426#682
prince-0408 wants to merge 1 commit into
scribe-org:mainfrom
prince-0408:refactor/keyboard-theme-manager-426

Conversation

@prince-0408

Copy link
Copy Markdown
Collaborator

Description

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

It extracts navigation bar color configuration, window decor insets, light/dark appearance controllers, empty state banner drawables, multi-layer suggestion button styling, and relative luminance calculations out of GeneralKeyboardIME.kt into a standalone helper class KeyboardThemeManager.

Detailed Changes Table

File / Component Changes Applied Detailed Impact
KeyboardThemeManager.kt Created standalone helper encapsulating system bar colors & insets (applyNavBarColor), empty-state banner themes (applyBannerTheme), multi-layer suggestion button styling (applyInformativeSuggestionStyle), single suggestion pill formatting (applySingleSuggestionStyle), word suggestion text colors (getSuggestionTextColor), and luminance calculations (isLightColor). Extracts UI theme resolution, drawable shape creation, and window insets management out of GeneralKeyboardIME.kt into a dedicated helper class.
GeneralKeyboardIME.kt Instantiated themeManager and delegated theme styling, banner formatting, navigation bar configuration, and suggestion button rendering (applyNavBarColor, applyBannerTheme, handlePluralIfNeeded, handleSingleType, setSuggestionButton). Removed direct ContextCompat drawable/tint boilerplate and unused imports. Fulfills the core goal of #426 by decoupling UI styling and theme management from GeneralKeyboardIME.kt while maintaining 100% backward compatibility for all callers.
FloatingKeyboardHandler.kt Updated ime.applyNavBarColorPublic() call to ime.applyNavBarColor() directly, allowing removal of the redundant forwarder method. Cleans up internal IME helper invocation pathways.
KeyboardThemeManagerTest.kt Added unit tests covering relative luminance calculations (isLightColor) for WHITE, BLACK, LTGRAY, and DKGRAY. Ensures unit test coverage for theme helper logic.

Key Benefits

  • Decoupled Theme & UI Styling Architecture: Removes direct window insets management, decor view modifications, and drawable shape tinting from GeneralKeyboardIME.kt.
  • Improved Testability & Maintainability: Theme resolutions, luminance evaluation, and system bar behaviors can now be tested and maintained independently of IME service lifecycles.
  • Zero Behavioral / API Breakage: Preserves exact navigation bar contrast, floating mode transient UI flags, banner theme styles, and suggestion button layouts for zero visual or functional regressions.

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