Migrate ReactTextChangedEvent to Kotlin (#50203)

Summary:
Migrate com.facebook.react.views.textinput.ReactTextChangedEvent to Kotlin.

## Changelog:

[INTERNAL] - Migrate com.facebook.react.views.textinput.ReactTextChangedEvent to Kotlin

Pull Request resolved: https://github.com/facebook/react-native/pull/50203

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: javache, Abbondanzo

Differential Revision: D71681502

Pulled By: arushikesarwani94

fbshipit-source-id: 9639740a41bbebf943bc716c495c3593461346a6
This commit is contained in:
Mateo Guzmán
2025-03-24 10:37:59 -07:00
committed by Facebook GitHub Bot
parent e797b1659e
commit cd04aae1a3
3 changed files with 52 additions and 54 deletions
@@ -7121,14 +7121,17 @@ public class com/facebook/react/views/textinput/ReactEditText : androidx/appcomp
protected fun verifyDrawable (Landroid/graphics/drawable/Drawable;)Z
}
public class com/facebook/react/views/textinput/ReactTextChangedEvent : com/facebook/react/uimanager/events/Event {
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 <init> (IILjava/lang/String;I)V
public fun <init> (ILjava/lang/String;I)V
protected fun getEventData ()Lcom/facebook/react/bridge/WritableMap;
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 <init> (Landroid/widget/EditText;)V
public final fun apply (Landroid/widget/EditText;)V
@@ -1,52 +0,0 @@
/*
* 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.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 text changes. VisibleForTesting from {@link
* TextInputEventsTestCase}.
*/
public class ReactTextChangedEvent extends Event<ReactTextChangedEvent> {
public static final String EVENT_NAME = "topChange";
private String mText;
private int mEventCount;
@Deprecated
public ReactTextChangedEvent(int viewId, String text, int eventCount) {
this(ViewUtil.NO_SURFACE_ID, viewId, text, eventCount);
}
public ReactTextChangedEvent(int surfaceId, int viewId, String text, int eventCount) {
super(surfaceId, viewId);
mText = text;
mEventCount = eventCount;
}
@Override
public String getEventName() {
return EVENT_NAME;
}
@Nullable
@Override
protected WritableMap getEventData() {
WritableMap eventData = Arguments.createMap();
eventData.putString("text", mText);
eventData.putInt("eventCount", mEventCount);
eventData.putInt("target", getViewTag());
return eventData;
}
}
@@ -0,0 +1,47 @@
/*
* 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.textinput
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 text changes. VisibleForTesting from
* [TextInputEventsTestCase].
*/
public class ReactTextChangedEvent(
surfaceId: Int,
viewId: Int,
private val text: String,
private val eventCount: Int
) : Event<ReactTextChangedEvent>(surfaceId, viewId) {
@Deprecated(
"Use the constructor with surfaceId instead",
ReplaceWith("ReactTextChangedEvent(surfaceId, viewId, text, eventCount)"))
public constructor(
viewId: Int,
text: String,
eventCount: Int
) : this(ViewUtil.NO_SURFACE_ID, viewId, text, eventCount)
override fun getEventName(): String = EVENT_NAME
override fun getEventData(): WritableMap? {
return Arguments.createMap().apply {
putString("text", text)
putInt("eventCount", eventCount)
putInt("target", viewTag)
}
}
public companion object {
public const val EVENT_NAME: String = "topChange"
}
}