GitToTheHub commented on code in PR #1955:
URL: https://github.com/apache/cordova-android/pull/1955#discussion_r3398370840
##########
cordova-js-src/plugin/android/statusbar.js:
##########
@@ -60,28 +60,28 @@ Object.defineProperty(statusBar, 'setBackgroundColor', {
statusBarScript.style.color = value;
var rgbStr =
window.getComputedStyle(statusBarScript).getPropertyValue('color');
- if (!rgbStr.match(/^rgb/)) { return; }
-
- var rgbVals = rgbStr.match(/\d+/g).map(function (v) { return
parseInt(v, 10); });
+ if (!rgbStr.match(/^rgb/)) {
+ return;
+ }
+ var rgbVals = rgbStr.match(/[\d.]+/g).map(function (v, i) { return (i
< 3) ? parseInt(v, 10) : parseFloat(v); });
if (rgbVals.length < 3) {
return;
- } else if (rgbVals.length === 3) {
- rgbVals = [255].concat(rgbVals);
}
- // TODO: Use `padStart(2, '0')` once SDK 24 is dropped.
- const padRgb = (val) => {
- const hex = val.toString(16);
- return hex.length === 1 ? '0' + hex : hex;
- };
- const a = padRgb(rgbVals[0]);
- const r = padRgb(rgbVals[1]);
- const g = padRgb(rgbVals[2]);
- const b = padRgb(rgbVals[3]);
- const hexStr = '#' + a + r + g + b;
-
if (window.StatusBar) {
Review Comment:
Just a thought. This line is only executed if the cordova-plugin-statusbar
is used or? Because I didn't find a
`window.StatusBar.backgroundColorByHexString` method online. This seems plugin
related. Maybe this can be added as a comment
```jsdoc
// cordova-plugin-statusbar used
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]