Status Update
Comments
si...@google.com <si...@google.com> #2
Branch: androidx-main
commit a330c0d3bcdd41326f37968a60e6084ad4a2e32c
Author: Chet Haase <chet@google.com>
Date: Wed Jul 05 07:26:46 2023
Convert APIs using PointF to use Float instead
PointF is a convenient mechanism for passing around x.y values
representing 2D points. But there are downsides, including:
- Converting to PointF: You may not have the data in PointF form
to begin with, so using an API which takes PointF requires converting
the data to that form (including allocating a PointF object every time)
- Mutability: Point structures can be mutated internally, causing
unpredictability in what that mutation means. Should the library
react to those changes? Ignore them? Do defensive copies (requiring
even more allocations)? Using primitive types like Float make the
behavior more obvious (by making the data inherently immutable).
- Allocations: Whenever we use object types, there are necessarily
allocations on the Java heap for them. This puts pressure on the GC
at both allocation and collection time. Given the amount of points
being passed around (especially at morph creation time, when curves
are being split and created), this causes a lot of PointF objects to
be allocated (even temporarily). Using Float avoids that problem.
Also fixed bug with unclosed paths causing discontinuity at the
start/end point.
Bug: 276466399
Bug: 290254314
Test: integration and unit tests pass
Relnote: PointF parameters changed to Float pairs
Change-Id: Id4705d27c7be31b26ade8186b99fffe2e2f8450e
M graphics/graphics-shapes/api/current.txt
M graphics/graphics-shapes/api/restricted_current.txt
M graphics/graphics-shapes/src/androidTest/java/androidx/graphics/shapes/CubicShapeTest.kt
M graphics/graphics-shapes/src/androidTest/java/androidx/graphics/shapes/CubicTest.kt
M graphics/graphics-shapes/src/androidTest/java/androidx/graphics/shapes/PolygonMeasureTest.kt
M graphics/graphics-shapes/src/androidTest/java/androidx/graphics/shapes/PolygonTest.kt
M graphics/graphics-shapes/src/androidTest/java/androidx/graphics/shapes/RoundedPolygonTest.kt
M graphics/graphics-shapes/src/androidTest/java/androidx/graphics/shapes/ShapesTest.kt
M graphics/graphics-shapes/src/androidTest/java/androidx/graphics/shapes/TestUtils.kt
M graphics/graphics-shapes/src/main/java/androidx/graphics/shapes/Cubic.kt
M graphics/graphics-shapes/src/main/java/androidx/graphics/shapes/CubicShape.kt
M graphics/graphics-shapes/src/main/java/androidx/graphics/shapes/FeatureMapping.kt
M graphics/graphics-shapes/src/main/java/androidx/graphics/shapes/FloatMapping.kt
M graphics/graphics-shapes/src/main/java/androidx/graphics/shapes/Morph.kt
M graphics/graphics-shapes/src/main/java/androidx/graphics/shapes/PolygonMeasure.kt
M graphics/graphics-shapes/src/main/java/androidx/graphics/shapes/RoundedPolygon.kt
M graphics/graphics-shapes/src/main/java/androidx/graphics/shapes/Shapes.kt
M graphics/graphics-shapes/src/main/java/androidx/graphics/shapes/Utils.kt
M graphics/integration-tests/testapp-compose/src/main/java/androidx/graphics/shapes/testcompose/DebugDraw.kt
M graphics/integration-tests/testapp-compose/src/main/java/androidx/graphics/shapes/testcompose/ShapeEditor.kt
M graphics/integration-tests/testapp/src/main/java/androidx/graphics/shapes/test/MaterialShapes.kt
si...@google.com <si...@google.com>
p....@arammeem.com <p....@arammeem.com> #3
si...@google.com <si...@google.com>
ho...@fulfillmenttools.com <ho...@fulfillmenttools.com> #4
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.graphics:graphics-shapes:1.0.0-alpha04
[Deleted User] <[Deleted User]> #5
cm...@googlemail.com <cm...@googlemail.com> #6
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