From e8347b985407b18b490157e4c9c7cdbb4fdd7f1d Mon Sep 17 00:00:00 2001 From: Ruslan Shestopalyuk Date: Thu, 2 Jan 2025 11:18:07 -0800 Subject: [PATCH] Migrate EventCategoryDef to Kotlin (#48446) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48446 # Changelog: [Internal] - As in the title. Reviewed By: tdn120 Differential Revision: D67759756 fbshipit-source-id: bc922b3062d8790ada3f9d5ee71593a08046752b --- .../ReactAndroid/api/ReactAndroid.api | 9 ++++ .../uimanager/events/EventCategoryDef.java | 45 ------------------ .../uimanager/events/EventCategoryDef.kt | 46 +++++++++++++++++++ 3 files changed, 55 insertions(+), 45 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventCategoryDef.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventCategoryDef.kt diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 1aacea0abf9..74909bcfda3 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -5563,6 +5563,15 @@ public abstract interface class com/facebook/react/uimanager/events/Event$EventA } public abstract interface annotation class com/facebook/react/uimanager/events/EventCategoryDef : java/lang/annotation/Annotation { + public static final field CONTINUOUS I + public static final field CONTINUOUS_END I + public static final field CONTINUOUS_START I + public static final field Companion Lcom/facebook/react/uimanager/events/EventCategoryDef$Companion; + public static final field DISCRETE I + public static final field UNSPECIFIED I +} + +public final class com/facebook/react/uimanager/events/EventCategoryDef$Companion { public static final field CONTINUOUS I public static final field CONTINUOUS_END I public static final field CONTINUOUS_START I diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventCategoryDef.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventCategoryDef.java deleted file mode 100644 index a4dbf0f8aeb..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventCategoryDef.java +++ /dev/null @@ -1,45 +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.uimanager.events; - -import static com.facebook.react.uimanager.events.EventCategoryDef.CONTINUOUS; -import static com.facebook.react.uimanager.events.EventCategoryDef.CONTINUOUS_END; -import static com.facebook.react.uimanager.events.EventCategoryDef.CONTINUOUS_START; -import static com.facebook.react.uimanager.events.EventCategoryDef.DISCRETE; -import static com.facebook.react.uimanager.events.EventCategoryDef.UNSPECIFIED; - -import androidx.annotation.IntDef; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * Java specific declaration of the `RawEvent::Category` enum. Keep in sync with - * `renderer/core/RawEvent.h`. - */ -@IntDef(value = {CONTINUOUS_START, CONTINUOUS_END, UNSPECIFIED, DISCRETE, CONTINUOUS}) -@Retention(RetentionPolicy.SOURCE) -public @interface EventCategoryDef { - /** Start of a continuous event. To be used with touchStart. */ - int CONTINUOUS_START = 0; - - /** End of a continuous event. To be used with touchEnd. */ - int CONTINUOUS_END = 1; - - /** - * Priority for this event will be determined from other events in the queue. If it is triggered - * by continuous event, its priority will be default. If it is not triggered by continuous event, - * its priority will be discrete. - */ - int UNSPECIFIED = 2; - - /** Forces discrete type for the event. Regardless if continuous event is ongoing. */ - int DISCRETE = 3; - - /** Forces continuous type for the event. Regardless if continuous event isn't ongoing. */ - int CONTINUOUS = 4; -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventCategoryDef.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventCategoryDef.kt new file mode 100644 index 00000000000..94993ad014d --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventCategoryDef.kt @@ -0,0 +1,46 @@ +/* + * 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.events + +import androidx.annotation.IntDef + +/** + * Kotlin/Java specific declaration of the `RawEvent::Category` enum. Keep in sync with + * `renderer/core/RawEvent.h`. + */ +@IntDef( + value = + [ + EventCategoryDef.CONTINUOUS_START, + EventCategoryDef.CONTINUOUS_END, + EventCategoryDef.UNSPECIFIED, + EventCategoryDef.DISCRETE, + EventCategoryDef.CONTINUOUS]) +@Retention(AnnotationRetention.SOURCE) +public annotation class EventCategoryDef { + public companion object { + /** Start of a continuous event. To be used with touchStart. */ + public const val CONTINUOUS_START: Int = 0 + + /** End of a continuous event. To be used with touchEnd. */ + public const val CONTINUOUS_END: Int = 1 + + /** + * Priority for this event will be determined from other events in the queue. If it is triggered + * by continuous event, its priority will be default. If it is not triggered by continuous + * event, its priority will be discrete. + */ + public const val UNSPECIFIED: Int = 2 + + /** Forces discrete type for the event. Regardless if continuous event is ongoing. */ + public const val DISCRETE: Int = 3 + + /** Forces continuous type for the event. Regardless if continuous event isn't ongoing. */ + public const val CONTINUOUS: Int = 4 + } +}