Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -3303,6 +3303,11 @@ public abstract class com/facebook/react/uimanager/GuardedFrameCallback : androi
protected abstract fun doFrameGuarded (J)V
}

public abstract interface class com/facebook/react/uimanager/HasChildPressedStateDelay {
public abstract fun getHasChildPressedStateDelay ()Ljava/lang/Boolean;
public abstract fun setHasChildPressedStateDelay (Ljava/lang/Boolean;)V
}

public abstract interface class com/facebook/react/uimanager/IViewGroupManager : com/facebook/react/uimanager/IViewManagerWithChildren {
public abstract fun addView (Landroid/view/View;Landroid/view/View;I)V
public abstract fun getChildAt (Landroid/view/View;I)Landroid/view/View;
Expand Down Expand Up @@ -5146,10 +5151,13 @@ public abstract interface class com/facebook/react/viewmanagers/VirtualViewManag
public abstract fun setRenderState (Landroid/view/View;I)V
}

public final class com/facebook/react/views/drawer/ReactDrawerLayout : androidx/drawerlayout/widget/DrawerLayout {
public final class com/facebook/react/views/drawer/ReactDrawerLayout : androidx/drawerlayout/widget/DrawerLayout, com/facebook/react/uimanager/HasChildPressedStateDelay {
public fun <init> (Lcom/facebook/react/bridge/ReactContext;)V
public fun getHasChildPressedStateDelay ()Ljava/lang/Boolean;
public fun onInterceptTouchEvent (Landroid/view/MotionEvent;)Z
public fun onTouchEvent (Landroid/view/MotionEvent;)Z
public fun setHasChildPressedStateDelay (Ljava/lang/Boolean;)V
public fun shouldDelayChildPressedState ()Z
}

public final class com/facebook/react/views/drawer/ReactDrawerLayoutManager : com/facebook/react/uimanager/ViewGroupManager, com/facebook/react/viewmanagers/AndroidDrawerLayoutManagerInterface {
Expand Down Expand Up @@ -5403,6 +5411,7 @@ public final class com/facebook/react/views/modal/ReactModalHostView : android/v
public final fun setStateWrapper (Lcom/facebook/react/uimanager/StateWrapper;)V
public final fun setStatusBarTranslucent (Z)V
public final fun setTransparent (Z)V
public fun shouldDelayChildPressedState ()Z
public final fun showOrUpdate ()V
}

Expand Down Expand Up @@ -5449,7 +5458,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/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, com/facebook/react/views/scroll/VirtualViewContainer {
public class com/facebook/react/views/scroll/ReactHorizontalScrollView : android/widget/HorizontalScrollView, android/view/View$OnLayoutChangeListener, android/view/ViewGroup$OnHierarchyChangeListener, com/facebook/react/uimanager/HasChildPressedStateDelay, 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, com/facebook/react/views/scroll/VirtualViewContainer {
public fun <init> (Landroid/content/Context;)V
public fun <init> (Landroid/content/Context;Lcom/facebook/react/views/scroll/FpsListener;)V
public synthetic fun <init> (Landroid/content/Context;Lcom/facebook/react/views/scroll/FpsListener;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
Expand All @@ -5469,6 +5478,7 @@ public class com/facebook/react/views/scroll/ReactHorizontalScrollView : android
public fun getFadingEdgeLengthStart ()I
public fun getFlingAnimator ()Landroid/animation/ValueAnimator;
public fun getFlingExtrapolatedDistance (I)I
public fun getHasChildPressedStateDelay ()Ljava/lang/Boolean;
public fun getLastScrollDispatchTime ()J
protected fun getLeftFadingEdgeStrength ()F
public fun getOverflow ()Ljava/lang/String;
Expand Down Expand Up @@ -5516,6 +5526,7 @@ public class com/facebook/react/views/scroll/ReactHorizontalScrollView : android
public fun setEndFillColor (I)V
public fun setFadingEdgeLengthEnd (I)V
public fun setFadingEdgeLengthStart (I)V
public fun setHasChildPressedStateDelay (Ljava/lang/Boolean;)V
public fun setLastScrollDispatchTime (J)V
public fun setOverflow (Ljava/lang/String;)V
public fun setOverflowInset (IIII)V
Expand All @@ -5534,6 +5545,7 @@ public class com/facebook/react/views/scroll/ReactHorizontalScrollView : android
public fun setSnapToEnd (Z)V
public fun setSnapToStart (Z)V
public fun setStateWrapper (Lcom/facebook/react/uimanager/StateWrapper;)V
public fun shouldDelayChildPressedState ()Z
public fun startFlingAnimator (II)V
public fun updateClippingRect ()V
public fun updateClippingRect (Ljava/util/Set;)V
Expand Down Expand Up @@ -5596,7 +5608,7 @@ public class com/facebook/react/views/scroll/ReactHorizontalScrollViewManager :
public final class com/facebook/react/views/scroll/ReactHorizontalScrollViewManager$Companion {
}

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, com/facebook/react/views/scroll/VirtualViewContainer {
public class com/facebook/react/views/scroll/ReactScrollView : android/widget/ScrollView, android/view/View$OnLayoutChangeListener, android/view/ViewGroup$OnHierarchyChangeListener, com/facebook/react/uimanager/HasChildPressedStateDelay, 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, com/facebook/react/views/scroll/VirtualViewContainer {
public fun <init> (Landroid/content/Context;)V
public fun <init> (Landroid/content/Context;Lcom/facebook/react/views/scroll/FpsListener;)V
public synthetic fun <init> (Landroid/content/Context;Lcom/facebook/react/views/scroll/FpsListener;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
Expand All @@ -5614,6 +5626,7 @@ public class com/facebook/react/views/scroll/ReactScrollView : android/widget/Sc
public fun getFadingEdgeLengthStart ()I
public fun getFlingAnimator ()Landroid/animation/ValueAnimator;
public fun getFlingExtrapolatedDistance (I)I
public fun getHasChildPressedStateDelay ()Ljava/lang/Boolean;
public fun getLastScrollDispatchTime ()J
protected fun getOverScrollerFromParent ()Landroid/widget/OverScroller;
public fun getOverflow ()Ljava/lang/String;
Expand Down Expand Up @@ -5660,6 +5673,7 @@ public class com/facebook/react/views/scroll/ReactScrollView : android/widget/Sc
public fun setEndFillColor (I)V
public fun setFadingEdgeLengthEnd (I)V
public fun setFadingEdgeLengthStart (I)V
public fun setHasChildPressedStateDelay (Ljava/lang/Boolean;)V
public fun setLastScrollDispatchTime (J)V
public fun setOverflow (Ljava/lang/String;)V
public fun setOverflowInset (IIII)V
Expand All @@ -5680,6 +5694,7 @@ public class com/facebook/react/views/scroll/ReactScrollView : android/widget/Sc
public fun setSnapToEnd (Z)V
public fun setSnapToStart (Z)V
public fun setStateWrapper (Lcom/facebook/react/uimanager/StateWrapper;)V
public fun shouldDelayChildPressedState ()Z
public fun startFlingAnimator (II)V
public fun updateClippingRect ()V
public fun updateClippingRect (Ljava/util/Set;)V
Expand Down Expand Up @@ -5948,15 +5963,18 @@ public final class com/facebook/react/views/scroll/VirtualViewContainerState$Com
public final fun create (Landroid/view/ViewGroup;)Lcom/facebook/react/views/scroll/VirtualViewContainerState;
}

public class com/facebook/react/views/swiperefresh/ReactSwipeRefreshLayout : androidx/swiperefreshlayout/widget/SwipeRefreshLayout {
public class com/facebook/react/views/swiperefresh/ReactSwipeRefreshLayout : androidx/swiperefreshlayout/widget/SwipeRefreshLayout, com/facebook/react/uimanager/HasChildPressedStateDelay {
public fun <init> (Lcom/facebook/react/bridge/ReactContext;)V
public fun canChildScrollUp ()Z
public fun getHasChildPressedStateDelay ()Ljava/lang/Boolean;
public fun onInterceptTouchEvent (Landroid/view/MotionEvent;)Z
public fun onLayout (ZIIII)V
public fun onTouchEvent (Landroid/view/MotionEvent;)Z
public fun requestDisallowInterceptTouchEvent (Z)V
public fun setHasChildPressedStateDelay (Ljava/lang/Boolean;)V
public final fun setProgressViewOffset (F)V
public fun setRefreshing (Z)V
public fun shouldDelayChildPressedState ()Z
}

public final class com/facebook/react/views/text/DefaultStyleValuesUtil {
Expand Down Expand Up @@ -6445,6 +6463,7 @@ public class com/facebook/react/views/view/ReactViewGroup : android/view/ViewGro
public fun setPointerEvents (Lcom/facebook/react/uimanager/PointerEvents;)V
public fun setRemoveClippedSubviews (Z)V
public final fun setTranslucentBackgroundDrawable (Landroid/graphics/drawable/Drawable;)V
public fun shouldDelayChildPressedState ()Z
public fun updateClippingRect ()V
public fun updateClippingRect (Ljava/util/Set;)V
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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.uimanager

/**
* Implemented by scrollable container views that allow the delaying of their children's pressed
* state (see [android.view.ViewGroup.shouldDelayChildPressedState]) to be toggled externally,
* without changing the view's default behavior.
*
* This lets a module that holds a reference to such a container disable the delay (e.g. when it
* knows the gesture will not turn into a scroll, so children should show their pressed state
* immediately) and re-enable it afterwards.
*/
public interface HasChildPressedStateDelay {
/**
* Overrides whether this view delays its children's pressed state (see
* [android.view.ViewGroup.shouldDelayChildPressedState]).
*
* When `null` (the default), the view's framework default is used. Set to `true` or `false` to
* force the behavior, and back to `null` to restore the default. Lets a module holding a
* reference to the container toggle the delay without changing the default.
*/
public var hasChildPressedStateDelay: Boolean?
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.facebook.common.logging.FLog
import com.facebook.react.R
import com.facebook.react.bridge.ReactContext
import com.facebook.react.common.ReactConstants
import com.facebook.react.uimanager.HasChildPressedStateDelay
import com.facebook.react.uimanager.ReactAccessibilityDelegate.AccessibilityRole
import com.facebook.react.uimanager.events.NativeGestureUtil.notifyNativeGestureEnded
import com.facebook.react.uimanager.events.NativeGestureUtil.notifyNativeGestureStarted
Expand All @@ -28,11 +29,14 @@ import com.facebook.react.uimanager.events.NativeGestureUtil.notifyNativeGesture
* Wrapper view for [DrawerLayout]. It manages the properties that can be set on the drawer and
* contains some ReactNative-specific functionality.
*/
public class ReactDrawerLayout(reactContext: ReactContext) : DrawerLayout(reactContext) {
public class ReactDrawerLayout(reactContext: ReactContext) :
DrawerLayout(reactContext), HasChildPressedStateDelay {
private var drawerPosition = Gravity.START
private var drawerWidth = DEFAULT_DRAWER_WIDTH
private var dragging = false

override var hasChildPressedStateDelay: Boolean? = null

init {
ViewCompat.setAccessibilityDelegate(
this,
Expand Down Expand Up @@ -60,6 +64,9 @@ public class ReactDrawerLayout(reactContext: ReactContext) : DrawerLayout(reactC
)
}

override fun shouldDelayChildPressedState(): Boolean =
hasChildPressedStateDelay ?: super.shouldDelayChildPressedState()

override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
try {
if (super.onInterceptTouchEvent(ev)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ public class ReactModalHostView(context: ThemedReactContext) :
dialogRootViewGroup.dispatchProvideStructure(structure)
}

override fun shouldDelayChildPressedState(): Boolean = false

protected override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
// Do nothing as we are laid out by UIManager
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ internal class ReactSafeAreaView(val reactContext: ThemedReactContext) : ViewGro

override fun onLayout(p0: Boolean, p1: Int, p2: Int, p3: Int, p4: Int): Unit = Unit

override fun shouldDelayChildPressedState(): Boolean = false

@Suppress("DEPRECATION")
@UiThread
private fun updateState(insets: Insets) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import com.facebook.react.common.ReactConstants
import com.facebook.react.common.build.ReactBuildConfig
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
import com.facebook.react.uimanager.BackgroundStyleApplicator
import com.facebook.react.uimanager.HasChildPressedStateDelay
import com.facebook.react.uimanager.LengthPercentage
import com.facebook.react.uimanager.LengthPercentageType
import com.facebook.react.uimanager.MeasureSpecAssertions
Expand Down Expand Up @@ -84,7 +85,8 @@ constructor(context: Context, private val fpsListener: FpsListener? = null) :
HasFlingAnimator,
HasScrollEventThrottle,
HasSmoothScroll,
VirtualViewContainer {
VirtualViewContainer,
HasChildPressedStateDelay {

private companion object {
private val DEBUG_MODE = false && ReactBuildConfig.DEBUG
Expand Down Expand Up @@ -197,6 +199,7 @@ constructor(context: Context, private val fpsListener: FpsListener? = null) :
override var stateWrapper: StateWrapper? = null
override var scrollEventThrottle: Int = 0
override var lastScrollDispatchTime: Long = 0L
override var hasChildPressedStateDelay: Boolean? = null

override val virtualViewContainerState: VirtualViewContainerState
get() =
Expand Down Expand Up @@ -631,6 +634,9 @@ constructor(context: Context, private val fpsListener: FpsListener? = null) :
}
}

override fun shouldDelayChildPressedState(): Boolean =
hasChildPressedStateDelay ?: super.shouldDelayChildPressedState()

override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
if (!scrollEnabled) return false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<2b0cbc5249ac34ae7f030a9c0fffd1f3>>
* @generated SignedSource<<cf60b52e15df339a179f392723007fab>>
*/

/**
Expand Down Expand Up @@ -38,6 +38,7 @@ import com.facebook.react.bridge.ReadableMap
import com.facebook.react.common.ReactConstants
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
import com.facebook.react.uimanager.BackgroundStyleApplicator
import com.facebook.react.uimanager.HasChildPressedStateDelay
import com.facebook.react.uimanager.LengthPercentage
import com.facebook.react.uimanager.LengthPercentageType
import com.facebook.react.uimanager.MeasureSpecAssertions
Expand Down Expand Up @@ -93,7 +94,8 @@ constructor(context: Context, private val fpsListener: FpsListener? = null) :
HasFlingAnimator,
HasScrollEventThrottle,
HasSmoothScroll,
VirtualViewContainer {
VirtualViewContainer,
HasChildPressedStateDelay {

private companion object {
private var scrollerField: java.lang.reflect.Field? = null
Expand All @@ -107,6 +109,7 @@ constructor(context: Context, private val fpsListener: FpsListener? = null) :
override var stateWrapper: StateWrapper? = null
override var scrollEventThrottle: Int = 0
override var lastScrollDispatchTime: Long = 0L
override var hasChildPressedStateDelay: Boolean? = null

public open var pointerEvents: PointerEvents = PointerEvents.AUTO

Expand Down Expand Up @@ -552,6 +555,9 @@ constructor(context: Context, private val fpsListener: FpsListener? = null) :
}
}

override fun shouldDelayChildPressedState(): Boolean =
hasChildPressedStateDelay ?: super.shouldDelayChildPressedState()

override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
if (!scrollEnabled) return false
if (!PointerEvents.canChildrenBeTouchTarget(pointerEvents)) return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import com.facebook.react.bridge.ReadableMap
import com.facebook.react.common.ReactConstants
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
import com.facebook.react.uimanager.BackgroundStyleApplicator
import com.facebook.react.uimanager.HasChildPressedStateDelay
import com.facebook.react.uimanager.LengthPercentage
import com.facebook.react.uimanager.LengthPercentageType
import com.facebook.react.uimanager.MeasureSpecAssertions
Expand Down Expand Up @@ -85,7 +86,8 @@ constructor(context: Context, private val fpsListener: FpsListener? = null) :
HasFlingAnimator,
HasScrollEventThrottle,
HasSmoothScroll,
VirtualViewContainer {
VirtualViewContainer,
HasChildPressedStateDelay {

private companion object {
private var scrollerField: java.lang.reflect.Field? = null
Expand All @@ -99,6 +101,7 @@ constructor(context: Context, private val fpsListener: FpsListener? = null) :
override var stateWrapper: StateWrapper? = null
override var scrollEventThrottle: Int = 0
override var lastScrollDispatchTime: Long = 0L
override var hasChildPressedStateDelay: Boolean? = null

public open var pointerEvents: PointerEvents = PointerEvents.AUTO

Expand Down Expand Up @@ -544,6 +547,9 @@ constructor(context: Context, private val fpsListener: FpsListener? = null) :
}
}

override fun shouldDelayChildPressedState(): Boolean =
hasChildPressedStateDelay ?: super.shouldDelayChildPressedState()

override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
if (!scrollEnabled) return false
if (!PointerEvents.canChildrenBeTouchTarget(pointerEvents)) return true
Expand Down
Loading
Loading