fixed text flashing when recomposing
This commit is contained in:
parent
5f8280b545
commit
11a6c97afa
3 changed files with 23 additions and 4 deletions
|
|
@ -134,10 +134,12 @@ public abstract class TypingHandler extends KeyPadHandler {
|
||||||
textField.deleteChars(prevChars);
|
textField.deleteChars(prevChars);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hold && suggestionOps.isEmpty() && mInputMode.recompose(textField.getWordBeforeCursor())) {
|
if (settings.getBackspaceRecomposing() && !hold && suggestionOps.isEmpty()) {
|
||||||
textField.deleteChars(mInputMode.getSequenceLength());
|
String previousWord = textField.getWordBeforeCursor();
|
||||||
|
if (textField.recompose(previousWord) && mInputMode.recompose(previousWord)) {
|
||||||
getSuggestions();
|
getSuggestions();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
* setText
|
||||||
* A fail-safe setter that appends text to the field, ignoring NULL input.
|
* A fail-safe setter that appends text to the field, ignoring NULL input.
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ public class ModePredictive extends InputMode {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean recompose(String word) {
|
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 + "'");
|
Logger.d(LOG_TAG, "Not recomposing invalid word: '" + word + "'");
|
||||||
textCase = CASE_CAPITALIZE;
|
textCase = CASE_CAPITALIZE;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue