1
0
Fork 0

restored the Clear filter key on the on-screen keyboard and fixed the Filter key not acting properly when being repeatedly pressed

This commit is contained in:
sspanak 2023-08-10 15:21:06 +03:00 committed by Dimo Karaivanov
parent 29339fc01e
commit a1235e95ac
2 changed files with 18 additions and 8 deletions

View file

@ -174,10 +174,13 @@
android:id="@+id/separator_2_2"
style="@style/numSeparator" />
<View
<io.github.sspanak.tt9.ui.main.keys.SoftKey
android:id="@+id/soft_key_filter_suggestions"
style="@android:style/Widget.Holo.Button.Borderless"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="@dimen/numpad_control_key_layout_weight" />
android:layout_height="match_parent"
android:layout_weight="@dimen/numpad_control_key_layout_weight"
android:text="Fltr" />
</LinearLayout>
@ -228,12 +231,13 @@
style="@style/numSeparator" />
<io.github.sspanak.tt9.ui.main.keys.SoftKey
android:id="@+id/soft_key_filter_suggestions"
android:id="@+id/soft_key_clear_filter"
style="@android:style/Widget.Holo.Button.Borderless"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_weight="@dimen/numpad_control_key_layout_weight"
android:text="Fltr" />
android:text="Clr" />
</LinearLayout>

View file

@ -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);