-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f2601e
commit ebd8619
Showing
20 changed files
with
689 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...droid/src/main/kotlin/com/datadog/reactnative/sessionreplay/NoopTextPropertiesResolver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* | ||
* * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* * This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* * Copyright 2016-Present Datadog, Inc. | ||
* | ||
*/ | ||
|
||
package com.datadog.reactnative.sessionreplay | ||
|
||
import android.widget.TextView | ||
import com.datadog.android.sessionreplay.model.MobileSegment | ||
|
||
internal class NoopTextPropertiesResolver: TextPropertiesResolver { | ||
override fun addReactNativeProperties( | ||
originalWireframe: MobileSegment.Wireframe.TextWireframe, | ||
view: TextView, | ||
pixelDensity: Float | ||
): MobileSegment.Wireframe.TextWireframe { | ||
return originalWireframe | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...replay/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/ShadowNodeWrapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* | ||
* * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* * This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* * Copyright 2016-Present Datadog, Inc. | ||
* | ||
*/ | ||
|
||
package com.datadog.reactnative.sessionreplay | ||
|
||
import com.datadog.android.api.InternalLogger | ||
import com.datadog.reactnative.sessionreplay.utils.ReflectionUtils | ||
import com.facebook.react.bridge.ReactContext | ||
import com.facebook.react.uimanager.ReactShadowNode | ||
import com.facebook.react.uimanager.UIImplementation | ||
import com.facebook.react.uimanager.UIManagerModule | ||
import java.util.concurrent.CountDownLatch | ||
|
||
internal class ShadowNodeWrapper( | ||
private val logger: InternalLogger, | ||
private val reactContext: ReactContext, | ||
private val uiManagerModule: UIManagerModule?, | ||
private val reflectionUtils: ReflectionUtils = ReflectionUtils(logger) | ||
) { | ||
private var shadowNode: ReactShadowNode<out ReactShadowNode<*>>? = null | ||
|
||
internal fun initialize(viewId: Int): Boolean { | ||
shadowNode = getShadowNode(viewId) | ||
return shadowNode != null | ||
} | ||
|
||
internal fun getDeclaredShadowNodeField(fieldName: String): Any? { | ||
return reflectionUtils.getDeclaredField( | ||
shadowNode?.javaClass?.superclass as Class<*>, | ||
shadowNode, | ||
fieldName | ||
) | ||
} | ||
|
||
private fun getShadowNode(viewId: Int): ReactShadowNode<out ReactShadowNode<*>>? { | ||
val countDownLatch = CountDownLatch(1) | ||
var target: ReactShadowNode<out ReactShadowNode<*>>? = null | ||
val shadowNodeRunnable = Runnable { | ||
val node = uiManagerModule?.resolveShadowNode(viewId) | ||
if (node != null) { | ||
target = node | ||
countDownLatch.countDown() | ||
} | ||
} | ||
synchronized(this) { | ||
reactContext.runOnNativeModulesQueueThread(shadowNodeRunnable) | ||
countDownLatch.await() | ||
return target | ||
} | ||
} | ||
|
||
private fun UIManagerModule.resolveShadowNode(tag: Int): ReactShadowNode<out ReactShadowNode<*>>? { | ||
javaClass.getDeclaredField("mUIImplementation").let { | ||
it.isAccessible = true | ||
val value = it.get(this) as UIImplementation | ||
return value.resolveShadowNode(tag) | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...y/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/TextPropertiesResolver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* | ||
* * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* * This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* * Copyright 2016-Present Datadog, Inc. | ||
* | ||
*/ | ||
|
||
package com.datadog.reactnative.sessionreplay | ||
|
||
import android.widget.TextView | ||
import com.datadog.android.sessionreplay.model.MobileSegment | ||
|
||
internal interface TextPropertiesResolver { | ||
fun addReactNativeProperties( | ||
originalWireframe: MobileSegment.Wireframe.TextWireframe, | ||
view: TextView, | ||
pixelDensity: Float, | ||
): MobileSegment.Wireframe.TextWireframe | ||
} |
15 changes: 0 additions & 15 deletions
15
...replay/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/extensions/IntExt.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.