fixed backspace not working in constrained input fields where composing text can not be displayed
This commit is contained in:
parent
b39204609a
commit
a42c1ed1ee
5 changed files with 27 additions and 8 deletions
|
|
@ -85,6 +85,10 @@ public class SuggestionOps {
|
|||
|
||||
|
||||
String acceptPrevious(int sequenceLength) {
|
||||
if (sequenceLength <= 0) {
|
||||
set(null);
|
||||
}
|
||||
|
||||
String lastComposingText = getCurrent(sequenceLength - 1);
|
||||
commitCurrent(false);
|
||||
return lastComposingText;
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ public abstract class TypingHandler extends KeyPadHandler {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onBackspace() {
|
||||
// Dialer fields seem to handle backspace on their own and we must ignore it,
|
||||
// otherwise, keyDown race condition occur for all keys.
|
||||
|
|
@ -105,9 +106,7 @@ public abstract class TypingHandler extends KeyPadHandler {
|
|||
return false;
|
||||
}
|
||||
|
||||
// * Some app may need special treatment, so let them be.
|
||||
// * When there is no text, allow double function keys to function normally (e.g. "Back" navigates back)
|
||||
if (appHacks.onBackspace(mInputMode) || textField.getStringBeforeCursor(1).isEmpty()) {
|
||||
if (appHacks.onBackspace(mInputMode)) {
|
||||
mInputMode.reset();
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,10 +138,11 @@ public class AppHacks {
|
|||
if (isKindleInvertedTextField()) {
|
||||
inputMode.clearWordStem();
|
||||
} else if (isTermux()) {
|
||||
sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
// When there is no text, allow double function keys to function normally (e.g. "Back" navigates back)
|
||||
return inputMode.getSuggestions().isEmpty() && textField.getStringBeforeCursor(1).isEmpty();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ public class Mode123 extends ModePassthrough {
|
|||
|
||||
@Override public final boolean is123() { return true; }
|
||||
@Override public boolean isPassthrough() { return false; }
|
||||
@Override public int getSequenceLength() { return 1; }
|
||||
@Override public boolean shouldAcceptPreviousSuggestion(int nextKey) { return true; }
|
||||
|
||||
private final ArrayList<ArrayList<String>> KEY_CHARACTERS = new ArrayList<>();
|
||||
|
|
@ -86,6 +85,16 @@ public class Mode123 extends ModePassthrough {
|
|||
return digitSequence.equals(NaturalLanguage.SPECIAL_CHARS_KEY) && super.nextSpecialCharacters();
|
||||
}
|
||||
|
||||
|
||||
@Override public boolean onBackspace() {
|
||||
if (suggestions.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean onNumber(int number, boolean hold, int repeat) {
|
||||
reset();
|
||||
digitSequence = String.valueOf(number);
|
||||
|
|
@ -100,7 +109,6 @@ public class Mode123 extends ModePassthrough {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* shouldIgnoreText
|
||||
* Since this is a numeric mode, we allow typing only numbers and:
|
||||
|
|
@ -120,6 +128,9 @@ public class Mode123 extends ModePassthrough {
|
|||
);
|
||||
}
|
||||
|
||||
@Override public void onAcceptSuggestion(@NonNull String ignored, boolean ignored2) {
|
||||
reset();
|
||||
}
|
||||
|
||||
@Override public void reset() {
|
||||
super.reset();
|
||||
|
|
|
|||
|
|
@ -20,8 +20,12 @@ public class ModeABC extends InputMode {
|
|||
|
||||
@Override
|
||||
public boolean onBackspace() {
|
||||
if (suggestions.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reset();
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue