{ "id": "62273", "key": "TIMOB-1641", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "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": "11225", "name": "Release 1.5.0", "archived": true, "released": true, "releaseDate": "2010-12-14" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T01:56:44.000+0000", "created": "2011-04-15T02:58:06.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "android", "feature" ], "versions": [], "issuelinks": [], "assignee": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-06-21T14:30:30.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": "{html}

Add support for overriding hardware buttons on Android devices.\nNot all devices will have all buttons. The following buttons should\nbe supported.

\n

Back, Camera, Focus (Half-Press of Camera), Search, Volume Up,\nand Volume Down.

\n

If an event is added for any of these buttons, it takes sole\nresponsibility for the action of the button. There will be no\nmethod to conditionally forward to the original handler. Removal of\nthe event listener will restore default handling.

\n

These handlers are allowed on Ti.UI.Window and will only\nfunction when attached to \"heavyweight\" windows. When\nTi.Android.Activity is released handlers will be\nsettable on Ti.Android.currentActivity.

\n

No additional data is passed in the event object.

\n

Example.

\n
\nwin.addEventListener('android:back', function(e) {\n    Ti.API.Info(\"Pressing Back Will Not Close The Activity/Window\");\n});\n
\n

Event Names:
\nandroid:back, android:camera, android:focus, android:search,\nandroid:volup, android:voldown

{html}", "attachment": [], "flagged": false, "summary": "Android: Support Event Handlers on Hardware Buttons", "creator": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "126249", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Sample used during dev. \nandroid-keyboard.js

{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:58:06.000+0000", "updated": "2011-04-15T02:58:06.000+0000" }, { "id": "126250", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

(from [b59fa44d54329b101c639252792968b10ba1113b])\n[#1641 state:fixed-in-qa] implemented. Events are\nfired on key up, down and repeat are ignored. Adding a listener\nshortcuts the key being passed on for default processing. \nhttp://github.com/appcelerator/titanium_mobile/commit/b59fa44d54329...

{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:58:06.000+0000", "updated": "2011-04-15T02:58:06.000+0000" }, { "id": "126251", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

(from [d62b2f33f5d5397758b06a33637e92ecd88694f6])\n[#1641 state:fixed-in-qa] implemented. Events are\nfired on key up, down and repeat are ignored. Adding a listener\nshortcuts the key being passed on for default processing. \nhttp://github.com/appcelerator/titanium_mobile/commit/d62b2f33f5d53...

{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:58:06.000+0000", "updated": "2011-04-15T02:58:06.000+0000" }, { "id": "126252", "author": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

thanks for the test content. Confirmed on simulator and device\n(though on the nexus I did not have a camera button, so camera and\nfocus were not tested).

{html}", "updateAuthor": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:58:07.000+0000", "updated": "2011-04-15T02:58:07.000+0000" }, { "id": "157320", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "For those that need it, here's a working example:\r\n\r\n{code:lang=javascript}\r\nTi.UI.setBackgroundColor('#000');\r\n\r\nvar tabGroup = Ti.UI.createTabGroup();\r\n\r\nvar win1 = Ti.UI.createWindow({\r\n backgroundColor:'white'\r\n});\r\nvar tab1 = Ti.UI.createTab({\r\n title:'Tab 1',\r\n window:win1\r\n});\r\n\r\nvar label1 = Ti.UI.createLabel({\r\n color:'#999',\r\n text:'click me',\r\n top:20\r\n});\r\nwin1.add(label1);\r\n\r\nlabel1.addEventListener('click', function(){\r\n var winHeavy = Ti.UI.createWindow({\r\n title:'Heavywight Window',\r\n backgroundColor:'blue',\r\n fullscreen:false // this causes the window to be heavyweight\r\n });\r\n winHeavy.addEventListener('android:back', function(e) {\r\n Ti.API.info(\"Pressing Back Will Not Close The Activity/Window\");\r\n });\r\n var label2 = Ti.UI.createLabel({\r\n color:'white',\r\n text:'Pressing the back button will test the Android back button event. Click this label to close this heavyweight window',\r\n top:20\r\n });\r\n winHeavy.add(label2);\r\n winHeavy.open();\r\n});\r\nvar win2 = Ti.UI.createWindow({\r\n title:'Tab 2',\r\n backgroundColor:'green'\r\n});\r\nvar tab2 = Ti.UI.createTab({\r\n title:'Tab 2',\r\n window:win2\r\n});\r\n\r\ntabGroup.addTab(tab1);\r\ntabGroup.addTab(tab2);\r\n\r\ntabGroup.open();\r\n{code}", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-06-21T14:30:30.000+0000", "updated": "2011-06-21T14:30:30.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }