Skip to content

Commit

Permalink
check for isScreenReaderFocusable and hasHint
Browse files Browse the repository at this point in the history
adding check on hintText in hasText method
the "hint text" for EditText's also counts as content, as it's still announced when the EditText has no text or contentDescription.
See Talkbacks implementation here for reference:
https://github.com/google/talkback/blob/6c0b475b7f52469e309e51bfcc13de58f18176ff/utils/src/main/java/com/google/android/accessibility/utils/AccessibilityNodeInfoUtils.java#L1663
#33690 (comment)

adding check for isScreenReaderFocusable in isAccessibilityFocusable
See Talkback's implementation here for reference:
https://github.com/google/talkback/blob/6c0b475b7f52469e309e51bfcc13de58f18176ff/utils/src/main/java/com/google/android/accessibility/utils/AccessibilityNodeInfoUtils.java#L1690
#33690 (comment)
  • Loading branch information
fabOnReact committed May 26, 2022
1 parent 0b620e0 commit 45e3040
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,9 @@ public static boolean isSpeakingNode(
public static boolean hasText(@Nullable AccessibilityNodeInfoCompat node) {
return node != null
&& node.getCollectionInfo() == null
&& (!TextUtils.isEmpty(node.getText()) || !TextUtils.isEmpty(node.getContentDescription()));
&& (!TextUtils.isEmpty(node.getText())
|| !TextUtils.isEmpty(node.getContentDescription())
|| !TextUtils.isEmpty(node.getHintText()));
}

/**
Expand All @@ -867,7 +869,7 @@ public static boolean isAccessibilityFocusable(
}

// Always focus "actionable" nodes.
return isActionableForAccessibility(node);
return node.isScreenReaderFocusable() || isActionableForAccessibility(node);
}

/**
Expand Down

0 comments on commit 45e3040

Please sign in to comment.