fixed text flashing when recomposing
This commit is contained in:
parent
5f8280b545
commit
11a6c97afa
3 changed files with 23 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue