mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user