[TIMOB-10260] Android: Ti.App.Properties 'change' event parity for Android
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-09-04T05:16:51.000+0000 |
Affected Version/s | Release 3.0.0 |
Fix Version/s | Release 3.0.0, Sprint 2012-18 API |
Components | Android |
Labels | api, module_app_properties, qe-review, qe-testadded |
Reporter | Blain Hamon |
Assignee | Hieu Pham |
Created | 2012-07-31T10:09:47.000+0000 |
Updated | 2012-12-08T00:47:52.000+0000 |
Description
Taken from TC-1101:
added a "change" event to Ti.App.Properties to listen for changes of Properties
The test case comes with a settings.bundle in attachment which allows to really test that feature.
var win = Ti.UI.createWindow({
backgroundColor: 'white'
});
var info = Ti.UI.createLabel();
win.add(info);
var switchButton = Ti.UI.createSwitch({
top:40,
value:Ti.App.Properties.getBool('test', false) // mandatory property for iOS
});
switchButton.addEventListener('change',function(_event){
Ti.App.Properties.setBool('test', _event.value);
});
win.add(switchButton);
function onPropertiesChange()
{
switchButton.value = Ti.App.Properties.getBool('test');
info.text = 'onPropertiesChange';
Ti.API.info('onPropertiesChange')
setTimeout(function(){info.text = '';}, 1000);
}
Ti.App.Properties.addEventListener('change',onPropertiesChange);
win.addEventListener('close', function() {
Ti.App.Properties.removeEventListener('change',onPropertiesChange);
});
win.open();
2. Click on switch button, you should see "onPropertiesChange" in log.
Verified on: SDK:2.2.0.v20120830182512 Studio:2.2.0.v20120830182512 Devices: Samsung galaxy tab(v 3.2)
Re-opening to edit label