mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Declare shared interface for accessibility delegate methods (#48543)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48543 Introduces a shared interface for methods that need to be called by the `ReactScrollViewAccessibilityDelegate` Changelog: [Internal] Reviewed By: alanleedev Differential Revision: D67948151 fbshipit-source-id: 9bafaa0b5f9ad5ba2fd73b7b1929d784fa4951c9
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b1938e9026
commit
8a12672e8a
@@ -6673,7 +6673,7 @@ public final class com/facebook/react/views/scroll/ReactHorizontalScrollContaine
|
||||
public final class com/facebook/react/views/scroll/ReactHorizontalScrollContainerViewManager$Companion {
|
||||
}
|
||||
|
||||
public class com/facebook/react/views/scroll/ReactHorizontalScrollView : android/widget/HorizontalScrollView, android/view/View$OnLayoutChangeListener, android/view/ViewGroup$OnHierarchyChangeListener, com/facebook/react/uimanager/ReactClippingViewGroup, com/facebook/react/uimanager/ReactOverflowViewWithInset, com/facebook/react/views/scroll/ReactScrollViewHelper$HasFlingAnimator, com/facebook/react/views/scroll/ReactScrollViewHelper$HasScrollEventThrottle, com/facebook/react/views/scroll/ReactScrollViewHelper$HasScrollState, com/facebook/react/views/scroll/ReactScrollViewHelper$HasSmoothScroll, com/facebook/react/views/scroll/ReactScrollViewHelper$HasStateWrapper {
|
||||
public class com/facebook/react/views/scroll/ReactHorizontalScrollView : android/widget/HorizontalScrollView, android/view/View$OnLayoutChangeListener, android/view/ViewGroup$OnHierarchyChangeListener, com/facebook/react/uimanager/ReactClippingViewGroup, com/facebook/react/uimanager/ReactOverflowViewWithInset, com/facebook/react/views/scroll/ReactAccessibleScrollView, com/facebook/react/views/scroll/ReactScrollViewHelper$HasFlingAnimator, com/facebook/react/views/scroll/ReactScrollViewHelper$HasScrollEventThrottle, com/facebook/react/views/scroll/ReactScrollViewHelper$HasScrollState, com/facebook/react/views/scroll/ReactScrollViewHelper$HasSmoothScroll, com/facebook/react/views/scroll/ReactScrollViewHelper$HasStateWrapper {
|
||||
public fun <init> (Landroid/content/Context;)V
|
||||
public fun <init> (Landroid/content/Context;Lcom/facebook/react/views/scroll/FpsListener;)V
|
||||
public fun abortAnimation ()V
|
||||
@@ -6798,7 +6798,7 @@ public class com/facebook/react/views/scroll/ReactHorizontalScrollViewManager :
|
||||
public fun updateState (Lcom/facebook/react/views/scroll/ReactHorizontalScrollView;Lcom/facebook/react/uimanager/ReactStylesDiffMap;Lcom/facebook/react/uimanager/StateWrapper;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public class com/facebook/react/views/scroll/ReactScrollView : android/widget/ScrollView, android/view/View$OnLayoutChangeListener, android/view/ViewGroup$OnHierarchyChangeListener, com/facebook/react/uimanager/ReactClippingViewGroup, com/facebook/react/uimanager/ReactOverflowViewWithInset, com/facebook/react/views/scroll/ReactScrollViewHelper$HasFlingAnimator, com/facebook/react/views/scroll/ReactScrollViewHelper$HasScrollEventThrottle, com/facebook/react/views/scroll/ReactScrollViewHelper$HasScrollState, com/facebook/react/views/scroll/ReactScrollViewHelper$HasSmoothScroll, com/facebook/react/views/scroll/ReactScrollViewHelper$HasStateWrapper {
|
||||
public class com/facebook/react/views/scroll/ReactScrollView : android/widget/ScrollView, android/view/View$OnLayoutChangeListener, android/view/ViewGroup$OnHierarchyChangeListener, com/facebook/react/uimanager/ReactClippingViewGroup, com/facebook/react/uimanager/ReactOverflowViewWithInset, com/facebook/react/views/scroll/ReactAccessibleScrollView, com/facebook/react/views/scroll/ReactScrollViewHelper$HasFlingAnimator, com/facebook/react/views/scroll/ReactScrollViewHelper$HasScrollEventThrottle, com/facebook/react/views/scroll/ReactScrollViewHelper$HasScrollState, com/facebook/react/views/scroll/ReactScrollViewHelper$HasSmoothScroll, com/facebook/react/views/scroll/ReactScrollViewHelper$HasStateWrapper {
|
||||
public fun <init> (Landroid/content/Context;)V
|
||||
public fun <init> (Landroid/content/Context;Lcom/facebook/react/views/scroll/FpsListener;)V
|
||||
public fun abortAnimation ()V
|
||||
@@ -6821,6 +6821,7 @@ public class com/facebook/react/views/scroll/ReactScrollView : android/widget/Sc
|
||||
public fun getScrollEventThrottle ()I
|
||||
public fun getStateWrapper ()Lcom/facebook/react/uimanager/StateWrapper;
|
||||
protected fun handleInterceptedTouchEvent (Landroid/view/MotionEvent;)V
|
||||
public fun isPartiallyScrolledInView (Landroid/view/View;)Z
|
||||
protected fun onAttachedToWindow ()V
|
||||
public fun onChildViewAdded (Landroid/view/View;Landroid/view/View;)V
|
||||
public fun onChildViewRemoved (Landroid/view/View;Landroid/view/View;)V
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.views.scroll
|
||||
|
||||
import android.view.View
|
||||
|
||||
/** Shared interface for the [ReactScrollViewAccessibilityDelegate] */
|
||||
internal interface ReactAccessibleScrollView {
|
||||
|
||||
val scrollEnabled: Boolean
|
||||
|
||||
/** Returns whether the given descendent is partially scrolled in view */
|
||||
fun isPartiallyScrolledInView(view: View): Boolean
|
||||
}
|
||||
+2
@@ -71,6 +71,7 @@ public class ReactHorizontalScrollView extends HorizontalScrollView
|
||||
implements ReactClippingViewGroup,
|
||||
ViewGroup.OnHierarchyChangeListener,
|
||||
View.OnLayoutChangeListener,
|
||||
ReactAccessibleScrollView,
|
||||
ReactOverflowViewWithInset,
|
||||
HasScrollState,
|
||||
HasStateWrapper,
|
||||
@@ -456,6 +457,7 @@ public class ReactHorizontalScrollView extends HorizontalScrollView
|
||||
}
|
||||
|
||||
/** Returns whether the given descendent is partially scrolled in view */
|
||||
@Override
|
||||
public boolean isPartiallyScrolledInView(View descendent) {
|
||||
int scrollDelta = getScrollDelta(descendent);
|
||||
descendent.getDrawingRect(mTempRect);
|
||||
|
||||
+3
-1
@@ -76,6 +76,7 @@ public class ReactScrollView extends ScrollView
|
||||
implements ReactClippingViewGroup,
|
||||
ViewGroup.OnHierarchyChangeListener,
|
||||
View.OnLayoutChangeListener,
|
||||
ReactAccessibleScrollView,
|
||||
ReactOverflowViewWithInset,
|
||||
HasScrollState,
|
||||
HasStateWrapper,
|
||||
@@ -380,7 +381,8 @@ public class ReactScrollView extends ScrollView
|
||||
}
|
||||
|
||||
/** Returns whether the given descendent is partially scrolled in view */
|
||||
boolean isPartiallyScrolledInView(View descendent) {
|
||||
@Override
|
||||
public boolean isPartiallyScrolledInView(View descendent) {
|
||||
int scrollDelta = getScrollDelta(descendent);
|
||||
descendent.getDrawingRect(mTempRect);
|
||||
return scrollDelta != 0 && Math.abs(scrollDelta) < mTempRect.width();
|
||||
|
||||
+6
-10
@@ -25,25 +25,25 @@ internal class ReactScrollViewAccessibilityDelegate : AccessibilityDelegateCompa
|
||||
|
||||
override fun onInitializeAccessibilityEvent(host: View, event: AccessibilityEvent) {
|
||||
super.onInitializeAccessibilityEvent(host, event)
|
||||
if (host is ReactScrollView || host is ReactHorizontalScrollView) {
|
||||
if (host is ReactAccessibleScrollView) {
|
||||
onInitializeAccessibilityEventInternal(host, event)
|
||||
} else {
|
||||
ReactSoftExceptionLogger.logSoftException(
|
||||
TAG,
|
||||
AssertionException(
|
||||
"ReactScrollViewAccessibilityDelegate should only be used with ReactScrollView or ReactHorizontalScrollView, not with class: ${host.javaClass.simpleName}"))
|
||||
"ReactScrollViewAccessibilityDelegate should only be used with ReactAccessibleScrollView, not with class: ${host.javaClass.simpleName}"))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInitializeAccessibilityNodeInfo(host: View, info: AccessibilityNodeInfoCompat) {
|
||||
super.onInitializeAccessibilityNodeInfo(host, info)
|
||||
if (host is ReactScrollView || host is ReactHorizontalScrollView) {
|
||||
if (host is ReactAccessibleScrollView) {
|
||||
onInitializeAccessibilityNodeInfoInternal(host, info)
|
||||
} else {
|
||||
ReactSoftExceptionLogger.logSoftException(
|
||||
TAG,
|
||||
AssertionException(
|
||||
"ReactScrollViewAccessibilityDelegate should only be used with ReactScrollView or ReactHorizontalScrollView, not with class: ${host.javaClass.simpleName}"))
|
||||
"ReactScrollViewAccessibilityDelegate should only be used with ReactAccessibleScrollView, not with class: ${host.javaClass.simpleName}"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,9 +61,7 @@ internal class ReactScrollViewAccessibilityDelegate : AccessibilityDelegateCompa
|
||||
for (index in 0..<contentView.childCount) {
|
||||
val nextChild = contentView.getChildAt(index)
|
||||
val isVisible: Boolean =
|
||||
if (view is ReactScrollView) {
|
||||
view.isPartiallyScrolledInView(nextChild)
|
||||
} else if (view is ReactHorizontalScrollView) {
|
||||
if (view is ReactAccessibleScrollView) {
|
||||
view.isPartiallyScrolledInView(nextChild)
|
||||
} else {
|
||||
return
|
||||
@@ -127,9 +125,7 @@ internal class ReactScrollViewAccessibilityDelegate : AccessibilityDelegateCompa
|
||||
info.setCollectionInfo(collectionInfoCompat)
|
||||
}
|
||||
|
||||
if (view is ReactScrollView) {
|
||||
info.isScrollable = view.scrollEnabled
|
||||
} else if (view is ReactHorizontalScrollView) {
|
||||
if (view is ReactAccessibleScrollView) {
|
||||
info.isScrollable = view.scrollEnabled
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user