{ "id": "62400", "key": "TIMOB-1768", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11228", "name": "Release 1.5.0 M03", "archived": true, "released": true, "releaseDate": "2010-11-29" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T01:57:07.000+0000", "created": "2011-04-15T03:01:41.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "android", "defect", "regression" ], "versions": [], "issuelinks": [], "assignee": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-04-17T01:57:07.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "{html}
1.launch KS on device or simulator
\n2.note the pop ups that show the sdk version and tab info (change\ntabs to generate more)
results: the windows are not opaque, as per the script they\nshould reflect:
\nopacity:0.7,
Here's a sample app.js that shows the problem (so you don't have\nto build KS):
\n\n/*global Ti, Titanium, alert, JSON */\nTitanium.UI.setBackgroundColor('#000');\nvar win = Titanium.UI.createWindow({ \n title:'Test',\n backgroundColor:'#fff',\n fullscreen: true,\n exitOnClose: true\n});\n\n\nvar messageView = Titanium.UI.createView({\n top: 0,\n height:30,\n width:250,\n borderRadius:10,\n backgroundColor:'blue',\n opacity:0.7,\n touchEnabled:false\n});\nwin.add(messageView);\n\nvar v = Titanium.UI.createView({\n top: 50,\n height:30,\n width:250,\n borderRadius:10,\n backgroundColor:'blue',\n touchEnabled:false\n});\nwin.add(v);\nwin.open();
\n
\nThe top view -- which sets opacity -- should look different than\nthe bottom view, which is otherwise the same. Because of this bug,\nthey look identical.
\nWhat's happening is that because a border property is being set\nin addition to background, a TiBackgroundDrawable is being used.\nTiBackgroundDrawable maintains its own copy of a drawable which it\ndraws to the canvas. It doesn't respect any of the alpha stuff\nbeing done in TiUIHelper.setDrawableOpacity.
\nI can get it to work properly by...
\nOverriding setAlpha() in TiBackgroundDrawable and keeping track\nof the alpha value internally there, then setting it in the\ninternal \"background\" variable (a drawable) before it draws to\ncanvas.
\nIn \nTiUIHelper.setDrawableOpacity, change ...
\n\nif (drawable instanceof ColorDrawable) {\n ColorDrawable colorDrawable = (ColorDrawable) drawable;\n colorDrawable.setAlpha(Math.round(opacity * 255));\n....
\n
\n... to ...
\n\nif (drawable instanceof ColorDrawable || drawable instanceof TiBackgroundDrawable) {\n drawable.setAlpha(Math.round(opacity * 255));\n....
\n
\nThis means, however, that TiBackgroundDrawable doesn't get the\ncolor matrix / color filter stuff -- .setColorFilter() is not\ncalled on it. I tried overriding .setColorFilter in\nTiBackgroundDrawable and passing the value to its private\n'background' Drawable, but that didn't work at all. Are we sure the\ncolor filter / color matrix thing works?
\nI haven't committed these changes, as I'm not strong in this\narea of drawables, color filters, etc. If Don/Marshall wants me to,\nI can.
here's a diff patch (based on master) in case you wanna use\nit.
(from [df00caa5c7758796ef957e3b58eb3b742e271e4a])\nmerging Bill's original patch for fixing opacity on views with\ncustom background drawables. tested with [#2031] as\nwell to verify [#1768 state:fixed-in-qa] \nhttps://github.com/appcelerator/titanium_mobile/commit/df00caa5c775...
Failed in 1.6 and 2.1, seems to work fore createImageView, but\nnot createView.
\nTitanium SDK version: 1.5.0 (11/22/10 20:42 19a59fd)
used the test code above
passed Android 2.1 Titanium SDK version: 1.5.0 (11/24/10 12:05\nc0aff27)
\npassed Android 1.6 Titanium SDK version: 1.5.0 (11/24/10 12:05\nc0aff27)