99import android .support .v4 .view .AccessibilityDelegateCompat ;
1010import android .support .v4 .view .ViewCompat ;
1111import android .support .v4 .view .accessibility .AccessibilityNodeInfoCompat ;
12+ import android .support .v4 .view .accessibility .AccessibilityNodeInfoCompat .CollectionItemInfoCompat ;
13+ import android .text .SpannableString ;
14+ import android .text .style .URLSpan ;
1215import android .view .View ;
1316import com .facebook .react .R ;
1417import java .util .Locale ;
@@ -98,7 +101,6 @@ public static void setDelegate(final View view) {
98101 public void onInitializeAccessibilityNodeInfo (
99102 View host , AccessibilityNodeInfoCompat info ) {
100103 super .onInitializeAccessibilityNodeInfo (host , info );
101- setRole (info , accessibilityRole , view .getContext ());
102104 if (!(accessibilityHint == null )) {
103105 String contentDescription =(String )info .getContentDescription ();
104106 if (contentDescription != null ) {
@@ -108,6 +110,8 @@ public void onInitializeAccessibilityNodeInfo(
108110 info .setContentDescription (accessibilityHint );
109111 }
110112 }
113+
114+ setRole (info , accessibilityRole , view .getContext ());
111115 }
112116 });
113117 }
@@ -127,6 +131,18 @@ public static void setRole(AccessibilityNodeInfoCompat nodeInfo, AccessibilityRo
127131 if (Locale .getDefault ().getLanguage ().equals (new Locale ("en" ).getLanguage ())) {
128132 if (role .equals (AccessibilityRole .LINK )) {
129133 nodeInfo .setRoleDescription (context .getString (R .string .link_description ));
134+
135+ if (nodeInfo .getContentDescription () != null ) {
136+ SpannableString spannable = new SpannableString (nodeInfo .getContentDescription ());
137+ spannable .setSpan (new URLSpan ("" ), 0 , spannable .length (), 0 );
138+ nodeInfo .setContentDescription (spannable );
139+ }
140+
141+ if (nodeInfo .getText () != null ) {
142+ SpannableString spannable = new SpannableString (nodeInfo .getText ());
143+ spannable .setSpan (new URLSpan ("" ), 0 , spannable .length (), 0 );
144+ nodeInfo .setText (spannable );
145+ }
130146 }
131147 if (role .equals (AccessibilityRole .SEARCH )) {
132148 nodeInfo .setRoleDescription (context .getString (R .string .search_description ));
@@ -140,6 +156,12 @@ public static void setRole(AccessibilityNodeInfoCompat nodeInfo, AccessibilityRo
140156 if (role .equals (AccessibilityRole .ADJUSTABLE )) {
141157 nodeInfo .setRoleDescription (context .getString (R .string .adjustable_description ));
142158 }
159+ if (role .equals (AccessibilityRole .HEADER )) {
160+ nodeInfo .setRoleDescription (context .getString (R .string .header_description ));
161+ final AccessibilityNodeInfoCompat .CollectionItemInfoCompat itemInfo =
162+ AccessibilityNodeInfoCompat .CollectionItemInfoCompat .obtain (0 , 1 , 0 , 1 , true );
163+ nodeInfo .setCollectionItemInfo (itemInfo );
164+ }
143165 }
144166 if (role .equals (AccessibilityRole .IMAGEBUTTON )) {
145167 nodeInfo .setClickable (true );
0 commit comments