problem
When using
applyProperties()
to add a number of properties to a Titanium proxy object, custom properties are not added on Android. On iOS and Mobileweb all properties, including custom ones, are added with the
applyProperties()
call. Android leaves the custom properties as
undefined
.
expected
Android should behave like other supported platforms and attach custom properties to the Titanium proxy object when they are added via
applyProperties()
.
test case
var win = Ti.UI.createWindow({
backgroundColor: '#fff',
fullscreen: false,
exitOnClose: true
});
win.open();
win.applyProperties({
customString: 'Ti.UI.Window',
customArray: ['class1','class2','class3'],
customObject: {
x: 1,
y: 2,
z: 3
},
navBarHidden: true,
backgroundGradient: {
type: 'linear',
startPoint: { x: '0%', y: '50%' },
endPoint: { x: '100%', y: '50%' },
colors: [
{ color: 'red', offset: 0.0},
{ color: 'blue', offset: 0.25 },
{ color: 'red', offset: 1.0 }
],
}
});
Ti.API.info('customString: ' + JSON.stringify(win.customString));
Ti.API.info('customArray: ' + JSON.stringify(win.customArray));
Ti.API.info('customObject: ' + JSON.stringify(win.customObject));
Ti.API.info('navBarHidden: ' + JSON.stringify(win.navBarHidden));
Ti.API.info('backgroundGradient: ' + JSON.stringify(win.backgroundGradient));
output
iOS does not show the
backgroundGradient
after the
applyProperties()
call, but this is a peripheral issue not associated with this ticket.
iOS 6.1 iPhone sim
[INFO] customString: "Ti.UI.Window"
[INFO] customArray: ["class1","class2","class3"]
[INFO] customObject: {"x":1,"y":2,"z":3}
[INFO] navBarHidden: true
[INFO] backgroundGradient: {}
Android 2.3.3 HVGA emulator
I/TiAPI ( 517): customString: undefined
I/TiAPI ( 517): customArray: undefined
I/TiAPI ( 517): customObject: undefined
I/TiAPI ( 517): navBarHidden: true
I/TiAPI ( 517): backgroundGradient: {"endPoint":{"y":"50%","x":"100%"},"type":"linear","colors":[{"offset":0,"color":"red"},{"offset":0.25,"color":"blue"},{"offset":1,"color":"red"}],"startPoint":{"y":"50%","x":"0%"}}
mobileweb + chrome
[INFO] customString: "Ti.UI.Window"
[INFO] customArray: ["class1","class2","class3"]
[INFO] customObject: {"x":1,"y":2,"z":3}
[INFO] navBarHidden: true
[INFO] backgroundGradient: {"type":"linear","startPoint":{"x":"0%","y":"50%"},"endPoint":{"x":"100%","y":"50%"},"colors":[{"color":"red","offset":0},{"color":"blue","offset":0.25},{"color":"red","offset":1}]}
+1 for this issue
+1 to fix this
+1 -- wish this was higher priority...
+1
+1, We are into cross platform, iOS and Android should act similarly.
+1, higher priority please!
any chance of this getting bumped up?
+1 same issue here.... This should act the same independently of the platform ! Any workarounds ?
applyProperties doesn't seem to be working for Android. Doing something like this works though if you need a workaround:-
Thanks Ashraf, Yes I noticed that setting it directly works. This should be relatively easy to patch...
master: https://github.com/appcelerator/titanium_mobile/pull/8557
Verified fixed, using the code in the description was able to view the custom properties in the console when running on an android device; this is shown below as you can see it no longer says "Undefined" for customString, customArray, customObject and navBarHidden.
*Environment*