[TIMOB-1768] Android: KS alerts are not respecting opacity.
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-04-17T01:57:07.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.5.0 M03 |
Components | Android |
Labels | android, defect, regression |
Reporter | Thomas Huelbert |
Assignee | Don Thorp |
Created | 2011-04-15T03:01:41.000+0000 |
Updated | 2011-04-17T01:57:07.000+0000 |
Description
1.launch KS on device or simulator
2.note the pop ups that show the sdk version and tab info (change
tabs to generate more)
results: the windows are not opaque, as per the script they should reflect:
opacity:0.7,
Attachments
File | Date | Size |
---|---|---|
1768_master.diff | 2011-04-15T03:01:41.000+0000 | 2363 |
Here's a sample app.js that shows the problem (so you don't have to build KS):
The top view -- which sets opacity -- should look different than the bottom view, which is otherwise the same. Because of this bug, they look identical.
What's happening is that because a border property is being set in addition to background, a TiBackgroundDrawable is being used. TiBackgroundDrawable maintains its own copy of a drawable which it draws to the canvas. It doesn't respect any of the alpha stuff being done in TiUIHelper.setDrawableOpacity.
I can get it to work properly by...
Overriding setAlpha() in TiBackgroundDrawable and keeping track of the alpha value internally there, then setting it in the internal "background" variable (a drawable) before it draws to canvas.
In http://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/org/appcelerator/titanium/util/TiUIHelper.java#L599"> TiUIHelper.setDrawableOpacity, change ...
... to ...
This means, however, that TiBackgroundDrawable doesn't get the color matrix / color filter stuff -- .setColorFilter() is not called on it. I tried overriding .setColorFilter in TiBackgroundDrawable and passing the value to its private 'background' Drawable, but that didn't work at all. Are we sure the color filter / color matrix thing works?
I haven't committed these changes, as I'm not strong in this area of drawables, color filters, etc. If Don/Marshall wants me to, I can.
here's a diff patch (based on master) in case you wanna use it.
(from [df00caa5c7758796ef957e3b58eb3b742e271e4a]) merging Bill's original patch for fixing opacity on views with custom background drawables. tested with [#2031] as well to verify [#1768 state:fixed-in-qa] https://github.com/appcelerator/titanium_mobile/commit/df00caa5c7758796ef957e3b58eb3b742e271e4a"> https://github.com/appcelerator/titanium_mobile/commit/df00caa5c775...
Failed in 1.6 and 2.1, seems to work fore createImageView, but not createView.
Titanium 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 c0aff27)
passed Android 1.6 Titanium SDK version: 1.5.0 (11/24/10 12:05 c0aff27)