[TIMOB-1653] Android: Need support for Android long press event
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-07-19T17:03:30.000+0000 |
Affected Version/s | Release 1.6.2 |
Fix Version/s | Sprint 2011-29, Release 1.8.0 |
Components | Android |
Labels | klist |
Reporter | Dawson Toth |
Assignee | Bill Dawson |
Created | 2011-04-15T02:58:30.000+0000 |
Updated | 2012-02-08T17:55:31.000+0000 |
Description
It's not currently possible to add an event listener for a 'long press' event on Android (pressing and holding the finger on a widget for a second or two), which is very frequently used for things like context menus on Android.
In StatusNet Mobile's accounts list we're trying to use a long-click to trigger a context menu for controls such as deletion to provide a more native-feeling interface (on iPhone we use the TableView's native editing mode, which is iOS-specific).
Since the native event isn't available, for now we're trying to emulate it by listening for touchstart, touchend etc. This seems to interfere with the natural behavior of the tableview rows; here's the entry in our bug tracker for this:
http://status.net/open-source/issues/2571">http://status.net/open-source/issues/2571
On the Android side, SimpleGestureListener has an onLongPress stub method which could be overridden to fire a 'longpress' event; it looks like long press support might need to be activated on the GestureDetector by calling setIsLongpressEnabled (I'm uncertain what the default value is, but if it's on scroll events don't work, so perhaps it should only be set when a listener is present):
http://developer.android.com/reference/android/view/GestureDetector.SimpleOnGestureListener.html"> http://developer.android.com/reference/android/view/GestureDetector...
http://developer.android.com/reference/android/view/GestureDetector.html"> http://developer.android.com/reference/android/view/GestureDetector...
Attachments
File | Date | Size |
---|---|---|
app.js | 2011-07-18T16:06:42.000+0000 | 3771 |
What's the status of this?
Updated priority to match this tickets dependency, [TIMOB-3492]. Both have a decent amount of interest from customers now.
Sample Code
The following code is an example of how we could utilize the long press from JavaScript. Drop it in an app.js and long press the label! (Hold down on the label for a couple of seconds, and an alert would be displayed.)Though we can (and will, via this ticket) provide longpress events, isn't the real issue that we should support registering context menus on views? Because for the real native experience you'd want a true Android context menu.
@Bill: yup; [TIMOB-3492]
longpress and longclick added. TESTING NOTES: * KitchenSink: Base UI -> Window Events has a longpress test. * KitchenSink: Base UI -> Views -> Table Views -> Basic has longclick events on the tableview rows. * The attached app.js is the test app I used while developing this. It's got a few touch-related events on each of the views/controls that it displays. But it only shows the results via log messages, so you'll have to use logcat to use it.
The app I used for testing while developing. (see attached app.js)
code review and functional test.
What about long press for iOS?
longpress was added to iOS in TIMOB-4508
But no longpress event at the TableView level? Please add it.
Closing issue Tested with Ti Studio build 1.0.8.201201262211 Ti Mob SDK 1.9.0.v20120207171634 OSX Lion 10.7.3 Nexus S OS 2.3.6 v8/rhino Verified that long press events are implemented and work correctly