1
0
Fork 0

fixed a crash when trying to add a word, but the input connection is already closed

This commit is contained in:
sspanak 2022-11-10 12:48:03 +02:00 committed by Dimo Karaivanov
parent 103bb93214
commit d37b7139c6
2 changed files with 11 additions and 0 deletions

View file

@ -157,8 +157,15 @@ class InputFieldHelper {
public static String getSurroundingWord(InputConnection currentInputConnection) {
if (currentInputConnection == null) {
return "";
}
String before = (String) currentInputConnection.getTextBeforeCursor(50, 0);
String after = (String) currentInputConnection.getTextAfterCursor(50, 0);
if (before == null || after == null) {
return "";
}
Matcher beforeMatch = Pattern.compile("(\\w+)$").matcher(before);
Matcher afterMatch = Pattern.compile("^(\\w+)").matcher(after);

View file

@ -511,6 +511,10 @@ public class TraditionalT9 extends KeyPadHandler {
private void showAddWord() {
if (currentInputConnection == null) {
return;
}
currentInputConnection.finishComposingText();
clearSuggestions();