feat(android): add support for custom style#648
Open
kacperzolkiewski wants to merge 7 commits into
Open
Conversation
…wski/feat-custom-style-android
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Android support for applying and persisting custom foreground/background colors in the enriched text editor by introducing a dedicated custom-style span, plumbing it through editing/state, and extending HTML parsing/serialization for <span style="...">.
Changes:
- Introduces
CustomStylesand aEnriched*CustomStyleSpanto apply/merge/split foreground & background color spans during editing. - Extends span/state plumbing to track and emit
customStyleinonChangeState, and wiressetStyle(...)command on Android. - Updates HTML import/export to parse/serialize CSS
color/background-colorvia a newEnrichedColorParser.
Reviewed changes
Copilot reviewed 17 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| android/src/main/java/com/swmansion/enriched/textinput/watchers/EnrichedTextWatcher.kt | Runs custom-style span maintenance after text edits. |
| android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpanState.kt | Tracks customStyle and emits it in state payload. |
| android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSelection.kt | Detects active custom-style at selection and updates span state. |
| android/src/main/java/com/swmansion/enriched/textinput/styles/CustomStyles.kt | New: applies custom-style spans for selection/caret and maintains span integrity. |
| android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedSpans.kt | Registers the new custom-style span type and merging config. |
| android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputCustomStyleSpan.kt | New: input-side custom-style span implementation. |
| android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputViewManager.kt | Implements Android setStyle command by delegating to the view. |
| android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputView.kt | Adds setStyle(...) entrypoint and transactions for applying custom style. |
| android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputSpannableFactory.kt | Creates custom-style spans when parsing HTML into the input. |
| android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextCustomStyleSpan.kt | New: read-only text rendering custom-style span implementation. |
| android/src/main/java/com/swmansion/enriched/text/EnrichedTextSpanFactory.kt | Creates custom-style spans when parsing HTML for enriched text rendering. |
| android/src/main/java/com/swmansion/enriched/common/spans/EnrichedCustomStyleSpan.kt | New: base span that applies foreground/background colors to TextPaint. |
| android/src/main/java/com/swmansion/enriched/common/parser/EnrichedSpanFactory.kt | Adds factory method for creating custom-style spans. |
| android/src/main/java/com/swmansion/enriched/common/parser/EnrichedParser.java | Parses <span style> to spans and serializes custom-style spans back to <span style>. |
| android/src/main/java/com/swmansion/enriched/common/parser/EnrichedColorParser.kt | New: parses CSS colors and serializes ARGB to hex. |
| android/src/main/java/com/swmansion/enriched/common/EnrichedSpanFlags.kt | Assigns priority/flags for custom-style spans. |
| android/src/main/java/com/swmansion/enriched/common/CustomStyle.kt | New: stores foreground/background color state. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…wski/feat-custom-style-android
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.
Summary
Add custom style to support foreground and background colors
Test Plan
Run the example app and experiment with applying foreground and background colors through the toolbar across different text styles.
Screenshots / Videos
Screen.Recording.2026-06-22.at.09.08.41.mov
Compatibility
Checklist