Skip to content

refactor: extract ClipboardHandler from GeneralKeyboardIME (#426) - #668

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

refactor: extract ClipboardHandler from GeneralKeyboardIME (#426)#668
prince-0408 wants to merge 1 commit into
scribe-org:mainfrom
prince-0408:refactor/extract-clipboard-handler-426

Conversation

@prince-0408

Copy link
Copy Markdown
Collaborator

Description

This PR is Part 3 of 6 in modularizing GeneralKeyboardIME to resolve #426.

It extracts all clipboard monitoring, suggestion chip state, and history panel operations out of GeneralKeyboardIME.kt into a dedicated helper class: ClipboardHandler.kt.

Detailed Changes Table:

File / Component Changes Applied Detailed Impact
ClipboardHandler.kt [NEW] Created dedicated helper class encapsulating clipboard state (latestClipText, hasNewClip), ClipboardMonitor callbacks, recycler view adapter setup, item deletion, and pin toggling. +126 lines added in a modular, decoupled helper class.
GeneralKeyboardIME.kt Delegated clipboard state properties and panel action methods (openClipboardPanel, closeClipboardPanel, hideClipboardSuggestionChip, onClipboardSuggestionClicked) to clipboardHandler. Reduced class size by ~100 lines (from 2,808 lines down to 2,743 lines).
GeneralKeyboardIME.kt — Lifecycle Hooks Updated onCreate(), onStartInputView(), and onFinishInputView() to trigger clipboardHandler.initClipboardMonitor(), startMonitoring(), and stopMonitoring(). Cleaned up service lifecycle methods.

Key Benefits:

  • Modularization: Isolates clipboard panel UI management, recycler view binding, and history persistence operations into ClipboardHandler.kt.
  • Monolith Size Reduction: Removes ~100 lines of boilerplate and UI management code from GeneralKeyboardIME.kt.
  • Zero Functional Changes: Retains exact clipboard behavior, chip visibility triggers, and database operations (ClipboardRepository).

Related Issue

Refactors part of #426

Type of Change

  • Refactoring (no functional changes, no API changes)

@prince-0408
prince-0408 requested a review from andrewtavis August 9, 2026 16:06
@prince-0408 prince-0408 self-assigned this Aug 9, 2026
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.

Code improvements to make Scribe ready for future features

1 participant