Kotlinify PointerEvents (#43876)

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

Changelog: [Internal]

As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)).

Reviewed By: tdn120

Differential Revision: D55764512

fbshipit-source-id: 49f3eabf8064d39ced9d28f240e91cfdc8ab98c9
This commit is contained in:
Fabrizio Cucci
2024-04-05 14:04:56 -07:00
committed by Facebook GitHub Bot
parent 98a38cc1a7
commit f6a8e4337f
3 changed files with 60 additions and 51 deletions
@@ -4253,14 +4253,21 @@ public final class com/facebook/react/uimanager/PointerEvents : java/lang/Enum {
public static final field AUTO Lcom/facebook/react/uimanager/PointerEvents;
public static final field BOX_NONE Lcom/facebook/react/uimanager/PointerEvents;
public static final field BOX_ONLY Lcom/facebook/react/uimanager/PointerEvents;
public static final field Companion Lcom/facebook/react/uimanager/PointerEvents$Companion;
public static final field NONE Lcom/facebook/react/uimanager/PointerEvents;
public static fun canBeTouchTarget (Lcom/facebook/react/uimanager/PointerEvents;)Z
public static fun canChildrenBeTouchTarget (Lcom/facebook/react/uimanager/PointerEvents;)Z
public static fun parsePointerEvents (Ljava/lang/String;)Lcom/facebook/react/uimanager/PointerEvents;
public static final fun canBeTouchTarget (Lcom/facebook/react/uimanager/PointerEvents;)Z
public static final fun canChildrenBeTouchTarget (Lcom/facebook/react/uimanager/PointerEvents;)Z
public static final fun parsePointerEvents (Ljava/lang/String;)Lcom/facebook/react/uimanager/PointerEvents;
public static fun valueOf (Ljava/lang/String;)Lcom/facebook/react/uimanager/PointerEvents;
public static fun values ()[Lcom/facebook/react/uimanager/PointerEvents;
}
public final class com/facebook/react/uimanager/PointerEvents$Companion {
public final fun canBeTouchTarget (Lcom/facebook/react/uimanager/PointerEvents;)Z
public final fun canChildrenBeTouchTarget (Lcom/facebook/react/uimanager/PointerEvents;)Z
public final fun parsePointerEvents (Ljava/lang/String;)Lcom/facebook/react/uimanager/PointerEvents;
}
public class com/facebook/react/uimanager/ReactAccessibilityDelegate : androidx/customview/widget/ExploreByTouchHelper {
public static final field TOP_ACCESSIBILITY_ACTION_EVENT Ljava/lang/String;
public static final field sActionIdMap Ljava/util/HashMap;
@@ -1,48 +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;
import com.facebook.infer.annotation.Nullsafe;
import java.util.Locale;
/**
* Possible values for pointer events that a view and its descendants should receive. See
* https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events for more info.
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
public enum PointerEvents {
/** Neither the container nor its children receive events. */
NONE,
/** Container doesn't get events but all of its children do. */
BOX_NONE,
/** Container gets events but none of its children do. */
BOX_ONLY,
/** Container and all of its children receive touch events (like pointerEvents is unspecified). */
AUTO,
;
public static PointerEvents parsePointerEvents(String pointerEventsStr) {
if (pointerEventsStr == null) {
return PointerEvents.AUTO;
} else {
return PointerEvents.valueOf(pointerEventsStr.toUpperCase(Locale.US).replace("-", "_"));
}
}
public static boolean canBeTouchTarget(PointerEvents pointerEvents) {
return pointerEvents == AUTO || pointerEvents == PointerEvents.BOX_ONLY;
}
public static boolean canChildrenBeTouchTarget(PointerEvents pointerEvents) {
return pointerEvents == PointerEvents.AUTO || pointerEvents == PointerEvents.BOX_NONE;
}
}
@@ -0,0 +1,50 @@
/*
* 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
import java.util.Locale
/**
* Possible values for pointer events that a view and its descendants should receive. See
* https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events for more info.
*/
public enum class PointerEvents {
/** Neither the container nor its children receive events. */
NONE,
/** Container doesn't get events but all of its children do. */
BOX_NONE,
/** Container gets events but none of its children do. */
BOX_ONLY,
/** Container and all of its children receive touch events (like pointerEvents is unspecified). */
AUTO;
public companion object {
@JvmStatic
public fun parsePointerEvents(pointerEventsStr: String?): PointerEvents {
if (pointerEventsStr == null) {
return AUTO
} else {
return PointerEvents.valueOf(pointerEventsStr.uppercase(Locale.US).replace("-", "_"))
}
}
@JvmStatic
public fun canBeTouchTarget(pointerEvents: PointerEvents): Boolean {
return pointerEvents == AUTO || pointerEvents == BOX_ONLY
}
@JvmStatic
public fun canChildrenBeTouchTarget(pointerEvents: PointerEvents): Boolean {
return pointerEvents == AUTO || pointerEvents == BOX_NONE
}
}
}