1
0
Fork 0

fixed text flashing when recomposing

This commit is contained in:
sspanak 2024-08-30 12:26:29 +03:00 committed by Dimo Karaivanov
parent 5f8280b545
commit 11a6c97afa
3 changed files with 23 additions and 4 deletions

View file

@ -134,9 +134,11 @@ public abstract class TypingHandler extends KeyPadHandler {
textField.deleteChars(prevChars);
}
if (!hold && suggestionOps.isEmpty() && mInputMode.recompose(textField.getWordBeforeCursor())) {
textField.deleteChars(mInputMode.getSequenceLength());
getSuggestions();
if (settings.getBackspaceRecomposing() && !hold && suggestionOps.isEmpty()) {
String previousWord = textField.getWordBeforeCursor();
if (textField.recompose(previousWord) && mInputMode.recompose(previousWord)) {
getSuggestions();
}
}
return true;

View file

@ -187,6 +187,23 @@ public class TextField extends InputField {
}
/**
* Erases the previous N characters and sets the given "text" as composing text. N is the length of
* the given "text". Returns "true" if the operation was successful, "false" otherwise.
*/
public boolean recompose(String text) {
if (connection == null || !isComposingSupported) {
return false;
}
connection.beginBatchEdit();
boolean success = connection.deleteSurroundingText(text.length(), 0) && connection.setComposingText(text, 1);
connection.endBatchEdit();
return success;
}
/**
* setText
* A fail-safe setter that appends text to the field, ignoring NULL input.

View file

@ -126,7 +126,7 @@ public class ModePredictive extends InputMode {
@Override
public boolean recompose(String word) {
if (!settings.getBackspaceRecomposing() || word == null || word.length() < 2 || word.contains(" ")) {
if (word == null || word.length() < 2 || word.contains(" ")) {
Logger.d(LOG_TAG, "Not recomposing invalid word: '" + word + "'");
textCase = CASE_CAPITALIZE;
return false;