Skip to content

Commit

Permalink
Merge pull request #790 from DataDog/carlosnogueira/RUM-8367/sr-fix-a…
Browse files Browse the repository at this point in the history
…ndroid-edit-text

[RUM-8367] Fix EditTextMapper to correctly handle the view's background & border
  • Loading branch information
marco-saia-datadog authored Feb 5, 2025
2 parents 9564964 + 8572652 commit 9b5285f
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import com.datadog.reactnative.sessionreplay.TextPropertiesResolver
import com.datadog.reactnative.sessionreplay.utils.TextViewUtils
import com.facebook.react.bridge.ReactContext
import com.facebook.react.uimanager.UIManagerModule
import com.facebook.react.views.image.ReactImageView
import com.facebook.react.views.textinput.ReactEditText

internal class ReactEditTextMapper(
Expand Down Expand Up @@ -102,7 +101,7 @@ internal class ReactEditTextMapper(
mappingContext: MappingContext,
asyncJobStatusCallback: AsyncJobStatusCallback
): MobileSegment.Wireframe? {
if (view !is ReactImageView) {
if (view !is ReactEditText) {
return super.resolveBackgroundAsImageWireframe(
view,
bounds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ import com.facebook.react.uimanager.LengthPercentage

internal fun LengthPercentage?.getRadius(width: Float, height: Float) = this
?.resolve(width, height)
?: 0f
?: 0f
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import android.graphics.drawable.Drawable
import android.graphics.drawable.InsetDrawable
import android.graphics.drawable.LayerDrawable
import com.datadog.android.internal.utils.densityNormalized
import com.datadog.android.sessionreplay.model.MobileSegment
import com.datadog.reactnative.sessionreplay.extensions.getRadius
import com.datadog.reactnative.sessionreplay.utils.DrawableUtils
Expand Down Expand Up @@ -85,8 +84,7 @@ internal class ReactViewBackgroundDrawableUtils : DrawableUtils() {
backgroundDrawable: CSSBackgroundDrawable,
pixelDensity: Float
): MobileSegment.ShapeBorder {
val borderWidth =
backgroundDrawable.fullBorderWidth.toLong().densityNormalized(pixelDensity)
val borderWidth = (backgroundDrawable.fullBorderWidth / pixelDensity).toLong()
val borderColor = formatAsRgba(backgroundDrawable.getBorderColor(Spacing.ALL))

return MobileSegment.ShapeBorder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ import com.facebook.react.uimanager.LengthPercentage
internal fun LengthPercentage?.getRadius(width: Float, height: Float) = this
?.resolve(width, height)
?.let { (it.horizontal + it.vertical) / 2f }
?: 0f
?: 0f
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import android.graphics.drawable.Drawable
import android.graphics.drawable.InsetDrawable
import android.graphics.drawable.LayerDrawable
import com.datadog.android.internal.utils.densityNormalized
import com.datadog.android.sessionreplay.model.MobileSegment
import com.datadog.reactnative.sessionreplay.extensions.getRadius
import com.datadog.reactnative.sessionreplay.utils.DrawableUtils
Expand Down Expand Up @@ -85,8 +84,7 @@ internal class ReactViewBackgroundDrawableUtils : DrawableUtils() {
backgroundDrawable: CSSBackgroundDrawable,
pixelDensity: Float
): MobileSegment.ShapeBorder {
val borderWidth =
backgroundDrawable.fullBorderWidth.toLong().densityNormalized(pixelDensity)
val borderWidth = (backgroundDrawable.fullBorderWidth / pixelDensity).toLong()
val borderColor = formatAsRgba(backgroundDrawable.getBorderColor(Spacing.ALL))

return MobileSegment.ShapeBorder(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import android.graphics.drawable.Drawable
import android.graphics.drawable.InsetDrawable
import android.graphics.drawable.LayerDrawable
import com.datadog.android.internal.utils.densityNormalized
import com.datadog.android.sessionreplay.model.MobileSegment
import com.datadog.reactnative.sessionreplay.utils.DrawableUtils
import com.datadog.reactnative.sessionreplay.utils.formatAsRgba
Expand All @@ -19,10 +18,7 @@ internal class ReactViewBackgroundDrawableUtils() : DrawableUtils() {
}

val borderProps = resolveBorder(drawable, pixelDensity)
val cornerRadius = drawable
.fullBorderRadius
.toLong()
.densityNormalized(pixelDensity)
val cornerRadius = (drawable.fullBorderRadius / pixelDensity).toLong()

val backgroundColor = getBackgroundColor(drawable)
val colorHexString = if (backgroundColor != null) {
Expand Down Expand Up @@ -63,8 +59,7 @@ internal class ReactViewBackgroundDrawableUtils() : DrawableUtils() {
backgroundDrawable: ReactViewBackgroundDrawable,
pixelDensity: Float
): MobileSegment.ShapeBorder {
val borderWidth =
backgroundDrawable.fullBorderWidth.toLong().densityNormalized(pixelDensity)
val borderWidth = (backgroundDrawable.fullBorderWidth / pixelDensity).toLong()
val borderColor = formatAsRgba(backgroundDrawable.getBorderColor(Spacing.ALL))

return MobileSegment.ShapeBorder(
Expand Down

0 comments on commit 9b5285f

Please sign in to comment.