fixed the Shift state sometimes not being update after holding backspace to delete all text
This commit is contained in:
parent
7a845c9ae5
commit
1a8e34461c
4 changed files with 22 additions and 1 deletions
|
|
@ -1,6 +1,8 @@
|
|||
package io.github.sspanak.tt9.ime;
|
||||
|
||||
import android.inputmethodservice.InputMethodService;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
|
||||
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 TextSelection textSelection = new TextSelection(null);
|
||||
@NonNull protected SuggestionOps suggestionOps = new SuggestionOps(null, null, null, null, null, null);
|
||||
@NonNull private Handler shiftStateDebounceHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
// input
|
||||
@NonNull protected ArrayList<Integer> allowedInputModes = new ArrayList<>();
|
||||
|
|
@ -141,6 +144,7 @@ public abstract class TypingHandler extends KeyPadHandler {
|
|||
suggestionOps.commitCurrent(false, true);
|
||||
mInputMode.reset();
|
||||
deleteText(settings.getBackspaceAcceleration() && repeat > 0);
|
||||
updateShiftStateDebounced(mInputMode.getSuggestions().isEmpty(), false);
|
||||
}
|
||||
|
||||
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());
|
||||
appHacks.setComposingTextWithHighlightedStem(trimmedWord, mInputMode);
|
||||
|
||||
updateShiftState(mInputMode.getSuggestions().isEmpty(), true);
|
||||
if (mInputMode.getSuggestions().isEmpty()) {
|
||||
updateShiftStateDebounced(true, false);
|
||||
} else {
|
||||
updateShiftStateDebounced(false, true);
|
||||
}
|
||||
|
||||
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) {
|
||||
if (onlyWhenLetters && !new Text(suggestionOps.getCurrent()).isAlphabetic()) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ class ModeWords extends ModeCheonjiin {
|
|||
@Override
|
||||
public boolean onBackspace() {
|
||||
isCursorDirectionForward = false;
|
||||
autoTextCase.doNotSkipNext();
|
||||
|
||||
if (digitSequence.isEmpty()) {
|
||||
clearWordStem();
|
||||
|
|
|
|||
|
|
@ -100,4 +100,8 @@ public class AutoTextCase {
|
|||
public void skipNext() {
|
||||
skipNext = true;
|
||||
}
|
||||
|
||||
public void doNotSkipNext() {
|
||||
skipNext = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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_PROGRESS_UPDATE_TIME = 250; // 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 int SLOW_QUERY_TIMEOUT = 3000; // ms
|
||||
public final static float SOFT_KEY_AMOUNT_OF_KEY_SIZE_FOR_SWIPE = 0.5f; // 1 = full key size
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue