RUMM-2779 Resolve view snapshot background from theme color#1230
Merged
mariusc83 merged 1 commit intoJan 13, 2023
Merged
Conversation
mariusc83
force-pushed
the
mconstantin/rumm-2779/resolve-theme-background-in-wireframes
branch
2 times, most recently
from
January 12, 2023 10:12
11b7319 to
1f53698
Compare
mariusc83
marked this pull request as ready for review
January 12, 2023 10:27
0xnm
reviewed
Jan 12, 2023
0xnm
left a comment
Member
There was a problem hiding this comment.
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 || |
Member
There was a problem hiding this comment.
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.
| // region hasNonTranslucentColor | ||
|
|
||
| @Test | ||
| fun `M return true W hasNonTranslucentColor { backgroundColor no translucent }`(forge: Forge) { |
Member
There was a problem hiding this comment.
Suggested change
| fun `M return true W hasNonTranslucentColor { backgroundColor no translucent }`(forge: Forge) { | |
| fun `M return true W hasNonTranslucentColor { backgroundColor not translucent }`(forge: Forge) { |
| } | ||
|
|
||
| // Then | ||
| assertThat(ThemeUtils.resolveThemeColor(mockTheme)).isEqualTo(fakeColor) |
Member
There was a problem hiding this comment.
probably it should be isNull here?
Member
Author
There was a problem hiding this comment.
yes and that's the reason I could not discover the bug in the code because this test was passing :)
xgouchet
approved these changes
Jan 12, 2023
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
|
mariusc83
force-pushed
the
mconstantin/rumm-2779/resolve-theme-background-in-wireframes
branch
from
January 12, 2023 14:50
1f53698 to
8f1f52f
Compare
0xnm
approved these changes
Jan 12, 2023
mariusc83
deleted the
mconstantin/rumm-2779/resolve-theme-background-in-wireframes
branch
January 13, 2023 08:38
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 theShapeStylefrom 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)