Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14285] Android: applyProperties() does not apply custom properties to proxy

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2016-11-17T15:27:49.000+0000
Affected Version/sRelease 3.1.1
Fix Version/sRelease 6.1.0
ComponentsAndroid
Labelsn/a
ReporterTony Lukasavage
AssigneeGary Mathews
Created2013-06-19T15:08:03.000+0000
Updated2016-11-29T19:47:24.000+0000

Description

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}]} 

Comments

  1. Lee Driscoll 2014-03-25

    +1 for this issue
  2. Ahmed Roshdy 2014-09-24

    +1 to fix this
  3. Brenton House 2014-11-14

    +1 -- wish this was higher priority...
  4. Manojkumar Murugesan 2015-05-10

    +1
  5. Manojkumar Murugesan 2015-11-05

    +1, We are into cross platform, iOS and Android should act similarly.
  6. Pascal 2016-02-01

    +1, higher priority please!
  7. Brenton House 2016-03-09

    any chance of this getting bumped up?
  8. christian ribe 2016-04-18

    +1 same issue here.... This should act the same independently of the platform ! Any workarounds ?
  9. Ashraf Abu 2016-04-25

    applyProperties doesn't seem to be working for Android. Doing something like this works though if you need a workaround:-
       win.customThings = "customThings";
       
  10. christian ribe 2016-04-25

    Thanks Ashraf, Yes I noticed that setting it directly works. This should be relatively easy to patch...
  11. Gary Mathews 2016-10-27

    master: https://github.com/appcelerator/titanium_mobile/pull/8557
  12. Samir Mohammed 2016-11-29

    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.
        [INFO] :   customString:       "Ti.UI.Window"
        [INFO] :   customArray:        ["class1","class2","class3"]
        [INFO] :   customObject:       {"z":3,"x":1,"y":2}
        [INFO] :   navBarHidden:       true
        [INFO] :   backgroundGradient: {"startPoint":{"x":"0%%","y":"50%%"},"endPoint":{"x":"100%%","y":"50%%"},"type":"linear","colors":[{"offset":0,"color":"red"},{"offset":0.25,"color":"blue"},{"offset":1,"color":"red"}]}
        
    *Environment*
        Appcelerator Command-Line Interface, version 6.0.0
        Android 7.0 (Google Nexus 6P)
        Operating System Name: Mac OS X El Capitan
        Operating System Version: 10.11.6
        Node.js Version: 4.6.0
        npm: 4.2.8
        Titanium CLI Version: 5.0.10
        Titanium SDK Version: 6.1.0.v20161129071600
        Xcode: 8.0
        Appcelerator Studio: 4.8.0.201611121409
        

JSON Source