Skip to content

Commit

Permalink
rename accessibilityCollectionInfo to accessibilityCollection
Browse files Browse the repository at this point in the history
  • Loading branch information
fabOnReact committed Feb 24, 2022
1 parent 062cdcd commit 78b5fe3
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const AndroidHorizontalScrollViewNativeComponent: HostComponent<Props> =
snapToStart: true,
snapToOffsets: true,
contentOffset: true,
accessibilityCollectionInfo: true,
accessibilityCollection: true,
borderBottomLeftRadius: true,
borderBottomRightRadius: true,
borderRadius: true,
Expand Down
14 changes: 6 additions & 8 deletions Libraries/Lists/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
return (
<View style={StyleSheet.compose(styles.row, columnWrapperStyle)}>
{item.map((it, kk) => {
const accessibilityCollectionItemInfo = {
const accessibilityCollectionItem = {
rowIndex: index,
rowSpan: 1,
columnIndex: (index * numColumns + kk) % numColumns,
Expand All @@ -627,9 +627,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
<View
importantForAccessibility="yes"
style={styles.cellStyle}
accessibilityCollectionItemInfo={
accessibilityCollectionItemInfo
}>
accessibilityCollectionItem={accessibilityCollectionItem}>
{renderer({
item: it,
index: index * numColumns + kk,
Expand All @@ -646,7 +644,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
} else {
const {index} = info;

const accessibilityCollectionItemInfo = {
const accessibilityCollectionItem = {
rowIndex: index,
rowSpan: 1,
columnIndex: 0,
Expand All @@ -659,7 +657,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
<View
importantForAccessibility="yes"
style={styles.cellStyle}
accessibilityCollectionItemInfo={accessibilityCollectionItemInfo}>
accessibilityCollectionItem={accessibilityCollectionItem}>
{renderer(info)}
</View>
);
Expand All @@ -668,7 +666,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
};
};

_getAccessibilityCollectionInfo = () => {
_getAccessibilityCollection = () => {
const accessibilityCollectionProps = {
itemCount: this.props.data ? this.props.data.length : 0,
rowCount: this._getItemCount(this.props.data),
Expand All @@ -693,7 +691,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
getItem={this._getItem}
getItemCount={this._getItemCount}
keyExtractor={this._keyExtractor}
accessibilityCollectionInfo={this._getAccessibilityCollectionInfo()}
accessibilityCollection={this._getAccessibilityCollection()}
accessibilityRole={Platform.select({
android: this.props.numColumns > 1 ? 'grid' : 'list',
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ public void setAccessibilityHint(@NonNull T view, @Nullable String accessibility
updateViewContentDescription(view);
}


@Override
@ReactProp(name = ViewProps.ACCESSIBILITY_ROLE)
public void setAccessibilityRole(@NonNull T view, @Nullable String accessibilityRole) {
Expand All @@ -176,17 +175,18 @@ public void setAccessibilityRole(@NonNull T view, @Nullable String accessibility
view.setTag(R.id.accessibility_role, AccessibilityRole.fromValue(accessibilityRole));
}


@Override
@ReactProp(name = ViewProps.ACCESSIBILITY_COLLECTION_INFO)
public void setAccessibilityCollectionInfo(@NonNull T view, @Nullable ReadableMap accessibilityCollectionInfo) {
view.setTag(R.id.accessibility_collection_info, accessibilityCollectionInfo);
@ReactProp(name = ViewProps.ACCESSIBILITY_COLLECTION)
public void setAccessibilityCollection(
@NonNull T view, @Nullable ReadableMap accessibilityCollection) {
view.setTag(R.id.accessibility_collection, accessibilityCollection);
}

@Override
@ReactProp(name = ViewProps.ACCESSIBILITY_COLLECTION_ITEM_INFO)
public void setAccessibilityCollectionItemInfo(@NonNull T view, @Nullable ReadableMap accessibilityCollectionItemInfo) {
view.setTag(R.id.accessibility_collection_item_info, accessibilityCollectionItemInfo);
@ReactProp(name = ViewProps.ACCESSIBILITY_COLLECTION_ITEM)
public void setAccessibilityCollectionItem(
@NonNull T view, @Nullable ReadableMap accessibilityCollectionItem) {
view.setTag(R.id.accessibility_collection_item, accessibilityCollectionItem);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ public void setAccessibilityLiveRegion(@NonNull T view, @Nullable String liveReg
public void setAccessibilityRole(@NonNull T view, @Nullable String accessibilityRole) {}

@Override
public void setAccessibilityCollectionInfo(@NonNull T view, @Nullable ReadableMap accessibilityCollectionInfo) {}
public void setAccessibilityCollection(
@NonNull T view, @Nullable ReadableMap accessibilityCollection) {}

@Override
public void setAccessibilityCollectionItemInfo(@NonNull T view, @Nullable ReadableMap accessibilityCollectionItemInfo) {}
public void setAccessibilityCollectionItem(
@NonNull T view, @Nullable ReadableMap accessibilityCollectionItem) {}

@Override
public void setViewState(@NonNull T view, @Nullable ReadableMap accessibilityState) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,14 @@ public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCo
final ReadableArray accessibilityActions =
(ReadableArray) host.getTag(R.id.accessibility_actions);

final ReadableMap accessibilityCollectionItemInfo =
(ReadableMap) host.getTag(R.id.accessibility_collection_item_info);
if (accessibilityCollectionItemInfo != null) {
int rowIndex = accessibilityCollectionItemInfo.getInt("rowIndex");
int columnIndex = accessibilityCollectionItemInfo.getInt("columnIndex");
int rowSpan = accessibilityCollectionItemInfo.getInt("rowSpan");
int columnSpan = accessibilityCollectionItemInfo.getInt("columnSpan");
boolean heading = accessibilityCollectionItemInfo.getBoolean("heading");
final ReadableMap accessibilityCollectionItem =
(ReadableMap) host.getTag(R.id.accessibility_collection_item);
if (accessibilityCollectionItem != null) {
int rowIndex = accessibilityCollectionItem.getInt("rowIndex");
int columnIndex = accessibilityCollectionItem.getInt("columnIndex");
int rowSpan = accessibilityCollectionItem.getInt("rowSpan");
int columnSpan = accessibilityCollectionItem.getInt("columnSpan");
boolean heading = accessibilityCollectionItem.getBoolean("heading");

AccessibilityNodeInfoCompat.CollectionItemInfoCompat collectionItemInfoCompat =
AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain(
Expand Down Expand Up @@ -474,7 +474,7 @@ public static void setDelegate(final View view) {
|| view.getTag(R.id.accessibility_state) != null
|| view.getTag(R.id.accessibility_actions) != null
|| view.getTag(R.id.react_test_id) != null
|| view.getTag(R.id.accessibility_collection_item_info) != null)) {
|| view.getTag(R.id.accessibility_collection_item) != null)) {
ViewCompat.setAccessibilityDelegate(view, new ReactAccessibilityDelegate());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public void setProperty(T view, String propName, @Nullable Object value) {
case ViewProps.ACCESSIBILITY_STATE:
mViewManager.setViewState(view, (ReadableMap) value);
break;
case ViewProps.ACCESSIBILITY_COLLECTION_INFO:
mViewManager.setAccessibilityCollectionInfo(view, (ReadableMap) value);
case ViewProps.ACCESSIBILITY_COLLECTION:
mViewManager.setAccessibilityCollection(view, (ReadableMap) value);
break;
case ViewProps.ACCESSIBILITY_COLLECTION_ITEM_INFO:
mViewManager.setAccessibilityCollectionItemInfo(view, (ReadableMap) value);
case ViewProps.ACCESSIBILITY_COLLECTION_ITEM:
mViewManager.setAccessibilityCollectionItem(view, (ReadableMap) value);
break;
case ViewProps.BACKGROUND_COLOR:
mViewManager.setBackgroundColor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public interface BaseViewManagerInterface<T extends View> {
void setAccessibilityLiveRegion(T view, @Nullable String liveRegion);

void setAccessibilityRole(T view, @Nullable String accessibilityRole);
void setAccessibilityCollectionInfo(T view, @Nullable ReadableMap accessibilityCollectionInfo);
void setAccessibilityCollectionItemInfo(T view, @Nullable ReadableMap accessibilityCollectionItemInfo);

void setAccessibilityCollection(T view, @Nullable ReadableMap accessibilityCollection);

void setAccessibilityCollectionItem(T view, @Nullable ReadableMap accessibilityCollectionItem);

void setViewState(T view, @Nullable ReadableMap accessibilityState);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ public class ViewProps {
public static final String Z_INDEX = "zIndex";
public static final String RENDER_TO_HARDWARE_TEXTURE = "renderToHardwareTextureAndroid";
public static final String ACCESSIBILITY_LABEL = "accessibilityLabel";
public static final String ACCESSIBILITY_COLLECTION_INFO = "accessibilityCollectionInfo";
public static final String ACCESSIBILITY_COLLECTION_ITEM_INFO = "accessibilityCollectionItemInfo";
public static final String ACCESSIBILITY_COLLECTION = "accessibilityCollection";
public static final String ACCESSIBILITY_COLLECTION_ITEM = "accessibilityCollectionItem";
public static final String ACCESSIBILITY_HINT = "accessibilityHint";
public static final String ACCESSIBILITY_LIVE_REGION = "accessibilityLiveRegion";
public static final String ACCESSIBILITY_ROLE = "accessibilityRole";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ public ReactHorizontalScrollView(Context context, @Nullable FpsListener fpsListe
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(host, event);
event.setScrollable(mScrollEnabled);
final ReadableMap accessibilityCollectionInfo =
(ReadableMap) host.getTag(R.id.accessibility_collection_info);
final ReadableMap accessibilityCollection =
(ReadableMap) host.getTag(R.id.accessibility_collection);

if (accessibilityCollectionInfo != null) {
event.setItemCount(accessibilityCollectionInfo.getInt("itemCount"));
if (accessibilityCollection != null) {
event.setItemCount(accessibilityCollection.getInt("itemCount"));
View contentView = getContentView();
Integer firstVisibleIndex = null;
Integer lastVisibleIndex = null;
Expand All @@ -145,36 +145,35 @@ public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event)
View nextChild = ((ViewGroup) contentView).getChildAt(index);
boolean isVisible = isPartiallyScrolledInView(nextChild);

ReadableMap accessibilityCollectionItemInfo =
(ReadableMap) nextChild.getTag(R.id.accessibility_collection_item_info);
ReadableMap accessibilityCollectionItem =
(ReadableMap) nextChild.getTag(R.id.accessibility_collection_item);

if (!(nextChild instanceof ViewGroup)) {
return;
}

int childCount = ((ViewGroup) nextChild).getChildCount();

// If this child's accessibilityCollectionItemInfo is null, we'll check one more
// If this child's accessibilityCollectionItem is null, we'll check one more
// nested child.
// Happens when getItemLayout is not passed in FlatList which adds an additional
// View in the hierarchy.
if (childCount > 0 && accessibilityCollectionItemInfo == null) {
if (childCount > 0 && accessibilityCollectionItem == null) {
View nestedNextChild = ((ViewGroup) nextChild).getChildAt(0);
if (nestedNextChild != null) {
ReadableMap nestedChildAccessibilityInfo =
(ReadableMap)
nestedNextChild.getTag(R.id.accessibility_collection_item_info);
(ReadableMap) nestedNextChild.getTag(R.id.accessibility_collection_item);
if (nestedChildAccessibilityInfo != null) {
accessibilityCollectionItemInfo = nestedChildAccessibilityInfo;
accessibilityCollectionItem = nestedChildAccessibilityInfo;
}
}
}

if (isVisible == true && accessibilityCollectionItemInfo != null) {
if (isVisible == true && accessibilityCollectionItem != null) {
if (firstVisibleIndex == null) {
firstVisibleIndex = accessibilityCollectionItemInfo.getInt("itemIndex");
firstVisibleIndex = accessibilityCollectionItem.getInt("itemIndex");
}
lastVisibleIndex = accessibilityCollectionItemInfo.getInt("itemIndex");
lastVisibleIndex = accessibilityCollectionItem.getInt("itemIndex");
;
}

Expand All @@ -198,13 +197,13 @@ public void onInitializeAccessibilityNodeInfo(
ReactAccessibilityDelegate.setRole(info, accessibilityRole, host.getContext());
}

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

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

AccessibilityNodeInfoCompat.CollectionInfoCompat collectionInfoCompat =
AccessibilityNodeInfoCompat.CollectionInfoCompat.obtain(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ public void setPagingEnabled(ReactHorizontalScrollView view, boolean pagingEnabl
view.setPagingEnabled(pagingEnabled);
}

@ReactProp(name = ViewProps.ACCESSIBILITY_COLLECTION_INFO)
public void setAccessibilityCollectionInfo(
ReactHorizontalScrollView view, @Nullable ReadableMap accessibilityCollectionInfo) {
view.setTag(R.id.accessibility_collection_info, accessibilityCollectionInfo);
@ReactProp(name = ViewProps.ACCESSIBILITY_COLLECTION)
public void setAccessibilityCollection(
ReactHorizontalScrollView view, @Nullable ReadableMap accessibilityCollection) {
view.setTag(R.id.accessibility_collection, accessibilityCollection);
}

/** Controls overScroll behaviour */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ public ReactScrollView(Context context, @Nullable FpsListener fpsListener) {
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(host, event);
event.setScrollable(mScrollEnabled);
final ReadableMap accessibilityCollectionInfo =
(ReadableMap) host.getTag(R.id.accessibility_collection_info);
final ReadableMap accessibilityCollection =
(ReadableMap) host.getTag(R.id.accessibility_collection);

if (accessibilityCollectionInfo != null) {
event.setItemCount(accessibilityCollectionInfo.getInt("itemCount"));
if (accessibilityCollection != null) {
event.setItemCount(accessibilityCollection.getInt("itemCount"));
View contentView = getContentView();
Integer firstVisibleIndex = null;
Integer lastVisibleIndex = null;
Expand All @@ -148,36 +148,35 @@ public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event)
View nextChild = ((ViewGroup) contentView).getChildAt(index);
boolean isVisible = isPartiallyScrolledInView(nextChild);

ReadableMap accessibilityCollectionItemInfo =
(ReadableMap) nextChild.getTag(R.id.accessibility_collection_item_info);
ReadableMap accessibilityCollectionItem =
(ReadableMap) nextChild.getTag(R.id.accessibility_collection_item);

if (!(nextChild instanceof ViewGroup)) {
return;
}

int childCount = ((ViewGroup) nextChild).getChildCount();

// If this child's accessibilityCollectionItemInfo is null, we'll check one more
// If this child's accessibilityCollectionItem is null, we'll check one more
// nested child.
// Happens when getItemLayout is not passed in FlatList which adds an additional
// View in the hierarchy.
if (childCount > 0 && accessibilityCollectionItemInfo == null) {
if (childCount > 0 && accessibilityCollectionItem == null) {
View nestedNextChild = ((ViewGroup) nextChild).getChildAt(0);
if (nestedNextChild != null) {
ReadableMap nestedChildAccessibilityInfo =
(ReadableMap)
nestedNextChild.getTag(R.id.accessibility_collection_item_info);
if (nestedChildAccessibilityInfo != null) {
accessibilityCollectionItemInfo = nestedChildAccessibilityInfo;
ReadableMap nestedChildAccessibility =
(ReadableMap) nestedNextChild.getTag(R.id.accessibility_collection_item);
if (nestedChildAccessibility != null) {
accessibilityCollectionItem = nestedChildAccessibility;
}
}
}

if (isVisible == true && accessibilityCollectionItemInfo != null) {
if (isVisible == true && accessibilityCollectionItem != null) {
if (firstVisibleIndex == null) {
firstVisibleIndex = accessibilityCollectionItemInfo.getInt("itemIndex");
firstVisibleIndex = accessibilityCollectionItem.getInt("itemIndex");
}
lastVisibleIndex = accessibilityCollectionItemInfo.getInt("itemIndex");
lastVisibleIndex = accessibilityCollectionItem.getInt("itemIndex");
;
}

Expand All @@ -201,13 +200,13 @@ public void onInitializeAccessibilityNodeInfo(
ReactAccessibilityDelegate.setRole(info, accessibilityRole, host.getContext());
}

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

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

AccessibilityNodeInfoCompat.CollectionInfoCompat collectionInfoCompat =
AccessibilityNodeInfoCompat.CollectionInfoCompat.obtain(
Expand Down
Loading

0 comments on commit 78b5fe3

Please sign in to comment.