diff --git a/res/layout/main_numpad.xml b/res/layout/main_numpad.xml index bd686326..a362740f 100644 --- a/res/layout/main_numpad.xml +++ b/res/layout/main_numpad.xml @@ -174,10 +174,13 @@ android:id="@+id/separator_2_2" style="@style/numSeparator" /> - + android:layout_height="match_parent" + android:layout_weight="@dimen/numpad_control_key_layout_weight" + android:text="Fltr" /> @@ -228,12 +231,13 @@ style="@style/numSeparator" /> + android:text="Clr" /> + diff --git a/src/io/github/sspanak/tt9/ui/main/keys/SoftKey.java b/src/io/github/sspanak/tt9/ui/main/keys/SoftKey.java index 64e3ed01..07bab940 100644 --- a/src/io/github/sspanak/tt9/ui/main/keys/SoftKey.java +++ b/src/io/github/sspanak/tt9/ui/main/keys/SoftKey.java @@ -27,6 +27,7 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement private boolean hold = false; private boolean repeat = false; private final Handler repeatHandler = new Handler(Looper.getMainLooper()); + private static int lastPressedKey = -1; public SoftKey(Context context) { @@ -73,7 +74,9 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement } else if (action == MotionEvent.ACTION_UP) { preventRepeat(); if (!repeat) { - return handleRelease(); + boolean result = handleRelease(); + lastPressedKey = getId(); + return result; } repeat = false; } @@ -105,6 +108,7 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement if (hold) { repeat = true; handleHold(); + lastPressedKey = getId(); repeatHandler.removeCallbacks(this::repeatOnLongPress); repeatHandler.postDelayed(this::repeatOnLongPress, tt9.getSettings().getSoftKeyRepeatDelay()); } @@ -134,9 +138,11 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement } int keyId = getId(); + boolean multiplePress = lastPressedKey == keyId; if (keyId == R.id.soft_key_add_word) return tt9.onKeyAddWord(false); - if (keyId == R.id.soft_key_filter_suggestions) return tt9.onKeyFilterSuggestions(false, repeat); + if (keyId == R.id.soft_key_filter_suggestions) return tt9.onKeyFilterSuggestions(false, multiplePress); + if (keyId == R.id.soft_key_clear_filter) return tt9.onKeyFilterClear(false); if (keyId == R.id.soft_key_left_arrow) return tt9.onKeyScrollSuggestion(false, true); if (keyId == R.id.soft_key_right_arrow) return tt9.onKeyScrollSuggestion(false, false); if (keyId == R.id.soft_key_input_mode) return tt9.onKeyNextInputMode(false);