-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "RUM-1002 Implement base64 for imageviews"
This reverts commit 3100b41.
- Loading branch information
1 parent
c757420
commit e135321
Showing
7 changed files
with
358 additions
and
45 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
86 changes: 86 additions & 0 deletions
86
...n/kotlin/com/datadog/android/sessionreplay/internal/recorder/mapper/EditTextViewMapper.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,86 @@ | ||
/* | ||
* 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.android.sessionreplay.internal.recorder.mapper | ||
|
||
import android.widget.EditText | ||
import com.datadog.android.sessionreplay.SessionReplayPrivacy | ||
import com.datadog.android.sessionreplay.internal.AsyncJobStatusCallback | ||
import com.datadog.android.sessionreplay.internal.recorder.MappingContext | ||
import com.datadog.android.sessionreplay.model.MobileSegment | ||
import com.datadog.android.sessionreplay.utils.StringUtils | ||
import com.datadog.android.sessionreplay.utils.UniqueIdentifierGenerator | ||
import com.datadog.android.sessionreplay.utils.ViewUtils | ||
|
||
/** | ||
* A [WireframeMapper] implementation to map a [EditText] component in case the | ||
* [SessionReplayPrivacy.ALLOW] rule was used in the configuration. | ||
* In this case the mapper will use the provided [textViewMapper] used for the current privacy | ||
* level and will only mask the [EditText] for which the input type is considered sensible | ||
* (password, email, address, postal address, numeric password) with the static mask: [***]. | ||
*/ | ||
internal open class EditTextViewMapper( | ||
internal val textViewMapper: TextViewMapper, | ||
private val uniqueIdentifierGenerator: UniqueIdentifierGenerator = UniqueIdentifierGenerator, | ||
viewUtils: ViewUtils = ViewUtils, | ||
stringUtils: StringUtils = StringUtils | ||
) : BaseWireframeMapper<EditText, MobileSegment.Wireframe>( | ||
viewUtils = viewUtils, | ||
stringUtils = stringUtils | ||
) { | ||
|
||
override fun map( | ||
view: EditText, | ||
mappingContext: MappingContext, | ||
asyncJobStatusCallback: AsyncJobStatusCallback | ||
): | ||
List<MobileSegment.Wireframe> { | ||
val mainWireframeList = textViewMapper.map(view, mappingContext, asyncJobStatusCallback) | ||
resolveUnderlineWireframe(view, mappingContext.systemInformation.screenDensity) | ||
?.let { wireframe -> | ||
return mainWireframeList + wireframe | ||
} | ||
return mainWireframeList | ||
} | ||
|
||
private fun resolveUnderlineWireframe( | ||
parent: EditText, | ||
pixelsDensity: Float | ||
): MobileSegment.Wireframe? { | ||
val identifier = uniqueIdentifierGenerator.resolveChildUniqueIdentifier( | ||
parent, | ||
UNDERLINE_KEY_NAME | ||
) ?: return null | ||
val viewGlobalBounds = resolveViewGlobalBounds(parent, pixelsDensity) | ||
val fieldUnderlineColor = resolveUnderlineColor(parent) | ||
return MobileSegment.Wireframe.ShapeWireframe( | ||
identifier, | ||
viewGlobalBounds.x, | ||
viewGlobalBounds.y + viewGlobalBounds.height - UNDERLINE_HEIGHT_IN_PIXELS, | ||
viewGlobalBounds.width, | ||
UNDERLINE_HEIGHT_IN_PIXELS, | ||
shapeStyle = MobileSegment.ShapeStyle( | ||
backgroundColor = fieldUnderlineColor, | ||
opacity = parent.alpha | ||
) | ||
) | ||
} | ||
|
||
private fun resolveUnderlineColor(view: EditText): String { | ||
view.backgroundTintList?.let { | ||
return colorAndAlphaAsStringHexa( | ||
it.defaultColor, | ||
OPAQUE_ALPHA_VALUE | ||
) | ||
} | ||
return colorAndAlphaAsStringHexa(view.currentTextColor, OPAQUE_ALPHA_VALUE) | ||
} | ||
|
||
companion object { | ||
internal const val UNDERLINE_HEIGHT_IN_PIXELS = 1L | ||
internal const val UNDERLINE_KEY_NAME = "underline" | ||
} | ||
} |
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
Oops, something went wrong.