Fixed
Status Update
Comments
tc...@google.com <tc...@google.com> #3
Thanks for the report!
si...@google.com <si...@google.com>
si...@google.com <si...@google.com>
si...@google.com <si...@google.com>
se...@google.com <se...@google.com>
ap...@google.com <ap...@google.com> #4
The release notes documentation has been edited to clarify this change in behavior for line height.
To support non-standard text sizes, we encourage users to follow the Material design system and use a different style = LocalTextStyle.current.copy(lineHeight = TextUnit.Unspecified)
, or create a custom Typography
entirely.
se...@google.com <se...@google.com>
se...@google.com <se...@google.com>
ap...@google.com <ap...@google.com> #5
deleted
ap...@google.com <ap...@google.com> #6
In my case, I have multiple font sizes in the same Text
(using SpanStyle
in AnnotatedString
). There are legitimate reasons for this. For example, when combining Chinese and English (phonetic) together (for language-learning purposes).
ap...@google.com <ap...@google.com> #7
Project: platform/frameworks/support
Branch: androidx-main
commit 291aa6c357ee9c232a29e707f606a747d67ac9f4
Author: Sean McQuillan <seanmcq@google.com>
Date: Tue Feb 16 18:24:44 2021
Add SoftwareKeyboardController.
Relnote: "Added new LocalSoftwareKeyboardController composition local
API to replace previous SoftwareKeyboardController interface on
TextField."
Test: Manual, automatic, demos
Bug: b/168778053
Change-Id: I5951e802fbec7c26862b976de64b78640accd1f7
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/CapitalizationAutoCorrectDemo.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeInputField.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/KeyboardSingleLineDemo.kt
M compose/material/material/samples/src/main/java/androidx/compose/material/samples/TextFieldSamples.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldTest.kt
M compose/ui/ui/api/1.0.0-beta02.txt
M compose/ui/ui/api/current.txt
M compose/ui/ui/api/public_plus_experimental_1.0.0-beta02.txt
M compose/ui/ui/api/public_plus_experimental_current.txt
M compose/ui/ui/api/restricted_1.0.0-beta02.txt
M compose/ui/ui/api/restricted_current.txt
A compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/SoftwareKeyboardControllerDemo.kt
M compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/UiDemos.kt
A compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/SoftwareKeyboardControllerSample.kt
A compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/LocalSoftwareKeyboardControllerTest.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/platform/LocalSoftwareKeyboardController.kt
A compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/platform/SoftwareKeyboardController.kt
https://android-review.googlesource.com/1593054
Branch: androidx-main
commit 291aa6c357ee9c232a29e707f606a747d67ac9f4
Author: Sean McQuillan <seanmcq@google.com>
Date: Tue Feb 16 18:24:44 2021
Add SoftwareKeyboardController.
Relnote: "Added new LocalSoftwareKeyboardController composition local
API to replace previous SoftwareKeyboardController interface on
TextField."
Test: Manual, automatic, demos
Bug:
Change-Id: I5951e802fbec7c26862b976de64b78640accd1f7
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/CapitalizationAutoCorrectDemo.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeInputField.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/KeyboardSingleLineDemo.kt
M compose/material/material/samples/src/main/java/androidx/compose/material/samples/TextFieldSamples.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldTest.kt
M compose/ui/ui/api/1.0.0-beta02.txt
M compose/ui/ui/api/current.txt
M compose/ui/ui/api/public_plus_experimental_1.0.0-beta02.txt
M compose/ui/ui/api/public_plus_experimental_current.txt
M compose/ui/ui/api/restricted_1.0.0-beta02.txt
M compose/ui/ui/api/restricted_current.txt
A compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/SoftwareKeyboardControllerDemo.kt
M compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/UiDemos.kt
A compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/SoftwareKeyboardControllerSample.kt
A compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/LocalSoftwareKeyboardControllerTest.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/platform/LocalSoftwareKeyboardController.kt
A compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/platform/SoftwareKeyboardController.kt
Description
Specifically, a user wanted to "close the software keyboard in onClick on a button", and Fudge's workaround was to capture the SoftwareKeyboardController in the onTextInputStarted callback and write it into a field in the parent. var controller by remember { mutableStateOf<SoftwareKeyboardController?> { null } } Button("Close", onClick={controller!!.hideSoftwareKeyboard()}) // Pray this doesn't crash (NPE) TextField(value=..., onClick=..., onTextInputStarted={c -> controller = c})
A better pattern would be to have the user create a SoftwareKeyboardController as-if it were a hoisted state object and pass it into the TextField. val controller by remember { SoftwareKeyboardController() } Button("Close", onClick={controller.hideSoftwareKeyboard()}) TextField(value=..., onClick=..., controller=controller)
We realize/expect this requires playing a bit of a trick with the internal implementation of the SoftwareKeyboardController, to make the hideSoftwareKeyboard() function capable of operating as if it were the source of truth, even though the actual source of truth doesn't exist until later when the TextField is initialized by Android, which is probably one reason why it didn't occur to the original author of this widget. But it results in a much cleaner declarative API with less reasoning about the flow of information.
Discussion in API Council back in August, but I don't think a bug ever got filed for this.