https://kotlinlang.org logo
#compose-android
Title
# compose-android
s

Sergey Y.

02/21/2024, 2:42 PM
Is there an alternative to
android.text.style.ReplacementSpan
for use with Jetpack Compose's
BasicTextField
or
BasicTextField2
? I need a way to customize character widths according to my specific requirements.
e

ephemient

02/21/2024, 2:44 PM
InlineContent
hmm I never tried with text fields though
s

Sergey Y.

02/21/2024, 2:45 PM
Unfortunatelly text fields do not support InlineContent
e

ephemient

02/21/2024, 2:45 PM
you may need to
AndroidView { EditText }
:-/
s

Sergey Y.

02/21/2024, 2:46 PM
Yeah, looks like we have to wait
We are considering the
AndroidView { EditText }
option.
To be honest, it would be ideal to have a convenient keyboard input connection manager with text update callbacks, without needing an editable view. For my use case, I don't even need
TextField
to draw anything, as I have a renderer for that. However, upon examining the internals of `BasicTextField`/`BasicTextField2`, the amount of infrastructure code required to properly handle
InputConnection
and various connection callbacks is substantial. Considering this, I'd prefer to use
EditText
within
AndroidView
.
z

Zach Klippenstein (he/him) [MOD]

02/21/2024, 4:23 PM
This is something we’ve got on our roadmap once the text field rewrite is done. I think it’s going to be very challenging to find the right api shape though, because: • cursor/selection gestures are also pretty complex, and so if we’re only providing the IC stuff all the gestures would be on you. • There’s the question of other input methods: would this thing handle hardware keys too, or only the IME/soft keyboard? What accessibility features would it support? Etc.
It would be helpful for future us if you could file a feature request with exactly what you’d like to see, so we have it on the record when we get around to designing it.
s

Sergey Y.

02/21/2024, 4:30 PM
I agree with everything you said, Zach. Delving deeper into the feature may complicate things, especially as we prepare it for broader use as part of a library API. I'll create a feature request ticket to outline the case and its purpose. We can start gradually, initially exposing some internal APIs for simpler cases. This will allow users to implement what they need while we iteratively expand the API surface.
👍🏻 1
z

Zach Klippenstein (he/him) [MOD]

02/21/2024, 4:34 PM
Thanks! I think this will be a fun design challenge, as long as we have a good set of constraints like this.
K 1
s

Sergey Y.

02/21/2024, 4:42 PM
Speaking generally, since you are a text expert in Compose (I saw that stream where you and the Italians were explaining BTF2 😜), do you think that in my situation, the only feasible solution is to stick with
EditText
? Does Compose have nothing to offer at this time to address my issue? thanks in advance. https://kotlinlang.slack.com/archives/CJLTWPH7S/p1708467781640219?thread_ts=1708467731.309909&cid=CJLTWPH7S
z

Zach Klippenstein (he/him) [MOD]

02/21/2024, 6:15 PM
Yea, at this point I think that’s your best option. I don’t think inline content would even necessarily be a good tool for this even if it were available already on text fields
❤️ 1
s

Sergey Y.

02/21/2024, 9:32 PM
9 Views