Skip to content

Commit

Permalink
move the logic to onInitializeAccessibilityNodeInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
fabOnReact committed Feb 24, 2022
1 parent 78b5fe3 commit 677fe4e
Showing 1 changed file with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import androidx.annotation.Nullable;
import androidx.core.view.AccessibilityDelegateCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.R;
Expand Down Expand Up @@ -188,41 +187,42 @@ public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event)
}
}

/*
@Override
public void onInitializeAccessibilityNodeInfo(
View host, AccessibilityNodeInfoCompat info) {
super.onInitializeAccessibilityNodeInfo(host, info);

final ReactAccessibilityDelegate.AccessibilityRole accessibilityRole =
(ReactAccessibilityDelegate.AccessibilityRole) host.getTag(R.id.accessibility_role);

if (accessibilityRole != null) {
ReactAccessibilityDelegate.setRole(info, accessibilityRole, host.getContext());
}

final ReadableMap accessibilityCollection =
(ReadableMap) host.getTag(R.id.accessibility_collection);

if (accessibilityCollection != null) {
int rowCount = accessibilityCollection.getInt("rowCount");
int columnCount = accessibilityCollection.getInt("columnCount");
boolean hierarchical = accessibilityCollection.getBoolean("hierarchical");

AccessibilityNodeInfoCompat.CollectionInfoCompat collectionInfoCompat =
AccessibilityNodeInfoCompat.CollectionInfoCompat.obtain(
rowCount, columnCount, hierarchical);
info.setCollectionInfo(collectionInfoCompat);
}

info.setScrollable(mScrollEnabled);
}
*/
});
}

@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);

final ReactAccessibilityDelegate.AccessibilityRole accessibilityRole =
(ReactAccessibilityDelegate.AccessibilityRole) getTag(R.id.accessibility_role);

if (accessibilityRole != null) {
AccessibilityNodeInfoCompat infoCompat = (AccessibilityNodeInfoCompat) info;
ReactAccessibilityDelegate.setRole(infoCompat, accessibilityRole, getContext());
}

final ReadableMap accessibilityCollection = (ReadableMap) getTag(R.id.accessibility_collection);

if (accessibilityCollection != null) {
int rowCount = accessibilityCollection.getInt("rowCount");
int columnCount = accessibilityCollection.getInt("columnCount");
boolean hierarchical = accessibilityCollection.getBoolean("hierarchical");

AccessibilityNodeInfo.CollectionInfo collectionInfo =
AccessibilityNodeInfo.CollectionInfo.obtain(rowCount, columnCount, hierarchical);
info.setCollectionInfo(collectionInfo);
}

info.setScrollable(mScrollEnabled);

// Expose the testID prop as the resource-id name of the view. Black-box E2E/UI testing
// frameworks, which interact with the UI through the accessibility framework, do not have
// access to view tags. This allows developers/testers to avoid polluting the
Expand Down

0 comments on commit 677fe4e

Please sign in to comment.