fix: 🐛 Updated setTextSlot function#135
Conversation
|
There was a problem hiding this comment.
Pull request overview
Adds typed text-slot support so callers can update text slots without wiping existing styling, addressing Issue #133 by reading the current slot document, swapping only the text, and writing the full document back.
Changes:
- Added
TextDocumentmodel with JSON (de)serialization for Lottie text-slot payloads. - Added
nativeGetSlotStrJNI binding and C++ implementation to read the current slot JSON. - Introduced
setTextSlot(slotId, document: TextDocument)overloads through the player, drawable, widgets, and Compose controller; updatedsetTextSlot(slotId, text: String)to preserve styling by round-tripping the document. - Bumped bundled native dlplayer version and library version.
Reviewed changes
Copilot reviewed 10 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| dotlottie/src/main/kotlin/com/lottiefiles/dotlottie/core/jni/DotLottiePlayer.kt | Adds JNI declaration for nativeGetSlotStr. |
| dotlottie/src/main/kotlin/com/dotlottie/dlplayer/TextDocument.kt | Introduces typed text-document representation and JSON conversion helpers. |
| dotlottie/src/main/kotlin/com/dotlottie/dlplayer/DotLottiePlayer.kt | Updates setTextSlot(String) to preserve styling; adds setTextSlot(TextDocument) and slot-document read helper. |
| dotlottie/src/main/java/com/lottiefiles/dotlottie/core/widget/DotLottieGLAnimation.kt | Exposes setTextSlot(slotId, TextDocument) for GL widget users. |
| dotlottie/src/main/java/com/lottiefiles/dotlottie/core/widget/DotLottieAnimation.kt | Exposes setTextSlot(slotId, TextDocument) for widget users. |
| dotlottie/src/main/java/com/lottiefiles/dotlottie/core/drawable/DotLottieDrawable.kt | Adds drawable-level setTextSlot(TextDocument) with frame scheduling. |
| dotlottie/src/main/java/com/lottiefiles/dotlottie/core/compose/runtime/DotLottieController.kt | Exposes setTextSlot(slotId, TextDocument) for Compose runtime users. |
| dotlottie/src/main/cpp/version.txt | Updates the embedded dlplayer version reference. |
| dotlottie/src/main/cpp/jni_bridge.cpp | Implements and registers nativeGetSlotStr. |
| dotlottie/build.gradle.kts | Bumps library version to 0.15.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add typed text slot support
Adds two
setTextSlotoverloads so callers can update a text slot eitherwith just a string or with full styling:
setTextSlot(slotId, text: String)— reads the slot's current document,swaps only the text, and writes it back (returns
falseif the slot hasno value). Fixes setTextSlot text can not show #133, where setting a string previously wiped the
document's font/size/color.
setTextSlot(slotId, document: TextDocument)— sets the full document.Also adds a
TextDocumenttype (text, font, size, colors, etc.) and thenativeGetSlotStrbinding to read the current slot value.Related PR -> LottieFiles/dotlottie-rs#586