Skip to content

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

Merged
andrewtavis merged 2 commits into
scribe-org:mainfrom
prince-0408:refactor/keyboard-theme-manager-426
Aug 23, 2026
Merged

refactor: extract KeyboardThemeManager from GeneralKeyboardIME (Part 9) - #426#682
andrewtavis merged 2 commits 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

@angrezichatterbox
angrezichatterbox force-pushed the refactor/keyboard-theme-manager-426 branch from 5d52e2a to 408f836 Compare August 23, 2026 18:34
@andrewtavis andrewtavis added the no-changelog No changelog entry is needed for this pull request label Aug 23, 2026
@andrewtavis

Copy link
Copy Markdown
Member

Note @Mounil2005: The CI changelog check's working! Really cool for a first experience with it 😊

@andrewtavis andrewtavis removed the no-changelog No changelog entry is needed for this pull request label Aug 23, 2026

@andrewtavis andrewtavis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Checking this with @angrezichatterbox now, @prince-0408 😊 Thanks for the continued work on refactoring and coordinating the work to be done here! :) :)

@andrewtavis
andrewtavis merged commit 873fc73 into scribe-org:main Aug 23, 2026
8 checks passed
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