From 29200b0abe1d65aa2f9ddefd247ab91563d666f8 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Tue, 26 Aug 2014 21:32:25 -0700 Subject: Set the text bgcolor only when CursorAnchorInfo is available When CursorAnchorInfo is unavailable, we shouldn't try to show the commit indicator and set the text highlight color. With this CL, RichInputConnection can be used to track if the application responded that it does support CursorAnchorInfo or not. This result will be taken into consideration when InputLogic needs to determine whether the commit indicator should be displayed or not. Change-Id: I945d70eeb02a7a5f3d9b22459b23d7028508910f --- .../inputmethod/latin/inputlogic/InputLogic.java | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java') diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java index e83f494b3..de62f9786 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java @@ -50,6 +50,7 @@ import com.android.inputmethod.latin.SuggestedWords; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.WordComposer; import com.android.inputmethod.latin.define.DebugFlags; +import com.android.inputmethod.latin.define.ProductionFlags; import com.android.inputmethod.latin.settings.SettingsValues; import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion; import com.android.inputmethod.latin.settings.SpacingAndPunctuations; @@ -140,8 +141,9 @@ public final class InputLogic { * Call this when input starts or restarts in some editor (typically, in onStartInputView). * * @param combiningSpec the combining spec string for this subtype + * @param settingsValues the current settings values */ - public void startInput(final String combiningSpec) { + public void startInput(final String combiningSpec, final SettingsValues settingsValues) { mEnteredText = null; mWordComposer.restartCombining(combiningSpec); resetComposingState(true /* alsoResetLastComposedWord */); @@ -159,15 +161,24 @@ public final class InputLogic { } else { mInputLogicHandler.reset(); } + + if (ProductionFlags.ENABLE_CURSOR_ANCHOR_INFO_CALLBACK) { + // AcceptTypedWord feature relies on CursorAnchorInfo. + if (settingsValues.mShouldShowUiToAcceptTypedWord) { + mConnection.requestUpdateCursorAnchorInfo(true /* enableMonitor */, + true /* requestImmediateCallback */); + } + } } /** * Call this when the subtype changes. * @param combiningSpec the spec string for the combining rules + * @param settingsValues the current settings values */ - public void onSubtypeChanged(final String combiningSpec) { + public void onSubtypeChanged(final String combiningSpec, final SettingsValues settingsValues) { finishInput(); - startInput(combiningSpec); + startInput(combiningSpec, settingsValues); } /** @@ -2238,6 +2249,10 @@ public final class InputLogic { */ private boolean shouldShowCommitIndicator(final SuggestedWords suggestedWords, final SettingsValues settingsValues) { + if (!mConnection.isCursorAnchorInfoMonitorEnabled()) { + // We cannot help in this case because we are heavily relying on this new API. + return false; + } if (!settingsValues.mShouldShowUiToAcceptTypedWord) { return false; } -- cgit v1.2.3-83-g751a