Status Update
Comments
si...@google.com <si...@google.com> #2
Branch: androidx-master-dev
commit c60f33e229e31ab328ef6b59dab63b264954831c
Author: Alexandre Elias <aelias@google.com>
Date: Fri Jul 10 16:23:09 2020
Semantics no-op cleanups
Partly in response to lmr's broad code review, I did a pass of
superficial API/implementation cleanup. The main changes are:
- I changed each Boolean SemanticsProperty where false is equivalent to
not being present to take "Unit" instead. This is conceptually
clearer: it avoids questions like "can I cancel out a semantics from a
merged child by setting it to false?" Because "property = Unit" looks
weird, I also changed the style of these to "property()".
- I moved the Semantics id generator closer to where it's used, in
SemanticsModifierCore. I made it internal and an AtomicInt.
(Note that integer ids are heavily used in the Android
AccessibilityNodeInfo APIs so I can't simply remove them entirely.)
- I deleted dead code. Some examples include SemanticsHintOverrides,
a public API not connected to anything, and SemanticsPropertyKey
merge() open method which is never called. (In both cases I have
a different plan in mind for accessibility.)
Fixes: 145951226
Fixes: 145955412
Test: existing tests
Relnote: "Single-value semantics properties now use a calling style.
For example, 'semantics { hidden = true }' is now written as:
'semantics { hidden() }'."
Change-Id: Ic1afd12ea22c926babc9662f1804d80b33aa0cfc
M ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/LayoutNodeModifierBenchmark.kt
M ui/ui-core/api/0.1.0-dev15.txt
M ui/ui-core/api/current.txt
M ui/ui-core/api/public_plus_experimental_0.1.0-dev15.txt
M ui/ui-core/api/public_plus_experimental_current.txt
M ui/ui-core/api/restricted_0.1.0-dev15.txt
M ui/ui-core/api/restricted_current.txt
M ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/graphics/vector/VectorTest.kt
M ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/semantics/SemanticsTests.kt
M ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidActuals.kt
M ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidComposeView.kt
M ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidComposeViewAccessibilityDelegateCompat.kt
M ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidPopup.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/Expect.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsConfiguration.kt
D ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsHintOverrides.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsModifier.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsNode.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsOwner.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsWrapper.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/semantics/SemanticsProperties.kt
M ui/ui-foundation/api/0.1.0-dev15.txt
M ui/ui-foundation/api/current.txt
M ui/ui-foundation/api/public_plus_experimental_0.1.0-dev15.txt
M ui/ui-foundation/api/public_plus_experimental_current.txt
M ui/ui-foundation/api/restricted_0.1.0-dev15.txt
M ui/ui-foundation/api/restricted_current.txt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/Clickable.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/Dialog.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/Scroller.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Selectable.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Toggleable.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/semantics/FoundationSemanticsProperties.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/CardTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxScreenshotTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonScreenshotTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/ripple/RippleIndicationTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldScreenshotTest.kt
M ui/ui-material/src/main/java/androidx/ui/material/AppBar.kt
M ui/ui-material/src/main/java/androidx/ui/material/TextFieldImpl.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/AssertsTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/CallSemanticsActionTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/ErrorMessagesTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/FindersTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/PrintToStringTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/ScrollToTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/TextActionsTest.kt
M ui/ui-test/src/main/java/androidx/ui/test/Actions.kt
M ui/ui-test/src/main/java/androidx/ui/test/Filters.kt
M ui/ui-text/api/0.1.0-dev15.txt
M ui/ui-text/api/current.txt
M ui/ui-text/api/public_plus_experimental_0.1.0-dev15.txt
M ui/ui-text/api/public_plus_experimental_current.txt
M ui/ui-text/api/restricted_0.1.0-dev15.txt
M ui/ui-text/api/restricted_current.txt
M ui/ui-text/src/commonMain/kotlin/androidx/ui/text/CoreTextField.kt
M ui/ui-text/src/commonMain/kotlin/androidx/ui/text/TextSemanticsProperties.kt
si...@google.com <si...@google.com>
a3...@heb.com <a3...@heb.com> #3
Is there any update on when this will be supported?
ra...@tipsport.cz <ra...@tipsport.cz> #4
su...@evolutepower.com <su...@evolutepower.com> #5
sh...@gmail.com <sh...@gmail.com> #6
When will compose Text support Html or any other markdown
so...@google.com <so...@google.com>
ma...@300624.cn <ma...@300624.cn> #7
ph...@gmail.com <ph...@gmail.com> #8
[Deleted User] <[Deleted User]> #9
go...@gmail.com <go...@gmail.com> #10
ka...@gmail.com <ka...@gmail.com> #11
bro
ap...@google.com <ap...@google.com> #12
Branch: androidx-main
commit d8048a5b8e38412aaac604ac84b6ad66e7b7b4f7
Author: Anastasia Soboleva <soboleva@google.com>
Date: Fri Mar 15 17:33:54 2024
Handle <annotation> tag inside String.parseAsHtml
Bug: 139326648
Test: AnnotatedStringFromHtmlTest
Relnote: "Support <annotation> tag inside String.parseAsHtml() method"
Change-Id: I306261acf030feb96e8b8198f88b25375ed9356b
M compose/ui/ui-text/src/androidInstrumentedTest/kotlin/androidx/compose/ui/text/AnnotatedStringFromHtmlTest.kt
M compose/ui/ui-text/src/androidInstrumentedTest/res/values/styled-string-for-test.xml
M compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/Html.android.kt
pa...@gmail.com <pa...@gmail.com> #13
This would be very useful. In an application that handles a lot of HTML content, the total migration to Jetpack Compose is making it difficult for me.
an...@gmail.com <an...@gmail.com> #14
A new method was added in Compose-UI version 1.7.0-alpha07.
AnnotatedString.fromHtml(htmlString)
It allows to convert a string marked with HTML tags into AnnotatedString.
ro...@google.com <ro...@google.com> #15
Could we expose Spanned.toAnnotatedString()
as a public API?
This would be extremely useful for people using the regular context.getText(<id>)
construct to get their text resources.
I'd even dare to propose textResource(@StringRes Int): AnnotatedString
alongside stringResource(@StringRes Int): String
ma...@marcardar.com <ma...@marcardar.com> #16
#15 How would that work if Spanned
has custom spans?
mi...@iag.com.au <mi...@iag.com.au> #17
Firstly, thank you for your work on this.
I have encountered 2 issues with this alpha version so far.
The first issue I've seen is that the linkStyle SpanStyle isn't working (eg. I can't make the links blue or red etc). My url links work, however I haven't been able to style them correctly yet. Perhaps I've missed something, and if so please kindly provide an example.
The second issue is as follows:
The compose preview isn't working, and the following is the stacktrace
java.lang.NoClassDefFoundError: org/xml/sax/XMLReader at androidx.compose.ui.text.Html_androidKt$TagHandler$1.handleTag(Html.android.kt:246) at android.text.HtmlToSpannedConverter.handleStartTag(Html.java:842) at android.text.HtmlToSpannedConverter.startElement(Html.java:1243) at org.ccil.cowan.tagsoup.Parser.push(Parser.java:795) at org.ccil.cowan.tagsoup.Parser.rectify(Parser.java:1062) at org.ccil.cowan.tagsoup.Parser.stage(Parser.java:1027) at org.ccil.cowan.tagsoup.HTMLScanner.scan(HTMLScanner.java:632) at org.ccil.cowan.tagsoup.Parser.parse(Parser.java:450) at android.text.HtmlToSpannedConverter.convert(Html.java:751) at android.text.Html.fromHtml(Html.java:246) at androidx.core.text.HtmlCompat$Api24Impl.fromHtml(HtmlCompat.java:198) at androidx.core.text.HtmlCompat.fromHtml(HtmlCompat.java:163) at androidx.compose.ui.text.Html_androidKt.fromHtml(Html.android.kt:63) at androidx.compose.ui.text.Html_androidKt.fromHtml$default(Html.android.kt:53)
so...@google.com <so...@google.com> #18
re:
Could you please show a repro of how you're setting the color of the link?
As for the preview issue, it's tracked in
mi...@iag.com.au <mi...@iag.com.au> #19
@Composable
fun HtmlText(
text: String,
style: TextStyle,
modifier: Modifier = Modifier,
textAlign: TextAlign = TextAlign.Start,
linkStyle: SpanStyle = defaultLinkStyle,
linkPressedStyle: SpanStyle = defaultLinkStyle,
linkFocusedStyle: SpanStyle = defaultLinkStyle,
linkHoveredStyle: SpanStyle = defaultLinkStyle,
onLinkSelect: (String) -> Unit = {},
onTagSelect: (String) -> Unit = {},
) {
val html = AnnotatedString.fromHtml(
htmlString = text,
linkStyle = linkStyle,
linkPressedStyle = linkPressedStyle,
linkFocusedStyle = linkFocusedStyle,
linkHoveredStyle = linkHoveredStyle
)
ClickableText(
text = html,
style = style.copy(
color = style.color,
textAlign = textAlign,
platformStyle = PlatformTextStyle(
includeFontPadding = false
),
lineHeightStyle = LineHeightStyle(
alignment = LineHeightStyle.Alignment.Center,
trim = LineHeightStyle.Trim.None
)
),
modifier = modifier,
onClick = {
// handle link
}
)
}
so...@google.com <so...@google.com> #20
re:
How do you call it? Note that it only applies this style to the links, in which case your string needs to be <a href="YOUR_URL">YOUR_TEXT</a>
.
Also don't pass this html string to the ClickableText
(which is deprecated in the latest alpha), pass it directly to the BasicText
or Text
which will handle the link.
mi...@iag.com.au <mi...@iag.com.au> #21
private val defaultLinkStyle = SpanStyle(color = Color.Red)
@Composable
fun HtmlText(
text: String,
style: TextStyle,
modifier: Modifier = Modifier,
textAlign: TextAlign = TextAlign.Start,
linkStyle: SpanStyle = defaultLinkStyle,
linkPressedStyle: SpanStyle = defaultLinkStyle,
linkFocusedStyle: SpanStyle = defaultLinkStyle,
linkHoveredStyle: SpanStyle = defaultLinkStyle,
onLinkSelect: (String) -> Unit = {},
onTagSelect: (String) -> Unit = {},
) {
val html = AnnotatedString.fromHtml(
htmlString = "This is a link test <a href=\"
linkStyle = linkStyle,
linkPressedStyle = linkPressedStyle,
linkFocusedStyle = linkFocusedStyle,
linkHoveredStyle = linkHoveredStyle
) {
Log.d(TAG, "Test")
}
Text(text = html)
BasicText(text = html)
}
so...@google.com <so...@google.com> #22
Re:
mi...@iag.com.au <mi...@iag.com.au> #23
Re:
ka...@gmail.com <ka...@gmail.com> #24
ap...@google.com <ap...@google.com> #25
Project: platform/frameworks/support
Branch: androidx-main
Author: Anastasia Soboleva <
Link:
Add internal APIs to add bullet list from the AnnotatedString builder
Expand for full commit details
Add internal APIs to add bullet list from the AnnotatedString builder
When we're past API freeze, make this APIs public.
Bug: 299662276, 139326648
Test: AnnotatedStringBuilderTest
Change-Id: I2212987ce813ff55cca3d2a4fa4aeb23dd86ec01
Files:
- M
compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/AndroidParagraphHelper.android.kt
- M
compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/extensions/SpannableExtensions.android.kt
- M
compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/style/BulletSpan.android.kt
- M
compose/ui/ui-text/src/androidUnitTest/kotlin/androidx/compose/ui/text/AnnotatedStringBuilderTest.kt
- M
compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/AnnotatedString.kt
- M
compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/Bullet.kt
Hash: eb01d1a28091a1c7c7d370a0000d0a077f6c0d0c
Date: Tue Oct 15 19:21:49 2024
ap...@google.com <ap...@google.com> #26
Project: platform/frameworks/support
Branch: androidx-main
Author: Anastasia Soboleva <
Link:
Add ul/li tags support to fromHtml
Expand for full commit details
Add ul/li tags support to fromHtml
Unlike TextView where indentation is added but bullet is always drawn at 0, in this implementation the bullet follows the start of text in the paragraph meaning that it's drawn with the indentation.
Test: new tests and updated demo
Bug: 299662276, 139326648
Relnote: "AnnotatedString.fromHtml now supports <ul>/<li> tags"
Change-Id: I7c2fe1717e72b66da4b2613efbeeb7b6f5ebb44e
Files:
- M
compose/ui/ui-text/samples/src/main/res/values/styled-string-for-sample.xml
- M
compose/ui/ui-text/src/androidInstrumentedTest/kotlin/androidx/compose/ui/text/AnnotatedStringFromHtmlTest.kt
- M
compose/ui/ui-text/src/androidInstrumentedTest/res/values/styled-string-for-test.xml
- M
compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/Html.android.kt
- M
compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/AndroidParagraphHelper.android.kt
- M
compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/extensions/SpannableExtensions.android.kt
- A
compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/style/BulletSpan.android.kt
- M
compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/style/DrawStyleSpan.android.kt
- M
compose/ui/ui-text/src/androidUnitTest/kotlin/androidx/compose/ui/text/AnnotatedStringBuilderTest.kt
- M
compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/AnnotatedString.kt
- A
compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/Bullet.kt
Hash: b6d4b40b1a0ffe65c9869ddcde3f133534a10a89
Date: Tue Oct 15 14:30:50 2024
Description
* It ends up partial and hard to make people happy
* Html in String resources