-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] PlatformTextInputService2 #1853
base: jb-main
Are you sure you want to change the base?
Conversation
a22af3e
to
d303828
Compare
updateTextFieldValue(newValue.toTextFieldValue()) | ||
val outputValueFlow = callbackFlow { | ||
state.collectImeNotifications { oldValue, newValue, restartIme -> | ||
println("IME Notification: oldValue=$oldValue, newValue=$newValue, restartIme=$restartIme") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove or wrap into some private debug flag
* If there aren't enough codepoints in the correct direction, returns 0 (if [offset] is negative) | ||
* or the length of the char sequence (if [offset] is positive). | ||
*/ | ||
private fun CharSequence.indexOfCodePointAtOffset(index: Int, offset: Int): Int { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not obvious logic, it's better to cover this function with tests separately
fun setComposingText(text: CharSequence, newCursorPosition: Int) | ||
} | ||
|
||
interface PlatformTextInputService2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All public APIs should be covered by KDocs
// | ||
// continuation.invokeOnCancellation { | ||
// textInputService.stopInput() | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented code before the merge
import androidx.compose.ui.geometry.Rect | ||
import androidx.compose.ui.text.TextRange | ||
|
||
interface TextEditorState : CharSequence { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to make it stable from the start?
d303828
to
56c4edb
Compare
private fun TextFieldCharSequence.asTextEditorState() = object : TextEditorState { | ||
|
||
override val length: Int | ||
get() = this@asTextEditorState.length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we need to override this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole wrapper is because TextFieldCharSequence
is in foundation, but PlatformTextInputService(2)
is in ui. So foundation needs to wrap it in an interface that's available in ui.
override val composition: TextRange? | ||
get() = this@asTextEditorState.composition | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same question about all overrides - I miss the context - for me this looks like redundant delegation - why we are doing this?
This is a WIP PR for transitioning the implementation of BTF2 away from using
PlatformTextInputService
andTextFieldValue
.