Skip to content

Commit

Permalink
Merge pull request #2011 from DataDog/xgouchet/RUM-4320/improve_maski…
Browse files Browse the repository at this point in the history
…ng_arch

RUM-4320 improve masking arch
  • Loading branch information
xgouchet authored Apr 30, 2024
2 parents 2adb85c + 3c7446f commit 1434002
Show file tree
Hide file tree
Showing 67 changed files with 1,954 additions and 2,854 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class com.datadog.android.sessionreplay.material.MaterialExtensionSupport : com.datadog.android.sessionreplay.ExtensionSupport
override fun getCustomViewMappers(): Map<com.datadog.android.sessionreplay.SessionReplayPrivacy, Map<Class<*>, com.datadog.android.sessionreplay.internal.recorder.mapper.WireframeMapper<android.view.View, *>>>
override fun getCustomViewMappers(): Map<Class<*>, com.datadog.android.sessionreplay.internal.recorder.mapper.WireframeMapper<android.view.View, *>>
override fun getOptionSelectorDetectors(): List<com.datadog.android.sessionreplay.internal.recorder.OptionSelectorDetector>

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ package com.datadog.android.sessionreplay.material

import android.view.View
import com.datadog.android.sessionreplay.ExtensionSupport
import com.datadog.android.sessionreplay.SessionReplayPrivacy
import com.datadog.android.sessionreplay.internal.recorder.OptionSelectorDetector
import com.datadog.android.sessionreplay.internal.recorder.mapper.MaskTextViewMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.TextViewMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.WireframeMapper
import com.datadog.android.sessionreplay.utils.ColorStringFormatter
Expand All @@ -35,55 +33,27 @@ class MaterialExtensionSupport : ExtensionSupport {
private val drawableToColorMapper: DrawableToColorMapper = DrawableToColorMapper.getDefault()

@Suppress("UNCHECKED_CAST")
override fun getCustomViewMappers(): Map<SessionReplayPrivacy, Map<Class<*>, WireframeMapper<View, *>>> {
val maskUserInputSliderMapper = MaskSliderWireframeMapper(
viewIdentifierResolver,
colorStringFormatter,
viewBoundsResolver
) as WireframeMapper<View, *>
val maskSliderMapper = MaskSliderWireframeMapper(
viewIdentifierResolver,
colorStringFormatter,
viewBoundsResolver
) as WireframeMapper<View, *>
val allowSliderMapper = SliderWireframeMapper(
override fun getCustomViewMappers(): Map<Class<*>, WireframeMapper<View, *>> {
val sliderWireframeMapper = SliderWireframeMapper(
viewIdentifierResolver,
colorStringFormatter,
viewBoundsResolver
) as WireframeMapper<View, *>

val maskTabWireframeMapper =
MaskTabWireframeMapper(
viewIdentifierResolver,
viewBoundsResolver,
MaskTextViewMapper(
viewIdentifierResolver,
colorStringFormatter,
viewBoundsResolver,
drawableToColorMapper
)
) as WireframeMapper<View, *>

val allowTabWireframeMapper =
TabWireframeMapper(
val tabWireframeMapper = TabWireframeMapper(
viewIdentifierResolver,
viewBoundsResolver,
TextViewMapper(
viewIdentifierResolver,
colorStringFormatter,
viewBoundsResolver,
TextViewMapper(viewIdentifierResolver, colorStringFormatter, viewBoundsResolver, drawableToColorMapper)
) as WireframeMapper<View, *>
drawableToColorMapper
)
) as WireframeMapper<View, *>

return mapOf(
SessionReplayPrivacy.ALLOW to mapOf(
Slider::class.java to allowSliderMapper,
TabLayout.TabView::class.java to allowTabWireframeMapper
),
SessionReplayPrivacy.MASK to mapOf(
Slider::class.java to maskSliderMapper,
TabLayout.TabView::class.java to maskTabWireframeMapper
),
SessionReplayPrivacy.MASK_USER_INPUT to mapOf(
Slider::class.java to maskUserInputSliderMapper,
TabLayout.TabView::class.java to allowTabWireframeMapper
)
Slider::class.java to sliderWireframeMapper,
TabLayout.TabView::class.java to tabWireframeMapper
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.datadog.android.sessionreplay.material

import android.content.res.ColorStateList
import com.datadog.android.sessionreplay.SessionReplayPrivacy
import com.datadog.android.sessionreplay.internal.recorder.MappingContext
import com.datadog.android.sessionreplay.internal.recorder.mapper.WireframeMapper
import com.datadog.android.sessionreplay.material.internal.densityNormalized
Expand Down Expand Up @@ -113,19 +114,11 @@ internal open class SliderWireframeMapper(
)
)

return resolveViewAsWireframesList(
trackNonActiveWireframe,
trackActiveWireframe,
thumbWireframe
)
}

protected open fun resolveViewAsWireframesList(
nonActiveTrackWireframe: MobileSegment.Wireframe.ShapeWireframe,
activeTrackWireframe: MobileSegment.Wireframe.ShapeWireframe,
thumbWireframe: MobileSegment.Wireframe.ShapeWireframe
): List<MobileSegment.Wireframe> {
return listOf(nonActiveTrackWireframe, activeTrackWireframe, thumbWireframe)
return if (mappingContext.privacy == SessionReplayPrivacy.ALLOW) {
listOf(trackNonActiveWireframe, trackActiveWireframe, thumbWireframe)
} else {
listOf(trackNonActiveWireframe)
}
}

private fun ColorStateList.getColor(state: IntArray): Int {
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 1434002

Please sign in to comment.