Status Update
Comments
pa...@hinge.co <pa...@hinge.co> #2
Branch: androidx-master-dev
commit b90079595f33f58fece04026a97faa0d243acdb1
Author: Yuichi Araki <yaraki@google.com>
Date: Wed Sep 18 16:55:49 2019
Change the way to detect mismatch between POJO and query
This fixes cursor mismatch warnings with expandProjection.
Bug: 140759491
Test: QueryMethodProcessorTest
Change-Id: I7659002e5e0d1ef60fc1af2a625c0c36da0664d8
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/testing/TestProcessor.kt
pa...@hinge.co <pa...@hinge.co> #3
kl...@google.com <kl...@google.com>
kl...@google.com <kl...@google.com> #4
Branch: androidx-master-dev
commit bdde5a1a970ddc9007b28de4aa29d60ffa588f08
Author: Yigit Boyar <yboyar@google.com>
Date: Thu Apr 16 16:47:05 2020
Re-factor how errors are dismissed when query is re-written
This CL changes how we handle errors/warnings if query is
re-written.
There was a bug in expandProjection where we would report warnings
for things that Room already fixes automatically (
The solution to that problem (I7659002e5e0d1ef60fc1af2a625c0c36da0664d8)
solved it by deferring validating of columns until after re-write
decision is made. Unfortunately, this required changing PojoRowAdapter
to have a dummy mapping until it is validating, make it hard to use
as it does have a non-null mapping which is not useful.
This CL partially reverts that change and instead rely on the log
deferring logic we have in Context. This way, we don't need to break
the stability of PojoRowAdapter while still having the ability to
drop warnings that room fixes. This will also play nicer when we
have different query re-writing options that can use more information
about the query results.
Bug: 153387066
Bug: 140759491
Test: existing tests pass
Change-Id: I2ec967c763d33d7a3ff02c1a13c6953b460d1e5f
M room/compiler/src/main/kotlin/androidx/room/log/RLog.kt
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
si...@google.com <si...@google.com>
kl...@google.com <kl...@google.com> #5
We may also need to use enableAccessibleClickableSpanSupport
Unrelated to this bug, we may also want to implement this using a custom span that overrides onClick to invoke the UrlHandler
from the composition instead of letting the default implementation directly fire an intent.
kl...@google.com <kl...@google.com> #6
It does not seem to be possible to override ClickableSpan
's getId()
method, which means that the only way to make this work is to actually use the same instance across a11y string conversions.
kl...@google.com <kl...@google.com> #7
We don't need to call enableAccessibleClickableSpanSupport
because AndroidComposeView
is already using the a11y delegate compat stuff. This will be fixed in
ap...@google.com <ap...@google.com> #8
Branch: androidx-main
commit 41183c41f686979fb051549196f7b06cc172022b
Author: Zach Klippenstein <klippenstein@google.com>
Date: Fri Mar 17 16:33:38 2023
Fix UrlAnnotation links not being opened by a11y services.
Relnote: "`UrlAnnotation`s in `AnnotatedString`s can now be opened via
accessibility services like TalkBack."
Test: AndroidAccessibilitySpannableStringTest.kt
Test: Manually with TalkBack
Fixes:
Change-Id: If4d82999d8c62aa3718e1e681eeeaac12a9b0f55
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeTextAccessibility.kt
M compose/ui/ui-text/api/public_plus_experimental_current.txt
M compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/platform/AndroidAccessibilitySpannableStringTest.kt
M compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/AndroidAccessibilitySpannableString.android.kt
A compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/URLSpanCache.kt
D compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/extensions/UrlAnnotationExtensions.android.kt
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeViewAccessibilityDelegateCompat.android.kt
na...@google.com <na...@google.com> #9
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.foundation:foundation:1.5.0-alpha02
androidx.compose.ui:ui:1.5.0-alpha02
androidx.compose.ui:ui-text:1.5.0-alpha02
ju...@google.com <ju...@google.com> #10
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.ui:ui-text-android:1.5.0-beta01
sv...@gmail.com <sv...@gmail.com> #11
Versions:
androidx.compose.ui:ui-text-android:1.5.1
androidx.compose.foundation:foundation:1.5.1
androidx.compose.ui:ui:1.5.1
androidx.compose.ui:ui-text:1.5.1
fu...@gmail.com <fu...@gmail.com> #12
fu...@gmail.com <fu...@gmail.com> #13
The issue is only fixed in URL redirection case but not custom action case, looks there will be
a LinkAnnotation
added in 1.7.0 for it.
In case anyone need solution now or unable to use newest compose version, might try these approaches:
Use customActions
instead of link
@OptIn(ExperimentalTextApi::class)
@Composable
fun TestInlineLink1() = Column(
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
) {
var result by remember { mutableStateOf("") }
fun action(tag: String) {
result = "Inline link [ $tag ] get clicked"
}
val text = buildAnnotatedString {
append("This is an example for ")
withAnnotation(tag = "link1", annotation = "link1") {
append("link1")
}
append(" and ")
withAnnotation(tag = "link2", annotation = "link2") {
append("link2")
}
}
ClickableText(
modifier = Modifier.semantics {
customActions = listOf(
CustomAccessibilityAction("link1") {
action("link1")
true
},
CustomAccessibilityAction("link2") {
action("link2")
true
},
)
},
text = text,
onClick = { offset ->
val tag = text.getStringAnnotations(offset, offset)
.singleOrNull()?.tag
tag?.let(::action)
}
)
Text(text = result)
}
Modify AccessibilityNodeInfo
@OptIn(ExperimentalTextApi::class)
@Composable
fun TestInlineLink2() = Column(
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
) {
var result by remember { mutableStateOf("") }
fun action(tag: String) {
result = "Inline link [ $tag ] get clicked"
}
val text = buildAnnotatedString {
append("This is an example for ")
withAnnotation(urlAnnotation = UrlAnnotation(url = "link1")) {
append("link1")
}
append(" and ")
withAnnotation(urlAnnotation = UrlAnnotation(url = "link2")) {
append("link2")
}
}
WrappingView {
ReplaceAccessibilityNodeInfoText(
text = text.toSpannableString(::action)
)
ClickableText(
text = text,
onClick = { offset ->
val tag = text.getUrlAnnotations(offset, offset)
.singleOrNull()?.item?.url
tag?.let(::action)
},
)
}
Text(text = result)
}
@Composable
private fun ReplaceAccessibilityNodeInfoText(
text: CharSequence,
) {
val view = LocalView.current
val defaultDelegate = ViewCompat.getAccessibilityDelegate(view)
val newDelegate = object : AccessibilityDelegateCompat() {
override fun onInitializeAccessibilityNodeInfo(
host: View,
info: AccessibilityNodeInfoCompat,
) {
defaultDelegate?.onInitializeAccessibilityNodeInfo(host, info)
info.text = text
}
}
ViewCompat.setAccessibilityDelegate(view, newDelegate)
}
/**
* use AndroidView to create an AndroidComposeView,
* aim to prevent modify accessibilityDelegate of outer view.
*/
@Composable
private fun WrappingView(
modifier: Modifier = Modifier,
content: @Composable () -> Unit,
) {
AndroidView(
modifier = modifier,
factory = { context ->
ComposeView(context).apply {
setContent(content)
}
}
)
}
@OptIn(ExperimentalTextApi::class)
private fun AnnotatedString.toSpannableString(
action: (String) -> Unit
) = buildSpannedString {
append(this@toSpannableString)
getUrlAnnotations(0, length).forEach { (item, start, end, _) ->
setSpan(
object : ClickableSpan() {
override fun onClick(widget: View) {
action(item.url)
}
},
start, end, SPAN_INCLUSIVE_EXCLUSIVE
)
}
}
Description
- Jetpack Compose component used: ClickableText with AnnotatedString including UrlAnnotation
- Android Studio Build: Android Studio Chipmunk | 2021.2.1 Patch 2
Build #AI-212.5712.43.2112.8815526, built on July 10, 2022
- Kotlin version: 1.7.20
- Devices/Android versions reproduced on: Android 30, 33 on Pixel 4As
- Keyboard (i.e. Gboard, Samsung, etc): Stock Google keyboard
If this is a bug in the library, we would appreciate if you could attach:
- Sample project to trigger the issue:
- A screenrecord or screenshots showing the issue (if UI related). This is included with the sample project but I attached it again here.
- Stack trace (if applicable) - N/A
There is a bug where the recently introduced UrlAnnotation is read correctly by Talkback, but the onClick is not called, so the link is not opened.
Steps to Reproduce:
1. Turn on Talkback in Accessibility settings
2. Run app
3. App will display a single line of text
4. Part of this text will be a URLAnnotation containing a link
5. Open the Talkback action menu per the prompt
6. Select "Links" in Talkback menu
7. Select the link to trigger the onClick method call, which opens the browser.
Expected:
1.Talkback correctly recognizes the link in the text
2. Talkback shows the link in the Talkback menu
3. When the link is selected in the Talkback menu, the onClick is called in ClickableText and the user is navigated to the browser.
Actual:
1. The onClick for the ClickableText is never called. Note that it is not the browser navigation that is broken. This can be confirmed using the logs in the sample app provided.