{ "id": "147220", "key": "TIMOB-19919", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "16980", "description": "New V8", "name": "Release 6.0.0", "archived": false, "released": true, "releaseDate": "2016-11-15" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2016-06-27T08:00:59.000+0000", "created": "2015-04-23T11:48:37.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "Community", "breaking-change" ], "versions": [], "issuelinks": [], "assignee": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "updated": "2017-07-31T18:58:08.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "Currently it is possible to override the default behavior for the back button. But you can't really use this for enhancing this functionality or just listen to the back button event without overriding it.\r\n\r\nThere is no way to call super.onBackPressed() from on the windows activity from JavaScript side. \r\n\r\nI think it would make sense to add another property to the Ti.UI.Window that lets you explicitly override this behavior. I'd prefer this:\r\n{code:javascript}\r\nvar win = Ti.UI.createWindow();\r\n\r\nwin.onBack = function(){\r\n // explicitly override back button behavior\r\n};\r\n\r\nwin.addEventListener('androidback', function(){\r\n // just listen for the event without influencing the default behavior\r\n});\r\n{code}\r\n\r\nDoes that make sense?\r\n\r\nThe reason why I need this is that I'm trying to create a proper navigation history. As there are no more lightweight windows, I want to implement a kind of backstack for Views or Fragments. ", "attachment": [], "flagged": false, "summary": "Android: add ability to listen to androidback without overriding", "creator": { "name": "manuellehner", "key": "manuellehner", "displayName": "Manuel Lehner", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "manuellehner", "key": "manuellehner", "displayName": "Manuel Lehner", "active": true, "timeZone": "Europe/Berlin" }, "environment": null, "closedSprints": [ { "id": 565, "state": "closed", "name": "2016 Sprint 2 SDK", "startDate": "2016-01-16T01:30:40.264Z", "endDate": "2016-01-30T01:30:00.000Z", "completeDate": "2016-01-31T01:27:07.537Z", "originBoardId": 114 }, { "id": 649, "state": "closed", "name": "2016 Sprint 13 SDK", "startDate": "2016-06-18T00:25:17.303Z", "endDate": "2016-07-02T00:25:00.000Z", "completeDate": "2016-07-04T04:25:16.889Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "352957", "author": { "name": "manuellehner", "key": "manuellehner", "displayName": "Manuel Lehner", "active": true, "timeZone": "Europe/Berlin" }, "body": "PR: https://github.com/appcelerator/titanium_mobile/pull/6859", "updateAuthor": { "name": "manuellehner", "key": "manuellehner", "displayName": "Manuel Lehner", "active": true, "timeZone": "Europe/Berlin" }, "created": "2015-05-19T07:44:01.000+0000", "updated": "2015-05-19T07:44:01.000+0000" }, { "id": "375535", "author": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "body": "PR merged.", "updateAuthor": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2016-01-30T23:51:52.000+0000", "updated": "2016-01-30T23:51:52.000+0000" }, { "id": "377898", "author": { "name": "manuellehner", "key": "manuellehner", "displayName": "Manuel Lehner", "active": true, "timeZone": "Europe/Berlin" }, "body": "Please note: *this is a breaking change!*\r\n\r\n{{win.addEventListener('androidback', onBack);}} will behave different than before. Apps using this to override the back-button need to update their code.", "updateAuthor": { "name": "manuellehner", "key": "manuellehner", "displayName": "Manuel Lehner", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-02-25T17:22:45.000+0000", "updated": "2016-02-25T17:22:45.000+0000" }, { "id": "377950", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~manuellehner] Thanks for the heads up. Will get this out of 5.4.0 (aka current Master) and get it merged back when we do 6.0.0. Will be reverting it right now and leave this ticket as opened.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-02-26T02:47:58.000+0000", "updated": "2016-02-26T02:47:58.000+0000" }, { "id": "377953", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "PR to revert this for 5.4.0 https://github.com/appcelerator/titanium_mobile/pull/7780 (Merged)", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-02-26T03:46:24.000+0000", "updated": "2016-02-26T08:23:00.000+0000" }, { "id": "377954", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "Note for when adding this back into 6.0.0: Add docs.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-02-26T03:48:29.000+0000", "updated": "2016-02-26T03:48:29.000+0000" }, { "id": "377987", "author": { "name": "timpoulsen", "key": "timpoulsen", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/Havana" }, "body": "I'm not sure I see the use case for this. You can already accomplish custom back button behavior while supporting the stock handling of windows (activities) using code like the following.\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow(),\r\n\tview = Ti.UI.createView();\r\n\r\nwin.add(view);\r\n\r\nfunction handleBackButton() {\r\n\twin.removeEventListener('androidback', handleBackButton);\r\n\t// do whatever you want here for custom back button handling\r\n\t// for example, \"close\" the view\r\n\tview.hide();\r\n\twin.remove(view);\r\n\tview = undefined;\r\n}\r\n\r\nwin.addEventListener('androidback', handleBackButton);\r\n\r\nwin.open();\r\n{code}", "updateAuthor": { "name": "timpoulsen", "key": "timpoulsen", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/Havana" }, "created": "2016-02-26T15:20:23.000+0000", "updated": "2016-02-26T15:20:23.000+0000" }, { "id": "389105", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "PR to get this in https://github.com/appcelerator/titanium_mobile/pull/8087", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-06-27T07:33:44.000+0000", "updated": "2016-06-27T07:33:44.000+0000" }, { "id": "389106", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "Pr merged", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-06-27T08:01:35.000+0000", "updated": "2016-06-27T08:01:35.000+0000" }, { "id": "392391", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "Test case is as described in original description.\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow();\r\n \r\nwin.onBack = function(){\r\n // explicitly override back button behavior\r\n};\r\n \r\nwin.addEventListener('androidback', function(){\r\n // just listen for the event without influencing the default behavior\r\n});\r\n{code}", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-08-04T06:32:37.000+0000", "updated": "2016-08-04T06:32:37.000+0000" }, { "id": "393072", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the improvement. \r\n\r\nClosing.\r\n\r\nEnvironment:\r\nAppc Studio : 4.7.0.201607250649\r\nTi SDK : 6.0.0.v20160811221444\r\nTi CLI : 5.0.9\r\nAlloy : 1.9.1\r\nMAC El Capitan : 10.11.6\r\nAppc NPM : 4.2.7\r\nAppc CLI : 6.0.0-24\r\nNode: 4.4.4\r\nNexus 5 - Android 6.0.1", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-08-13T00:13:03.000+0000", "updated": "2016-08-13T00:13:03.000+0000" }, { "id": "425113", "author": { "name": "manuellehner", "key": "manuellehner", "displayName": "Manuel Lehner", "active": true, "timeZone": "Europe/Berlin" }, "body": "This does not work for Tabgroup.", "updateAuthor": { "name": "manuellehner", "key": "manuellehner", "displayName": "Manuel Lehner", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-07-31T18:58:08.000+0000", "updated": "2017-07-31T18:58:08.000+0000" } ], "maxResults": 13, "total": 13, "startAt": 0 } } }