Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24361] iOS: Using rgb color values causing a false warning, Android: 2-digit float-values do not work

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2017-05-09T22:33:03.000+0000
Affected Version/sRelease 6.0.1
Fix Version/sRelease 6.1.0
ComponentsAndroid, iOS
Labelsmerge-6.1.0
ReporterHans Knöchel
AssigneeHans Knöchel
Created2017-01-31T20:42:25.000+0000
Updated2017-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!

Comments

  1. Michael Gangolf 2017-01-31

    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*\\)");
       
    the second \d always needs a + PR and test will follow.
  2. Hans Knöchel 2017-01-31

    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();
       
  3. Vijay Singh 2017-02-08

    iOS changes are fine.
  4. Gary Mathews 2017-02-14

    [~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();
       
  5. Hans Knöchel 2017-02-16

    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.
  6. Hans Knöchel 2017-05-03

    It has to be from 0-255, on both platforms. See the Colors section 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/9011
  7. Hans Knöchel 2017-05-03

    And [~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?
  8. Michael Gangolf 2017-05-03

  9. Eric Wieber 2017-05-09

    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().
  10. Eric Wieber 2017-05-09

    Fix verified in builds: 6.1.0.v20170509153815 6.2.0.v20170509154110

JSON Source