I am new to Android development and am working on an accessibility research project for blind people (Jelly Bean API level 17 project). I have been experimenting with some gestures and the Two-Finger-Drag gesture has been really tough to implement. The following image captures what I actually require quite well.
I want the blind user to drag two fingers across horizontally (anywhere on the screen) and he would obtain an Audio output of the text he/she typed in the EditText. Also according to the distance the two fingers travel while dragging, we output each word separately.(Example below)
Example: If the user types "Today is a good day" and drags his finger (x value) by (say) 10 units to Left we output "good day" but if he drags it say 20 units to Left we output "a good day", for 30 units to Left "is a good day" etc etc.
I stumbled across which seems to detect two-finger touch:
TouchEvent(MotionEvent event)
Also this tutorial on detecting multiple touches seems promising, but I need it to work for touch and drag which I am not sure can be implemented like this.
Any new suggestions to implement this or pointers to tutorials that can help would be great!
Thanks in advance, Adit
I don't know how relevant adding an answer now would be to such an old question but I have been developing a library to support basic 1 and 2 finger gestures on Android with a very very simple drop in functionality.
Most gestures can be set as easily as
It is open source as well as available to be downloaded as a .jar
Okay So thanks to Gabe here and numerous blogs on this, I have found a solution to my question!
First I initialized my variables in the "Activity" class
Next, Inside the onCreate():
Now define the function handleTouch(m) as follows, it outputs the current position of the "Two-finger-touch" along with the initial position of the touch:
There you have it! The "Two-finger-drag" gesture finally implemented. Looks, like I can wrte a tiny blog post on it as well!! :)
Touch and drag is a series of events. First you have a down, then you have 1 or more moves, then you have an up. You detect a starting point on the down, then the drag occurs on the moves. THe drag stops on an up.
To do a 2 finger drag, only pay attention to drags if MotionEvent.getPointerCount() ==2.