am d8380fdb: Merge "resolved conflicts for merge of 8159336b
to master"
* commit 'd8380fdba04d82566c623f1efbcb86aa33d9e401': Set the text bgcolor only when CursorAnchorInfo is availablemain
commit
4db998d65a
|
@ -57,7 +57,6 @@ import android.view.inputmethod.InputMethodSubtype;
|
|||
import com.android.inputmethod.accessibility.AccessibilityUtils;
|
||||
import com.android.inputmethod.annotations.UsedForTesting;
|
||||
import com.android.inputmethod.compat.CursorAnchorInfoCompatWrapper;
|
||||
import com.android.inputmethod.compat.InputConnectionCompatUtils;
|
||||
import com.android.inputmethod.compat.InputMethodServiceCompatUtils;
|
||||
import com.android.inputmethod.dictionarypack.DictionaryPackConstants;
|
||||
import com.android.inputmethod.event.Event;
|
||||
|
@ -778,20 +777,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
// is not guaranteed. It may even be called at the same time on a different thread.
|
||||
final RichInputMethodSubtype richSubtype = new RichInputMethodSubtype(subtype);
|
||||
mSubtypeSwitcher.onSubtypeChanged(richSubtype);
|
||||
mInputLogic.onSubtypeChanged(SubtypeLocaleUtils.getCombiningRulesExtraValue(subtype));
|
||||
mInputLogic.onSubtypeChanged(SubtypeLocaleUtils.getCombiningRulesExtraValue(subtype),
|
||||
mSettings.getCurrent());
|
||||
loadKeyboard();
|
||||
}
|
||||
|
||||
private void onStartInputInternal(final EditorInfo editorInfo, final boolean restarting) {
|
||||
super.onStartInput(editorInfo, restarting);
|
||||
if (ProductionFlags.ENABLE_CURSOR_ANCHOR_INFO_CALLBACK) {
|
||||
// AcceptTypedWord feature relies on CursorAnchorInfo.
|
||||
if (mSettings.getCurrent().mShouldShowUiToAcceptTypedWord) {
|
||||
InputConnectionCompatUtils.requestUpdateCursorAnchorInfo(
|
||||
getCurrentInputConnection(), true /* enableMonitor */,
|
||||
true /* requestImmediateCallback */);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -860,7 +852,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
// span, so we should reset our state unconditionally, even if restarting is true.
|
||||
// We also tell the input logic about the combining rules for the current subtype, so
|
||||
// it can adjust its combiners if needed.
|
||||
mInputLogic.startInput(mSubtypeSwitcher.getCombiningRulesExtraValueOfCurrentSubtype());
|
||||
mInputLogic.startInput(mSubtypeSwitcher.getCombiningRulesExtraValueOfCurrentSubtype(),
|
||||
currentSettingsValues);
|
||||
|
||||
// Note: the following does a round-trip IPC on the main thread: be careful
|
||||
final Locale currentLocale = mSubtypeSwitcher.getCurrentSubtypeLocale();
|
||||
|
|
|
@ -30,7 +30,9 @@ import android.view.inputmethod.CorrectionInfo;
|
|||
import android.view.inputmethod.ExtractedText;
|
||||
import android.view.inputmethod.ExtractedTextRequest;
|
||||
import android.view.inputmethod.InputConnection;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import com.android.inputmethod.compat.InputConnectionCompatUtils;
|
||||
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
|
||||
import com.android.inputmethod.latin.utils.CapsModeUtils;
|
||||
import com.android.inputmethod.latin.utils.DebugLogUtils;
|
||||
|
@ -906,4 +908,33 @@ public final class RichInputConnection {
|
|||
mIC.setSelection(mExpectedSelStart, mExpectedSelEnd);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean mCursorAnchorInfoMonitorEnabled = false;
|
||||
|
||||
/**
|
||||
* Requests the editor to call back {@link InputMethodManager#updateCursorAnchorInfo}.
|
||||
* @param enableMonitor {@code true} to request the editor to call back the method whenever the
|
||||
* cursor/anchor position is changed.
|
||||
* @param requestImmediateCallback {@code true} to request the editor to call back the method
|
||||
* as soon as possible to notify the current cursor/anchor position to the input method.
|
||||
* @return {@code true} if the request is accepted. Returns {@code false} otherwise, which
|
||||
* includes "not implemented" or "rejected" or "temporarily unavailable" or whatever which
|
||||
* prevents the application from fulfilling the request. (TODO: Improve the API when it turns
|
||||
* out that we actually need more detailed error codes)
|
||||
*/
|
||||
public boolean requestUpdateCursorAnchorInfo(final boolean enableMonitor,
|
||||
final boolean requestImmediateCallback) {
|
||||
final boolean scheduled = InputConnectionCompatUtils.requestUpdateCursorAnchorInfo(mIC,
|
||||
enableMonitor, requestImmediateCallback);
|
||||
mCursorAnchorInfoMonitorEnabled = (scheduled && enableMonitor);
|
||||
return scheduled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the application reported that the monitor mode of
|
||||
* {@link InputMethodService#onUpdateCursorAnchorInfo(CursorAnchorInfo)} is currently enabled.
|
||||
*/
|
||||
public boolean isCursorAnchorInfoMonitorEnabled() {
|
||||
return mCursorAnchorInfoMonitorEnabled;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue