Skip to content

Commit

Permalink
use mock values to set nodeInfo.setCollectionItemInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
fabOnReact committed Feb 18, 2022
1 parent ee23f45 commit db77060
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@
package com.facebook.react.uimanager;

import android.content.Context;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.SpannableString;
import android.text.style.URLSpan;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import androidx.annotation.Nullable;
import androidx.core.view.AccessibilityDelegateCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat.RangeInfoCompat;
import com.facebook.common.logging.FLog;
import com.facebook.react.R;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Dynamic;
Expand All @@ -45,7 +44,6 @@
* AccessibilityNodeInfo.
*/
public class ReactAccessibilityDelegate extends AccessibilityDelegateCompat {

private static final String TAG = "ReactAccessibilityDelegate";
public static final String TOP_ACCESSIBILITY_ACTION_EVENT = "topAccessibilityAction";
private static int sCounter = 0x3f000000;
Expand Down Expand Up @@ -226,15 +224,17 @@ public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCo
(ReadableArray) host.getTag(R.id.accessibility_actions);

final ReadableMap accessibilityCollectionItemInfo =
(ReadableMap) host.getTag(R.id.accessibility_collection_item_info);
(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");

AccessibilityNodeInfoCompat.CollectionItemInfoCompat collectionItemInfoCompat = AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain(rowIndex, rowSpan, columnIndex, columnSpan, heading);
AccessibilityNodeInfoCompat.CollectionItemInfoCompat collectionItemInfoCompat =
AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain(
rowIndex, rowSpan, columnIndex, columnSpan, heading);
info.setCollectionItemInfo(collectionItemInfoCompat);
}

Expand Down Expand Up @@ -293,7 +293,6 @@ public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCo
}
}


@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(host, event);
Expand Down Expand Up @@ -437,6 +436,27 @@ public static void setRole(
final AccessibilityNodeInfoCompat.CollectionItemInfoCompat itemInfo =
AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain(0, 1, 0, 1, true);
nodeInfo.setCollectionItemInfo(itemInfo);
} else if (role.equals(AccessibilityRole.GRID)) {
/*
final ReactAccessibilityDelegate.AccessibilityRole accessibilityRole = AccessibilityRole.GRID;
FLog.w(
"TESTING::ReactAccessibilityDelegate",
"accessibilityRole: "
+ (accessibilityRole)
+ " at ReactAccessibilityDelegate: "
);
ReactAccessibilityDelegate.setRole(nodeInfo, accessibilityRole, context);
int rowCount = 10;
int columnCount = 3;
boolean hierarchical = false;
AccessibilityNodeInfoCompat.CollectionInfoCompat collectionInfoCompat =
AccessibilityNodeInfoCompat.CollectionInfoCompat.obtain(
rowCount, columnCount, hierarchical);
nodeInfo.setCollectionInfo(collectionInfoCompat);
nodeInfo.setScrollable(true);
*/
} else if (role.equals(AccessibilityRole.ALERT)) {
nodeInfo.setRoleDescription(context.getString(R.string.alert_description));
} else if (role.equals(AccessibilityRole.COMBOBOX)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ public class ReactScrollView extends ScrollView
new ReactScrollViewScrollState(ViewCompat.LAYOUT_DIRECTION_LTR);
private final ValueAnimator DEFAULT_FLING_ANIMATOR = ObjectAnimator.ofInt(this, "scrollY", 0, 0);
private PointerEvents mPointerEvents = PointerEvents.AUTO;
public String BLACK = "\u001B[47m\u001B[30m";
public String WHITE = "\u001B[40m\u001B[37m";
public String PURPLE = "\u001B[45m\u001B[37m";
public String RESET = "\u001B[0m";

public ReactScrollView(Context context) {
this(context, null);
Expand Down Expand Up @@ -191,8 +195,8 @@ public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event)
}

if (firstVisibleIndex != null && lastVisibleIndex != null) {
event.setFromIndex(firstVisibleIndex);
event.setToIndex(lastVisibleIndex);
// event.setFromIndex(firstVisibleIndex);
// event.setToIndex(lastVisibleIndex);
}
}
}
Expand All @@ -205,7 +209,6 @@ public void onInitializeAccessibilityNodeInfo(

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

if (accessibilityRole != null) {
ReactAccessibilityDelegate.setRole(info, accessibilityRole, host.getContext());
}
Expand All @@ -214,9 +217,14 @@ public void onInitializeAccessibilityNodeInfo(
(ReadableMap) host.getTag(R.id.accessibility_collection_info);

if (accessibilityCollectionInfo != null) {
/*
int rowCount = accessibilityCollectionInfo.getInt("rowCount");
int columnCount = accessibilityCollectionInfo.getInt("columnCount");
boolean hierarchical = accessibilityCollectionInfo.getBoolean("hierarchical");
*/
int rowCount = 10;
int columnCount = 3;
boolean hierarchical = false;

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

0 comments on commit db77060

Please sign in to comment.