Add clarifying comments for accessibility implementation

- Explain why accessibility delegate is not set during batch selection
- Explain why map is cleared and rebuilt on each accessibility update
- Improves code maintainability and readability

Co-authored-by: adbenitez <24558636+adbenitez@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-11 23:14:55 +00:00
parent 54332e8bac
commit e8d3458a7b
2 changed files with 8 additions and 2 deletions
@@ -431,7 +431,10 @@ public class ConversationItem extends BaseConversationItem
bodyText.setText(spannable);
bodyText.setVisibility(View.VISIBLE);
// Set accessibility delegate for TalkBack to expose links as custom actions
// Set accessibility delegate for TalkBack to expose links as custom actions.
// Note: During batch selection mode (batchSelected.isEmpty() == false), links are not
// linkified (see line 427-428), so there's no need to set the accessibility delegate.
// This also ensures that accessibility focus doesn't interfere with batch selection UI.
if (Util.isTouchExplorationEnabled(context) && batchSelected.isEmpty()) {
if (linkAccessibilityDelegate == null) {
linkAccessibilityDelegate = new LinkAccessibilityDelegate(context);
@@ -53,7 +53,10 @@ public class LinkAccessibilityDelegate extends View.AccessibilityDelegate {
Spanned spanned = (Spanned) text;
LongClickCopySpan[] spans = spanned.getSpans(0, spanned.length(), LongClickCopySpan.class);
// Clear previous mappings
// Clear and rebuild mappings each time. This is necessary because:
// 1. TextView content may have changed since the last call
// 2. The same delegate instance may be reused for different text content
// 3. This method is called infrequently enough that performance is not a concern
actionSpanMap.clear();
// Add a custom action for each link