-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RUM-6195: Add support for Compose Checkbox #2414
RUM-6195: Add support for Compose Checkbox #2414
Conversation
33e6311
to
66d7340
Compare
66d7340
to
9d12c72
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I briefly went through the production files, didn't cover tests
...adog/android/sessionreplay/compose/internal/mappers/semantics/CheckboxSemanticsNodeMapper.kt
Outdated
Show resolved
Hide resolved
...adog/android/sessionreplay/compose/internal/mappers/semantics/CheckboxSemanticsNodeMapper.kt
Outdated
Show resolved
Hide resolved
...adog/android/sessionreplay/compose/internal/mappers/semantics/CheckboxSemanticsNodeMapper.kt
Outdated
Show resolved
Hide resolved
...ompose/src/main/kotlin/com/datadog/android/sessionreplay/compose/internal/utils/PathUtils.kt
Outdated
Show resolved
Hide resolved
...e/src/main/kotlin/com/datadog/android/sessionreplay/compose/internal/utils/SemanticsUtils.kt
Show resolved
Hide resolved
...e/src/main/kotlin/com/datadog/android/sessionreplay/compose/internal/utils/SemanticsUtils.kt
Outdated
Show resolved
Hide resolved
...e/src/main/kotlin/com/datadog/android/sessionreplay/compose/internal/utils/SemanticsUtils.kt
Outdated
Show resolved
Hide resolved
...adog/android/sessionreplay/compose/internal/mappers/semantics/CheckboxSemanticsNodeMapper.kt
Outdated
Show resolved
Hide resolved
...adog/android/sessionreplay/compose/internal/mappers/semantics/CheckboxSemanticsNodeMapper.kt
Outdated
Show resolved
Hide resolved
...adog/android/sessionreplay/compose/internal/mappers/semantics/CheckboxSemanticsNodeMapper.kt
Outdated
Show resolved
Hide resolved
...adog/android/sessionreplay/compose/internal/mappers/semantics/CheckboxSemanticsNodeMapper.kt
Outdated
Show resolved
Hide resolved
...adog/android/sessionreplay/compose/internal/mappers/semantics/CheckboxSemanticsNodeMapper.kt
Show resolved
Hide resolved
@@ -37,6 +37,16 @@ internal object ComposeReflection { | |||
val ColorField = BackgroundElementClass?.getDeclaredFieldSafe("color") | |||
val ShapeField = BackgroundElementClass?.getDeclaredFieldSafe("shape") | |||
|
|||
val CheckDrawingCacheClass = getClassSafe("androidx.compose.material.CheckDrawingCache") | |||
val CheckboxKtClass = getClassSafe("androidx.compose.material.CheckboxKt\$CheckboxImpl\$1\$1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, updating proguard consumer rules is necessary
9d12c72
to
f23bb5f
Compare
f23bb5f
to
8864b27
Compare
4411582
to
a02fc56
Compare
427dafe
to
7a92c24
Compare
b35cace
to
0da9659
Compare
7f56e9a
to
a12c7ad
Compare
0da9659
to
2ef05ac
Compare
2ef05ac
to
8b092b1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! I left some comments/suggestions, but nothing major.
dd-sdk-android-internal/src/main/java/com/datadog/android/internal/utils/ImageViewUtils.kt
Outdated
Show resolved
Hide resolved
...e/src/main/kotlin/com/datadog/android/sessionreplay/compose/internal/utils/SemanticsUtils.kt
Outdated
Show resolved
Hide resolved
...adog/android/sessionreplay/compose/internal/mappers/semantics/CheckboxSemanticsNodeMapper.kt
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
if (wireframes.isNotEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: you probably can just do return wireframes.ifEmpty { createManualCheckedWireframe }
...adog/android/sessionreplay/compose/internal/mappers/semantics/CheckboxSemanticsNodeMapper.kt
Outdated
Show resolved
Hide resolved
...e/src/test/kotlin/com/datadog/android/sessionreplay/compose/internal/utils/ColorUtilsTest.kt
Outdated
Show resolved
Hide resolved
...ain/kotlin/com/datadog/android/sessionreplay/internal/recorder/resources/ResourceResolver.kt
Show resolved
Hide resolved
...session-replay/src/main/kotlin/com/datadog/android/sessionreplay/internal/utils/PathUtils.kt
Outdated
Show resolved
Hide resolved
...ssion-replay/src/main/kotlin/com/datadog/android/sessionreplay/utils/ImageWireframeHelper.kt
Outdated
Show resolved
Hide resolved
...datadog/android/sessionreplay/internal/recorder/resources/DefaultImageWireframeHelperTest.kt
Outdated
Show resolved
Hide resolved
cd5a77c
to
11155d6
Compare
.thenReturn(TextAndInputPrivacy.MASK_ALL_INPUTS) | ||
|
||
// When | ||
val wireframes = testedMapper.map( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since return type is SemanticsWireframe
should this one be called wireframe
? or checkboxWireframe
.
Otherwise wireframes.wireframes
below looks strange.
// Then | ||
assertThat(wireframes.wireframes).hasSize(1) | ||
val actualWireframe = wireframes.wireframes[0] as MobileSegment.Wireframe.ShapeWireframe | ||
assertThat(actualWireframe).isNotNull |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to have null
at all? the type here is MobileSegment.Wireframe.ShapeWireframe
, not MobileSegment.Wireframe.ShapeWireframe?
fun `M return input value W convertRgbaToArgb() { length is less than 8 }`( | ||
forge: Forge | ||
) { | ||
// Given | ||
val input = forge.anAsciiString(1) | ||
|
||
// Then | ||
assertThat(testedUtils.convertRgbaToArgb(input)).isEqualTo(input) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so if we pass rgb
string, the output will be wrong? Shouldn't we check in the convertRgbaToArgb
method that input is exactly 8 characters (or 6 if we want to support rgb
?
Otherwise we may have this function trying to compose something for the strings of format we don't expect.
11155d6
to
c1b4f66
Compare
What does this PR do?
Adds support for the Checkbox Semantics role. Resolves the path of the checkbox to a bitmap and sends as an imageWireframe, but if unsuccessful will create a ShapeWireframe approximation. This pr includes:
• Creation of checked/unchecked state for the checkbox.
• Fallback to a manual shape wireframe if we couldn't resolve the checkmark path.
• Caching of the checkmark resourceId in the
ResourcesLruCache
.• Generation of a cache key for the checkmark using
PathMeasure
on the path to fingerprint it by sampling at intervals. This is bounded by a configurable maximum number of samples.Unchecked state:

Checked state if succesful in resolving the path:

Checked state fallback if path resolution is unsuccessful:

Motivation
Part of the initiative to support Jetpack Compose.
Additional Notes
Anything else we should know when reviewing?
Review checklist (to be filled by reviewers)