{ "id": "89745", "key": "TIMOB-8648", "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": "14137", "description": "Release 2.1.3", "name": "Release 2.1.3", "archived": true, "released": true, "releaseDate": "2012-10-03" }, { "id": "13505", "description": "Release 3.0.0", "name": "Release 3.0.0", "archived": true, "released": true, "releaseDate": "2012-12-14" }, { "id": "14098", "description": "Sprint 2012-18 API", "name": "Sprint 2012-18 API", "archived": true, "released": true, "releaseDate": "2012-09-10" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-09-04T13:45:49.000+0000", "created": "2012-04-10T09:14:50.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "SupportTeam", "android", "api", "qe-review", "qe-testadded", "titanbeta" ], "versions": [ { "id": "13273", "description": "Release 2.0.2", "name": "Release 2.0.2", "archived": false, "released": true, "releaseDate": "2012-05-31" }, { "id": "13272", "description": "Release 2.0.1", "name": "Release 2.0.1", "archived": true, "released": true, "releaseDate": "2012-04-16" }, { "id": "14096", "description": "Release 2.1.2", "name": "Release 2.1.2", "archived": true, "released": true, "releaseDate": "2012-08-31" } ], "issuelinks": [ { "id": "29463", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "115554", "key": "TIMOB-14130", "fields": { "summary": "Android: Window events, windows in the Tab and test", "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": "Medium", "id": "3" }, "issuetype": { "id": "5", "description": "The sub-task of the issue", "name": "Sub-task", "subtask": true } } } } ], "assignee": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2013-06-10T23:19:29.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": "h4.Problem\r\nOn a window with a TextField, tapping the TextField to bring up the keyboard, then tapping the android:back button closes the window. Doing the same thing on the emulator simply dismisses the keyboard.\r\n\r\nh4.Actual Behavior\r\nClicking the android:back button when the keyboard is displayed closes the window (because the 'android:back' event is fired).\r\n\r\nh4.Expected Behavior\r\nClicking the android:back button when the keyboard is displayed should just dismiss the keyboard, and not fire the 'android:back' event.\r\n\r\nh4. Original Testcase\r\napp.js\r\n{code}\r\nvar win1=Ti.UI.createWindow({\r\n layout:'vertical',\r\n url:'win1.js',\r\n backgroundColor:'gray',\r\n exitOnClose:true,\r\n navBarHidden:true\r\n });\r\nwin1.open();\r\n{code}\r\n\r\n*NOTE*: The \"android:back\" event is buggy on some devices. It may never fire at all.\r\n You may need to try various devices to reproduce the failure case.\r\n To verify the expected behavior change the event to \"androidback\" (no colon).\r\n\r\nwin1.js\r\n{code}\r\nvar win1=Ti.UI.currentWindow;\r\n\r\nvar TheLabel=Ti.UI.createLabel({\r\n color:'black',\r\n text:'Click the edit, then hit the back button. Keyboard should be dismissed, but the window should not close.',\r\n width:'auto'\r\n });\r\nwin1.add(TheLabel);\r\n\r\nvar TheTextField=Ti.UI.createTextField(\r\n {color:'black',\r\n width:150\r\n });\r\nwin1.add(TheTextField);\r\n\r\nfunction AndroidBackClicked()\r\n{\r\n win1.close();\r\n}\r\nwin1.addEventListener('android:back',AndroidBackClicked);\r\n{code}\r\n\r\nh4. Test case to verify 'androidback' does not fire when dismissing keyboard.\r\n{code:javascript}\r\nvar win = Ti.UI.createWindow();\r\nwin.add(Ti.UI.createTextField({width: '75%'}));\r\n\r\nwin.addEventListener('androidback', function() {\r\n alert('back event fired!');\r\n});\r\n\r\nwin.open();\r\n\r\n{code}\r\n\r\n1. Run application on a device that uses a soft keyboard.\r\n2. Focus the textfield to bring up the soft keyboard.\r\n3. Hit the \"back\" button on the device. You should see NO alert.\r\n4. Hit the \"back\" button again. You SHOULD see an alert.\r\n\r\nFail: You see two alerts (one for each \"back\" press).\r\nPass: You only get an alert in step 4.\r\n\r\nh4. Test: Closing a series of LWs using the \"androidback\" event.\r\n{code:javascript}\r\nfunction openWindows() {\r\n ['blue', 'red', 'white'].forEach(function(color) {\r\n var win = Ti.UI.createWindow({backgroundColor: color});\r\n win.addEventListener('androidback', function() {\r\n alert('closing window');\r\n win.close();\r\n });\r\n win.open();\r\n });\r\n}\r\n\r\nvar mainWindow = Ti.UI.createWindow();\r\n\r\nvar button = Ti.UI.createButton({title: 'Open windows'});\r\nbutton.addEventListener('click', openWindows);\r\nmainWindow.add(button);\r\n\r\nmainWindow.open();\r\n{code}\r\n\r\n1. Run application and click \"Open windows\".\r\n2. Hit the back button. You should see an alert and the window should close.\r\n3. Repeat step 2 for each window until all of them are closed and you are back to the main window.\r\n", "attachment": [], "flagged": false, "summary": "Android: android:back listener reacts when using \"back\" to dismiss keyboard", "creator": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "environment": "- Android 2.2 (device only...HTC Aria for example) - Happening in Galaxy Note and HTC ChaCha as well. \r\n- Titanium Mobile SDK 2.0.0.v20120325213306\r\n- Titanium Studio 1.0.9.201202141208\r\n", "comment": { "comments": [ { "id": "208651", "author": { "name": "eventreporter", "key": "eventreporter", "displayName": "Mihai Lan", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This is a very important bug!", "updateAuthor": { "name": "eventreporter", "key": "eventreporter", "displayName": "Mihai Lan", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-07-20T07:19:24.000+0000", "updated": "2012-07-20T07:19:24.000+0000" }, { "id": "216224", "author": { "name": "krowley", "key": "krowley", "displayName": "Karl Rowley", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Can't reproduce using Android 2.2 emulator. I haven't yet been\r\nable to locate an Android 2.2 device that can reproduce this.", "updateAuthor": { "name": "krowley", "key": "krowley", "displayName": "Karl Rowley", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-27T11:19:29.000+0000", "updated": "2012-08-27T11:19:29.000+0000" }, { "id": "216244", "author": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "body": "Mauro added that he reproduced it on a Galaxy Note and GaGa.\r\n\r\nIn my testing, it happens on an HTC Aria. I would guess that all HTCs would do it, but I haven't tested that guess.\r\n", "updateAuthor": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "created": "2012-08-27T11:57:12.000+0000", "updated": "2012-08-27T11:57:12.000+0000" }, { "id": "216276", "author": { "name": "krowley", "key": "krowley", "displayName": "Karl Rowley", "active": true, "timeZone": "America/Los_Angeles" }, "body": "QE doesn't have any of the devices listed to reproduce it,\r\nand I haven't been able to locate any of them in engineering\r\neither.\r\n", "updateAuthor": { "name": "krowley", "key": "krowley", "displayName": "Karl Rowley", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-27T13:37:15.000+0000", "updated": "2012-08-27T13:37:15.000+0000" }, { "id": "216282", "author": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "body": "I might be willing to ship my HTC Aria to you for testing, if I could get it back relatively quickly and if this would prevent this ticket from being prematurely closed.", "updateAuthor": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "created": "2012-08-27T13:44:31.000+0000", "updated": "2012-08-27T13:44:31.000+0000" }, { "id": "216369", "author": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I would argue the current behavior is correct. The \"android:back\" event is low level and is\r\nalways fired when the button is pressed. Calling close() on the window shouldn't be required if\r\nit is hosted by its own activity (aka \"heavy weight\"). The window/activity should be destroyed by Android\r\nautomatically.", "updateAuthor": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-27T19:22:55.000+0000", "updated": "2012-08-27T19:22:55.000+0000" }, { "id": "216372", "author": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Can we get some more information on the use case from the customer why they need this \"back\" button callback?\r\nThis would allow us to provide the best solution.\r\n\r\nBy the way the \"android:\" events are marked as deprecated in the implementation.\r\nWe should avoid their usage and look to non-platform specific solutions if possible.", "updateAuthor": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-27T19:33:16.000+0000", "updated": "2012-08-27T19:38:30.000+0000" }, { "id": "216408", "author": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "body": "Josh, the \"android:back\" event is *not* being fired on the emulator when the Back button is pressed. It *is* being fired on the device in that situation. In testcase code, AndroidBackClicked is calling win1.close() unconditionally, but in the actual app, there's a condition in there that keeps the window from closing if an invalid state is detected (for example, incomplete or inconsistent settings). Please do not judge testcase code for this kind of thing, and remember that testcases have been simplified down significantly.\r\n\r\nYou say that the \"android:\" events are deprecated, and that we should be using a non-platform specific solution. Is there such a thing for handling the press of the Back button?\r\n\r\nAnyway, I think the real issue here is that the \"android:back\" event shouldn't fire on the window when it wasn't pressed on the window...it was pressed to remove the keyboard.", "updateAuthor": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "created": "2012-08-28T05:31:54.000+0000", "updated": "2012-08-28T05:31:54.000+0000" }, { "id": "216700", "author": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Shawn,\r\n\r\nThank you for providing the additional information.\r\nLooking at the implementation further is using an older style\r\nof intercepting these \"back\" events. It seems if we use the newer API (onBackPressed)\r\nthe \"expected\" behavior is seen. So this might be the solution we end up merging in.\r\n\r\nAs for the deprecation to be more specific the name is deprecated. The name is being changed\r\nto \"androidback\" in the next major release. Both will likely remain working for some time to allow\r\ndevelopers to transition their code.", "updateAuthor": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-28T20:48:07.000+0000", "updated": "2012-08-28T20:48:07.000+0000" }, { "id": "216705", "author": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Created [PR #2851|https://github.com/appcelerator/titanium_mobile/pull/2851] to modify the new \"androidback\"\r\nevent to use Activity.onBackPressed() to dispatch the event.", "updateAuthor": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-28T22:07:12.000+0000", "updated": "2012-08-28T22:07:12.000+0000" }, { "id": "217049", "author": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "body": "Josh, how far back in the Ti mobile SDK does \"androidback\" work (as opposed to \"android:back\")? I'm currently using 2.1.0.GA. Can I change all of my \"android:back\"s to \"androidback\" now?", "updateAuthor": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "created": "2012-08-30T12:44:58.000+0000", "updated": "2012-08-30T12:44:58.000+0000" }, { "id": "217050", "author": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Shawn, if we back port this change it will likely introduce the new event into the 2.1.x series.\r\nThis isn't final yet, but we will give a heads up on our action once we decide.", "updateAuthor": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-30T12:50:18.000+0000", "updated": "2012-08-30T12:50:18.000+0000" }, { "id": "217217", "author": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Updated ticket with another test case which verifies the back event\r\nis always fired onto the top window of the current activity.", "updateAuthor": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-31T13:07:49.000+0000", "updated": "2012-08-31T13:07:49.000+0000" }, { "id": "217464", "author": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The fix for this issue causes a crash when pressing back on the root activity.\r\n\r\nSteps to repro:\r\n\r\n1. Run this code:\r\n{code}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor:'white',\r\n title:'test',\r\n modal:true\r\n});\r\n \r\nwin.open();\r\n{code}\r\n\r\n2. Press back twice. Observe NPE.\r\n\r\n\r\nThis looks like a simple NP check. Reopening bug.", "updateAuthor": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-09-04T11:31:07.000+0000", "updated": "2012-09-04T11:31:07.000+0000" }, { "id": "217476", "author": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Created [PR #2865|https://github.com/appcelerator/titanium_mobile/pull/2865] to resolve regression.", "updateAuthor": { "name": "joshroesslein", "key": "joshroesslein", "displayName": "Josh Roesslein", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-09-04T12:25:08.000+0000", "updated": "2012-09-04T12:25:08.000+0000" }, { "id": "217626", "author": { "name": "tsmolich", "key": "tsmolich", "displayName": "Tamila Smolich", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing as fixed. Tested and verified on:\r\nTitanium Studio, build: 2.1.2.201208301612\r\nTitanium SDK, build: 2.1.3.v20120904163110\r\nOS: Mac OS X Lion 10.7.4\r\nDevice: HTC Evo (4.0.3)\r\n\r\nOriginal test case:\r\nWorks fine in 2.0.0.GA and 2.1.3.v20120904163110 if event listener changed from \"android:back\" to \"androidback\".\r\n\r\nTest case to verify 'androidback' does not fire when dismissing keyboard.\r\nFail case in 2.0.0.GA: Alert \"Back event fired\" does not appear after second click the \"back\" button.\r\nFixed result in 2.1.3.v20120904163110: Alert appears only after second click the \"back\" button, as expected.\r\n\r\nTest: Closing a series of LWs using the \"androidback\" event.\r\nFail case in 2.0.0.GA: Clicking the android \"back\" button brings you back to the main window without any alerts.\r\nFixed result in 2.1.3.v20120904163110: Getting an alert every time before all windows are closed.\r\n\r\nNote: All fails were reproducible only on HTC device.", "updateAuthor": { "name": "tsmolich", "key": "tsmolich", "displayName": "Tamila Smolich", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-09-05T11:19:18.000+0000", "updated": "2012-09-05T11:19:18.000+0000" } ], "maxResults": 20, "total": 20, "startAt": 0 } } }