Skip to content

Commit 04834d3

Browse files
authored
Create README.md
1 parent d6d3c78 commit 04834d3

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Multi-Touch Gestures
2+
Multi-Touch Gestures(Java) for detecting custom gestures
3+
4+
![alt text](screens/300p.gif)
5+
## Add to your project
6+
Add the jitpack maven repository
7+
```
8+
allprojects {
9+
repositories {
10+
...
11+
maven { url 'https://jitpack.io' }
12+
}
13+
}
14+
```
15+
Add the dependency
16+
```
17+
dependencies {
18+
implementation 'com.github.slaviboy:MultiTouchGestures:0.1.0'
19+
}
20+
```
21+
22+
23+
## Documentation
24+
### Examples
25+
Set up your view(it can be whatever view type you want) using **xml**
26+
```xml
27+
<View
28+
android:id="@+id/gesture_view"
29+
android:layout_width="match_parent"
30+
android:layout_height="match_parent"/>
31+
32+
```
33+
34+
Create your gesture detector object using **java**
35+
```JAVA
36+
// init multi finger gesture detector
37+
GestureDetector detector = new GestureDetector();
38+
39+
// attach gesture detector listener to your view
40+
View view = findViewById(R.id.gesture_view);
41+
view.setOnTouchListener(detector);
42+
```
43+
44+
### Add Listener
45+
```JAVA
46+
47+
detector.setOnGestureListener(new GestureDetector.OnGestureListener() {
48+
@Override
49+
public void onStateChange(Finger[] fingers, int fingerIndex) {
50+
51+
}
52+
});
53+
```
54+
55+
## Supported finger states
56+
At any moment in time, each finger has a current state. Using those states for multiple
57+
fingers, you can form multi-touch gesture.
58+
59+
- NONE
60+
- SWIPE UP
61+
- SWIPE DOWN
62+
- SWIPE LEFT
63+
- SWIPE RIGHT
64+
- HOLD_DOWN
65+
- DOWN
66+
- UP
67+
- MOVE UP
68+
- MOVE DOWN
69+
- MOVE LEFT
70+
- MOVE RIGHT
71+
- DOUBLE TAP
72+
73+
### GestureDetector Object Properties
74+
* **holdDownDelay** - *(default:100)* delay time(ms) after which if finger is -hold down, state will be changed to HOLD_DOWN
75+
* **upDelay** - *(default:50)* delay time(ms), after which if finger is -swiped, state will be changed to UP
76+
* **consumeTouchEvents** - *(default:true)* whether to consume touch event after handling
77+
* **numberOfFingers** - *(default:2)* number of allowed fingers, that will be detected
78+
79+
### Finger Object Properties
80+
* **minDistanceSwipe** - *(default:10)* minimum distance finger must travel, before **swipe** can be detected
81+
* **maxDurationSwipe** - *(default:400)* maximum time after which swipe WILL NOT be detected (ms)
82+
* **minDistanceMove** - *(default:30)* minimum distance finger must travel, before **move** can be detected
83+
* **maxDurationDoubleTap** - *(default:250)* maximum delay time between the two -down events for the double tap (ms)
84+
* **maxDownDoubleTap** - *(default:100)* maximum time the finger can be hold down for the two -down events (ms)
85+
* **slopeIntolerance** - *(default:1)* slope intolerance for swipe and move

0 commit comments

Comments
 (0)