fix: Color white statusbar#1939
Conversation
|
Hi good catch. Since you already noted that These methods set
The variable |
|
I agree with the points raised. I’ve pushed a new commit for review where I removed the INVALID_COLOR. I believe INVALID_COLOR no longer makes sense in this functionality and could be handled differently. @GitToTheHub could you please take another look? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1939 +/- ##
=======================================
Coverage 61.43% 61.43%
=======================================
Files 24 24
Lines 4922 4922
=======================================
Hits 3024 3024
Misses 1898 1898 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
It might be safe to use 0 ( |
|
If possible, I’d appreciate it if someone from the community could review this PR so we can determine whether it’s viable to merge it. |
breautek
left a comment
There was a problem hiding this comment.
Tests passes and I think this is definitely an improvement.
We can't really reserve an int for INVALID_COLOR because any value within the int range is a valid colour, assuming you have a 4x 8bit channels (that's you're RGBA).
If wanted to reserve a number value for invalid color and not have it conflict, we'd have to pick a value outside of an int32 range, which means using Long value.
Or we can do what this PR does and use String / null which I think is perfectly reasonable as well provided there is null guarding. Looks like all APIs being modified here are private methods, so it should be relatively safe change.
Assuming there is no other objections, ping me in a couple days and I'll merge.
|
|
||
| int parsedColor = parseColorFromString(hexColor); | ||
| if (parsedColor == INVALID_COLOR) return; | ||
| overrideStatusBarBackgroundColor = String.format("#%02X%02X%02X%02X", a, r, g, b); |
There was a problem hiding this comment.
Previously overrideStatusBarBackgroundColor did get the parsed color here.
I would change overrideStatusBarBackgroundColor to Integer and set the parsed color directly here, e.g.:
overrideStatusBarBackgroundColor = parseColorFromString(String.format("#%02X%02X%02X%02X", a, r, g, b));So it's the same behaviour as before and is null if the parsing failed
|
|
||
| overrideStatusBarBackgroundColor = parsedColor; | ||
| updateStatusBar(overrideStatusBarBackgroundColor); | ||
| updateSystemBars(); |
There was a problem hiding this comment.
When you change overrideStatusBarBackgroundColor to an Integer, you can call updateStatusBar(overrideStatusBarBackgroundColor) again instead of updateSystemBars(). Or is there any other reason to call updateSystemBars() instead of updateStatusBar()?
| if (statusBarBackgroundColor == null) { | ||
| statusBarBackgroundColor = canEdgeToEdge ? Color.TRANSPARENT : getUiModeColor(); | ||
| } | ||
|
|
There was a problem hiding this comment.
When overrideStatusBarBackgroundColor is an Integer this can be removed.
| int parsedColor = parseColorFromString(colorString); | ||
| if (parsedColor != INVALID_COLOR) return parsedColor; | ||
|
|
||
| return getUiModeColor(); // fallback |
There was a problem hiding this comment.
Why did you removed the fallback getUiModeColor()?


Platforms affected
Motivation and Context
This change fixes an issue where the color #FFFFFFFF (fully opaque white) is treated as an invalid color when used for the status bar background.
The problem happens because Color.parseColor("#FFFFFFFF") correctly returns -1, which collides with the current sentinel value used for INVALID_COLOR.
As a result, valid white colors cannot be applied to the status bar.
fixes: #1938
Description
Updated the invalid color handling to avoid collisions with valid ARGB color values returned by Color.parseColor().
This allows colors such as #FFFFFFFF to be parsed and applied correctly.
Example of an invalid sentinel collision:
window.statusbar.setBackgroundColor('#80000000');
This returns a value equal to Integer.MIN_VALUE.
Testing
Checklist
(platform)if this change only applies to one platform (e.g.(android))