From 4da586ead99f421be71ca8b89ca891ed6fb90a99 Mon Sep 17 00:00:00 2001
From: Parsa Nasirimehr
Date: Mon, 4 Nov 2024 06:57:47 -0800
Subject: [PATCH] chore(Android): Migrate DebugOverlayTag and
ReactDebugOverlayTag to Kotlin (#47362)
Summary:
I believe these two were the last items under `com.facebook.debug` that were still Java.
I thought about making DebugOverlayTag a Data class, but i will leave it up to the reviewer to decide if it would be needed or not.
## Changelog:
[INTERNAL] [FIXED] - Migrate DebugOverlayTag and ReactDebugOverlayTag to Kotlin
Pull Request resolved: https://github.com/facebook/react-native/pull/47362
Test Plan:
`./gradlew test`:
Reviewed By: javache
Differential Revision: D65417984
Pulled By: cortinico
fbshipit-source-id: e39224e40bde281498fdbed1609a03b264967396
---
.../debugoverlay/model/DebugOverlayTag.java | 30 -------------
.../debugoverlay/model/DebugOverlayTag.kt | 21 +++++++++
.../debug/tags/ReactDebugOverlayTags.java | 38 ----------------
.../debug/tags/ReactDebugOverlayTags.kt | 45 +++++++++++++++++++
4 files changed, 66 insertions(+), 68 deletions(-)
delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/debugoverlay/model/DebugOverlayTag.java
create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/debugoverlay/model/DebugOverlayTag.kt
delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/tags/ReactDebugOverlayTags.java
create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/tags/ReactDebugOverlayTags.kt
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/debugoverlay/model/DebugOverlayTag.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/debugoverlay/model/DebugOverlayTag.java
deleted file mode 100644
index 4ee3353ffa8..00000000000
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/debugoverlay/model/DebugOverlayTag.java
+++ /dev/null
@@ -1,30 +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.debug.debugoverlay.model;
-
-import javax.annotation.concurrent.Immutable;
-
-/** Tag for a debug overlay log message. Name must be unique. */
-@Immutable
-public class DebugOverlayTag {
-
- /** Name of tag. */
- public final String name;
-
- /** Description to display in settings. */
- public final String description;
-
- /** Color for tag display. */
- public final int color;
-
- public DebugOverlayTag(String name, String description, int color) {
- this.name = name;
- this.description = description;
- this.color = color;
- }
-}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/debugoverlay/model/DebugOverlayTag.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/debugoverlay/model/DebugOverlayTag.kt
new file mode 100644
index 00000000000..7aa4c8d645b
--- /dev/null
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/debugoverlay/model/DebugOverlayTag.kt
@@ -0,0 +1,21 @@
+/*
+ * 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.debug.debugoverlay.model
+
+/**
+ * Tag for a debug overlay log message. Name must be unique.
+ *
+ * @param name Name of tag.
+ * @param description Description to display in settings.
+ * @param color Color for tag display.
+ */
+public class DebugOverlayTag(
+ public val name: String,
+ public val description: String,
+ public val color: Int,
+)
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/tags/ReactDebugOverlayTags.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/tags/ReactDebugOverlayTags.java
deleted file mode 100644
index 9df0352aa42..00000000000
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/tags/ReactDebugOverlayTags.java
+++ /dev/null
@@ -1,38 +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.debug.tags;
-
-import android.graphics.Color;
-import com.facebook.debug.debugoverlay.model.DebugOverlayTag;
-
-/** Category for debug overlays. */
-public class ReactDebugOverlayTags {
-
- public static final DebugOverlayTag PERFORMANCE =
- new DebugOverlayTag("Performance", "Markers for Performance", Color.GREEN);
- public static final DebugOverlayTag NAVIGATION =
- new DebugOverlayTag("Navigation", "Tag for navigation", Color.rgb(0x9C, 0x27, 0xB0));
- public static final DebugOverlayTag RN_CORE =
- new DebugOverlayTag("RN Core", "Tag for React Native Core", Color.BLACK);
- public static final DebugOverlayTag BRIDGE_CALLS =
- new DebugOverlayTag(
- "Bridge Calls", "JS to Java calls (warning: this is spammy)", Color.MAGENTA);
- public static final DebugOverlayTag NATIVE_MODULE =
- new DebugOverlayTag("Native Module", "Native Module init", Color.rgb(0x80, 0x00, 0x80));
- public static final DebugOverlayTag UI_MANAGER =
- new DebugOverlayTag(
- "UI Manager",
- "UI Manager View Operations (requires restart\nwarning: this is spammy)",
- Color.CYAN);
- public static final DebugOverlayTag FABRIC_UI_MANAGER =
- new DebugOverlayTag("FabricUIManager", "Fabric UI Manager View Operations", Color.CYAN);
- public static final DebugOverlayTag FABRIC_RECONCILER =
- new DebugOverlayTag("FabricReconciler", "Reconciler for Fabric", Color.CYAN);
- public static final DebugOverlayTag RELAY =
- new DebugOverlayTag("Relay", "including prefetching", Color.rgb(0xFF, 0x99, 0x00));
-}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/tags/ReactDebugOverlayTags.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/tags/ReactDebugOverlayTags.kt
new file mode 100644
index 00000000000..4a9b33bae4a
--- /dev/null
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/debug/tags/ReactDebugOverlayTags.kt
@@ -0,0 +1,45 @@
+/*
+ * 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.debug.tags
+
+import android.graphics.Color
+import com.facebook.debug.debugoverlay.model.DebugOverlayTag
+
+/** Category for debug overlays. */
+public object ReactDebugOverlayTags {
+ @JvmField
+ public val PERFORMANCE: DebugOverlayTag =
+ DebugOverlayTag("Performance", "Markers for Performance", Color.GREEN)
+ @JvmField
+ public val NAVIGATION: DebugOverlayTag =
+ DebugOverlayTag("Navigation", "Tag for navigation", Color.rgb(0x9C, 0x27, 0xB0))
+ @JvmField
+ public val RN_CORE: DebugOverlayTag =
+ DebugOverlayTag("RN Core", "Tag for React Native Core", Color.BLACK)
+ @JvmField
+ public val BRIDGE_CALLS: DebugOverlayTag =
+ DebugOverlayTag("Bridge Calls", "JS to Java calls (warning: this is spammy)", Color.MAGENTA)
+ @JvmField
+ public val NATIVE_MODULE: DebugOverlayTag =
+ DebugOverlayTag("Native Module", "Native Module init", Color.rgb(0x80, 0x00, 0x80))
+ @JvmField
+ public val UI_MANAGER: DebugOverlayTag =
+ DebugOverlayTag(
+ "UI Manager",
+ "UI Manager View Operations (requires restart\nwarning: this is spammy)",
+ Color.CYAN)
+ @JvmField
+ public val FABRIC_UI_MANAGER: DebugOverlayTag =
+ DebugOverlayTag("FabricUIManager", "Fabric UI Manager View Operations", Color.CYAN)
+ @JvmField
+ public val FABRIC_RECONCILER: DebugOverlayTag =
+ DebugOverlayTag("FabricReconciler", "Reconciler for Fabric", Color.CYAN)
+ @JvmField
+ public val RELAY: DebugOverlayTag =
+ DebugOverlayTag("Relay", "including prefetching", Color.rgb(0xFF, 0x99, 0x00))
+}