From 12cddf4befe3538dcc61f5742ae9253c493f8602 Mon Sep 17 00:00:00 2001 From: codokie <151087174+codokie@users.noreply.github.com> Date: Fri, 31 May 2024 15:26:15 +0300 Subject: [PATCH] adapt last commit dc4755b9 to #688 --- .../java/helium314/keyboard/latin/LatinIME.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/helium314/keyboard/latin/LatinIME.java b/app/src/main/java/helium314/keyboard/latin/LatinIME.java index a136468f7..cf1edf5b1 100644 --- a/app/src/main/java/helium314/keyboard/latin/LatinIME.java +++ b/app/src/main/java/helium314/keyboard/latin/LatinIME.java @@ -348,6 +348,10 @@ public boolean hasPendingUpdateSuggestions() { return hasMessages(MSG_UPDATE_SUGGESTION_STRIP); } + public boolean hasPendingResumeSuggestions() { + return hasMessages(MSG_RESUME_SUGGESTIONS); + } + public boolean hasPendingReopenDictionaries() { return hasMessages(MSG_REOPEN_DICTIONARIES); } @@ -984,6 +988,9 @@ void onStartInputViewInternal(final EditorInfo editorInfo, final boolean restart // initialSelStart and initialSelEnd sometimes are lying. Make a best effort to // work around this bug. mInputLogic.mConnection.tryFixLyingCursorPosition(); + if (mInputLogic.mConnection.isCursorTouchingWord(currentSettingsValues.mSpacingAndPunctuations, true)) { + mHandler.postResumeSuggestions(true /* shouldDelay */); + } needToCallLoadKeyboardLater = false; } } else { @@ -1012,9 +1019,12 @@ void onStartInputViewInternal(final EditorInfo editorInfo, final boolean restart // Space state must be updated before calling updateShiftState switcher.requestUpdatingShiftState(getCurrentAutoCapsState(), getCurrentRecapitalizeState()); } - - mHandler.cancelUpdateSuggestionStrip(); - mHandler.postResumeSuggestions(true /* shouldDelay */); + // This will set the punctuation suggestions if next word suggestion is off; + // otherwise it will clear the suggestion strip. + if (!mHandler.hasPendingResumeSuggestions()) { + mHandler.cancelUpdateSuggestionStrip(); + setNeutralSuggestionStrip(); + } mainKeyboardView.setMainDictionaryAvailability(mDictionaryFacilitator.hasAtLeastOneInitializedMainDictionary()); mainKeyboardView.setKeyPreviewPopupEnabled(currentSettingsValues.mKeyPreviewPopupOn);