From d2d2a8a598cb8b5e5218c3c21cef408de2142fe4 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 31 Mar 2023 15:34:45 -0700 Subject: [PATCH] Introduce NO_SURFACE constant to specify the lack of surfaces used by legacy system (#36747) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/36747 Introduce NO_SURFACE constant to specify the lack of surfaces used by legacy system changelog: [internal] internal Reviewed By: sshic Differential Revision: D44563649 fbshipit-source-id: 99c7028c5ee508c2982cefc9b3199a332c2346c7 --- .../src/main/java/com/facebook/react/fabric/BUCK | 1 + .../react/fabric/events/FabricEventEmitter.java | 14 ++++++++------ .../react/fabric/mounting/MountingManager.java | 15 +++++++++------ .../facebook/react/uimanager/common/ViewUtil.java | 2 ++ .../views/drawer/events/DrawerClosedEvent.java | 3 ++- .../views/drawer/events/DrawerOpenedEvent.java | 3 ++- .../views/drawer/events/DrawerSlideEvent.java | 3 ++- .../drawer/events/DrawerStateChangedEvent.java | 3 ++- .../react/views/image/ImageLoadEvent.java | 11 ++++++----- .../react/views/modal/RequestCloseEvent.java | 3 ++- .../com/facebook/react/views/modal/ShowEvent.java | 3 ++- .../facebook/react/views/scroll/ScrollEvent.java | 3 ++- .../react/views/swiperefresh/RefreshEvent.java | 3 ++- .../react/views/switchview/ReactSwitchEvent.java | 3 ++- .../textinput/ReactContentSizeChangedEvent.java | 3 ++- .../views/textinput/ReactTextChangedEvent.java | 3 ++- .../views/textinput/ReactTextInputBlurEvent.java | 3 ++- .../textinput/ReactTextInputEndEditingEvent.java | 3 ++- .../views/textinput/ReactTextInputEvent.java | 3 ++- .../views/textinput/ReactTextInputFocusEvent.java | 3 ++- .../textinput/ReactTextInputKeyPressEvent.java | 3 ++- .../textinput/ReactTextInputSelectionEvent.java | 3 ++- .../ReactTextInputSubmitEditingEvent.java | 3 ++- .../react/views/view/ViewGroupClickEvent.java | 3 ++- 24 files changed, 64 insertions(+), 36 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/BUCK b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/BUCK index e788d9290f5..31752b347a2 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/BUCK +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/BUCK @@ -44,6 +44,7 @@ rn_android_library( react_native_target("java/com/facebook/react/modules/i18nmanager:i18nmanager"), react_native_target("java/com/facebook/react/touch:touch"), react_native_target("java/com/facebook/react/uimanager:uimanager"), + react_native_target("java/com/facebook/react/uimanager/common:common"), react_native_target("java/com/facebook/react/views/text:text"), react_native_target("java/com/facebook/react/views/view:view"), react_native_target("jni/react/fabric:jni"), diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/events/FabricEventEmitter.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/events/FabricEventEmitter.java index d02d7c96533..6674681fc40 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/events/FabricEventEmitter.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/events/FabricEventEmitter.java @@ -12,6 +12,7 @@ import androidx.annotation.Nullable; import com.facebook.react.bridge.WritableArray; import com.facebook.react.bridge.WritableMap; import com.facebook.react.fabric.FabricUIManager; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.EventCategoryDef; import com.facebook.react.uimanager.events.RCTModernEventEmitter; import com.facebook.react.uimanager.events.TouchEvent; @@ -20,8 +21,6 @@ import com.facebook.systrace.Systrace; public class FabricEventEmitter implements RCTModernEventEmitter { - private static final String TAG = "FabricEventEmitter"; - @NonNull private final FabricUIManager mUIManager; public FabricEventEmitter(@NonNull FabricUIManager uiManager) { @@ -30,7 +29,7 @@ public class FabricEventEmitter implements RCTModernEventEmitter { @Override public void receiveEvent(int reactTag, @NonNull String eventName, @Nullable WritableMap params) { - receiveEvent(-1, reactTag, eventName, params); + receiveEvent(ViewUtil.NO_SURFACE_ID, reactTag, eventName, params); } @Override @@ -51,9 +50,12 @@ public class FabricEventEmitter implements RCTModernEventEmitter { Systrace.beginSection( Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricEventEmitter.receiveEvent('" + eventName + "')"); - mUIManager.receiveEvent( - surfaceId, reactTag, eventName, canCoalesceEvent, customCoalesceKey, params, category); - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + try { + mUIManager.receiveEvent( + surfaceId, reactTag, eventName, canCoalesceEvent, customCoalesceKey, params, category); + } finally { + Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); + } } /** Touches are dispatched by {@link #receiveTouches(TouchEvent)} */ diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java index 269a911467e..0efb84e8b96 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java @@ -32,6 +32,7 @@ import com.facebook.react.touch.JSResponderHandler; import com.facebook.react.uimanager.RootViewManager; import com.facebook.react.uimanager.ThemedReactContext; import com.facebook.react.uimanager.ViewManagerRegistry; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.yoga.YogaMeasureMode; import java.util.Map; import java.util.Queue; @@ -280,12 +281,12 @@ public class MountingManager { * Send an accessibility eventType to a Native View. eventType is any valid `AccessibilityEvent.X` * value. * - *

Why accept `-1` SurfaceId? Currently there are calls to UIManager.sendAccessibilityEvent - * which is a legacy API and accepts only reactTag. We will have to investigate and migrate away - * from those calls over time. + *

Why accept {@ViewUtils.NO_SURFACE_ID}(-1) SurfaceId? Currently there are calls to + * UIManager.sendAccessibilityEvent which is a legacy API and accepts only reactTag. We will have + * to investigate and migrate away from those calls over time. * - * @param surfaceId {@link int} that identifies the surface or -1 to temporarily support backward - * compatibility. + * @param surfaceId {@link int} that identifies the surface or {@ViewUtils.NO_SURFACE_ID}(-1) to + * temporarily support backward compatibility. * @param reactTag {@link int} that identifies the react Tag of the view. * @param eventType {@link int} that identifies Android eventType. see {@link * View#sendAccessibilityEvent} @@ -326,7 +327,9 @@ public class MountingManager { @ThreadConfined(ANY) public @Nullable EventEmitterWrapper getEventEmitter(int surfaceId, int reactTag) { SurfaceMountingManager surfaceMountingManager = - (surfaceId == -1 ? getSurfaceManagerForView(reactTag) : getSurfaceManager(surfaceId)); + (surfaceId == ViewUtil.NO_SURFACE_ID + ? getSurfaceManagerForView(reactTag) + : getSurfaceManager(surfaceId)); if (surfaceMountingManager == null) { return null; } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/ViewUtil.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/ViewUtil.java index 5e5955b158a..086afd06ac7 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/ViewUtil.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/ViewUtil.java @@ -12,6 +12,8 @@ import static com.facebook.react.uimanager.common.UIManagerType.FABRIC; public class ViewUtil { + public static final int NO_SURFACE_ID = -1; + /** * Counter for uniquely identifying views. - % 2 === 0 means it is a Fabric tag. See * https://github.com/facebook/react/pull/12587 diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/events/DrawerClosedEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/events/DrawerClosedEvent.java index 4e4d9eaa65a..17617bfa5bd 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/events/DrawerClosedEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/events/DrawerClosedEvent.java @@ -9,6 +9,7 @@ package com.facebook.react.views.drawer.events; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; public class DrawerClosedEvent extends Event { @@ -17,7 +18,7 @@ public class DrawerClosedEvent extends Event { @Deprecated public DrawerClosedEvent(int viewId) { - this(-1, viewId); + this(ViewUtil.NO_SURFACE_ID, viewId); } public DrawerClosedEvent(int surfaceId, int viewId) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/events/DrawerOpenedEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/events/DrawerOpenedEvent.java index 46bfc8f1df9..baf6d603511 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/events/DrawerOpenedEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/events/DrawerOpenedEvent.java @@ -9,6 +9,7 @@ package com.facebook.react.views.drawer.events; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; public class DrawerOpenedEvent extends Event { @@ -17,7 +18,7 @@ public class DrawerOpenedEvent extends Event { @Deprecated public DrawerOpenedEvent(int viewId) { - this(-1, viewId); + this(ViewUtil.NO_SURFACE_ID, viewId); } public DrawerOpenedEvent(int surfaceId, int viewId) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/events/DrawerSlideEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/events/DrawerSlideEvent.java index 0bba976967b..ab20422e312 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/events/DrawerSlideEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/events/DrawerSlideEvent.java @@ -9,6 +9,7 @@ package com.facebook.react.views.drawer.events; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; /** Event emitted by a DrawerLayout as it is being moved open/closed. */ @@ -20,7 +21,7 @@ public class DrawerSlideEvent extends Event { @Deprecated public DrawerSlideEvent(int viewId, float offset) { - this(-1, viewId, offset); + this(ViewUtil.NO_SURFACE_ID, viewId, offset); } public DrawerSlideEvent(int surfaceId, int viewId, float offset) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/events/DrawerStateChangedEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/events/DrawerStateChangedEvent.java index 52091824e38..f99e37b914b 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/events/DrawerStateChangedEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/drawer/events/DrawerStateChangedEvent.java @@ -9,6 +9,7 @@ package com.facebook.react.views.drawer.events; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; public class DrawerStateChangedEvent extends Event { @@ -19,7 +20,7 @@ public class DrawerStateChangedEvent extends Event { @Deprecated public DrawerStateChangedEvent(int viewId, int drawerState) { - this(-1, viewId, drawerState); + this(ViewUtil.NO_SURFACE_ID, viewId, drawerState); } public DrawerStateChangedEvent(int surfaceId, int viewId, int drawerState) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ImageLoadEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ImageLoadEvent.java index 715d0871a71..1949960dd76 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ImageLoadEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ImageLoadEvent.java @@ -11,6 +11,7 @@ import androidx.annotation.IntDef; import androidx.annotation.Nullable; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -36,29 +37,29 @@ public class ImageLoadEvent extends Event { @Deprecated public static final ImageLoadEvent createLoadStartEvent(int viewId) { - return createLoadStartEvent(-1, viewId); + return createLoadStartEvent(ViewUtil.NO_SURFACE_ID, viewId); } @Deprecated public static final ImageLoadEvent createProgressEvent( int viewId, @Nullable String imageUri, int loaded, int total) { - return createProgressEvent(-1, viewId, imageUri, loaded, total); + return createProgressEvent(ViewUtil.NO_SURFACE_ID, viewId, imageUri, loaded, total); } @Deprecated public static final ImageLoadEvent createLoadEvent( int viewId, @Nullable String imageUri, int width, int height) { - return createLoadEvent(-1, viewId, imageUri, width, height); + return createLoadEvent(ViewUtil.NO_SURFACE_ID, viewId, imageUri, width, height); } @Deprecated public static final ImageLoadEvent createErrorEvent(int viewId, Throwable throwable) { - return createErrorEvent(-1, viewId, throwable); + return createErrorEvent(ViewUtil.NO_SURFACE_ID, viewId, throwable); } @Deprecated public static final ImageLoadEvent createLoadEndEvent(int viewId) { - return createLoadEndEvent(-1, viewId); + return createLoadEndEvent(ViewUtil.NO_SURFACE_ID, viewId); } public static final ImageLoadEvent createLoadStartEvent(int surfaceId, int viewId) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/RequestCloseEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/RequestCloseEvent.java index 4ea4b50f396..979b8bce8c9 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/RequestCloseEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/RequestCloseEvent.java @@ -10,6 +10,7 @@ package com.facebook.react.views.modal; import androidx.annotation.Nullable; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; /** {@link Event} for dismissing a Dialog. */ @@ -19,7 +20,7 @@ import com.facebook.react.uimanager.events.Event; @Deprecated protected RequestCloseEvent(int viewTag) { - this(-1, viewTag); + this(ViewUtil.NO_SURFACE_ID, viewTag); } protected RequestCloseEvent(int surfaceId, int viewTag) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ShowEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ShowEvent.java index 7ded5c9f072..d077c1870c2 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ShowEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ShowEvent.java @@ -10,6 +10,7 @@ package com.facebook.react.views.modal; import androidx.annotation.Nullable; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; /** {@link Event} for showing a Dialog. */ @@ -19,7 +20,7 @@ import com.facebook.react.uimanager.events.Event; @Deprecated protected ShowEvent(int viewTag) { - this(-1, viewTag); + this(ViewUtil.NO_SURFACE_ID, viewTag); } protected ShowEvent(int surfaceId, int viewTag) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ScrollEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ScrollEvent.java index 487a131cd3e..5f44afce015 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ScrollEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ScrollEvent.java @@ -14,6 +14,7 @@ import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.ReactSoftExceptionLogger; import com.facebook.react.bridge.WritableMap; import com.facebook.react.uimanager.PixelUtil; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; /** A event dispatched from a ScrollView scrolling. */ @@ -46,7 +47,7 @@ public class ScrollEvent extends Event { int scrollViewWidth, int scrollViewHeight) { return obtain( - -1, + ViewUtil.NO_SURFACE_ID, viewTag, scrollEventType, scrollX, diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/RefreshEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/RefreshEvent.java index 0d2780f202d..ca7fa73c577 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/RefreshEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/RefreshEvent.java @@ -10,13 +10,14 @@ package com.facebook.react.views.swiperefresh; import androidx.annotation.Nullable; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; public class RefreshEvent extends Event { @Deprecated protected RefreshEvent(int viewTag) { - this(-1, viewTag); + this(ViewUtil.NO_SURFACE_ID, viewTag); } protected RefreshEvent(int surfaceId, int viewTag) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchEvent.java index ef0d94d1fc7..e28accad39e 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchEvent.java @@ -10,6 +10,7 @@ package com.facebook.react.views.switchview; import androidx.annotation.Nullable; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; /** Event emitted by a ReactSwitchManager once a switch is fully switched on/off */ @@ -21,7 +22,7 @@ import com.facebook.react.uimanager.events.Event; @Deprecated public ReactSwitchEvent(int viewId, boolean isChecked) { - this(-1, viewId, isChecked); + this(ViewUtil.NO_SURFACE_ID, viewId, isChecked); } public ReactSwitchEvent(int surfaceId, int viewId, boolean isChecked) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactContentSizeChangedEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactContentSizeChangedEvent.java index 40d4b04c048..1180910ded7 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactContentSizeChangedEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactContentSizeChangedEvent.java @@ -10,6 +10,7 @@ package com.facebook.react.views.textinput; import androidx.annotation.Nullable; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; /** Event emitted by EditText native view when content size changes. */ @@ -22,7 +23,7 @@ public class ReactContentSizeChangedEvent extends Event { @Deprecated public ReactContentSizeChangedEvent(int viewId, float contentSizeWidth, float contentSizeHeight) { - this(-1, viewId, contentSizeWidth, contentSizeHeight); + this(ViewUtil.NO_SURFACE_ID, viewId, contentSizeWidth, contentSizeHeight); } public ReactContentSizeChangedEvent( diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextChangedEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextChangedEvent.java index ac0568363fc..4540b90abc2 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextChangedEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextChangedEvent.java @@ -10,6 +10,7 @@ package com.facebook.react.views.textinput; import androidx.annotation.Nullable; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; /** @@ -25,7 +26,7 @@ public class ReactTextChangedEvent extends Event { @Deprecated public ReactTextChangedEvent(int viewId, String text, int eventCount) { - this(-1, viewId, text, eventCount); + this(ViewUtil.NO_SURFACE_ID, viewId, text, eventCount); } public ReactTextChangedEvent(int surfaceId, int viewId, String text, int eventCount) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputBlurEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputBlurEvent.java index a2b6165391e..99377f84839 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputBlurEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputBlurEvent.java @@ -10,6 +10,7 @@ package com.facebook.react.views.textinput; import androidx.annotation.Nullable; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; /** Event emitted by EditText native view when it loses focus. */ @@ -19,7 +20,7 @@ import com.facebook.react.uimanager.events.Event; @Deprecated public ReactTextInputBlurEvent(int viewId) { - this(-1, viewId); + this(ViewUtil.NO_SURFACE_ID, viewId); } public ReactTextInputBlurEvent(int surfaceId, int viewId) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputEndEditingEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputEndEditingEvent.java index ec9e2fa9cea..5e8fc71471c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputEndEditingEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputEndEditingEvent.java @@ -10,6 +10,7 @@ package com.facebook.react.views.textinput; import androidx.annotation.Nullable; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; /** @@ -24,7 +25,7 @@ class ReactTextInputEndEditingEvent extends Event @Deprecated public ReactTextInputEndEditingEvent(int viewId, String text) { - this(-1, viewId, text); + this(ViewUtil.NO_SURFACE_ID, viewId, text); } public ReactTextInputEndEditingEvent(int surfaceId, int viewId, String text) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputEvent.java index e43499d61e9..2f4fb2fa783 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputEvent.java @@ -10,6 +10,7 @@ package com.facebook.react.views.textinput; import androidx.annotation.Nullable; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; /** @@ -28,7 +29,7 @@ public class ReactTextInputEvent extends Event { @Deprecated public ReactTextInputEvent( int viewId, String text, String previousText, int rangeStart, int rangeEnd) { - this(-1, viewId, text, previousText, rangeStart, rangeEnd); + this(ViewUtil.NO_SURFACE_ID, viewId, text, previousText, rangeStart, rangeEnd); } public ReactTextInputEvent( diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputFocusEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputFocusEvent.java index 62563b85f69..1689ca369a6 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputFocusEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputFocusEvent.java @@ -10,6 +10,7 @@ package com.facebook.react.views.textinput; import androidx.annotation.Nullable; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; /** Event emitted by EditText native view when it receives focus. */ @@ -19,7 +20,7 @@ import com.facebook.react.uimanager.events.Event; @Deprecated public ReactTextInputFocusEvent(int viewId) { - this(-1, viewId); + this(ViewUtil.NO_SURFACE_ID, viewId); } public ReactTextInputFocusEvent(int surfaceId, int viewId) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputKeyPressEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputKeyPressEvent.java index 9236b348d9c..206f0ce84c9 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputKeyPressEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputKeyPressEvent.java @@ -10,6 +10,7 @@ package com.facebook.react.views.textinput; import androidx.annotation.Nullable; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; /** Event emitted by EditText native view when key pressed */ @@ -21,7 +22,7 @@ public class ReactTextInputKeyPressEvent extends Event { @Deprecated ReactTextInputKeyPressEvent(int viewId, final String key) { - this(-1, viewId, key); + this(ViewUtil.NO_SURFACE_ID, viewId, key); } ReactTextInputKeyPressEvent(int surfaceId, int viewId, final String key) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputSelectionEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputSelectionEvent.java index 161a577f89a..ede96cd369f 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputSelectionEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputSelectionEvent.java @@ -10,6 +10,7 @@ package com.facebook.react.views.textinput; import androidx.annotation.Nullable; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; /** Event emitted by EditText native view when the text selection changes. */ @@ -22,7 +23,7 @@ import com.facebook.react.uimanager.events.Event; @Deprecated public ReactTextInputSelectionEvent(int viewId, int selectionStart, int selectionEnd) { - this(-1, viewId, selectionStart, selectionEnd); + this(ViewUtil.NO_SURFACE_ID, viewId, selectionStart, selectionEnd); } public ReactTextInputSelectionEvent( diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputSubmitEditingEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputSubmitEditingEvent.java index 9e1b5db2668..e93a48c4caf 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputSubmitEditingEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputSubmitEditingEvent.java @@ -10,6 +10,7 @@ package com.facebook.react.views.textinput; import androidx.annotation.Nullable; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; /** Event emitted by EditText native view when the user submits the text. */ @@ -22,7 +23,7 @@ import com.facebook.react.uimanager.events.Event; @Deprecated public ReactTextInputSubmitEditingEvent(int viewId, String text) { - this(-1, viewId, text); + this(ViewUtil.NO_SURFACE_ID, viewId, text); } public ReactTextInputSubmitEditingEvent(int surfaceId, int viewId, String text) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ViewGroupClickEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ViewGroupClickEvent.java index a9bc7bc2109..0d071c23d80 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ViewGroupClickEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ViewGroupClickEvent.java @@ -10,6 +10,7 @@ package com.facebook.react.views.view; import androidx.annotation.Nullable; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; /** Represents a Click on the ReactViewGroup */ @@ -18,7 +19,7 @@ public class ViewGroupClickEvent extends Event { @Deprecated public ViewGroupClickEvent(int viewId) { - this(-1, viewId); + this(ViewUtil.NO_SURFACE_ID, viewId); } public ViewGroupClickEvent(int surfaceId, int viewId) {