{ "id": "83771", "key": "TIMOB-6648", "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": [ { "id": "12092", "description": "", "name": "Sprint 2011-52", "archived": true, "released": true, "releaseDate": "2011-12-30" }, { "id": "12593", "name": "Release 2.0.0", "archived": false, "released": true, "releaseDate": "2012-03-30" }, { "id": "12677", "description": "Release 1.8 Service Pack 1", "name": "Release 1.8.1", "archived": true, "released": true, "releaseDate": "2012-01-31" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-03-11T22:27:16.000+0000", "created": "2011-12-13T15:10:46.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "module_android", "qe-testadded", "regression" ], "versions": [ { "id": "12580", "description": "Dual Runtime 1.8.0", "name": "Release 1.8.0.1", "archived": true, "released": true, "releaseDate": "2011-12-22" } ], "issuelinks": [ { "id": "14384", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "inwardIssue": { "id": "63840", "key": "TIMOB-3208", "fields": { "summary": "Android: Heavyweight Windows Opened by Menu Items Often Cause Null Pointer Exceptions", "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" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "14204", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "83340", "key": "TIMOB-6439", "fields": { "summary": "Android: Menu: Rhino/v8: Adding onCreateOptionsMenu after window creation does not work", "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" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2012-03-11T22:27:16.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": "h1. Problem\r\nThe onCreateOptionsMenu is very brittle with heavyweight windows in master / 1.9.0 compared to 1.7.5.\r\n\r\nThese two use cases no longer work:\r\n* Ti.Android.currentActivity.onCreateOptionsMenu does not work.\r\n* win.activity.onCreateOptionsMenu after \"open\" is called but before the open event fires does not work.\r\n\r\nThese two use cases do work:\r\n* win.activity.onCreateOptionsMenu after the open event fires works.\r\n* win.activity.onCreateOptionsMenu before \"open\" is called.\r\n\r\nh2. Expected Behavior\r\nUse cases that worked in 1.7.5 should work here as well.\r\n\r\nh2. Example Code\r\nDrop the following in an app.js, and change the \"useApproach\" constant to the approach you want to see in action.\r\n{code:title=app.js}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: 'white',\r\n exitOnClose: true,\r\n navBarHidden: true\r\n});\r\n\r\nwin.add(Ti.UI.createLabel({\r\n text: 'Press your Android device\\'s menu button!',\r\n color: '#000'\r\n}));\r\n\r\nvar useApproach = 1;\r\nswitch (useApproach) {\r\n case 1:\r\n /*\r\n WORKS in 1.7.5. BROKEN in 1.8.0.1.\r\n Does not work. Ti.Android.currentActivity won't be accurate because we created a heavyweight window above.\r\n */\r\n win.open();\r\n Ti.Android.currentActivity.onCreateOptionsMenu = function (e) {\r\n e.menu.add({ title: 'Approach 1', itemId: 1 });\r\n };\r\n break;\r\n case 2:\r\n /*\r\n WORKS in 1.7.5. BROKEN in 1.8.0.1.\r\n Does not work. It looks like \"activity\" is not accurate yet.\r\n */\r\n win.open();\r\n win.activity.onCreateOptionsMenu = function (e) {\r\n e.menu.add({ title: 'Approach 2', itemId: 2 });\r\n };\r\n break;\r\n case 3:\r\n /*\r\n WORKS in both 1.7.5 and 1.8.0.1.\r\n It looks like \"activity\" is accurate before we call \"open\".\r\n */\r\n win.activity.onCreateOptionsMenu = function (e) {\r\n e.menu.add({ title: 'Approach 3', itemId: 2 });\r\n };\r\n win.open();\r\n break;\r\n case 4:\r\n /*\r\n WORKS in both 1.7.5 and 1.8.0.1.\r\n If we wait until the open event fires, we can then define the onCreateOptionsMenu properly.\r\n */\r\n win.addEventListener('open', function (evt) {\r\n win.activity.onCreateOptionsMenu = function (e) {\r\n e.menu.add({ title: 'Approach 4', itemId: 3 });\r\n };\r\n });\r\n win.open();\r\n break;\r\n}\r\n{code}\r\n\r\nh2. Console\r\nThe following shows up in the console regardless of if the menu shows up or not:\r\n{quote}\r\n12-13 15:09:27.082: E/imdg81(2450): IsShutDownStarted()\r\n12-13 15:09:27.086: I/KeyInputQueue(2450): Input event\r\n12-13 15:09:27.207: E/imdg81(2450): IsShutDownStarted()\r\n12-13 15:09:27.207: I/KeyInputQueue(2450): Input event\r\n{quote}", "attachment": [], "flagged": false, "summary": "Android: onCreateOptionsMenu Regressions in 1.9.0 from 1.7.5", "creator": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "environment": "REGRESSED in version=1.9.0 module_apiversion=2 timestamp=12/13/11 12:31 githash=761ae6b...\r\nWORKS in version=1.7.5 timestamp=11/02/11 17:00 githash=ab20af7", "comment": { "comments": [ { "id": "175994", "author": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "body": "[TIMOB-6439] took care of not being able to bind the options menu after the window's \"open\" event fires. But there are two other use cases identified here that do not work.", "updateAuthor": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "created": "2011-12-13T15:11:55.000+0000", "updated": "2011-12-13T15:11:55.000+0000" }, { "id": "177343", "author": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR ready here: https://github.com/appcelerator/titanium_mobile/pull/1104\r\n\r\nNote: case 1 should not work", "updateAuthor": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-12-27T16:42:46.000+0000", "updated": "2011-12-27T16:42:46.000+0000" }, { "id": "179140", "author": { "name": "wluu", "key": "wluu", "displayName": "Wilson Luu", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing bug. Verified fix on:\r\n\r\nSDK build: 1.9.0.v20120112104633\r\nRuntime: V8, Rhino\r\nTitanium Studio, build: 1.0.8.201201111843\r\nDevice: Droid 3 (2.3.4)\r\n\r\nNote: Verified with Allen that case 1 in the attached code will not behave the same as in 1.7.5; i.e. case 1 will not work for 1.8.X, 1.9.X and up because underlying changes have been made.", "updateAuthor": { "name": "wluu", "key": "wluu", "displayName": "Wilson Luu", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2012-01-12T16:56:18.000+0000", "updated": "2012-01-12T16:56:18.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }