Status Update
Comments
pa...@hinge.co <pa...@hinge.co> #2
Thank you for reporting this issue. For us to further investigate this issue, please provide the following additional information:
- Android bug report (to be captured after reproducing the issue)
Android Wear devices connected to Android devices
-
On you Android phone, following the instructions below, under the section ‘Instructions on your companion phone or tablets (Android)’
-
Launch the ‘Android Wear’ app on your phone or tablet.
-
Tap on the three vertical ellipsis on the top right hand corner of the screen and click on “Report Wearable Bug” to capture a bug report from the watch
-
On the watch, you will observe a notification card with the text “Bug report #X is being generated”. It can take up to 20 minutes for the bug report to be generated and transferred to your phone.
-
Once the bug report is done, the notification card on the watch changes to “Bug report #X captured” and you will receive a notification on the phone that reads “Wearable bug report finished.
-
Tap to send." Tap on this notification and email the bug report to a pre populated email address
Instructions on your companion phone or tablets (Android)
- On your Android device, go to Settings > About phone or About tablet.
- At the bottom of the screen, touch 'Build number' seven times in quick succession. You’ll see a message saying you’re now in developer mode.
- Press Back to go back to the main Settings screen.
- Touch Developer options.
- At the top of the screen, make sure 'Developer options' is set to ON.
- Check the box next to USB debugging.
- Check the box next to Bug report shortcut.
- Reproduce the issue or error message on your phone or tablet. It’s important that your device logs at least one occurrence of the problem.
- Immediately after seeing the issue, press and hold the power button until the power menu appears.
- Select Take bug report, then select Report in the dialog that follows.
- After a significant delay -- up to two minutes -- your phone or tablet will vibrate and display a notification saying ‘Bug report captured’. Touch the notification to open Gmail with the report attached. +After replying to this message, you can disable developer mode and bug reports by going to Settings > Developer Options and sliding the top toggle to OFF.
pa...@hinge.co <pa...@hinge.co> #3
I have followed the following steps:
1. Run an app with the following permission:
<uses-permission-sdk-23 android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
2. Run either one of the two pieces of code:
// Will fail silently with ActivityTaskManager system_server I START u0 {act=android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS dat=package:cmp=com.google.android.apps.wearable.settings/com.google.android.clockwork.settings.FakeSettingsActivity}
val intent = Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)
intent.setData(Uri.parse("package:" + context.packageName));
context.startActivity(intent);
// Will crash the app with android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS dat=package: }
val intent = Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS)
intent.setData(Uri.parse("package:" + context.packageName));
context.startActivity(intent);
I executed the first piece of code and then the second, and captured a dump state. See here (shared with android-bugreport@google.com):
kl...@google.com <kl...@google.com>
kl...@google.com <kl...@google.com> #4
Would appreciate your assistance.
*Uri*
On Thu, Oct 31, 2024 at 7:10 PM <buganizer-system@google.com> wrote:
si...@google.com <si...@google.com>
kl...@google.com <kl...@google.com> #5
Thanks for the information. We have shared this with our product and engineering team and will update this issue with more information as it becomes available.
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.