Skip to content

Commit

Permalink
RUM-1002 Implement base64 for imageviews
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanmos committed Sep 27, 2023
1 parent 458c8ce commit 3100b41
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 358 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import android.view.View
import android.widget.Button
import android.widget.CheckBox
import android.widget.CheckedTextView
import android.widget.EditText
import android.widget.ImageButton
import android.widget.ImageView
import android.widget.NumberPicker
import android.widget.RadioButton
Expand All @@ -28,8 +26,7 @@ import com.datadog.android.sessionreplay.internal.recorder.mapper.BasePickerMapp
import com.datadog.android.sessionreplay.internal.recorder.mapper.ButtonMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.CheckBoxMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.CheckedTextViewMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.EditTextViewMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.ImageButtonMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.ImageViewMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.MapperTypeWrapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.MaskCheckBoxMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.MaskCheckedTextViewMapper
Expand All @@ -45,8 +42,6 @@ import com.datadog.android.sessionreplay.internal.recorder.mapper.SeekBarWirefra
import com.datadog.android.sessionreplay.internal.recorder.mapper.SwitchCompatMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.TextViewMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.UnsupportedViewMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.ViewScreenshotWireframeMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.ViewWireframeMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.WireframeMapper
import com.datadog.android.sessionreplay.utils.UniqueIdentifierGenerator
import androidx.appcompat.widget.Toolbar as AppCompatToolbar
Expand Down Expand Up @@ -86,17 +81,14 @@ enum class SessionReplayPrivacy {
val imageWireframeHelper = ImageWireframeHelper(base64Serializer = base64Serializer)
val uniqueIdentifierGenerator = UniqueIdentifierGenerator

val viewWireframeMapper = ViewWireframeMapper()
val unsupportedViewMapper = UnsupportedViewMapper()
val imageButtonMapper = ImageButtonMapper(
val imageViewMapper = ImageViewMapper(
base64Serializer = base64Serializer,
imageWireframeHelper = imageWireframeHelper,
uniqueIdentifierGenerator = uniqueIdentifierGenerator
)
val imageMapper: ViewScreenshotWireframeMapper
val textMapper: TextViewMapper
val buttonMapper: ButtonMapper
val editTextViewMapper: EditTextViewMapper
val checkedTextViewMapper: CheckedTextViewMapper
val checkBoxMapper: CheckBoxMapper
val radioButtonMapper: RadioButtonMapper
Expand All @@ -105,13 +97,11 @@ enum class SessionReplayPrivacy {
val numberPickerMapper: BasePickerMapper?
when (this) {
ALLOW -> {
imageMapper = ViewScreenshotWireframeMapper(viewWireframeMapper)
textMapper = TextViewMapper(
imageWireframeHelper = imageWireframeHelper,
uniqueIdentifierGenerator = uniqueIdentifierGenerator
)
buttonMapper = ButtonMapper(textMapper)
editTextViewMapper = EditTextViewMapper(textMapper)
checkedTextViewMapper = CheckedTextViewMapper(textMapper)
checkBoxMapper = CheckBoxMapper(textMapper)
radioButtonMapper = RadioButtonMapper(textMapper)
Expand All @@ -120,13 +110,11 @@ enum class SessionReplayPrivacy {
numberPickerMapper = getNumberPickerMapper()
}
MASK -> {
imageMapper = ViewScreenshotWireframeMapper(viewWireframeMapper)
textMapper = MaskTextViewMapper(
imageWireframeHelper = imageWireframeHelper,
uniqueIdentifierGenerator = uniqueIdentifierGenerator
)
buttonMapper = ButtonMapper(textMapper)
editTextViewMapper = EditTextViewMapper(textMapper)
checkedTextViewMapper = MaskCheckedTextViewMapper(textMapper)
checkBoxMapper = MaskCheckBoxMapper(textMapper)
radioButtonMapper = MaskRadioButtonMapper(textMapper)
Expand All @@ -135,13 +123,11 @@ enum class SessionReplayPrivacy {
numberPickerMapper = getMaskNumberPickerMapper()
}
MASK_USER_INPUT -> {
imageMapper = ViewScreenshotWireframeMapper(viewWireframeMapper)
textMapper = MaskInputTextViewMapper(
imageWireframeHelper = imageWireframeHelper,
uniqueIdentifierGenerator = uniqueIdentifierGenerator
)
buttonMapper = ButtonMapper(textMapper)
editTextViewMapper = EditTextViewMapper(textMapper)
checkedTextViewMapper = MaskCheckedTextViewMapper(textMapper)
checkBoxMapper = MaskCheckBoxMapper(textMapper)
radioButtonMapper = MaskRadioButtonMapper(textMapper)
Expand All @@ -156,10 +142,8 @@ enum class SessionReplayPrivacy {
MapperTypeWrapper(CheckBox::class.java, checkBoxMapper.toGenericMapper()),
MapperTypeWrapper(CheckedTextView::class.java, checkedTextViewMapper.toGenericMapper()),
MapperTypeWrapper(Button::class.java, buttonMapper.toGenericMapper()),
MapperTypeWrapper(ImageButton::class.java, imageButtonMapper.toGenericMapper()),
MapperTypeWrapper(EditText::class.java, editTextViewMapper.toGenericMapper()),
MapperTypeWrapper(TextView::class.java, textMapper.toGenericMapper()),
MapperTypeWrapper(ImageView::class.java, imageMapper.toGenericMapper()),
MapperTypeWrapper(ImageView::class.java, imageViewMapper.toGenericMapper()),
MapperTypeWrapper(AppCompatToolbar::class.java, unsupportedViewMapper.toGenericMapper())
)

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

package com.datadog.android.sessionreplay.internal.recorder.mapper

import android.widget.ImageButton
import android.widget.ImageView
import com.datadog.android.sessionreplay.internal.AsyncJobStatusCallback
import com.datadog.android.sessionreplay.internal.recorder.MappingContext
import com.datadog.android.sessionreplay.internal.recorder.base64.Base64Serializer
Expand All @@ -16,16 +16,16 @@ import com.datadog.android.sessionreplay.internal.recorder.densityNormalized
import com.datadog.android.sessionreplay.model.MobileSegment
import com.datadog.android.sessionreplay.utils.UniqueIdentifierGenerator

internal class ImageButtonMapper(
internal class ImageViewMapper(
private val base64Serializer: Base64Serializer,
private val imageWireframeHelper: ImageWireframeHelper,
uniqueIdentifierGenerator: UniqueIdentifierGenerator
) : BaseAsyncBackgroundWireframeMapper<ImageButton>(
) : BaseAsyncBackgroundWireframeMapper<ImageView>(
imageWireframeHelper = imageWireframeHelper,
uniqueIdentifierGenerator = uniqueIdentifierGenerator
) {
override fun map(
view: ImageButton,
view: ImageView,
mappingContext: MappingContext,
asyncJobStatusCallback: AsyncJobStatusCallback
): List<MobileSegment.Wireframe> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import android.view.View
import android.widget.Button
import android.widget.CheckBox
import android.widget.CheckedTextView
import android.widget.EditText
import android.widget.ImageButton
import android.widget.ImageView
import android.widget.NumberPicker
import android.widget.RadioButton
Expand All @@ -23,8 +21,7 @@ import androidx.appcompat.widget.SwitchCompat
import com.datadog.android.sessionreplay.internal.recorder.mapper.ButtonMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.CheckBoxMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.CheckedTextViewMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.EditTextViewMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.ImageButtonMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.ImageViewMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.MapperTypeWrapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.MaskCheckBoxMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.MaskCheckedTextViewMapper
Expand All @@ -40,7 +37,6 @@ import com.datadog.android.sessionreplay.internal.recorder.mapper.SeekBarWirefra
import com.datadog.android.sessionreplay.internal.recorder.mapper.SwitchCompatMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.TextViewMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.UnsupportedViewMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.ViewScreenshotWireframeMapper
import com.datadog.android.sessionreplay.internal.recorder.mapper.WireframeMapper
import com.datadog.tools.unit.setStaticValue
import org.assertj.core.api.Assertions.assertThat
Expand Down Expand Up @@ -110,16 +106,12 @@ internal class SessionReplayPrivacyTest {

// BASE
private val mockButtonMapper: ButtonMapper = mock()
private val mockEditTextViewMapper: EditTextViewMapper = mock()
private val mockImageMapper: ViewScreenshotWireframeMapper = mock()
private val mockUnsupportedViewMapper: UnsupportedViewMapper = mock()
private val mockImageButtonViewMapper: ImageButtonMapper = mock()
private val mockImageViewMapper: ImageViewMapper = mock()

private val baseMappers = listOf(
MapperTypeWrapper(Button::class.java, mockButtonMapper.toGenericMapper()),
MapperTypeWrapper(EditText::class.java, mockEditTextViewMapper.toGenericMapper()),
MapperTypeWrapper(ImageView::class.java, mockImageMapper.toGenericMapper()),
MapperTypeWrapper(ImageButton::class.java, mockImageButtonViewMapper.toGenericMapper()),
MapperTypeWrapper(ImageView::class.java, mockImageViewMapper.toGenericMapper()),
MapperTypeWrapper(AppCompatToolbar::class.java, mockUnsupportedViewMapper.toGenericMapper())
)

Expand Down
Loading

0 comments on commit 3100b41

Please sign in to comment.