Bug Report
Problem
Setting a status bar background color with an alpha value like #FFFF0000 by window.statusbar.setBackgroundColor on older web view versions like they are present on an Android 7 or 8 emulator, becuase they can't be update there, because no Google Play is available, it will result in a black color. E.g. for setting status bar to red:
window.statusbar.setBackgroundColor('#FFFF0000');
The following JavaScript code in cordova-js-src/plugin-android-statusbar.js will create the problem:
|
statusBarScript.style.color = value; |
|
var rgbStr = window.getComputedStyle(statusBarScript).getPropertyValue('color'); |
The value is assigned to style.color, then read back via computed style. If parsing fails or degrades on old WebView, computed color falls back to black, e.g. rgb (0, 0, 0).
Alpha 255 will be prepended after and producing [255,0,0,0]:
|
} else if (rgbVals.length === 3) { |
|
rgbVals = [255].concat(rgbVals); |
|
} |
I debugged it in the Chrome dev tools on an Android 8.1 emulator, and it can be seen, that the value #FFFF0000 is computed to rgb (0, 0, 0):
This does not happen on an Android 9 emulator, where the WebView can be updated.
On Android the string could be just forwarded to the native side of the plugin, like it is done, when the color is set by preference in config.xml:
<preference name="StatusBarBackgroundColor" value="#FFFF0000" />
On iOS, that preference is not read directly at runtime from config.xml. It is transformed during prepare, then loaded by storyboard as a named color. So the behaviour is different there.
On iOS exists also a problem with Alpha when setting by window.statusbar.setBackgroundColor but this is on the native side: apache/cordova-ios#1659
Interestingly Visual Studio also don't uses the alpha channel and reads a color string #AAFFFFFF like #AAFFFF like it is currently on iOS the case:
What is expected to happen?
The color should be set with alpha on older web view versions.
What does actually happen?
The color results in black on older web view versions.
Information
Command or Code
Environment, Platform, Device
Version information
Checklist
Bug Report
Problem
Setting a status bar background color with an alpha value like
#FFFF0000bywindow.statusbar.setBackgroundColoron older web view versions like they are present on an Android 7 or 8 emulator, becuase they can't be update there, because no Google Play is available, it will result in a black color. E.g. for setting status bar to red:The following JavaScript code in
cordova-js-src/plugin-android-statusbar.jswill create the problem:cordova-android/cordova-js-src/plugin/android/statusbar.js
Lines 60 to 61 in a63c1e1
The value is assigned to
style.color, then read back via computed style. If parsing fails or degrades on old WebView, computed color falls back to black, e.g.rgb (0, 0, 0).Alpha 255 will be prepended after and producing
[255,0,0,0]:cordova-android/cordova-js-src/plugin/android/statusbar.js
Lines 69 to 71 in a63c1e1
I debugged it in the Chrome dev tools on an Android 8.1 emulator, and it can be seen, that the value
#FFFF0000is computed torgb (0, 0, 0):This does not happen on an Android 9 emulator, where the WebView can be updated.
On Android the string could be just forwarded to the native side of the plugin, like it is done, when the color is set by preference in config.xml:
On iOS, that preference is not read directly at runtime from config.xml. It is transformed during prepare, then loaded by storyboard as a named color. So the behaviour is different there.
On iOS exists also a problem with Alpha when setting by
window.statusbar.setBackgroundColorbut this is on the native side: apache/cordova-ios#1659Interestingly Visual Studio also don't uses the alpha channel and reads a color string
#AAFFFFFFlike#AAFFFFlike it is currently on iOS the case:What is expected to happen?
The color should be set with alpha on older web view versions.
What does actually happen?
The color results in black on older web view versions.
Information
Command or Code
Environment, Platform, Device
Version information
Checklist