Skip to content

[Accessibility] Add 'button' for TalkBalk on Android Tap Gesture Recognizers#28393

Merged
rmarinho merged 2 commits into
mainfrom
dev/TJ/BindableLayoutAccessibility-Android
Mar 17, 2025
Merged

[Accessibility] Add 'button' for TalkBalk on Android Tap Gesture Recognizers#28393
rmarinho merged 2 commits into
mainfrom
dev/TJ/BindableLayoutAccessibility-Android

Conversation

@tj-devel709
Copy link
Copy Markdown
Member

@tj-devel709 tj-devel709 commented Mar 13, 2025

Description of Change

This PR allows android tap gestures to be announced as buttons by the screenreader similar to how iOS operates. This PR is related to #28388.

There was already logic to announce "double tap to activate" when a tap gesture required just one primary press. This PR keeps that logic but also adds the "button" to be announced for any tap gesture recognizer.

The Maui Controls Sample page for TapGestureRecognizers showcases this well:

android3.mp4

Issues Fixed

Partially fixes: #26913 and #26895

@tj-devel709 tj-devel709 added platform/android area-gestures Gesture types t/a11y Relates to accessibility labels Mar 13, 2025
@tj-devel709 tj-devel709 added this to the .NET 9 SR6 milestone Mar 13, 2025
@tj-devel709 tj-devel709 requested review from PureWeen and Copilot March 13, 2025 21:39
@tj-devel709 tj-devel709 requested a review from a team as a code owner March 13, 2025 21:39
@tj-devel709 tj-devel709 requested a review from jsuarezruiz March 13, 2025 21:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the accessibility semantics for Android tap gestures so that they are announced as buttons, similar to iOS behavior, while retaining the existing "double tap to activate" announcement for primary tap gestures.

  • Updated SemanticExtensions.cs to have TapGestureRecognizerNeedsDelegate delegate to the new button announcement check.
  • Modified the Android accessibility update logic to use separate checks for action click and button announcement.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Controls/src/Core/Platform/SemanticExtensions.cs Updated internal accessibility helper methods to differentiate between action click and button announcement.
src/Controls/src/Core/Platform/Android/Extensions/SemanticExtensions.cs Adjusted the Android accessibility node update logic to add both the click action and the button class name when applicable.
Comments suppressed due to low confidence (3)

src/Controls/src/Core/Platform/SemanticExtensions.cs:9

  • [nitpick] Review if renaming the delegate check to directly reference button announcement accurately reflects the intent; if the purpose is to indicate a delegate is needed, the naming might be misleading.
=> virtualView.TapGestureRecognizerNeedsButtonAnnouncement();

src/Controls/src/Core/Platform/Android/Extensions/SemanticExtensions.cs:14

  • Verify that replacing the previous delegate check with a call to TapGestureRecognizerNeedsActionClick preserves the intended behavior for adding the click accessibility action, as this could affect which gestures trigger a click announcement.
if (virtualView.TapGestureRecognizerNeedsActionClick())

src/Controls/src/Core/Platform/Android/Extensions/SemanticExtensions.cs:19

  • Ensure that setting the ClassName to 'android.widget.Button' does not override any pre-existing accessibility configurations, especially if multiple accessibility properties are applied.
if (virtualView.TapGestureRecognizerNeedsButtonAnnouncement())

@tj-devel709 tj-devel709 changed the title Dev/tj/bindable layout accessibility android [Accessibility] Add 'button' for TalkBalk on Android Tap Gesture Recognizers Mar 13, 2025
@github-project-automation github-project-automation Bot moved this from Todo to Approved in MAUI SDK Ongoing Mar 17, 2025
@rmarinho rmarinho merged commit 0f1060c into main Mar 17, 2025
@rmarinho rmarinho deleted the dev/TJ/BindableLayoutAccessibility-Android branch March 17, 2025 12:50
@github-project-automation github-project-automation Bot moved this from Approved to Done in MAUI SDK Ongoing Mar 17, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-gestures Gesture types platform/android t/a11y Relates to accessibility

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

No Role is defined as buttons for work, personal, health, family and friends in tags section: A11y_.NET 9 template_Projects_Name Role Value.

4 participants