From 402b93dd0cdaf3ae5f4ca557b157904ef98ca31c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateo=20Guzm=C3=A1n?= Date: Thu, 27 Mar 2025 10:25:10 -0700 Subject: [PATCH] Internalize classes exposed for TextInputEventsTestCase (#50305) Summary: TextInputEventsTestCase is a test that no longer exists; it seems like in the past, some classes/methods were made public to allow this file to use them. We can clean this up by removing its reference from the codebase and internalizing what's not used in OSS. Internalized classes: - [ReactContentSizeChangedEvent](https://github.com/search?type=code&q=NOT+is%3Afork+NOT+org%3Afacebook+NOT+repo%3Areact-native-tvos%2Freact-native-tvos+NOT+repo%3Anuagoz%2Freact-native+NOT+repo%3A2lambda123%2Freact-native+NOT+repo%3Abeanchips%2Ffacebookreactnative+NOT+repo%3AfabOnReact%2Freact-native-notes+NOT+user%3Ahuntie+NOT+user%3Acortinico+NOT+repo%3AMaxdev18%2Fpowersync_app+NOT+repo%3Acarter-0%2Finstagram-decompiled+NOT+repo%3Am0mosenpai%2Finstadamn+NOT+repo%3AA-Star100%2FA-Star100-AUG2-2024+NOT+repo%3Alclnrd%2Fdetox-scrollview-reproductible+NOT+repo%3ADionisisChytiris%2FWorldWiseTrivia_Main+NOT+repo%3Apast3l%2Fhi2+NOT+repo%3AoneDotpy%2FCaribouQuest+NOT+repo%3Abejayoharen%2Fdailytodo+NOT+repo%3Amolangning%2Freversing-discord+NOT+repo%3AScottPrzy%2Freact-native+NOT+repo%3Agabrieldonadel%2Freact-native-visionos+NOT+repo%3AGabriel2308%2FTestes-Soft+NOT+repo%3Adawnzs03%2FflakyBuild+NOT+repo%3Acga2351%2Fcode+NOT+repo%3Astreeg%2Ftcc+NOT+repo%3Asoftware-mansion-labs%2Freact-native-swiftui+NOT+repo%3Apkcsecurity%2Fdecompiled-lightbulb+com.facebook.react.views.textinput.ReactContentSizeChangedEvent) - [ReactTextChangedEvent](https://github.com/search?type=code&q=NOT+is%3Afork+NOT+org%3Afacebook+NOT+repo%3Areact-native-tvos%2Freact-native-tvos+NOT+repo%3Anuagoz%2Freact-native+NOT+repo%3A2lambda123%2Freact-native+NOT+repo%3Abeanchips%2Ffacebookreactnative+NOT+repo%3AfabOnReact%2Freact-native-notes+NOT+user%3Ahuntie+NOT+user%3Acortinico+NOT+repo%3AMaxdev18%2Fpowersync_app+NOT+repo%3Acarter-0%2Finstagram-decompiled+NOT+repo%3Am0mosenpai%2Finstadamn+NOT+repo%3AA-Star100%2FA-Star100-AUG2-2024+NOT+repo%3Alclnrd%2Fdetox-scrollview-reproductible+NOT+repo%3ADionisisChytiris%2FWorldWiseTrivia_Main+NOT+repo%3Apast3l%2Fhi2+NOT+repo%3AoneDotpy%2FCaribouQuest+NOT+repo%3Abejayoharen%2Fdailytodo+NOT+repo%3Amolangning%2Freversing-discord+NOT+repo%3AScottPrzy%2Freact-native+NOT+repo%3Agabrieldonadel%2Freact-native-visionos+NOT+repo%3AGabriel2308%2FTestes-Soft+NOT+repo%3Adawnzs03%2FflakyBuild+NOT+repo%3Acga2351%2Fcode+NOT+repo%3Astreeg%2Ftcc+NOT+repo%3Asoftware-mansion-labs%2Freact-native-swiftui+NOT+repo%3Apkcsecurity%2Fdecompiled-lightbulb+com.facebook.react.views.textinput.ReactTextChangedEvent) Both classes above are used only in gutenberg aztec (archived repo) Internalized methods: - ReactEditText.maybeSetText (method only used within the class itself) ## Changelog: [INTERNAL] - Internalize classes exposed for TextInputEventsTestCase Pull Request resolved: https://github.com/facebook/react-native/pull/50305 Test Plan: ```sh yarn test-android yarn android ``` Reviewed By: Abbondanzo Differential Revision: D71964410 Pulled By: javache fbshipit-source-id: fa6476ed12cc71a28498479f3c56eb143a51c6bc --- .../ReactAndroid/api/ReactAndroid.api | 23 ------------------- .../react/views/text/ReactTextUpdate.kt | 5 +--- .../textinput/ReactContentSizeChangedEvent.kt | 8 +++---- .../react/views/textinput/ReactEditText.java | 6 +---- .../views/textinput/ReactTextChangedEvent.kt | 13 ++++------- 5 files changed, 11 insertions(+), 44 deletions(-) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 26e4ff81bdf..29da2733ae0 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -7009,17 +7009,6 @@ public abstract interface class com/facebook/react/views/textinput/ContentSizeWa public abstract fun onLayout ()V } -public final class com/facebook/react/views/textinput/ReactContentSizeChangedEvent : com/facebook/react/uimanager/events/Event { - public static final field Companion Lcom/facebook/react/views/textinput/ReactContentSizeChangedEvent$Companion; - public static final field EVENT_NAME Ljava/lang/String; - public fun (IFF)V - public fun (IIFF)V - public fun getEventName ()Ljava/lang/String; -} - -public final class com/facebook/react/views/textinput/ReactContentSizeChangedEvent$Companion { -} - public class com/facebook/react/views/textinput/ReactEditText : androidx/appcompat/widget/AppCompatEditText { public static final field DEBUG_MODE Z protected field mContainsImages Z @@ -7043,7 +7032,6 @@ public class com/facebook/react/views/textinput/ReactEditText : androidx/appcomp public fun invalidateDrawable (Landroid/graphics/drawable/Drawable;)V public fun isLayoutRequested ()Z public fun maybeSetSelection (III)V - public fun maybeSetText (Lcom/facebook/react/views/text/ReactTextUpdate;)V public fun maybeSetTextFromJS (Lcom/facebook/react/views/text/ReactTextUpdate;)V public fun maybeSetTextFromState (Lcom/facebook/react/views/text/ReactTextUpdate;)V public fun maybeUpdateTypeface ()V @@ -7099,17 +7087,6 @@ public class com/facebook/react/views/textinput/ReactEditText : androidx/appcomp protected fun verifyDrawable (Landroid/graphics/drawable/Drawable;)Z } -public final class com/facebook/react/views/textinput/ReactTextChangedEvent : com/facebook/react/uimanager/events/Event { - public static final field Companion Lcom/facebook/react/views/textinput/ReactTextChangedEvent$Companion; - public static final field EVENT_NAME Ljava/lang/String; - public fun (IILjava/lang/String;I)V - public fun (ILjava/lang/String;I)V - public fun getEventName ()Ljava/lang/String; -} - -public final class com/facebook/react/views/textinput/ReactTextChangedEvent$Companion { -} - public final class com/facebook/react/views/textinput/ReactTextInputLocalData { public fun (Landroid/widget/EditText;)V public final fun apply (Landroid/widget/EditText;)V diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextUpdate.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextUpdate.kt index 7fccd893152..08e46397c64 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextUpdate.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextUpdate.kt @@ -11,10 +11,7 @@ import android.text.Layout import android.text.Spannable import com.facebook.react.common.ReactConstants -/** - * Class that contains the data needed for a text update. Used by both and - * VisibleForTesting from [TextInputEventsTestCase]. - */ +/** Class that contains the data needed for a text update. Used by both and . */ public class ReactTextUpdate( public val text: Spannable, public val jsEventCounter: Int, diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactContentSizeChangedEvent.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactContentSizeChangedEvent.kt index 4c39cf2d547..f1023156063 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactContentSizeChangedEvent.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactContentSizeChangedEvent.kt @@ -13,7 +13,7 @@ import com.facebook.react.uimanager.common.ViewUtil import com.facebook.react.uimanager.events.Event /** Event emitted by EditText native view when content size changes. */ -public class ReactContentSizeChangedEvent( +internal class ReactContentSizeChangedEvent( surfaceId: Int, viewId: Int, private val contentWidth: Float, @@ -23,7 +23,7 @@ public class ReactContentSizeChangedEvent( "Use the constructor with surfaceId instead", ReplaceWith( "ReactContentSizeChangedEvent(surfaceId, viewId, contentSizeWidth, contentSizeHeight)")) - public constructor( + constructor( viewId: Int, contentSizeWidth: Float, contentSizeHeight: Float @@ -44,7 +44,7 @@ public class ReactContentSizeChangedEvent( } } - public companion object { - public const val EVENT_NAME: String = "topContentSizeChange" + companion object { + const val EVENT_NAME: String = "topContentSizeChange" } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java index 6b654bdf449..c1f41389bb3 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -93,7 +93,6 @@ import java.util.concurrent.CopyOnWriteArrayList; * *

The wrapper stops the EditText from triggering *TextChanged events, in the case where JS has * called this explicitly. This is the default behavior on other platforms as well. - * VisibleForTesting from {@link TextInputEventsTestCase}. */ public class ReactEditText extends AppCompatEditText { @@ -654,7 +653,6 @@ public class ReactEditText extends AppCompatEditText { } } - // VisibleForTesting from {@link TextInputEventsTestCase}. public void requestFocusFromJS() { if (ReactNativeFeatureFlags.useEditTextStockAndroidFocusBehavior()) { requestFocusProgramatically(); @@ -667,7 +665,6 @@ public class ReactEditText extends AppCompatEditText { clearFocus(); } - // VisibleForTesting from {@link TextInputEventsTestCase}. public int incrementAndGetEventCounter() { return ++mNativeEventCount; } @@ -688,8 +685,7 @@ public class ReactEditText extends AppCompatEditText { return eventCounter >= mNativeEventCount; } - // VisibleForTesting from {@link TextInputEventsTestCase}. - public void maybeSetText(ReactTextUpdate reactTextUpdate) { + private void maybeSetText(ReactTextUpdate reactTextUpdate) { if (isSecureText() && TextUtils.equals(getText(), reactTextUpdate.getText())) { return; } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextChangedEvent.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextChangedEvent.kt index 969efcf45e5..ce863d3cc74 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextChangedEvent.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextChangedEvent.kt @@ -12,11 +12,8 @@ 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 text changes. VisibleForTesting from - * [TextInputEventsTestCase]. - */ -public class ReactTextChangedEvent( +/** Event emitted by EditText native view when text changes. */ +internal class ReactTextChangedEvent( surfaceId: Int, viewId: Int, private val text: String, @@ -25,7 +22,7 @@ public class ReactTextChangedEvent( @Deprecated( "Use the constructor with surfaceId instead", ReplaceWith("ReactTextChangedEvent(surfaceId, viewId, text, eventCount)")) - public constructor( + constructor( viewId: Int, text: String, eventCount: Int @@ -41,7 +38,7 @@ public class ReactTextChangedEvent( } } - public companion object { - public const val EVENT_NAME: String = "topChange" + companion object { + const val EVENT_NAME: String = "topChange" } }