Status Update
Comments
si...@google.com <si...@google.com> #2
I've submitted a fix for this, which should (I hope) make it into Jellyfish Canary 12. There's a relatively straightforward workaround, which is to explicitly declare the version of the com.android.tools.build:gradle
artifact in all build files -- in the screenshot, your project has a versioned classpath
dependency, but also an unversioned one, and it's that unversioned one that tripped up the AGP Upgrade Assistant. Since there is that workaround of making sure that all the classpath dependencies on com.android.tools.build:gradle
have an explicit version, we probably won't patch this for Iguana, I'm afraid.
Thanks very much for the report!
si...@google.com <si...@google.com>
p....@arammeem.com <p....@arammeem.com> #3
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Jellyfish | 2023.3.1 Canary 12
- Android Gradle Plugin 8.4.0-alpha12
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
si...@google.com <si...@google.com>
ho...@fulfillmenttools.com <ho...@fulfillmenttools.com> #4
[Deleted User] <[Deleted User]> #5
cm...@googlemail.com <cm...@googlemail.com> #6
same problem in latest koala, AGP upgrade assistant never opens
Please could you open a new issue, and upload enough details about your project to be able to investigate or (ideally) reproduce the problem? Thank you!
my...@gmail.com <my...@gmail.com> #7
si...@google.com <si...@google.com> #8
Hi
This should be doable with height/layout calculations with onTextLayoutResult, or even before by calculating the final px min height with the fontSize (and maybe lineHeight) that you provide.
Currently minimum lines and maximum lines are different in my perspective since maxLines is more closely related to text, where minLines is more about height calculations.
Since the issue is voted a lot of times, can you please elaborate the challenge and issue with setting the height based on fontSize?
cf...@gmail.com <cf...@gmail.com> #9
How do you set the height based on fontSize
? I am trying to set the height to 2 lines, so I converted the fontSize
to DP then multiplied that by 2, however the resulting height fits only about 1 line. So what's the exact formula? And how does line height fit into it? Is a line equal to lineHeight + fontSize
, or max(lineHeight, fontSize)
, or something else?
It would be beneficial if this calculation was available through the API so the developer does not have to figure out and perform the math manually. This could be in the form of adding a minLines
parameter to TextField
, or even a new TextStyle
method that returns the height of a line based on this TextStyle
's font size and line height. The latter solution would be more versatile and fits with your philosophy that minLines
is more about height calculations and not necessarily the responsibility of the TextField
as much as maxLines
is.
One reason I can think of to offer a minLines
property of TextField
instead is that doesn't the TextField
have some padding around the text? So if you set the height directly to how tall a line should be, then that wouldn't be accounting for the TextField
padding, and the resulting height would not fit the padding in addition to the line height, so the line would be slightly cut off.
de...@edistera.com <de...@edistera.com> #10
be...@gmail.com <be...@gmail.com> #11
Yes Please, Giv attention
al...@gmail.com <al...@gmail.com> #12
In response to
But I agree that it would be better to have an API to make this automatic similar to EditText
.
ub...@gmail.com <ub...@gmail.com> #13
I have outlined a workaround
Would be great to get official minLines
support here as requirements like "The text needs to be exactly x lines long" (usually combined with ellipsize) is very common when receiving designs as a developer.
[Deleted User] <[Deleted User]> #14
I don't think I've seen this mentioned yet, but another workaround is to use an AndroidView
.
For example:
AndroidView(
factory = { context ->
TextView(context, null, R.style.Body).apply {
text = "Some text"
setLines(2)
}
}
)
be...@gmail.com <be...@gmail.com> #15
Is that not the point? getting away from XML -> Compose?
ma...@ext.carrefour.com <ma...@ext.carrefour.com> #16
I agree with #15. The goal is to be independent of XML layouts. Android Views may work for a while, but not in the long term.
so...@google.com <so...@google.com>
si...@google.com <si...@google.com> #17
I understand the need for a simpler API.
Is a line equal to lineHeight + fontSize, or max(lineHeight, fontSize), or something else?
- A line is lineHeight.toPx() * 1, x lines is lineHeight.toPx() * x
- if lineHeight is not defined, it is fontSize.toPx() * x
It is necessarily very accurate and might require an if.
This could be in the form of adding a minLines parameter to TextField
a new TextStyle method that returns the height of a line based on this TextStyle's font size and line height
Both are good suggestions. I would love to have a Modifier.minLines(X) or Modifier.minLines(X, textStyle) rather than parameters if it was possible.
si...@google.com <si...@google.com>
le...@google.com <le...@google.com>
be...@gmail.com <be...@gmail.com> #18
It seen this project is just been sent from one desk stack to another desk stack, are you afraid to implement it?
ap...@google.com <ap...@google.com> #19
Branch: androidx-main
commit dfc6b04ca597d18af510e2a374635417cfa9cb01
Author: Andrei Ancuta <andreiancuta@google.com>
Date: Thu Sep 29 16:50:52 2022
Change MaxLinesHeightModifier to also handle minLines
Rename MaxLinesHeightModifier to HeightInLinesModifier and add a minLines parameter.
Rename MaxLinesHeightModifierTest to HeightInLinesModifierTest and add tests for the minLines functionality.
Bug: 122476634
Test: HeightInLinesModifierTest.kt
Test: ./gradlew :compose:ui:ui-text:cAT
Relnote: N/A
Change-Id: I7433ede0096f950a89c494084e194157a4bbaaab
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/HeightInLinesModifier.kt
M compose/foundation/foundation/api/public_plus_experimental_current.txt
M compose/foundation/foundation/api/restricted_current.txt
M compose/foundation/foundation/api/current.txt
A compose/foundation/foundation/api/restricted_current.ignore
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/HeightInLinesModifierTest.kt
A compose/foundation/foundation/api/current.ignore
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldScrollTest.kt
si...@google.com <si...@google.com> #20
Assigned for the open CL at aosp/2237754
da...@gmail.com <da...@gmail.com> #21
Are there plans to make this modifier public so that we can use it from our own apps? Or are there intentions to expose the minLines behavior via another mechanism that internally uses this Modifier?
so...@google.com <so...@google.com>
ap...@google.com <ap...@google.com> #22
Branch: androidx-main
commit e74bce3b62ac62a8115f7707bf5b58adc8d2c340
Author: Andrei Ancuta <andreiancuta@google.com>
Date: Thu Sep 29 21:30:43 2022
Add minLines parameter to BasicText and BasicTextField
Bug: 122476634
Test: ./gradlew compose:foundation:foundation:test
Relnote: "Added minLines parameter to the BasicText and BasicTextField.
It allows to set the minimum height of these composables in terms of
number of lines"
Change-Id: I2429479960eef317f467fa054b979c12fd73689d
M compose/compiler/compiler-hosted/integration-tests/build.gradle
M compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/TargetAnnotationsTransformTests.kt
M compose/foundation/foundation/api/current.txt
M compose/foundation/foundation/api/public_plus_experimental_current.txt
M compose/foundation/foundation/api/restricted_current.txt
A compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/BasicTextMinMaxLinesDemo.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeInputFieldMinMaxLines.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TextDemos.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/BasicText.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/BasicTextField.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreText.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/HeightInLinesModifier.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/TextDelegate.kt
M compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/TextControllerTest.kt
M compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/TextDelegateTest.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/Text.kt
M compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/Text.kt
M wear/compose/compose-material/src/commonMain/kotlin/androidx/wear/compose/material/Text.kt
na...@google.com <na...@google.com> #23
The following release(s) address this bug:
androidx.compose.foundation:foundation:1.4.0-alpha01
al...@gmail.com <al...@gmail.com> #24
Are you certain this landed in 1.4.0-alpha01? I was not able to find this API in the new release. Android Studio doesn't show me a minLines: Int
argument when I update to 1.4.0-alpha01
.
so...@google.com <so...@google.com> #25
Alex is right, the API change haven't landed in 1.4.0-alpha
. We cut the build just before the API change in BasicText(Field)
landed so the build only contains the implementation.
so...@google.com <so...@google.com>
be...@yescapa.com <be...@yescapa.com> #26
minLines is not used in the basicText implementation so it's not working :
line 212 of BasicText :
val controller = remember {
TextController(
TextState(
TextDelegate(
text = text,
style = style,
density = density,
softWrap = softWrap,
fontFamilyResolver = fontFamilyResolver,
overflow = overflow,
maxLines = maxLines,
placeholders = placeholders
),
selectableId
)
)
}
minLines = minLines
is missing in the TextDelegate constructor
Edit: I'm on 1.4.0-alpha02
so...@google.com <so...@google.com> #27
Good catch! We missed that during code review, on it.
Please note that String override should be fine, it wasn't propagated to AnnotatedString override only.
ap...@google.com <ap...@google.com> #28
Branch: androidx-main
commit 8068bf450819393cf10b8f37d73533cf3b8e6cec
Author: Anastasia Soboleva <soboleva@google.com>
Date: Thu Nov 10 16:34:40 2022
Pass minLines to AnnotatedString override of BasicText
Relnote: "Fix `minLines` of the AnnotatedString override of Text and
BasicText - before this change applying minLines did nothing"
Test: added more tests to cover minLines in BasicText and
BasicTextField
Test: updated HeightInLinesModifierTest some tests of which were false
negatives
Bug: 122476634
Change-Id: I2a7f20069ac2f0da053940f8eadb72656bbb592c
A compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/BasicTextMinLinesTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/HeightInLinesModifierTest.kt
A compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldMinMaxLinesTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/BasicText.kt
si...@google.com <si...@google.com>
ap...@google.com <ap...@google.com> #29
Branch: androidx-main
commit 1ea832da88dda876c4b4d283012f7231eadfcf83
Author: Aurimas Liutikas <aurimas@google.com>
Date: Mon Nov 14 16:48:33 2022
Revert "Pass minLines to AnnotatedString override of BasicText"
This reverts commit 8068bf450819393cf10b8f37d73533cf3b8e6cec.
Reason for revert: Added tests 100% fails on API 33
Bug: 122476634
Change-Id: Ibba3f2354b4ff7c6e5e47f3e8d1ccb1f11da4ea9
D compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/BasicTextMinLinesTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/HeightInLinesModifierTest.kt
D compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldMinMaxLinesTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/BasicText.kt
si...@google.com <si...@google.com> #30
The reverted commit was rever-reverted via
This ticket should be fixed. Looks like there is something about the Density's that are being used on device that need some attention. They do not set the font scale therefore they are impacted by the font scale on the device.
si...@google.com <si...@google.com> #31
Based onthe comment on the other ticket
The following release(s) address this bug.It is possible this bug has only been partially addressed:
- androidx.compose.foundation:foundation:1.4.0-alpha04
Description