1
0
Fork 0

added longer initial repeat delay for the on-screen backspace

This commit is contained in:
sspanak 2023-01-24 07:58:29 +02:00 committed by Dimo Karaivanov
parent d95ad32678
commit 1a1c0ec910
2 changed files with 20 additions and 6 deletions

View file

@ -17,7 +17,6 @@ class SoftKeyHandler implements View.OnTouchListener {
private final TraditionalT9 tt9;
private View view = null;
private static final int BACKSPACE_DEBOUNCE_TIME = 40;
private long lastBackspaceCall = 0;
public SoftKeyHandler(TraditionalT9 tt9) {
@ -104,18 +103,26 @@ class SoftKeyHandler implements View.OnTouchListener {
}
protected boolean handleBackspaceHold() {
if (System.currentTimeMillis() - lastBackspaceCall < BACKSPACE_DEBOUNCE_TIME) {
private boolean handleBackspaceHold() {
if (System.currentTimeMillis() - lastBackspaceCall < tt9.settings.getSoftKeyRepeatDelay()) {
return true;
}
boolean handled = tt9.onBackspace();
lastBackspaceCall = System.currentTimeMillis();
long now = System.currentTimeMillis();
lastBackspaceCall = lastBackspaceCall == 0 ? tt9.settings.getSoftKeyInitialDelay() + now : now;
return handled;
}
private boolean handleBackspaceUp() {
lastBackspaceCall = 0;
return true;
}
@Override
public boolean onTouch(View view, MotionEvent event) {
int action = event.getAction();
@ -131,8 +138,12 @@ class SoftKeyHandler implements View.OnTouchListener {
return view.performClick();
}
if (buttonId == R.id.main_right && action == MotionEvent.AXIS_PRESSURE) {
if (buttonId == R.id.main_right) {
if (action == MotionEvent.AXIS_PRESSURE) {
return handleBackspaceHold();
} else if (action == MotionEvent.ACTION_UP) {
return handleBackspaceUp();
}
}
return false;

View file

@ -224,6 +224,9 @@ public class SettingsStore {
public int getSuggestionSelectAnimationDuration() { return 66; }
public int getSuggestionTranslateAnimationDuration() { return 0; }
public int getSoftKeyInitialDelay() { return 250; /* ms */ }
public int getSoftKeyRepeatDelay() { return 40; /* ms */ }
/************* add word, last word *************/