prevented some unnecessary text operations in ABC and 123 modes
This commit is contained in:
parent
34d32e0f72
commit
ac94941ae9
5 changed files with 17 additions and 17 deletions
|
|
@ -192,7 +192,7 @@ public abstract class TypingHandler extends KeyPadHandler {
|
|||
|
||||
// Auto-adjust the text case before each word, if the InputMode supports it.
|
||||
if (suggestionOps.getCurrent().isEmpty()) {
|
||||
mInputMode.determineNextWordTextCase(textField.getStringBeforeCursor());
|
||||
mInputMode.determineNextWordTextCase();
|
||||
}
|
||||
|
||||
if (!mInputMode.onNumber(key, hold, repeat)) {
|
||||
|
|
@ -339,7 +339,7 @@ public abstract class TypingHandler extends KeyPadHandler {
|
|||
protected void onAcceptSuggestionAutomatically(String word) {
|
||||
mInputMode.onAcceptSuggestion(word, true);
|
||||
autoCorrectSpace(word, false, mInputMode.getSequence().isEmpty() ? -1 : mInputMode.getSequence().charAt(0) - '0');
|
||||
mInputMode.determineNextWordTextCase(textField.getStringBeforeCursor());
|
||||
mInputMode.determineNextWordTextCase();
|
||||
}
|
||||
|
||||
private void onAcceptSuggestionsDelayed(String word) {
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@ import io.github.sspanak.tt9.ime.modes.InputMode;
|
|||
import io.github.sspanak.tt9.languages.Language;
|
||||
import io.github.sspanak.tt9.languages.LanguageKind;
|
||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||
import io.github.sspanak.tt9.util.InputConnectionTools;
|
||||
import io.github.sspanak.tt9.util.InputConnectionCompat;
|
||||
import io.github.sspanak.tt9.util.Logger;
|
||||
import io.github.sspanak.tt9.util.Text;
|
||||
|
||||
public class TextField extends InputField {
|
||||
@NonNull private final InputConnectionTools connectionTools;
|
||||
@NonNull private final InputConnectionCompat connectionCompat;
|
||||
|
||||
private CharSequence composingText = "";
|
||||
private final boolean isComposingSupported;
|
||||
|
|
@ -33,7 +33,7 @@ public class TextField extends InputField {
|
|||
public TextField(InputConnection inputConnection, EditorInfo inputField) {
|
||||
super(inputConnection, inputField);
|
||||
|
||||
connectionTools = new InputConnectionTools(inputConnection);
|
||||
connectionCompat = new InputConnectionCompat(inputConnection);
|
||||
|
||||
InputType inputType = new InputType(inputConnection, inputField);
|
||||
isComposingSupported = !inputType.isNumeric() && !inputType.isLimited() && !inputType.isRustDesk() && !inputType.isDeezerSearchBar();
|
||||
|
|
@ -42,13 +42,13 @@ public class TextField extends InputField {
|
|||
|
||||
|
||||
public String getStringAfterCursor(int numberOfChars) {
|
||||
CharSequence chars = connectionTools.getTextAfterCursor(numberOfChars, 0);
|
||||
CharSequence chars = connectionCompat.getTextAfterCursor(numberOfChars, 0);
|
||||
return chars != null ? chars.toString() : "";
|
||||
}
|
||||
|
||||
|
||||
public String getStringBeforeCursor(int numberOfChars) {
|
||||
CharSequence chars = connectionTools.getTextBeforeCursor(numberOfChars, 0);
|
||||
CharSequence chars = connectionCompat.getTextBeforeCursor(numberOfChars, 0);
|
||||
return chars != null ? chars.toString() : "";
|
||||
}
|
||||
|
||||
|
|
@ -399,6 +399,6 @@ public class TextField extends InputField {
|
|||
|
||||
|
||||
public boolean shouldReportConnectionErrors() {
|
||||
return connectionTools.shouldReportTimeout();
|
||||
return connectionCompat.shouldReportTimeout();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ abstract public class InputMode {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void determineNextWordTextCase(String textBeforeCursor) {}
|
||||
public void determineNextWordTextCase() {}
|
||||
|
||||
// Based on the internal logic of the mode (punctuation or grammar rules), re-adjust the text case for when getSuggestions() is called.
|
||||
protected String adjustSuggestionTextCase(String word, int newTextCase) { return word; }
|
||||
|
|
|
|||
|
|
@ -337,8 +337,8 @@ class ModeWords extends ModeCheonjiin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void determineNextWordTextCase(String textBeforeCursor) {
|
||||
textCase = autoTextCase.determineNextWordTextCase(textCase, textFieldTextCase, textBeforeCursor, digitSequence);
|
||||
public void determineNextWordTextCase() {
|
||||
textCase = autoTextCase.determineNextWordTextCase(textCase, textFieldTextCase, textField.getStringBeforeCursor(), digitSequence);
|
||||
}
|
||||
|
||||
private void determineTextFieldTextCase() {
|
||||
|
|
|
|||
|
|
@ -16,20 +16,20 @@ import java.util.concurrent.TimeoutException;
|
|||
|
||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||
|
||||
public class InputConnectionTools {
|
||||
private static final String LOG_TAG = InputConnectionTools.class.getSimpleName();
|
||||
public class InputConnectionCompat {
|
||||
private static final String LOG_TAG = InputConnectionCompat.class.getSimpleName();
|
||||
|
||||
@Nullable private final InputConnection connection;
|
||||
|
||||
@Nullable CompletableFuture<Boolean> future;
|
||||
@NonNull ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
@Nullable private CompletableFuture<Boolean> future;
|
||||
@NonNull private final ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
private int connectionErrors = 0;
|
||||
private boolean isErrorReported = false;
|
||||
|
||||
private CharSequence result;
|
||||
|
||||
|
||||
public InputConnectionTools(@Nullable InputConnection connection) {
|
||||
public InputConnectionCompat(@Nullable InputConnection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ public class InputConnectionTools {
|
|||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
private void getTextNextToCursorModern(int i, int ii, boolean after) {
|
||||
// CompletableFuture is supported only in Android 24 and above, so we initialize it here.
|
||||
// CompletableFuture is supported only in API 24 and above, so we initialize it here.
|
||||
future = new CompletableFuture<>();
|
||||
|
||||
// Start only the watchdog in a separate thread. If we start the main operation there too,
|
||||
Loading…
Add table
Add a link
Reference in a new issue