Skip to content

Commit

Permalink
Changed prop name "currentViewStates" to "accessibilityStates" in And…
Browse files Browse the repository at this point in the history
…roid (2/3)

Summary:
Context:
After discussing with @[1038750002:yungsters], `currentViewStates` is a very ambiguous name for a prop, especially because there are only two possible values. From a developer's perspective, it makes more sense to just call them `accessibilityStates` because the main use for them is to add states to Talkback and Voiceover.
Defense for changing name in Android: The actual implementation of what we're changing under the hood in Native Code is abstracted away from developers using React Native, so as long as behavior is as they would expect, it makes more sense to change the name into a clear one regardless of how it is implemented.

Changes:
changed the Prop name from `currentViewStates` to `accessibilityStates` in the BaseViewManager file where the view property is being exposed.

Reviewed By: PeteTheHeat

Differential Revision: D8896389

fbshipit-source-id: 35dcd9239fae016b790e528947994681684bd654
  • Loading branch information
Ziqi Chen authored and facebook-github-bot committed Jul 19, 2018
1 parent 03036f7 commit 3bedc78
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +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_ACCESSIBILITY_STATES = "accessibilityStates";
private static final String PROP_IMPORTANT_FOR_ACCESSIBILITY = "importantForAccessibility";

// DEPRECATED
Expand Down Expand Up @@ -124,12 +124,12 @@ public void setAccessibilityRole(T view, String accessibilityRole) {
AccessibilityRoleUtil.updateAccessibilityRole(view, accessibilityRole);
}

@ReactProp(name = PROP_CURRENT_VIEW_STATES)
public void setViewStates(T view, ReadableArray currentViewStates) {
@ReactProp(name = PROP_ACCESSIBILITY_STATES)
public void setViewStates(T view, ReadableArray accessibilityStates) {
view.setSelected(false);
view.setEnabled(true);
for (int i = 0; i < currentViewStates.size(); i++) {
String state = currentViewStates.getString(i);
for (int i = 0; i < accessibilityStates.size(); i++) {
String state = accessibilityStates.getString(i);
if (state.equals("selected")) {
view.setSelected(true);
} else if (state.equals("disabled")) {
Expand Down

0 comments on commit 3bedc78

Please sign in to comment.