GitToTheHub opened a new issue, #1949:
URL: https://github.com/apache/cordova-android/issues/1949

   # 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:
   
   ```js
   window.statusbar.setBackgroundColor('#FFFF0000');
   ```
   
   The following JavaScript code in 
`cordova-js-src/plugin-android-statusbar.js` will create the problem:
   
   
https://github.com/apache/cordova-android/blob/a63c1e18ca941145b0439802170f8aa405c56f42/cordova-js-src/plugin/android/statusbar.js#L60-L61
   
   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]`:
   
   
https://github.com/apache/cordova-android/blob/a63c1e18ca941145b0439802170f8aa405c56f42/cordova-js-src/plugin/android/statusbar.js#L69-L71
   
   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)`:
   
   <img width="831" 
src="https://github.com/user-attachments/assets/847e4ac0-0373-4f00-bd5b-e462e796a77c";
 />
   
   This does not happen on an Android 9 emulator, where the WebView can be 
updated.
   
   Honestly I don't understand why the color isn't just forwarded to the native 
side of the plugin, like it is done, when the color is set by preference in 
config.xml:
   
   ```xml
   <preference name="StatusBarBackgroundColor" value="#FFFF0000" />
   ```
   
   On the iOS side, formats with Alpha are not supported by the JS side, but as 
preference.
   
   Example:
   
   ```js
   window.statusbar.setBackgroundColor('#AAFFFFFF');
   ```
   
   Will be interpreted as `#AAFFFF`:
   
   <img width="300" 
src="https://github.com/user-attachments/assets/6a6188c7-13b3-44b6-a7c9-926a036d0826";
 />
   
   So it just uses the first 6 hex values.
   
   Interestingly Visual Studio also don't uses the alpha channel and reads a 
color string `#AAFFFFFF` like iOS does:
   
   <img width="500" 
src="https://github.com/user-attachments/assets/dcfb6aba-8574-4715-9b75-1d7befa1b6e3";
 />
   
   ### 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
   <!-- Include all relevant information that might help understand and 
reproduce the problem -->
   
   
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   
   
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you 
experiencing the issue? -->
   
   
   
   ### Version information
   <!--
   What are relevant versions you are using?
   For example:
   Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins
   Other Frameworks: Ionic Framework and CLI version
   Operating System, Android Studio, Xcode etc.
   -->
   
   
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [ ] I searched for existing GitHub issues
   - [ ] I updated all Cordova tooling to most recent version
   - [ ] I included all the necessary information above
   


-- 
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]

Reply via email to