Skip to content
This repository was archived by the owner on Jan 1, 2023. It is now read-only.

Commit e3ffb19

Browse files
Add 5 second reset of tap pattern
1 parent fd62ef2 commit e3ffb19

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

mobile/src/main/java/org/codechimp/ttw/PluginActivity.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,23 @@ public void onClick(View v) {
102102
dialogButtonTap.setOnTouchListener(new ImageButton.OnTouchListener() {
103103
@Override
104104
public boolean onTouch(View v, MotionEvent event) {
105-
if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_DOWN) {
106-
Long now = System.currentTimeMillis();
105+
Long now = System.currentTimeMillis();
106+
107+
if (event.getAction() == MotionEvent.ACTION_DOWN) {
108+
//If longer than 5 seconds since last tap then we've started a new pattern
109+
if (now - lastTouchAction > 5000) {
110+
ResetTapPattern();
111+
} else {
112+
if (lastTouchAction > 0)
113+
taps.add(now - lastTouchAction);
114+
}
115+
lastTouchAction = now;
116+
} else if (event.getAction() == MotionEvent.ACTION_UP) {
107117
if (lastTouchAction > 0)
108118
taps.add(now - lastTouchAction);
109119

110120
lastTouchAction = now;
111121
}
112-
113122
return false;
114123
}
115124
});

0 commit comments

Comments
 (0)