From e4acc4a598c2b68c2ce84a9a13cb234e7132df5a Mon Sep 17 00:00:00 2001 From: Daosheng Mu Date: Thu, 9 May 2019 15:49:45 -0700 Subject: [PATCH] Clean compositing text when switching keyboard. (#1189) --- .../vrbrowser/ui/widgets/KeyboardWidget.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/KeyboardWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/KeyboardWidget.java index d410e1375..cc86650fd 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/KeyboardWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/KeyboardWidget.java @@ -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; } @@ -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(); @@ -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());