[TIMOB-1641] Android: Support Event Handlers on Hardware Buttons
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-04-17T01:56:44.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.5.0 |
Components | Android |
Labels | android, feature |
Reporter | Don Thorp |
Assignee | Don Thorp |
Created | 2011-04-15T02:58:06.000+0000 |
Updated | 2011-06-21T14:30:30.000+0000 |
Description
Add support for overriding hardware buttons on Android devices. Not all devices will have all buttons. The following buttons should be supported.
Back, Camera, Focus (Half-Press of Camera), Search, Volume Up, and Volume Down.
If an event is added for any of these buttons, it takes sole responsibility for the action of the button. There will be no method to conditionally forward to the original handler. Removal of the event listener will restore default handling.
These handlers are allowed on Ti.UI.Window and will only
function when attached to "heavyweight" windows. When
Ti.Android.Activity
is released handlers will be
settable on Ti.Android.currentActivity
.
No additional data is passed in the event object.
Example.
win.addEventListener('android:back', function(e) {
Ti.API.Info("Pressing Back Will Not Close The Activity/Window");
});
Event Names:
android:back, android:camera, android:focus, android:search,
android:volup, android:voldown
Sample used during dev. http://github.com/donthorp/androidng/blob/b078177e2386bf4149fb7f37b607147921eb21bf/assets/Resources/android-keyboard.js"> android-keyboard.js
(from [b59fa44d54329b101c639252792968b10ba1113b]) [#1641 state:fixed-in-qa] implemented. Events are fired on key up, down and repeat are ignored. Adding a listener shortcuts the key being passed on for default processing. http://github.com/appcelerator/titanium_mobile/commit/b59fa44d54329b101c639252792968b10ba1113b"> http://github.com/appcelerator/titanium_mobile/commit/b59fa44d54329...
(from [d62b2f33f5d5397758b06a33637e92ecd88694f6]) [#1641 state:fixed-in-qa] implemented. Events are fired on key up, down and repeat are ignored. Adding a listener shortcuts the key being passed on for default processing. http://github.com/appcelerator/titanium_mobile/commit/d62b2f33f5d5397758b06a33637e92ecd88694f6"> http://github.com/appcelerator/titanium_mobile/commit/d62b2f33f5d53...
thanks for the test content. Confirmed on simulator and device (though on the nexus I did not have a camera button, so camera and focus were not tested).
For those that need it, here's a working example: