-
Notifications
You must be signed in to change notification settings - Fork 61
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
RUMM-2779 Resolve view snapshot background from theme color #1230
RUMM-2779 Resolve view snapshot background from theme color #1230
Conversation
11b7319
to
1f53698
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've added few comments/questions
fun resolveThemeColor(theme: Theme): Int? { | ||
val a = TypedValue() | ||
theme.resolveAttribute(android.R.attr.windowBackground, a, true) | ||
return if (a.type >= TypedValue.TYPE_FIRST_COLOR_INT || |
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.
probably here it should be &&
instead of ||
, because we want to check that value is in the range TypedValue.TYPE_FIRST_COLOR_INT..TypedValue.TYPE_LAST_COLOR_INT
. With ||
I believe this condition always evaluates to true
.
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.
yes, of course 🤦
// region hasNonTranslucentColor | ||
|
||
@Test | ||
fun `M return true W hasNonTranslucentColor { backgroundColor no translucent }`(forge: Forge) { |
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.
fun `M return true W hasNonTranslucentColor { backgroundColor no translucent }`(forge: Forge) { | |
fun `M return true W hasNonTranslucentColor { backgroundColor not translucent }`(forge: Forge) { |
...id-session-replay/src/test/kotlin/com/datadog/android/sessionreplay/utils/StringUtilsTest.kt
Show resolved
Hide resolved
} | ||
|
||
// Then | ||
assertThat(ThemeUtils.resolveThemeColor(mockTheme)).isEqualTo(fakeColor) |
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.
probably it should be isNull
here?
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.
yes and that's the reason I could not discover the bug in the code because this test was passing :)
...d-session-replay/src/test/kotlin/com/datadog/android/sessionreplay/utils/WireframeExtTest.kt
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## feature/sdkv2 #1230 +/- ##
==============================================
Coverage 82.79% 82.79%
==============================================
Files 354 358 +4
Lines 12590 12616 +26
Branches 2088 2095 +7
==============================================
+ Hits 10423 10445 +22
- Misses 1526 1527 +1
- Partials 641 644 +3
|
1f53698
to
8f1f52f
Compare
Resolve view snapshot background from theme color
What does this PR do?
In this PR we are making sure that whenever a screen snapshot is performed for SR records, if the root wireframe does not have a
ShapeStyle
(meaning that we could not resolve the background from a potential drawable attached to theView
) we will resolve theShapeStyle
from theTheme#windowBackground
. This way we will make sure that we will not have transparent backgrounds in our snapshots and we simulate the system behaviour.Motivation
What inspired you to submit this pull request?
Additional Notes
Anything else we should know when reviewing?
Review checklist (to be filled by reviewers)