@@ -22,7 +22,11 @@ class InputListener implements View.OnTouchListener {
22
22
private float startingY ;
23
23
private int previousDirection = 1 ;
24
24
private int veryLastDirection = 1 ;
25
+ // Whether or not we have made a move, i.e. the blocks shifted or tried to shift.
25
26
private boolean hasMoved = false ;
27
+ // Whether or not we began the press on an icon. This is to disable swipes if the user began
28
+ // the press on an icon.
29
+ private boolean beganOnIcon = false ;
26
30
27
31
public InputListener (MainView view ) {
28
32
super ();
@@ -42,11 +46,13 @@ public boolean onTouch(View view, MotionEvent event) {
42
46
lastDx = 0 ;
43
47
lastDy = 0 ;
44
48
hasMoved = false ;
49
+ beganOnIcon = iconPressed (mView .sXNewGame , mView .sYIcons )
50
+ || iconPressed (mView .sXUndo , mView .sYIcons );
45
51
return true ;
46
52
case MotionEvent .ACTION_MOVE :
47
53
x = event .getX ();
48
54
y = event .getY ();
49
- if (mView .game .isActive ()) {
55
+ if (mView .game .isActive () && ! beganOnIcon ) {
50
56
float dx = x - previousX ;
51
57
if (Math .abs (lastDx + dx ) < Math .abs (lastDx ) + Math .abs (dx ) && Math .abs (dx ) > RESET_STARTING
52
58
&& Math .abs (x - startingX ) > SWIPE_MIN_DISTANCE ) {
@@ -154,6 +160,6 @@ private boolean inRange(float starting, float check, float ending) {
154
160
}
155
161
156
162
private boolean isTap (int factor ) {
157
- return pathMoved () <= mView .iconSize * factor ;
163
+ return pathMoved () <= mView .iconSize * mView . iconSize * factor ;
158
164
}
159
165
}
0 commit comments