77import android .os .Build ;
88import android .view .View ;
99import android .view .ViewParent ;
10-
11- import java .util .ArrayList ;
12- import java .util .HashMap ;
10+ import android .support .annotation .NonNull ;
11+ import android .support .annotation .Nullable ;
1312
1413import com .facebook .react .R ;
1514import com .facebook .react .bridge .Dynamic ;
2423import com .facebook .react .uimanager .util .ReactFindViewUtil ;
2524import java .util .Locale ;
2625
27- import javax .annotation .Nonnull ;
26+ import java .util .ArrayList ;
27+ import java .util .HashMap ;
28+ import java .util .List ;
2829import java .util .Map ;
29- import javax .annotation .Nullable ;
3030
3131/**
3232 * Base class that should be suitable for the majority of subclasses of {@link ViewManager}.
@@ -66,7 +66,7 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
6666 new MatrixMathHelper .MatrixDecompositionContext ();
6767 private static double [] sTransformDecompositionArray = new double [16 ];
6868
69- public static final HashMap <String , Integer > sStateDescription = new HashMap <String , Integer >();
69+ public static final Map <String , Integer > sStateDescription = new HashMap <>();
7070
7171 static {
7272 sStateDescription .put ("busy" , R .string .state_busy_description );
@@ -115,7 +115,7 @@ public void setZIndex(T view, float zIndex) {
115115 int integerZIndex = Math .round (zIndex );
116116 ViewGroupManager .setViewZIndex (view , integerZIndex );
117117 ViewParent parent = view .getParent ();
118- if (parent != null && parent instanceof ReactZIndexedViewGroup ) {
118+ if (parent instanceof ReactZIndexedViewGroup ) {
119119 ((ReactZIndexedViewGroup ) parent ).updateDrawingOrder ();
120120 }
121121 }
@@ -180,7 +180,8 @@ public void setViewState(@Nonnull T view, @Nullable ReadableMap accessibilitySta
180180 private void updateViewContentDescription (@ Nonnull T view ) {
181181 final String accessibilityLabel = (String ) view .getTag (R .id .accessibility_label );
182182 final ReadableMap accessibilityState = (ReadableMap ) view .getTag (R .id .accessibility_state );
183- final ArrayList <String > contentDescription = new ArrayList <String >();
183+ final List <String > contentDescription = new ArrayList <>();
184+ final ReadableMap accessibilityValue = (ReadableMap ) view .getTag (R .id .accessibility_value );
184185 if (accessibilityLabel != null ) {
185186 contentDescription .add (accessibilityLabel );
186187 }
@@ -198,6 +199,12 @@ private void updateViewContentDescription(@Nonnull T view) {
198199 }
199200 }
200201 }
202+ if (accessibilityValue != null && accessibilityValue .hasKey ("text" )) {
203+ final Dynamic text = accessibilityValue .getDynamic ("text" );
204+ if (text != null && text .getType () == ReadableType .String ) {
205+ contentDescription .add (text .asString ());
206+ }
207+ }
201208 if (contentDescription .size () > 0 ) {
202209 view .setContentDescription (TextUtils .join (", " , contentDescription ));
203210 }
@@ -212,6 +219,18 @@ public void setAccessibilityActions(T view, ReadableArray accessibilityActions)
212219 view .setTag (R .id .accessibility_actions , accessibilityActions );
213220 }
214221
222+ @ ReactProp (name = ViewProps .ACCESSIBILITY_VALUE )
223+ public void setAccessibilityValue (T view , ReadableMap accessibilityValue ) {
224+ if (accessibilityValue == null ) {
225+ return ;
226+ }
227+
228+ view .setTag (R .id .accessibility_value , accessibilityValue );
229+ if (accessibilityValue .hasKey ("text" )) {
230+ updateViewContentDescription (view );
231+ }
232+ }
233+
215234 @ ReactProp (name = PROP_IMPORTANT_FOR_ACCESSIBILITY )
216235 public void setImportantForAccessibility (
217236 @ Nonnull T view , @ Nullable String importantForAccessibility ) {
0 commit comments