Skip to content

Commit

Permalink
Clean compositing text when switching keyboard. (#1189)
Browse files Browse the repository at this point in the history
  • Loading branch information
daoshengmu authored and MortimerGoro committed May 9, 2019
1 parent aebcc65 commit e4acc4a
Showing 1 changed file with 14 additions and 9 deletions.
Expand Up @@ -252,15 +252,7 @@ public void updateFocusedView(View aFocusedView) {
((TextView)mFocusedView).addTextChangedListener(this);
}
} else {
if (mComposingText.length() > 0 && mInputConnection != null) {
mComposingText = "";
// Clear composited text when the keyboard is dismissed
final InputConnection input = mInputConnection;
postInputCommand(() -> {
displayComposingText("");
input.finishComposingText();
});
}
cleanComposingText();
hideOverlays();
mInputConnection = null;
}
Expand Down Expand Up @@ -504,6 +496,17 @@ private KeyboardInterface getKeyboardForLocale(@Nullable Locale aLocale) {
return null;
}

private void cleanComposingText() {
if (mComposingText.length() > 0 && mInputConnection != null) {
mComposingText = "";
// Clear composited text when the keyboard is dismissed
final InputConnection input = mInputConnection;
postInputCommand(() -> {
displayComposingText("");
input.finishComposingText();
});
}
}

private void handleShift(boolean isShifted) {
CustomKeyboard keyboard = (CustomKeyboard) mKeyboardView.getKeyboard();
Expand Down Expand Up @@ -577,6 +580,8 @@ private void handleGlobeClick() {
}

private void handleLanguageChange(KeyboardInterface aKeyboard) {
cleanComposingText();

mCurrentKeyboard = aKeyboard;
SettingsStore.getInstance(getContext()).setSelectedKeyboard(aKeyboard.getLocale());
mKeyboardView.setKeyboard(mCurrentKeyboard.getAlphabeticKeyboard());
Expand Down

0 comments on commit e4acc4a

Please sign in to comment.