RUM-936: Serialize TextViews/Buttons to base64#1592
Conversation
6acc1fc to
00b44c6
Compare
Codecov Report
@@ Coverage Diff @@
## feature/base64-jmoskovich #1592 +/- ##
=============================================================
+ Coverage 83.44% 83.50% +0.06%
=============================================================
Files 446 446
Lines 15181 15305 +124
Branches 2288 2299 +11
=============================================================
+ Hits 12667 12779 +112
- Misses 1912 1928 +16
+ Partials 602 598 -4
|
09325c9 to
3307416
Compare
0xnm
left a comment
There was a problem hiding this comment.
nice feature! I added few questions/suggestions
|
|
||
| return compoundDrawableLocationMap | ||
| } | ||
| private fun getCompoundDrawableStartCoords( |
There was a problem hiding this comment.
what are the start/top/end/bottom coordinates of the compound drawable? what do they describe?
There was a problem hiding this comment.
It describes the absolute positions of the drawables surrounding the TextView
| return result | ||
| } | ||
|
|
||
| private fun createCompoundDrawableLocationMap( |
There was a problem hiding this comment.
overall I think this logic needs to be simplified here, right now is quite hard to read and as @0xnm mentioned I am not sure you need all this logic
There was a problem hiding this comment.
In the end the problem that you are trying to solve is to get the bounds of a drawable depending on its parent (view) global bounds + padding + position (left, right, top, bottom) . I think you can find a cleaner logic to achieve this.
There was a problem hiding this comment.
I've simplified and moved the bounds logic into ViewUtilsInternal
abb64fc to
f117c2d
Compare
|
|
||
| private companion object { | ||
| private const val DRAWABLE_CHILD_NAME = "drawable" | ||
| @Suppress("NestedBlockDepth") |
There was a problem hiding this comment.
much much better this way, tks !!
| val (shapeStyle, border) = view.background?.resolveShapeStyleAndBorder(view.alpha) | ||
| ?: (null to null) | ||
|
|
||
| resolveTextElements( |
There was a problem hiding this comment.
I like this and is quite scalable
0xnm
left a comment
There was a problem hiding this comment.
looks good! I left some final suggestions.
| @Suppress("ThreadSafety") // TODO REPLAY-1861 caller thread of .map is unknown? | ||
| createImageWireframe( | ||
| view = view, | ||
| index = ++currentIndex, |
There was a problem hiding this comment.
I would also suggest to convert index to enum in this method instead of doing it inside createImageWireframe, this has several advantages:
- we don't use
indexin thecreateImageWireframe, it removes confusion because when insidecreateImageWireframeit is not clear what is the index. createImageWireframesignature is cleaner, it will get an enum.- it will remove the need for
CompoundDrawablePositionsto havepositionproperty, because you can create it right in the beginning of theforEachIndexedlambda in the following way:
val drawablePosition = when(index) {
0 -> ...
1 -> ...
...
}
since it will be close to the comment describing compoundDrawables property, it will be clear what is the index.
There was a problem hiding this comment.
I understand the confusion here - this is a different index. The index for compoundDrawable represents the left, top, right, bottom drawable, however the index for createImageWireframe represents the index of the wireframe in the stack of wireframes. Since we are creating potentially multiple imagewireframes off the same view we need a way to generate unique ids for each wireframe to avoid collisions - this can be seen in line39 of imageWireframeHelper where the index is appended to the resolveChildUniqueIdentifier call.
There was a problem hiding this comment.
Then still maybe it is better to remove this confusion, because here https://github.com/DataDog/dd-sdk-android/pull/1592/files#diff-7870c4af39004135266ff0b27eb0e6ee96774f0443572f43f1225b716dc9a0d3R80 it is still 0 to left, etc. So we can create enum in the current method, and let then index to be used in createImageWireframe only for ID generation.
0xnm
left a comment
There was a problem hiding this comment.
lgtm! I added few suggestions, but they are not blocking.
63dc7b6 to
c3bc12b
Compare
c3bc12b to
7ad210b
Compare
What does this PR do?
Implement serialization of TextViews and Buttons to base64.
Motivation
Continuation of base64 support for different views.
Additional Notes
Anything else we should know when reviewing?
Review checklist (to be filled by reviewers)