{ "id": "170780", "key": "TIMOB-25669", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "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": [], "resolution": { "id": "11", "description": "Is not a bug in our product", "name": "Not Our Bug" }, "resolutiondate": "2018-01-15T09:15:05.000+0000", "created": "2018-01-12T11:39:38.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "android", "drawerlayout", "toolbar" ], "versions": [], "issuelinks": [], "assignee": null, "updated": "2019-01-16T20:37:09.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": "I'm using a Toolbar as an ActionBar and I want to show the left drawer menu when clicking on the navigation icon, but the problem is that nothing happens when I click it.\r\n\r\nCheck my code below.\r\n\r\nview/xml:\r\n{code:xml}\r\n\r\n\t\r\n\t\t\r\n\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t\t \r\n\t\t\t\t\t \r\n\t\t\t\t\t\r\n\r\n\t\t\t\r\n\t\t\r\n\r\n\t\r\n\r\n{code}\r\n\r\nstyle/tss:\r\n{code:css}\r\n\"Window\":{\r\n\ttheme : 'AppTheme.TransBtns.Drawer',\r\n\twindowSoftInputMode: Ti.UI.Android.SOFT_INPUT_STATE_HIDDEN\r\n}\r\n{code}\r\n\r\nandroid theme:\r\n{code:xml}\r\n\r\n{code}\r\n\r\ncontroller/js: \r\n{code:javascript}\r\nfunction open() {\r\n\tvar activity = $.window.getActivity();\r\n\t\r\n\tif (activity) {\r\n\t\tvar actionBar = activity.getActionBar();\r\n\t\tif (actionBar) {\r\n\t\t\tactionBar.displayHomeAsUp = true;\r\n\t\t\tactionBar.onHomeIconItemSelected = function() {\r\n\t\t\t\t$.drawerLayout.toggleLeft();\r\n\t\t\t};\r\n\t\t}\r\n\t}\r\n}\r\n{code}\r\n\r\nI tried showing on console the value of activity.getActionBar() and apparently it shows the value of the original ActionBar, the one which isn't visible, instead of showing the Toolbar.\r\n\r\nI also tried this but nothing happens:\r\n{code:javascript}\r\n// $.actionBar is the id of the Toolbar\r\n$.actionBar.onHomeIconItemSelected = function() {\r\n\t$.drawerLayout.toggleLeft();\r\n};\r\n{code}", "attachment": [], "flagged": false, "summary": "Android: when using Ti.UI.Toolbar as ActionBar, onHomeIconItemSelected doesn't work", "creator": { "name": "gfigueras", "key": "gfigueras", "displayName": "Guillermo Figueras", "active": true, "timeZone": "Europe/Madrid" }, "subtasks": [], "reporter": { "name": "gfigueras", "key": "gfigueras", "displayName": "Guillermo Figueras", "active": true, "timeZone": "Europe/Madrid" }, "environment": "MacOS Sierra 10.12.4\r\nAppcelerator Studio 5.0.0\r\nTitanium SDK 7.0.1.GA\r\nGoogle Nexus 5X 7.1.0 (emulator)", "closedSprints": [ { "id": 985, "state": "closed", "name": "2018 Sprint 01 SDK", "startDate": "2017-12-31T16:58:54.631Z", "endDate": "2018-01-14T16:58:00.000Z", "completeDate": "2018-01-17T22:44:27.028Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "433115", "author": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "body": "Hello [~gfigueras],\r\nThanks for sharing with us. Can you please share a complete runnable test case with us to reproduce the issue on our end?", "updateAuthor": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "created": "2018-01-13T06:14:46.000+0000", "updated": "2018-01-13T06:14:46.000+0000" }, { "id": "433145", "author": { "name": "gfigueras", "key": "gfigueras", "displayName": "Guillermo Figueras", "active": true, "timeZone": "Europe/Madrid" }, "body": "Hi Mostafizur,\r\n\r\nI came up with a solution for my problem. I added the customToolbar property to my DrawerLayout (it has to be the id of the Toolbar).\r\n\r\n{code:xml}\r\n\r\n{code}\r\n\r\nAnd I also did this on my controller:\r\n\r\n{code:javascript}\r\n$.window.activity.supportToolbar = $.actionBar;\r\n\r\nfunction open() {\r\n $.window.activity.actionBar.displayHomeAsUp = true;\r\n $.window.activity.actionBar.onHomeIconItemSelected = function() {\r\n $.drawerLayout.toggleLeft();\r\n }\r\n}\r\n{code}\r\n\r\nThe ticket can be closed.", "updateAuthor": { "name": "gfigueras", "key": "gfigueras", "displayName": "Guillermo Figueras", "active": true, "timeZone": "Europe/Madrid" }, "created": "2018-01-15T08:45:48.000+0000", "updated": "2018-01-15T08:45:48.000+0000" }, { "id": "433147", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Thanks [~gfigueras], I've resolved the ticket. But it would still make sense to improve the documentation regarding this point I think. If you feel you can describe this in a few sentences, feel free to submit a PR by simply editing [this file|https://github.com/appcelerator/titanium_mobile/edit/master/apidoc/Titanium/UI/Android/DrawerLayout.yml]. Thanks for your time!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-01-15T09:16:51.000+0000", "updated": "2018-01-15T09:16:51.000+0000" }, { "id": "440272", "author": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing as \"not our bug\". If you disagree, please reopen.", "updateAuthor": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-08-06T17:52:05.000+0000", "updated": "2018-08-06T17:52:05.000+0000" }, { "id": "445400", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "It would be nice to be able to use the {{onHomeIconItemSelected}} with a {{DrawerLayout}}. \r\n\r\nIn the following XML the {{onClickHome}} is triggered in the controller:\r\n{code}\r\n\r\n\t\r\n\t\t\r\n\t\r\n\r\n{code}\r\n\r\nBut when you add a DrawerLayout:\r\n{code}\r\n\r\n\t\r\n\t\t\r\n\t\t\r\n\t\t\t\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\r\n\t\t\r\n\t\r\n\r\n{code}\r\n\r\nit won't trigger the {{onHomeIconItemSelected}} function.\r\n\r\nBoth cases create the following classic code\r\n{code}\r\n$.__views.index.activity.setSupportActionBar($.__views.toolbar), \r\n$.__views.index.activity.actionBar.displayHomeAsUp = !0, \r\n$.__views.index.activity.actionBar.homeButtonEnabled = !0, \r\n$.__views.index.activity.actionBar.onHomeIconItemSelected = onClickHome)\r\n{code}\r\n\r\nTested with Ti SDK 7.5.0.GA, Android 7 (HTC A9).\r\n\r\nAssigning the JS in the controller by hand is working as mentioned in the comment above, so you can create a workaround. Still not sure why it is not working with the Alloy-only way", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-01-16T17:32:20.000+0000", "updated": "2019-01-16T17:32:20.000+0000" }, { "id": "445415", "author": { "name": "ahmed.mohamed20320", "key": "ahmed.mohamed20320", "displayName": "Ahmed Mohamed", "active": true, "timeZone": "Africa/Cairo" }, "body": "The toolbar must be child of window. and you can't put it inside any view to support toolbar by `customToolbar`\r\n\r\n{code:xml}\r\n\r\n \t\r\n \t\t\r\n \t\r\n \r\n{code}\r\n\r\n{code:javascript}\r\nfunction onClickHome(){\r\n\t$.drawer.toggleLeft();\r\n}\r\n\r\n$.index.open();\r\n{code}", "updateAuthor": { "name": "ahmed.mohamed20320", "key": "ahmed.mohamed20320", "displayName": "Ahmed Mohamed", "active": true, "timeZone": "Africa/Cairo" }, "created": "2019-01-16T20:37:09.000+0000", "updated": "2019-01-16T20:37:09.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }