cashapp / paparazzi

Render your Android screens without a physical device or emulator
https://cashapp.github.io/paparazzi/
Apache License 2.0
2.22k stars 210 forks source link

Support adding more accessibility information #1485

Open VirtualParticle opened 2 weeks ago

VirtualParticle commented 2 weeks ago

This is currently how the text to be shown on the accessibility pane is chosen:

private fun SemanticsNode.accessibilityText() =
  (
    config.getOrNull(SemanticsProperties.ContentDescription)?.joinToString(", ")
      ?: config.getOrNull(SemanticsProperties.Text)?.joinToString(", ")
      ?: config.getOrNull(SemanticsProperties.StateDescription)
      ?: config.getOrNull(SemanticsActions.OnClick)?.label
      ?: config.getOrNull(SemanticsProperties.Role)?.toString()
    ).let {
    // Escape newline characters to simplify accessibility text.
    it?.replaceLineBreaks()
  }

I think adding some extra info like Heading or Selected would be helpful, maybe even more if it fits the circumstance. Not sure if it would be best to just add it here or make AccessibilityRenderExtension take in some properties for that. The way that it currently only picks one also means that we can't see both the text and the role if they're both present, for example.