[TIMOB-24361] iOS: Using rgb color values causing a false warning, Android: 2-digit float-values do not work
| GitHub Issue | n/a | 
|---|---|
| Type | Bug | 
| Priority | Medium | 
| Status | Closed | 
| Resolution | Fixed | 
| Resolution Date | 2017-05-09T22:33:03.000+0000 | 
| Affected Version/s | Release 6.0.1 | 
| Fix Version/s | Release 6.1.0 | 
| Components | Android, iOS | 
| Labels | merge-6.1.0 | 
| Reporter | Hans Knöchel | 
| Assignee | Hans Knöchel | 
| Created | 2017-01-31T20:42:25.000+0000 | 
| Updated | 2017-05-09T23:14:18.000+0000 | 
Description
	In TIMOB-23453 we fixed an issue where a warning log was thrown when using 
rgba() values. Unfortunately, this did not include rgb-values, so for rgb() values the [WARN] Hex color passed looks invalid: rgb(...) warning is still logged. This should be fixed!
The Android part of rgba() has a bug too: https://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/java/org/appcelerator/titanium/util/TiColorHelper.java#L28 doesn't allow to have more than one number after the
.while this is working in 6.0.1:rgba(0.3, 1.0, 1.0, 0.1)something like this won't work:rgba(0.35, 0.55, 0.55, 0.15)Fix for TiColorHelper.java:static Pattern rgbaPattern = Pattern.compile("rgba\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*(\\d\\.\\d+)\\s*\\)"); static Pattern floatsPattern = Pattern.compile("rgba\\(\\s*(\\d\\.\\d+)\\s*,\\s*(\\d\\.\\d+)\\s*,\\s*(\\d\\.\\d+)\\s*,\\s*(\\d\\.\\d+)\\s*\\)");\dalways needs a+PR and test will follow.PR: https://github.com/appcelerator/titanium_mobile/pull/8809 Test-Case:
var win = Titanium.UI.createWindow({ backgroundColor: 'rgb(255, 255, 0)', // Shoult not throw a warning, making the background yellow }); win.addEventListener('click', function() { win.setBackgroundColor('rgb(255.00, 255.00, 255.00, 0.55)'); // Should also work on Android, making the background gray }); win.open();iOS changes are fine.
[~hansknoechel] [~vijaysingh] Here's a fixed test case, you may want to re-test iOS?
var win = Titanium.UI.createWindow({ backgroundColor: 'rgb(255, 255, 0)', // background yellow }); win.addEventListener('click', function() { win.setBackgroundColor('rgba(1.00, 1.00, 1.00, 0.55)'); // background gray }); win.open();If Android works like this, we have a more critical parity issue than I thought here. They definitely need to work the same in the future. But that could be handled in an own ticket, where we need to think on how to deprecate properly without removing backwards compatibility.
It has to be from 0-255, on both platforms. See the
Colorssection of [the docs](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI) for details. Requested PR (6_1_X): https://github.com/appcelerator/titanium_mobile/pull/9011And [~michael]: I think we got confused by your comment about
rgba(0.3, 1.0, 1.0, 0.1), because the docs say 0-255 and you talked about 0-1. You ok as well with sticking with the 255-bit length?FR Passed, using: MacOS 10.12 (16A323) Studio 4.9.0.201704061825 Ti SDK 6.1.0.v20170503095848 Appc NPM 4.2.9 Appc CLI 6.2.0 Alloy 1.9.11 Xcode 8.3.2 (8E2002) 2-digit float values are accepted on both iOS and Android platforms, for rgb() and rgba().
Fix verified in builds: 6.1.0.v20170509153815 6.2.0.v20170509154110