1
0
Fork 0

fixed the Shift state sometimes not being update after holding backspace to delete all text

This commit is contained in:
sspanak 2025-06-24 19:40:00 +03:00 committed by Dimo Karaivanov
parent 7a845c9ae5
commit 1a8e34461c
4 changed files with 22 additions and 1 deletions

View file

@ -1,6 +1,8 @@
package io.github.sspanak.tt9.ime; package io.github.sspanak.tt9.ime;
import android.inputmethodservice.InputMethodService; import android.inputmethodservice.InputMethodService;
import android.os.Handler;
import android.os.Looper;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -33,6 +35,7 @@ public abstract class TypingHandler extends KeyPadHandler {
@NonNull protected TextField textField = new TextField(null, null, null); @NonNull protected TextField textField = new TextField(null, null, null);
@NonNull protected TextSelection textSelection = new TextSelection(null); @NonNull protected TextSelection textSelection = new TextSelection(null);
@NonNull protected SuggestionOps suggestionOps = new SuggestionOps(null, null, null, null, null, null); @NonNull protected SuggestionOps suggestionOps = new SuggestionOps(null, null, null, null, null, null);
@NonNull private Handler shiftStateDebounceHandler = new Handler(Looper.getMainLooper());
// input // input
@NonNull protected ArrayList<Integer> allowedInputModes = new ArrayList<>(); @NonNull protected ArrayList<Integer> allowedInputModes = new ArrayList<>();
@ -141,6 +144,7 @@ public abstract class TypingHandler extends KeyPadHandler {
suggestionOps.commitCurrent(false, true); suggestionOps.commitCurrent(false, true);
mInputMode.reset(); mInputMode.reset();
deleteText(settings.getBackspaceAcceleration() && repeat > 0); deleteText(settings.getBackspaceAcceleration() && repeat > 0);
updateShiftStateDebounced(mInputMode.getSuggestions().isEmpty(), false);
} }
if (settings.getBackspaceRecomposing() && repeat == 0 && noTextSelection && suggestionOps.isEmpty() && !DictionaryLoader.getInstance(this).isRunning()) { if (settings.getBackspaceRecomposing() && repeat == 0 && noTextSelection && suggestionOps.isEmpty() && !DictionaryLoader.getInstance(this).isRunning()) {
@ -427,7 +431,12 @@ public abstract class TypingHandler extends KeyPadHandler {
String trimmedWord = suggestionOps.getCurrent(mLanguage, mInputMode.getSequenceLength()); String trimmedWord = suggestionOps.getCurrent(mLanguage, mInputMode.getSequenceLength());
appHacks.setComposingTextWithHighlightedStem(trimmedWord, mInputMode); appHacks.setComposingTextWithHighlightedStem(trimmedWord, mInputMode);
updateShiftState(mInputMode.getSuggestions().isEmpty(), true); if (mInputMode.getSuggestions().isEmpty()) {
updateShiftStateDebounced(true, false);
} else {
updateShiftStateDebounced(false, true);
}
forceShowWindow(); forceShowWindow();
} }
@ -440,6 +449,12 @@ public abstract class TypingHandler extends KeyPadHandler {
} }
protected void updateShiftStateDebounced(boolean determineTextCase, boolean onlyWhenLetters) {
shiftStateDebounceHandler.removeCallbacksAndMessages(null);
shiftStateDebounceHandler.postDelayed(() -> updateShiftState(determineTextCase, onlyWhenLetters), SettingsStore.SHIFT_STATE_DEBOUNCE_TIME);
}
protected void updateShiftState(boolean determineTextCase, boolean onlyWhenLetters) { protected void updateShiftState(boolean determineTextCase, boolean onlyWhenLetters) {
if (onlyWhenLetters && !new Text(suggestionOps.getCurrent()).isAlphabetic()) { if (onlyWhenLetters && !new Text(suggestionOps.getCurrent()).isAlphabetic()) {
return; return;

View file

@ -61,6 +61,7 @@ class ModeWords extends ModeCheonjiin {
@Override @Override
public boolean onBackspace() { public boolean onBackspace() {
isCursorDirectionForward = false; isCursorDirectionForward = false;
autoTextCase.doNotSkipNext();
if (digitSequence.isEmpty()) { if (digitSequence.isEmpty()) {
clearWordStem(); clearWordStem();

View file

@ -100,4 +100,8 @@ public class AutoTextCase {
public void skipNext() { public void skipNext() {
skipNext = true; skipNext = true;
} }
public void doNotSkipNext() {
skipNext = false;
}
} }

View file

@ -20,6 +20,7 @@ public class SettingsStore extends SettingsHotkeys {
public final static int DICTIONARY_IMPORT_BATCH_SIZE = 5000; // words public final static int DICTIONARY_IMPORT_BATCH_SIZE = 5000; // words
public final static int DICTIONARY_IMPORT_PROGRESS_UPDATE_TIME = 250; // ms public final static int DICTIONARY_IMPORT_PROGRESS_UPDATE_TIME = 250; // ms
public final static int RESIZE_THROTTLING_TIME = 60; // ms public final static int RESIZE_THROTTLING_TIME = 60; // ms
public final static int SHIFT_STATE_DEBOUNCE_TIME = 175; // ms
public final static byte SLOW_QUERY_TIME = 50; // ms public final static byte SLOW_QUERY_TIME = 50; // ms
public final static int SLOW_QUERY_TIMEOUT = 3000; // ms public final static int SLOW_QUERY_TIMEOUT = 3000; // ms
public final static float SOFT_KEY_AMOUNT_OF_KEY_SIZE_FOR_SWIPE = 0.5f; // 1 = full key size public final static float SOFT_KEY_AMOUNT_OF_KEY_SIZE_FOR_SWIPE = 0.5f; // 1 = full key size