added android functionality for currentViewStates
Summary: Added native android support for the prop accessibilityStates. If 'selected' is passed in, it calls view.setSelected(true) If 'disabled' is passed in, it calls view.setEnabled(false) If both are passed in, both are set on the view. Reviewed By: blavalla Differential Revision: D8838407 fbshipit-source-id: a942dabcdc5d9e35f0316465e97317739a8b4b25
This commit is contained in:
parent
edf71005b5
commit
c1d0ccde0f
|
@ -12,6 +12,7 @@ import android.support.v4.view.ViewCompat;
|
|||
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
|
@ -102,7 +103,7 @@ public class AccessibilityRoleUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Variables and methods for setting accessibilityRole on view properties.
|
||||
* Method for setting accessibilityRole on view properties.
|
||||
*/
|
||||
public static void updateAccessibilityRole(View view, String role) {
|
||||
if (role == null) {
|
||||
|
|
|
@ -30,6 +30,7 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
|||
private static final String PROP_ACCESSIBILITY_COMPONENT_TYPE = "accessibilityComponentType";
|
||||
private static final String PROP_ACCESSIBILITY_LIVE_REGION = "accessibilityLiveRegion";
|
||||
private static final String PROP_ACCESSIBILITY_ROLE = "accessibilityRole";
|
||||
private static final String PROP_CURRENT_VIEW_STATES = "currentViewStates";
|
||||
private static final String PROP_IMPORTANT_FOR_ACCESSIBILITY = "importantForAccessibility";
|
||||
|
||||
// DEPRECATED
|
||||
|
@ -123,6 +124,20 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
|||
AccessibilityRoleUtil.updateAccessibilityRole(view, accessibilityRole);
|
||||
}
|
||||
|
||||
@ReactProp(name = PROP_CURRENT_VIEW_STATES)
|
||||
public void setViewStates(T view, ReadableArray currentViewStates) {
|
||||
view.setSelected(false);
|
||||
view.setEnabled(true);
|
||||
for (int i = 0; i < currentViewStates.size(); i++) {
|
||||
String state = currentViewStates.getString(i);
|
||||
if (state.equals("selected")) {
|
||||
view.setSelected(true);
|
||||
} else if (state.equals("disabled")) {
|
||||
view.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ReactProp(name = PROP_IMPORTANT_FOR_ACCESSIBILITY)
|
||||
public void setImportantForAccessibility(T view, String importantForAccessibility) {
|
||||
if (importantForAccessibility == null || importantForAccessibility.equals("auto")) {
|
||||
|
|
Loading…
Reference in New Issue