|
6 | 6 | package com.facebook.react.uimanager; |
7 | 7 |
|
8 | 8 | import android.graphics.Color; |
| 9 | +import android.text.TextUtils; |
9 | 10 | import android.view.View; |
10 | 11 | import android.view.ViewParent; |
11 | 12 | import androidx.core.view.ViewCompat; |
12 | 13 |
|
| 14 | +import java.util.ArrayList; |
13 | 15 | import java.util.HashMap; |
| 16 | +import java.util.List; |
14 | 17 |
|
15 | 18 | import com.facebook.react.R; |
16 | 19 | import com.facebook.react.bridge.ReadableArray; |
@@ -173,23 +176,23 @@ private void updateViewContentDescription(@Nonnull T view) { |
173 | 176 | final String accessibilityLabel = (String) view.getTag(R.id.accessibility_label); |
174 | 177 | final ReadableArray accessibilityStates = (ReadableArray) view.getTag(R.id.accessibility_states); |
175 | 178 | final String accessibilityHint = (String) view.getTag(R.id.accessibility_hint); |
176 | | - StringBuilder contentDescription = new StringBuilder(); |
| 179 | + final List<String> contentDescription = new ArrayList<>(); |
177 | 180 | if (accessibilityLabel != null) { |
178 | | - contentDescription.append(accessibilityLabel + ", "); |
| 181 | + contentDescription.add(accessibilityLabel); |
179 | 182 | } |
180 | 183 | if (accessibilityStates != null) { |
181 | 184 | for (int i = 0; i < accessibilityStates.size(); i++) { |
182 | 185 | String state = accessibilityStates.getString(i); |
183 | 186 | if (sStateDescription.containsKey(state)) { |
184 | | - contentDescription.append(view.getContext().getString(sStateDescription.get(state)) + ", "); |
| 187 | + contentDescription.add(view.getContext().getString(sStateDescription.get(state))); |
185 | 188 | } |
186 | 189 | } |
187 | 190 | } |
188 | 191 | if (accessibilityHint != null) { |
189 | | - contentDescription.append(accessibilityHint + ", "); |
| 192 | + contentDescription.add(accessibilityHint); |
190 | 193 | } |
191 | | - if (contentDescription.length() > 0) { |
192 | | - view.setContentDescription(contentDescription.toString()); |
| 194 | + if (contentDescription.size() > 0) { |
| 195 | + view.setContentDescription(TextUtils.join(", ", contentDescription)); |
193 | 196 | } |
194 | 197 | } |
195 | 198 |
|
|
0 commit comments