{ "id": "114981", "key": "TIMOB-14003", "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": "16593", "description": "Release 4.0.0", "name": "Release 4.0.0", "archived": false, "released": true, "releaseDate": "2015-05-21" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2015-03-12T18:15:08.000+0000", "created": "2013-05-27T12:52:01.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "android", "picker" ], "versions": [], "issuelinks": [], "assignee": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "updated": "2015-03-12T18:15: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": "The callback of showDatePickerDialog and showTimePickerDialog always return with the cancel property set to false. It doesn't matter if you press the back button or press outside the modal dialog, cancel gets never true.\r\n\r\nFurthermore, if you click on the Set/Ok/Done/Ready button, the callback is called twice.\r\n\r\nNote that in the picker dialog, we have only a single button \"Set\", so no Cancel button. This is fine as you should be able to cancel dialog with the back button. Clicking the back button fires wrongly a success (cancel=false) event.\r\n\r\n{code:title=Example code|borderStyle=solid}\r\n\t\tvar picker = Ti.UI.createPicker( {\r\n\t\t type : Ti.UI.PICKER_TYPE_TIME\r\n\t\t});\r\n\t\t \r\n\t\tpicker.showDatePickerDialog({\r\n\t\t callback: function(e) {\r\n\t\t if (e.cancel) {\r\n\t\t Ti.API.info('user canceled dialog');\r\n\t\t } else {\r\n\t\t Ti.API.info('user selected date: ' + e.value);\r\n\t\t }\r\n\t\t }\r\n\t\t});\r\n{code} \r\n\r\nProblem does not occur on older Android devices, like Android 2.3.\r\n\r\nSee https://github.com/markruys/titanium-test-picker for a working project to reproduce.", "attachment": [ { "id": "39117", "filename": "Dialog.jpg", "author": { "name": "mark.ruys@in2sports.net", "key": "mark.ruys@in2sports.net", "displayName": "Mark Ruys", "active": true, "timeZone": "Europe/Berlin" }, "created": "2013-05-28T08:13:44.000+0000", "size": 46950, "mimeType": "image/jpeg" }, { "id": "39118", "filename": "Logcat.jpg", "author": { "name": "mark.ruys@in2sports.net", "key": "mark.ruys@in2sports.net", "displayName": "Mark Ruys", "active": true, "timeZone": "Europe/Berlin" }, "created": "2013-05-28T08:14:15.000+0000", "size": 47572, "mimeType": "image/jpeg" } ], "flagged": false, "summary": "Android: showDatePickerDialog and showTimePickerDialog can't be cancelled", "creator": { "name": "mark.ruys@in2sports.net", "key": "mark.ruys@in2sports.net", "displayName": "Mark Ruys", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "clathrop", "key": "clathrop", "displayName": "Carter Lathrop", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Android 4.2.2 (probably Android 4+)\r\nGalaxy Nexus\r\nTitanium SDK 3.1.0, 2.1.4, 2.0.1, etc", "closedSprints": [ { "id": 258, "state": "closed", "name": "2014 Sprint 24 SDK", "startDate": "2014-11-24T22:28:25.425Z", "endDate": "2014-12-06T01:00:00.000Z", "completeDate": "2014-12-08T17:21:15.171Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "254122", "author": { "name": "clathrop", "key": "clathrop", "displayName": "Carter Lathrop", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Mark,\n\nWhen submitting a bug report it is required that you provide a full test, one that is easily copied and pasted into an app.js to clearly show the issue at hand. (Please refer to: https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report for more information) That said, I have created a small test case to try and duplicate this issue, please see below:\n\n{code}\nvar win = Ti.UI.createWindow({\n backgroundColor:'gray'\n});\n \nvar picker = Ti.UI.createPicker( {\n type : Ti.UI.PICKER_TYPE_TIME\n});\n \npicker.showDatePickerDialog({\n callback: function(e) {\n if (e.cancel) {\n alert('user canceled dialog');\n } else {\n alert('user selected date: ' + e.value);\n }\n }\n});\n\nwin.add(picker);\nwin.open();\n{code}\n\nThis code is working as expected; cancel event is firing on 'Cancel' button press as well as back button press. I am using Ti SDK 3.2.0 on a Galaxy S3 running 4.1.2. Can you please let me know if this code is not working for you? And provide any more information needed to replicate your issue?\n\nThanks,\nCarter", "updateAuthor": { "name": "clathrop", "key": "clathrop", "displayName": "Carter Lathrop", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-05-27T20:10:24.000+0000", "updated": "2013-05-27T20:10:24.000+0000" }, { "id": "254199", "author": { "name": "mark.ruys@in2sports.net", "key": "mark.ruys@in2sports.net", "displayName": "Mark Ruys", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hi Carter,\n\nToo bad you can't reproduce. To prove the bug, I created a repository on Github with a complete Titanium project ready for you to checkout: https://github.com/markruys/titanium-test-picker\n\nSee also the screenshots logcat.png and device-2013-05-28-094042.png. The logcat is generated by:\n\n1. Start the app;\n2. open picker & clicking outside the dialog;\n3. open picker & clicking on the back button;\n4. open picker & clicking on the Done button.\n\nExpected output:\n\n\t05-28 09:39:58.026: I/TiAPI(1779): user canceled dialog\n\t05-28 09:40:12.206: I/TiAPI(1779): user canceled dialog\n\t05-28 09:40:56.717: I/TiAPI(1779): user selected date: Tue May 28 2013 09:40:56 GMT+0200 (CEST)\n\nBut got output:\n\n\t05-28 09:39:58.026: I/TiAPI(1779): user selected date: Tue May 28 2013 09:39:57 GMT+0200 (CEST)\n\t05-28 09:40:12.206: I/TiAPI(1779): user selected date: Tue May 28 2013 09:40:12 GMT+0200 (CEST)\n\t05-28 09:40:56.717: I/TiAPI(1779): user selected date: Tue May 28 2013 09:40:56 GMT+0200 (CEST)\n\t05-28 09:40:56.757: I/TiAPI(1779): user selected date: Tue May 28 2013 09:40:56 GMT+0200 (CEST)\n\n\nTested on:\n\n- Titanium SDK 3.1.0, Android SDK 4.1.1 emulator\n- Titanium SDK 3.1.0, Android 4.2.2 Galaxy Nexus\n- Titanium SDK 2.1.4, Android 4.2.2 Galaxy Nexus\n- Titanium SDK 2.0.1, Android 4.2.2 Galaxy Nexus\n\n\nThis you should enable you to reproduce it. You used Ti SDK 3.2.0, but that's not GA, so please use the latested GA release.", "updateAuthor": { "name": "mark.ruys@in2sports.net", "key": "mark.ruys@in2sports.net", "displayName": "Mark Ruys", "active": true, "timeZone": "Europe/Berlin" }, "created": "2013-05-28T08:12:30.000+0000", "updated": "2013-05-28T08:12:30.000+0000" }, { "id": "254314", "author": { "name": "clathrop", "key": "clathrop", "displayName": "Carter Lathrop", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hm, that's weird. I tested your git project on emulator 4.1.2 and was able to reproduce. It is interesting the default date picker in the emulator did not have a cancel button associated with it though, though it does on my device (Galaxy S3). So this is indeed a bug but only seen on certain android versions and not others. Moving to Ti-Mobile. Thanks for bringing this to our attention.\n\nFor clarity, Bug reproduced on:\nAndroid Emulator 4.1.2\nTi SDK 3.1.0GA\nTitanium Studio, build: 3.1.0.201303032333\n\nBut not seen on:\nGalaxy S3 4.1.2\nTi SDK 3.1.0GA\nTitanium Studio, build: 3.1.0.201303032333", "updateAuthor": { "name": "clathrop", "key": "clathrop", "displayName": "Carter Lathrop", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-05-28T17:51:21.000+0000", "updated": "2013-05-28T17:51:21.000+0000" }, { "id": "277867", "author": { "name": "jialhe85@gmail.com", "key": "jialhe85@gmail.com", "displayName": "David He", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I have the same issue that needs to be resolved urgently. Any progress on that?\r\n", "updateAuthor": { "name": "jialhe85@gmail.com", "key": "jialhe85@gmail.com", "displayName": "David He", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-11-03T02:02:24.000+0000", "updated": "2013-11-03T02:02:24.000+0000" }, { "id": "332709", "author": { "name": "xcash", "key": "xcash", "displayName": "Paolo Casciello", "active": true, "timeZone": "Europe/Berlin" }, "body": "Guys this bug is open since last year! Any progress on this?? It's quite annoying to discover it when docs doesn't mention it and you based an interface on this dialog... :/\r\n\r\nPlease let us know...", "updateAuthor": { "name": "xcash", "key": "xcash", "displayName": "Paolo Casciello", "active": true, "timeZone": "Europe/Berlin" }, "created": "2014-11-18T15:17:37.000+0000", "updated": "2014-11-18T15:17:37.000+0000" }, { "id": "332713", "author": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I've placed this into triage for review in the near future.", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-11-18T15:29:31.000+0000", "updated": "2014-11-18T15:29:31.000+0000" }, { "id": "332722", "author": { "name": "xcash", "key": "xcash", "displayName": "Paolo Casciello", "active": true, "timeZone": "Europe/Berlin" }, "body": "For anyone landing here for this bug, following is a workaround working almost like the native Android dialog.\r\n\r\n{code:javascript}\r\nfunction showTimePickerDialog(opt, callback) {\r\n\tvar picker = Ti.UI.createPicker({\r\n\t\ttype: Ti.UI.PICKER_TYPE_TIME,\r\n\t\tformat24: true,\r\n\t\tvalue: opt.value\r\n\t});\r\n\t\r\n\tvar ad = Ti.UI.createAlertDialog({\r\n\t\tandroidView: picker,\r\n\t\ttitle: opt.title,\r\n\t\tcancel: 0,\r\n\t\tbuttonNames: [ '', opt.okButtonTitle ]\r\n\t});\r\n\tad.addEventListener('click', function (e) {\r\n\t\tconsole.log('e.cancel = ' + e.cancel);\r\n\t\tif (!(e.index === e.source.cancel)) {\r\n\t\t\tcallback(picker.getValue());\r\n\t\t}\r\n\t});\r\n\tad.show();\r\n\t\r\n}\r\n{code}\r\n\r\nYou can use it as follows\r\n\r\n{code:javascript}\r\n\tshowTimePickerDialog({\r\n\t\ttitle: 'MyTitle',\r\n\t\tvalue: new Date(),\r\n\t\tokButtonTitle: 'Send',\r\n\t},\r\n\tfunction (value) {\r\n\t\tTi.API.info(value);\r\n\t});\r\n{code}\r\n\r\nThe first buttonNames element is the cancel button. Passing it empty ('') allows you to have an invisible cancel button and thus the e.cancel property is set to true. In this case i use the 'cross-platform way' to check the cancel button.\r\n\r\nHope this helps.\r\n\r\nFor Ingo, *the bug is present even in the whole AlertDialog* which doesn't set e.cancel = true in the event no cancel button is provided!\r\n\r\n\r\n", "updateAuthor": { "name": "xcash", "key": "xcash", "displayName": "Paolo Casciello", "active": true, "timeZone": "Europe/Berlin" }, "created": "2014-11-18T16:55:47.000+0000", "updated": "2014-11-18T16:55:47.000+0000" }, { "id": "333592", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "PR: https://github.com/appcelerator/titanium_mobile/pull/6394", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2014-11-25T09:46:12.000+0000", "updated": "2014-11-25T09:46:12.000+0000" }, { "id": "333593", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "Sample app.js:\r\n{code}\r\n// this sets the background color of the master UIView (when there are no windows/tab groups on it)\r\nTitanium.UI.setBackgroundColor('#000');\r\n\r\n// create tab group\r\nvar tabGroup = Titanium.UI.createTabGroup();\r\n\r\n\r\n//\r\n// create base UI tab and root window\r\n//\r\nvar win1 = Titanium.UI.createWindow({ \r\n title:'Tab 1',\r\n backgroundColor:'#fff'\r\n});\r\nvar tab1 = Titanium.UI.createTab({ \r\n icon:'KS_nav_views.png',\r\n title:'Tab 1',\r\n window:win1\r\n});\r\n\r\nvar button1 = Titanium.UI.createButton({\r\n\tcolor:'#999',\r\n\ttitle:'Open time picker',\r\n\tfont:{fontSize:20,fontFamily:'Helvetica Neue'},\r\n\ttextAlign:'center',\r\n\twidth:'auto'\r\n});\r\n\r\nwin1.add(button1);\r\n\r\nbutton1.addEventListener('click', function() {\r\n\tvar picker = Ti.UI.createPicker( {\r\n\t type : Ti.UI.PICKER_TYPE_TIME\r\n\t});\r\n\t \r\n\tpicker.showTimePickerDialog({\r\n\t callback: function(e) {\r\n\t if (e.cancel) {\r\n\t Ti.API.info('user canceled dialog');\r\n\t } else {\r\n\t Ti.API.info('user selected date: ' + e.value);\r\n\t }\r\n\t }\r\n\t});\r\n});\r\n\r\n\r\n\r\n\r\n//\r\n// create controls tab and root window\r\n//\r\nvar win2 = Titanium.UI.createWindow({ \r\n title:'Tab 2',\r\n backgroundColor:'#fff'\r\n});\r\nvar tab2 = Titanium.UI.createTab({ \r\n icon:'KS_nav_ui.png',\r\n title:'Tab 2',\r\n window:win2\r\n});\r\n\r\nvar label2 = Titanium.UI.createLabel({\r\n\tcolor:'#999',\r\n\ttext:'I am Window 2',\r\n\tfont:{fontSize:20,fontFamily:'Helvetica Neue'},\r\n\ttextAlign:'center',\r\n\twidth:'auto'\r\n});\r\n\r\n\r\n\r\nvar button2 = Titanium.UI.createButton({\r\n\tcolor:'#999',\r\n\ttitle:'Open date picker',\r\n\tfont:{fontSize:20,fontFamily:'Helvetica Neue'},\r\n\ttextAlign:'center',\r\n\twidth:'auto'\r\n});\r\n\r\nwin2.add(button2);\r\n\r\nbutton2.addEventListener('click', function() {\r\n\tvar picker = Ti.UI.createPicker( {\r\n\t type : Ti.UI.PICKER_TYPE_DATE\r\n\t});\r\n\t \r\n\tpicker.showDatePickerDialog({\r\n\t callback: function(e) {\r\n\t if (e.cancel) {\r\n\t Ti.API.info('user canceled dialog');\r\n\t } else {\r\n\t Ti.API.info('user selected date: ' + e.value);\r\n\t }\r\n\t }\r\n\t});\r\n});\r\n\r\n\r\n//\r\n// add tabs\r\n//\r\ntabGroup.addTab(tab1); \r\ntabGroup.addTab(tab2); \r\n\r\n\r\n// open tab group\r\ntabGroup.open();\r\n{code}", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2014-11-25T09:46:45.000+0000", "updated": "2014-11-25T09:46:45.000+0000" }, { "id": "345858", "author": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Verified fixed using:\r\n\r\nTitanium SDK 4.0.0.v20150312092612\r\nStudio 4.0.0.201503062102\r\nCLI 3.4.2\r\nXcode 6.2\r\nNode 0.12\r\n\r\nOn:\r\nNote 2, Android 4.3\r\nNexus 5, Android 5\r\n\r\nAble to cancel picker dialog without issue.", "updateAuthor": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2015-03-12T17:54:54.000+0000", "updated": "2015-03-12T17:54:54.000+0000" } ], "maxResults": 11, "total": 11, "startAt": 0 } } }