Status Update
Comments
si...@google.com <si...@google.com> #2
Branch: androidx-main
commit 9082f62682f853ad5251a1c79dde9eccba7abdd9
Author: Max Alfonso-Ying <maxying@google.com>
Date: Thu Apr 18 00:34:40 2024
[M2 text field] Apply background to decoration box
...instead of to the BasicTextField, so changing the
backgroundColor will properly change the decoration
box's background color.
Fixes:
Test: added unit tests
Relnote: "Fix backgroundColor not applying to
TextFieldDecorationBox and OutlinedTextFieldDecorationBox.
Decoration boxes now accept a `shape` parameter."
Change-Id: I371c26718597cb36ac537e9412ce476532afb40d
M compose/material/material/api/current.txt
M compose/material/material/api/restricted_current.txt
M compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/TextFieldDecorationBoxDemos.kt
M compose/material/material/src/androidInstrumentedTest/kotlin/androidx/compose/material/textfield/TextFieldDecorationBoxTest.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/OutlinedTextField.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/TextField.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/TextFieldDefaults.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/TextFieldImpl.kt
si...@google.com <si...@google.com>
si...@google.com <si...@google.com>
si...@google.com <si...@google.com> #3
Correction: current structure is:
CoreTextField(EditorValue, (EditorValue) -> Unit) (in ui.text) TextField(TextFieldValue, (TextFieldValue) -> Unit) (in ui.foundation) FilledTextField(TextFieldValue, (TextFieldValue) -> Unit) (in ui.material) FilledTextField(String, (String) -> Unit) (in ui.material)
We have decided to investigate if it is possible to unify EditorValue and TextField value. (keeping the name TextfieldValue) at
I tried to see the side effects of such a change, and implemented a change that has two steps:
- Use TextFieldValue in CoreTextField/TextField/FilledTextField. Deprecated older functions. aosp/1326149
- Use TextFieldValue in ui-text-core, and lower layers of editing (below CoreTextField). aosp/1326150
Based on these changes what I see is:
- The change is costly, and changes a lot of API surface
foundation.TextField
usesTextFieldValue
which does not have composition. I agree with Nona and Anastasia that app developers will not need composition information. However on the other handfoundation.TextField
uses EditorValue.composition. When we moveTextFieldValue
toCoreTextField
we need to add TextFieldValue.composition which in turn is accepted or returned to the developers. I believe the previous layering for TextFieldValue and EditorValue is correct. We can think more about the restructuring however I am not sure if it would make big changes in the API- i.e. Rename EditorValue as CoreTextFieldValue
- i.e. Extend TextFieldValue from CoreTextFieldValue, or reuse CoreTextFieldValue in TextFieldValue etc, but somehow hide composition from TextFieldValue
Looking at the CLs my suggestion would be not making such a change, and at most renaming EditorValue and making in sync with TextFieldValue. (CoreTextFieldValue? TextInputValue? CoreInputFieldValue) (Note: We also had a discussion of changing TextField to InputField (and therefore CoreTextField to CoreInputField)
si...@google.com <si...@google.com> #4
When
@Deprecated
data class Data1 {}
@Deprecated
@Composable fun Fun1{value=Data1}
Lint on server doesn't like it
it gave me error:
w: /buildbot/src/android/androidx-master-dev/frameworks/support/ui/ui-text/src/main/java/androidx/ui/text/CoreTextField.kt: (52, 26): 'EditorValue' is deprecated. Use androidx.ui.input.TextFieldValue instead
w: /buildbot/src/android/androidx-master-dev/frameworks/support/ui/ui-text/src/main/java/androidx/ui/text/CoreTextField.kt: (58, 12): 'EditorValue' is deprecated. Use androidx.ui.input.TextFieldValue instead
w: /buildbot/src/android/androidx-master-dev/frameworks/support/ui/ui-text/src/main/java/androidx/ui/text/CoreTextField.kt: (60, 21): 'EditorValue' is deprecated. Use androidx.ui.input.TextFieldValue instead
w: /buildbot/src/android/androidx-master-dev/frameworks/support/ui/ui-text/src/main/java/androidx/ui/text/CoreTextField.kt: (88, 13): 'EditorValue' is deprecated. Use androidx.ui.input.TextFieldValue instead
Therefore I tried by not deprecating Data1
but only the composable.
si...@google.com <si...@google.com> #5
I first created changes that I took a two step approach:
- change ui-text and ui-text-core, while using deprecated composable in ui-foundation.
- change ui-foundation and ui-material to start using new object
Because of the problem mentioned in the previous comment, I abandoned those attempts:
https://android-review.googlesource.com/q/topic:%2522textfieldvalue%2522 https://android-review.googlesource.com/q/topic:%2522editor_value%2522+
Created one CL that contains all the change
ap...@google.com <ap...@google.com> #7
Branch: androidx-master-dev
commit c2e5559d05db4329d7e0d3e92e53508194bf5d8d
Author: Siyamed Sinir <siyamed@google.com>
Date: Tue Jun 09 09:37:23 2020
Use TextFieldValue in all TextFields
Test: ./gradlew ui:ui-material:test
Test: ./gradlew ui:ui-material:cAT
Test: ./gradlew ui:ui-foundation:test
Test: ./gradlew ui:ui-foundation:cAT
Test: ./gradlew ui:ui-text:test
Test: ./gradlew ui:ui-text:cAT
Test: ./gradlew ui:ui-text-core:test
Test: ./gradlew ui:ui-text-core:cAT
Test: ./gradlew ui:ui-core:test
Test: ./gradlew ui:ui-core:cAT
Test: Manual test in the Demo app.
RelNote: "androidx.ui.foundation.TextFieldValue and
androidx.ui.input.EditorValue is deprecated. TextField,
FilledTextField and CoreTextField composables that uses
that type is also deprecated. Please use
androidx.ui.input.TextFieldValue instead"
Bug: 155211005
Change-Id: I4066d1f4d2e3e3514753aa3495680292dc55f89d
M compose/compose-runtime/samples/src/main/java/androidx/compose/samples/ModelSamples.kt
M ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/input/EditProcessorBenchmark.kt
M ui/integration-tests/demos/src/main/java/androidx/ui/demos/DemoApp.kt
M ui/integration-tests/demos/src/main/java/androidx/ui/demos/DemoFilter.kt
M ui/ui-core/integration-tests/ui-core-demos/src/main/java/androidx/ui/core/demos/PopupDemo.kt
M ui/ui-core/integration-tests/ui-core-demos/src/main/java/androidx/ui/core/demos/autofill/ExplicitAutofillTypesDemo.kt
M ui/ui-core/src/androidTest/java/androidx/ui/input/RecordingInputConnectionTest.kt
M ui/ui-core/src/main/java/androidx/ui/input/InputState.kt
M ui/ui-core/src/main/java/androidx/ui/input/RecordingInputConnection.kt
M ui/ui-core/src/main/java/androidx/ui/input/TextInputServiceAndroid.kt
M ui/ui-core/src/test/java/androidx/ui/input/RecordingInputConnectionUpdateTextFieldValueTest.kt
M ui/ui-core/src/test/java/androidx/ui/input/TextInputServiceAndroidTest.kt
M ui/ui-desktop/src/jvmMain/kotlin/androidx/ui/desktop/DesktopPlatformInput.kt
M ui/ui-foundation/api/0.1.0-dev14.txt
M ui/ui-foundation/api/current.txt
M ui/ui-foundation/api/public_plus_experimental_0.1.0-dev14.txt
M ui/ui-foundation/api/public_plus_experimental_current.txt
M ui/ui-foundation/api/restricted_0.1.0-dev14.txt
M ui/ui-foundation/api/restricted_current.txt
M ui/ui-foundation/samples/src/main/java/androidx/ui/foundation/samples/TextFieldSample.kt
M ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/SoftwareKeyboardTest.kt
M ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldFocusTest.kt
M ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldOnValueChangeTextFieldValueTest.kt
M ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldTest.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/Scroller.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/TextField.kt
M ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/TextLayoutDirectionModifierTest.kt
M ui/ui-material/api/0.1.0-dev14.txt
M ui/ui-material/api/current.txt
M ui/ui-material/api/public_plus_experimental_0.1.0-dev14.txt
M ui/ui-material/api/public_plus_experimental_current.txt
M ui/ui-material/api/restricted_0.1.0-dev14.txt
M ui/ui-material/api/restricted_current.txt
M ui/ui-material/samples/src/main/java/androidx/ui/material/samples/TextFieldSamples.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/FilledTextFieldTest.kt
M ui/ui-material/src/main/java/androidx/ui/material/TextField.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/TextActionsTest.kt
M ui/ui-test/src/main/java/androidx/ui/test/TextInputServiceForTests.kt
M ui/ui-text-core/api/0.1.0-dev14.txt
M ui/ui-text-core/api/current.txt
M ui/ui-text-core/api/public_plus_experimental_0.1.0-dev14.txt
M ui/ui-text-core/api/public_plus_experimental_current.txt
M ui/ui-text-core/api/restricted_0.1.0-dev14.txt
M ui/ui-text-core/api/restricted_current.txt
M ui/ui-text-core/build.gradle
M ui/ui-text-core/src/commonMain/kotlin/androidx/ui/input/EditProcessor.kt
D ui/ui-text-core/src/commonMain/kotlin/androidx/ui/input/EditorValue.kt
A ui/ui-text-core/src/commonMain/kotlin/androidx/ui/input/TextFieldValue.kt
M ui/ui-text-core/src/commonMain/kotlin/androidx/ui/input/TextInputService.kt
M ui/ui-text-core/src/test/java/androidx/ui/input/EditProcessorTest.kt
M ui/ui-text-core/src/test/java/androidx/ui/text/TextInputServiceTest.kt
M ui/ui-text/api/0.1.0-dev14.txt
M ui/ui-text/api/current.txt
M ui/ui-text/api/public_plus_experimental_0.1.0-dev14.txt
M ui/ui-text/api/public_plus_experimental_current.txt
M ui/ui-text/api/restricted_0.1.0-dev14.txt
M ui/ui-text/api/restricted_current.txt
M ui/ui-text/integration-tests/ui-text-compose-demos/src/main/java/androidx/ui/text/demos/ComposeInputField.kt
M ui/ui-text/integration-tests/ui-text-compose-demos/src/main/java/androidx/ui/text/demos/ComposeInputFieldFocusTransition.kt
M ui/ui-text/integration-tests/ui-text-compose-demos/src/main/java/androidx/ui/text/demos/ComposeInputFieldTrickyUseCase.kt
M ui/ui-text/integration-tests/ui-text-compose-demos/src/main/java/androidx/ui/text/demos/ComposeVariousInputField.kt
M ui/ui-text/integration-tests/ui-text-compose-demos/src/main/java/androidx/ui/text/demos/TailFollowingTextField.kt
M ui/ui-text/integration-tests/ui-text-compose-demos/src/main/java/androidx/ui/text/demos/TextFieldWIthScroller.kt
M ui/ui-text/src/androidTest/java/androidx/ui/text/TextFieldDelegateIntegrationTest.kt
M ui/ui-text/src/main/java/androidx/ui/text/CoreTextField.kt
M ui/ui-text/src/main/java/androidx/ui/text/TextFieldDelegate.kt
M ui/ui-text/src/test/java/androidx/ui/text/TextFieldDelegateTest.kt
si...@google.com <si...@google.com> #8
FYI: this caused far too many work. I regret pushing the change in.
Description
CoreTextField(EditorValue, (EditorValue) -> Unit) (in ui.text)
TextField(EditorValue, (EditorValue) -> Unit) (in ui.foundation)
TextField(TextFieldValue, (TextFieldValue) -> Unit) (in ui.foundation)
FilledTextField(TextFieldValue, (TextFieldValue) -> Unit) (in ui.material)
FilledTextField(String, (String) -> Unit) (in ui.material)
EditorValue is the most powerful API, where every aspect of the text field is controllable, but also more cumbersome to use.
TextFieldValue is middle-weight, with only string value and selection controllable, but still a bit cumbersome to use
String is the least powerful API, but also the most convenient and powerful enough to satisfy the overwhelming majority of use cases.
My suggestion is to refactor these overloads to have each one fit into one of two overloads:
1. EditorValue-based (cumbersome, powerful)
2. String-based (convenient, useful)
The string-based variants would have an `onSelectionChanged: (Selection) -> Unit` parameter, but would not allow for a selection to be *controlled* (hence the past tense on the parameter name).
It seems to me like the need to control or listen to the selection state are both somewhat rare, but the need to control it is even more so. On the other hand, the need to control the text value is virtually 100% of the time. As a result, adding the overhead of the selection controllability in the common case feels wrong, since the times you might want to do that, the more powerful EditorValue API might be something you need to reach for anyway.
As a result, my proposal is to have the following APIs:
in ui.text:
fun CoreTextField(value: EditorValue, onValueChange: (EditorValue) -> Unit) (unchanged)
in ui.foundation:
fun TextField(EditorValue, (EditorValue) -> Unit) (unchanged)
fun TextField(value: String, onValueChange: (String) -> Unit, onSelectionChanged: (Selection) -> Unit)
in ui.material:
fun FilledTextField(EditorValue, (EditorValue) -> Unit)
fun FilledTextField(value: String, onValueChange: (String) -> Unit, onSelectionChanged: (Selection) -> Unit)