Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -5867,12 +5867,12 @@ public class com/facebook/react/views/common/ViewUtils {
public static fun getTestId (Landroid/view/View;)Ljava/lang/String;
}

public class com/facebook/react/views/debuggingoverlay/DebuggingOverlay : android/view/View {
public final class com/facebook/react/views/debuggingoverlay/DebuggingOverlay : android/view/View {
public fun <init> (Landroid/content/Context;)V
public fun clearElementsHighlights ()V
public final fun clearElementsHighlights ()V
public fun onDraw (Landroid/graphics/Canvas;)V
public fun setHighlightedElementsRectangles (Ljava/util/List;)V
public fun setTraceUpdates (Ljava/util/List;)V
public final fun setHighlightedElementsRectangles (Ljava/util/List;)V
public final fun setTraceUpdates (Ljava/util/List;)V
}

public class com/facebook/react/views/debuggingoverlay/DebuggingOverlayManager : com/facebook/react/uimanager/SimpleViewManager {
Expand All @@ -5894,9 +5894,9 @@ public class com/facebook/react/views/debuggingoverlay/DebuggingOverlayManager$$

public final class com/facebook/react/views/debuggingoverlay/TraceUpdate {
public fun <init> (ILandroid/graphics/RectF;I)V
public fun getColor ()I
public fun getId ()I
public fun getRectangle ()Landroid/graphics/RectF;
public final fun getColor ()I
public final fun getId ()I
public final fun getRectangle ()Landroid/graphics/RectF;
}

public class com/facebook/react/views/drawer/ReactDrawerLayoutManager : com/facebook/react/uimanager/ViewGroupManager, com/facebook/react/viewmanagers/AndroidDrawerLayoutManagerInterface {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* 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.debuggingoverlay

import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.RectF
import android.view.View
import androidx.annotation.UiThread
import com.facebook.react.bridge.UiThreadUtil

public class DebuggingOverlay(context: Context) : View(context) {
private val traceUpdatePaint = Paint()
private val traceUpdatesToDisplayMap: HashMap<Int, TraceUpdate> = hashMapOf()
private val traceUpdateIdToCleanupRunnableMap: HashMap<Int, Runnable> = hashMapOf()

private val highlightedElementsPaint = Paint()
private var highlightedElementsRectangles: MutableList<RectF> = ArrayList()

init {
traceUpdatePaint.style = Paint.Style.STROKE
traceUpdatePaint.strokeWidth = 6f
highlightedElementsPaint.style = Paint.Style.FILL
highlightedElementsPaint.color = 0xCCC8E6FF.toInt()
}

@UiThread
public fun setTraceUpdates(traceUpdates: List<TraceUpdate>) {
for (traceUpdate in traceUpdates) {
val traceUpdateId = traceUpdate.id
if (traceUpdateIdToCleanupRunnableMap.containsKey(traceUpdateId)) {
UiThreadUtil.removeOnUiThread(traceUpdateIdToCleanupRunnableMap[traceUpdateId])
traceUpdateIdToCleanupRunnableMap.remove(traceUpdateId)
}

traceUpdatesToDisplayMap[traceUpdateId] = traceUpdate
}

invalidate()
}

@UiThread
public fun setHighlightedElementsRectangles(elementsRectangles: MutableList<RectF>) {
highlightedElementsRectangles = elementsRectangles
invalidate()
}

@UiThread
public fun clearElementsHighlights() {
highlightedElementsRectangles.clear()
invalidate()
}

public override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)

// Draw border outside of the given overlays to be aligned with web trace highlights
for (traceUpdate in traceUpdatesToDisplayMap.values) {
traceUpdatePaint.color = traceUpdate.color
canvas.drawRect(traceUpdate.rectangle, traceUpdatePaint)

val traceUpdateId = traceUpdate.id
val block = Runnable {
traceUpdatesToDisplayMap.remove(traceUpdateId)
traceUpdateIdToCleanupRunnableMap.remove(traceUpdateId)

invalidate()
}

if (!traceUpdateIdToCleanupRunnableMap.containsKey(traceUpdateId)) {
traceUpdateIdToCleanupRunnableMap[traceUpdateId] = block
UiThreadUtil.runOnUiThread(block, 2000)
}
}

for (elementRectangle in highlightedElementsRectangles) {
canvas.drawRect(elementRectangle, highlightedElementsPaint)
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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.debuggingoverlay

import android.graphics.RectF

public class TraceUpdate(public val id: Int, public val rectangle: RectF, public val color: Int)