[TIMOB-20451] Window.close should use new activity*Transition instead of activity*Animation or default
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Medium |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2016-04-28T06:58:28.000+0000 |
| Affected Version/s | Release 5.2.0 |
| Fix Version/s | Release 5.4.0 |
| Components | Android |
| Labels | n/a |
| Reporter | Fokke Zandbergen |
| Assignee | Srikanth Sombhatla |
| Created | 2016-02-24T12:22:51.000+0000 |
| Updated | 2016-07-14T22:25:24.000+0000 |
Description
With TIMOB-19580 we have introduced
activity*Transition properties for Ti.UI.Window.
We also still have activity*Animation properties for Ti.UI.Window.open() and Ti.UI.Window.close().
The Issue
This is confusing, but also seems to not always work as expected: If you try the _Activity Transitions_ example in the [Ti 5.2.0 Sample App](https://github.com/appcelerator-developer-relations/appc-sample-ti520) and set allactivity*Transition properties to TRANSITION_NONE you will see that if you use the system navigation bar (or hardware) back button in Window B it will indeed close without animation. But if you use the Action Bar Level Up icon (which simply calls Ti.UI.Window.close()) it will fade out.
Solution
We should: 1. Make sure that if I callTi.UI.Window.close() without activityEnterAnimation and activityExitAnimation, it will honour Ti.UI.Window.activityReturnTransition.
2. Deprecate and in 6.0 remove the activity*Animation properties.
PR: https://github.com/appcelerator/titanium_mobile/pull/7961 Using
Ti.UI.Window.close()or device back should close with transition.Ti.UI.setBackgroundColor('#000'); var win = Ti.UI.createWindow({ backgroundColor: 'black', fullscreen: false, title: 'Master' }); var IMG_BASE = 'https://github.com/appcelerator/titanium_mobile/raw/master/demos/KitchenSink/Resources/images/'; var defaultFontSize = Ti.Platform.name === 'android' ? 16 : 14; var tableData = []; for (var i=1; i<=20; i++){ var row = Ti.UI.createTableViewRow({ className:'forumEvent', // used to improve table performance selectedBackgroundColor:'white', rowIndex:i, // custom property, useful for determining the row during events height:110 }); var avatar = createAvatar(); avatar.transitionName = "avatar"; row.add(avatar); var labelUserName = Ti.UI.createLabel({ color:'#576996', font:{fontFamily:'Arial', fontSize:defaultFontSize+6, fontWeight:'bold'}, text:'Fred Smith ' + i, left:70, top: 6, width:200, height: 30, }); row.add(labelUserName); var labelDetails = Ti.UI.createLabel({ color:'#222', font:{fontFamily:'Arial', fontSize:defaultFontSize+2, fontWeight:'normal'}, text:'Replied to post with id ' + randomInt(1000) + '.', left:70, top:44, width:360 }); row.add(labelDetails); var imageCalendar = Ti.UI.createImageView({ image:IMG_BASE + 'custom_tableview/eventsButton.png', left:70, bottom: 2, width:32, height: 32 }); row.add(imageCalendar); var labelDate = Ti.UI.createLabel({ color:'#999', font:{fontFamily:'Arial', fontSize:defaultFontSize, fontWeight:'normal'}, text:'on ' + randomInt(30) + ' Nov 2012', left:105, bottom:10, width:200, height:20 }); row.add(labelDate); tableData.push(row); } var tableView = Ti.UI.createTableView({ backgroundColor:'white', data:tableData }); tableView.addEventListener('click', function(e){ var masterAvatar = e.row.children[0]; var masterUsername = e.row.children[1]; var win2 = Ti.UI.createWindow({ animated: true, layout: 'vertical', backgroundColor: 'white', title: 'Details-', activityEnterAnimation: Ti.Android.R.anim.fade_in, activityExitAnimation: Ti.Android.R.anim.fade_out }); var avatar = createAvatar(); avatar.width = 80; avatar.height = 80; avatar.left = 100; avatar.transitionName = "avatar"; var labelUserName2 = Ti.UI.createLabel({ color:'#576996', font:{fontFamily:'Arial', fontSize:defaultFontSize+6, fontWeight:'bold'}, text:'Tap to close', top: 20, width:250, height: 60, transitionName: "username", }); labelUserName2.addEventListener('click', function() { win2.close() }); win2.add(avatar) win2.add(labelUserName2); win2.addSharedElement(masterAvatar, "avatar"); win2.addSharedElement(masterUsername, "username"); win2.open(); }); win.add(tableView); win.open(); function createAvatar() { var avatar = Ti.UI.createView({ backgroundColor: 'green', left:10, top:5, width:50, height:50, }); return avatar; } // generate random number, used to make each row appear distinct for this example function randomInt(max){ return Math.floor(Math.random() * max) + 1; }We should move this to 5.4.0
PR merged
Thanks [~ssombhatla]! [~msamah] The PR deals with #1 - what are your thoughts on #2? * Deprecate and in 6.0 remove the
activity*Animationproperties.[~msamah], I have verified the fix for #1, & as [~fokkezb] commented are we doing anything for #2. I am gonna leave it resolved as the fix is just for #1 as of now. Environment: Appc Studio : 4.6.0.201605201934 Ti SDK : 5.4.0.v20160608165242 Ti CLI : 5.0.8 Alloy : 1.8.7 MAC El Capitan : 10.11.4 Appc NPM : 4.2.7-2 Appc CLI : 5.4.0-11 Node: 4.4.4 Nexus 6 - Android 6.0.0
Closing.