feat: Jetpack Compose reimplementation of GapFillTextView#1
Draft
feat: Jetpack Compose reimplementation of GapFillTextView#1
Conversation
- Upgrade build system: Gradle 8.4, AGP 8.2.2, Kotlin 1.9.22, Compose BOM 2024.02.01 - Add GapFillParser.kt: sealed Segment hierarchy + parseRawText() - Add GapFillState.kt: GapFillState (mutableStateOf-backed) + rememberGapFillState() - Add GapFillAnnotatedString.kt: AnnotatedString builder, inline deletion-icon content, Spanned→AnnotatedString converter, orderedAnswers helper - Add GapFillPopup.kt: DropdownMenu-based option picker (styled to match popupwnd_bkg.xml) - Add GapFillEditorDialog.kt: Dialog-based free-form editor with animated colour, no-scrim, keyboard handling - Add GapFillText.kt: GapFillConfig data class + GapFillText composable with idle detection, tap handling, and observer callbacks Agent-Logs-Url: https://github.com/rayworks/RichTextView/sessions/db30412a-5e23-4911-a342-83615401ef14 Co-authored-by: rayworks <1329281+rayworks@users.noreply.github.com>
- formattedFullText: use regex to match both {} and {placeholder} blanks
- populateAnswer: use local val to avoid redundant !! assertions on currentChecker
Agent-Logs-Url: https://github.com/rayworks/RichTextView/sessions/db30412a-5e23-4911-a342-83615401ef14
Co-authored-by: rayworks <1329281+rayworks@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
rayworks
April 15, 2026 03:26
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a pure-Compose equivalent of
GapFillTextView, replacing the View-based span/popup/dialog machinery with idiomatic Compose state, layout, and effect primitives. Also upgrades the build system to support Kotlin + Compose.Build system
richtextviewmodule (ui,foundation,material3,runtime,animation)namespacemoved fromAndroidManifesttobuild.gradleNew files —
com.rayworks.library.composeGapFillParser.ktParses raw gap-fill text into a typed segment list. Applies the same normalisation and markdown→HTML conversion (
Utils.getHtmlTextWithMarkups) as the original before splitting on{…}patterns.GapFillState.ktCompose state holder —
filledAnswersandactiveBlankIndexbacked bymutableStateOf. Includesreset(),firstUnfilledBlankIndex(), andformattedFullText()(regex-based so it handles both{}and{placeholder}blanks).GapFillAnnotatedString.ktBuilds the
AnnotatedStringfrom parsed segments + current state. Handles:BLANKstring annotations on every blank span for tap resolutionSpanStyle) on answered blanksTextDecoration.Underlinefor error-correction + review modeInlineTextContent+appendInlineContentfor the deletion-icon blankSpanned → AnnotatedStringconversion forStyleSpan/ForegroundColorSpanGapFillPopup.ktDropdownMenu-based option picker styled to matchpopupwnd_bkg.xml(blue, 8dp corners). Deletion option renders an icon+label row. Max 4 items visible before scroll.GapFillEditorDialog.ktDialog-based free-form editor. Background animates blue → orange-red when word limit is exceeded (mirrorsrectangle_gapfill_form_bkg*.xml). Dim scrim removed viaDialogWindowProvider. Keyboard hidden on dismiss.GapFillText.ktTop-level composable +
GapFillConfigdata class (replaces XML attrs and setter methods).BasicText+detectTapGestures+TextLayoutResult.getOffsetForPositionLaunchedEffect(interactionKey)— restarts on every blank tap, cancelling the previous delay (replacesHandler.postDelayed)AnswerResultObserver/AnswerCorrectionCheckercallback parity with the originalBoxcarries thewriting_text_frame_bkgborder (1dp light-grey stroke, 8dp corners)All existing Java source files are unchanged.