Status Update
Comments
cl...@google.com <cl...@google.com>
po...@google.com <po...@google.com> #2
Branch: androidx-main
commit 0d92f9936b46c7f380d4114c1334f1eca5e2818f
Author: Zach Klippenstein <klippenstein@google.com>
Date: Fri Mar 10 14:27:30 2023
Rewrite PlatformTextInput* to be more session-oriented.
This completely changes how text input clients interact with the
PlatformTextInput system. Instead of reading a composition local to get
the registry, and then asking the registry for the adapter for their
plugin, they now must implement a Modifier.Node that implements the
PlatformTextInputModifierNode interface. Such nodes have access to a
suspend function that will show the keyboard and ask the system to start
a new input session. The function takes platform-specific input that
specifies how to wire up to the platform APIs. The lifetime of the
coroutine is tied to the lifetime of the input session: the function
will suspend the calling coroutine until the session is closed, and
cancelling the coroutine early will close the session. When the last
session is closed the keyboard will automatically be hidden.
See go/platform-text-input for more info.
PlatformTextInput APIs were originally introduced in aosp/2406439.
Fixes:
Fixes:
Bug:
Test: AndroidTextInputSessionRequestTest
Test: AndroidPlatformTextInputSessionTest
Test: NullableInputConnectionWrapperTest
Test: SessionMutexTest
Test: PlatformTextInputViewIntegrationTest
Test: DesktopTextInputSessionTest
Relnote: "Completely redesigned `PlatformTextInput*` API."
Change-Id: I6c93a1111561b5cb55c6a34e2fc3738be3c8941d
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/PlatformTextInputAdapterDemo.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TextDemos.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text2/BasicTextField2Demos.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text2/BasicTextField2ImmIntegrationTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text2/BasicTextField2Test.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text2/TextFieldKeyboardActionsTest.kt
D compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text2/input/internal/AndroidTextInputAdapterTest.kt
A compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text2/input/internal/AndroidTextInputSessionTest.kt
M compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/text2/BasicTextField2.kt
D compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/text2/input/internal/AndroidTextInputAdapter.kt
D compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/text2/input/internal/AndroidTextInputPlugin.kt
A compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/text2/input/internal/AndroidTextInputSession.android.kt
M compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/text2/input/internal/TextFieldDecoratorModifier.kt
D compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text2/input/internal/TextInputCommandExecutorTest.kt
M compose/ui/ui-text/api/current.txt
M compose/ui/ui-text/api/restricted_current.txt
D compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/input/PlatformTextInputAdapter.android.kt
A compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/input/PlatformTextInputMethodRequest.android.kt
D compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/input/PlatformTextInputAdapter.kt
A compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/input/PlatformTextInputMethodRequest.kt
M compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/input/TextInputService.kt
D compose/ui/ui-text/src/desktopMain/kotlin/androidx/compose/ui/text/input/PlatformTextInputAdapter.desktop.kt
A compose/ui/ui-text/src/desktopMain/kotlin/androidx/compose/ui/text/input/PlatformTextInputMethodRequest.desktop.kt
M compose/ui/ui/api/current.ignore
M compose/ui/ui/api/current.txt
M compose/ui/ui/api/restricted_current.ignore
M compose/ui/ui/api/restricted_current.txt
A compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/PlatformTextInputModifierNodeSample.kt
M compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidComposeViewAccessibilityDelegateCompatTest.kt
M compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/HitPathTrackerTest.kt
M compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInputEventProcessorTest.kt
M compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/Helpers.kt
M compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/LocalSoftwareKeyboardControllerTest.kt
A compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/text/input/AndroidPlatformTextInputSessionTest.kt
A compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/text/input/NullableInputConnectionWrapperTest.kt
D compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/text/input/PlatformTextInputAdapterRegistryTest.kt
D compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/text/input/PlatformTextInputEditTextIntegrationTest.kt
M compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/text/input/PlatformTextInputViewIntegrationTest.kt
A compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/text/input/TestInputMethodRequest.kt
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeView.android.kt
A compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidPlatformTextInputSession.kt
A compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/PlatformTextInputSession.android.kt
D compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/text/input/AndroidTextInputServicePlugin.kt
A compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/text/input/NullableInputConnectionWrapper.kt
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/text/input/TextInputServiceAndroid.android.kt
A compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/AtomicReference.kt
A compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/SessionMutex.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/Owner.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/platform/CompositionLocals.kt
A compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/platform/PlatformTextInputModifierNode.kt
M compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/awt/ComposeLayer.desktop.kt
M compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/DesktopPlatformInput.desktop.kt
A compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/DesktopTextInputSession.kt
M compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/PlatformComponent.desktop.kt
A compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/PlatformTextInputSession.desktop.kt
A compose/ui/ui/src/desktopTest/kotlin/androidx/compose/ui/platform/DesktopTextInputSessionTest.kt
A compose/ui/ui/src/jvmMain/kotlin/androidx/compose/ui/AtomicReference.jvm.kt
M compose/ui/ui/src/skikoMain/kotlin/androidx/compose/ui/platform/PlatformInput.skiko.kt
M compose/ui/ui/src/skikoMain/kotlin/androidx/compose/ui/platform/SkiaBasedOwner.skiko.kt
A compose/ui/ui/src/test/kotlin/androidx/compose/ui/SessionMutexTest.kt
M compose/ui/ui/src/test/kotlin/androidx/compose/ui/node/LayoutNodeTest.kt
M compose/ui/ui/src/test/kotlin/androidx/compose/ui/node/ModifierLocalConsumerEntityTest.kt
M compose/ui/ui/src/test/kotlin/androidx/compose/ui/text/input/TextInputServiceAndroidCommandDebouncingTest.kt
M development/build_log_simplifier/messages.ignore
ap...@google.com <ap...@google.com> #3
Branch: androidx-main
commit 646912a194282dae0f26239faf838f1b0abb7149
Author: Zach Klippenstein <klippenstein@google.com>
Date: Mon Jun 26 13:40:30 2023
Move BasicTextField2 to common.
Bug:
Test: existing test coverage, no behavior change just moving source sets
Relnote: n/a
Change-Id: I62b95e65d196e0f1e5a8c27845d7e7d0b3a473ba
M compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/text2/input/internal/ComposeInputMethodManager.android.kt
M compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/text2/input/internal/StatelessInputConnection.android.kt
M compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/text2/input/internal/TextInputSession.android.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/DeadKeyCombiner.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/BasicSecureTextField.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/BasicTextField2.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/AllCapsFilter.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/CodepointTransformation.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/MaxLengthFilter.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/TextEditFilter.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/TextEditResult.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/TextFieldBuffer.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/TextFieldBufferWithSelection.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/TextFieldCharSequence.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/TextFieldLineLimits.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/TextFieldState.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/TextObfuscationMode.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/internal/ApplyEditCommand.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/internal/ChangeTracker.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/internal/EditCommand.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/internal/EditProcessor.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/internal/EditingBuffer.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/internal/GapBuffer.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/internal/MathUtils.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/internal/TextFieldCoreModifier.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/internal/TextFieldDecoratorModifier.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/internal/TextFieldKeyEventHandler.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/internal/TextFieldTextLayoutModifier.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/internal/TextLayoutState.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/input/internal/TextPreparedSelection.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text2/selection/TextFieldSelectionState.kt
A compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/text2/input/internal/DesktopTextInputSession.desktop.kt
[Deleted User] <[Deleted User]> #4
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.foundation:foundation:1.6.0-alpha02
androidx.compose.foundation:foundation-android:1.6.0-alpha02
androidx.compose.ui:ui:1.6.0-alpha02
androidx.compose.ui:ui-android:1.6.0-alpha02
androidx.compose.ui:ui-text:1.6.0-alpha02
androidx.compose.ui:ui-text-android:1.6.0-alpha02
po...@google.com <po...@google.com> #5
Note that parentWidth
was referring to the size of the current modifier (the same one returned when calling layout
), not to the size of the parent.
In general there would be a way to extend the layout system to provide the info you are looking for (the size of our parent when placing our children). However, I do not think this would be a good idea because modifiers relying on the parent size would not be nicely composable. I can write a modifier that positions children at a percentage of the parent but what if before me there is a modifier that offsets me? The percentage will not work anymore for my content.
[Deleted User] <[Deleted User]> #6
Hmm. I see that as completely valid though. You might want to place it in the center but offset X a number of DP.
But I understand there might be other complexities. I was just surprised there was no way to write such a modifier today.
Description
PlacementScope
already has aparentWidth
which is convenient but it does not have aparentHeight
. For consistency it should probably have both or neither. I would prefer both as it would allow for something like this: