aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/LatinIME.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java36
1 files changed, 25 insertions, 11 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index d51c63dd3..4d7e43e17 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -808,6 +808,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@SuppressWarnings("deprecation")
private void onStartInputViewInternal(final EditorInfo editorInfo, final boolean restarting) {
super.onStartInputView(editorInfo, restarting);
+ mRichImm.clearSubtypeCaches();
final KeyboardSwitcher switcher = mKeyboardSwitcher;
final MainKeyboardView mainKeyboardView = switcher.getMainKeyboardView();
// If we are starting input in a different text field from before, we'll have to reload
@@ -903,12 +904,17 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// Sometimes, while rotating, for some reason the framework tells the app we are not
// connected to it and that means we can't refresh the cache. In this case, schedule a
// refresh later.
+ final boolean canReachInputConnection;
if (!mConnection.resetCachesUponCursorMoveAndReturnSuccess(editorInfo.initialSelStart,
false /* shouldFinishComposition */)) {
// We try resetting the caches up to 5 times before giving up.
mHandler.postResetCaches(isDifferentTextField, 5 /* remainingTries */);
+ canReachInputConnection = false;
} else {
- if (isDifferentTextField) mHandler.postResumeSuggestions();
+ if (isDifferentTextField) {
+ mHandler.postResumeSuggestions();
+ }
+ canReachInputConnection = true;
}
if (isDifferentTextField) {
@@ -920,7 +926,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
suggest.setAutoCorrectionThreshold(currentSettingsValues.mAutoCorrectionThreshold);
}
- switcher.loadKeyboard(editorInfo, currentSettingsValues);
+ if (canReachInputConnection) {
+ // If we can't reach the input connection, we don't want to call loadKeyboard yet.
+ // It will be done in #retryResetCaches.
+ switcher.loadKeyboard(editorInfo, currentSettingsValues);
+ }
} else if (restarting) {
// TODO: Come up with a more comprehensive way to reset the keyboard layout when
// a keyboard layout set doesn't get reloaded in this method.
@@ -1049,7 +1059,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// Should do the following in onFinishInputInternal but until JB MR2 it's not called :(
if (mWordComposer.isComposingWord()) mConnection.finishComposingText();
resetComposingState(true /* alsoResetLastComposedWord */);
- mRichImm.clearSubtypeCaches();
// Notify ResearchLogger
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
ResearchLogger.latinIME_onFinishInputViewInternal(finishingInput, mLastSelectionStart,
@@ -1402,14 +1411,15 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// Called from the KeyboardSwitcher which needs to know auto caps state to display
// the right layout.
public int getCurrentAutoCapsState() {
- if (!mSettings.getCurrent().mAutoCap) return Constants.TextUtils.CAP_MODE_OFF;
+ final SettingsValues currentSettingsValues = mSettings.getCurrent();
+ if (!currentSettingsValues.mAutoCap) return Constants.TextUtils.CAP_MODE_OFF;
final EditorInfo ei = getCurrentInputEditorInfo();
if (ei == null) return Constants.TextUtils.CAP_MODE_OFF;
final int inputType = ei.inputType;
// Warning: this depends on mSpaceState, which may not be the most current value. If
// mSpaceState gets updated later, whoever called this may need to be told about it.
- return mConnection.getCursorCapsMode(inputType, mSubtypeSwitcher.getCurrentSubtypeLocale(),
+ return mConnection.getCursorCapsMode(inputType, currentSettingsValues,
SPACE_STATE_PHANTOM == mSpaceState);
}
@@ -1450,9 +1460,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
private boolean maybeDoubleSpacePeriod() {
- final SettingsValues settingsValues = mSettings.getCurrent();
- if (!settingsValues.mCorrectionEnabled) return false;
- if (!settingsValues.mUseDoubleSpacePeriod) return false;
+ final SettingsValues currentSettingsValues = mSettings.getCurrent();
+ if (!currentSettingsValues.mCorrectionEnabled) return false;
+ if (!currentSettingsValues.mUseDoubleSpacePeriod) return false;
if (!mHandler.isAcceptingDoubleSpacePeriod()) return false;
// We only do this when we see two spaces and an accepted code point before the cursor.
// The code point may be a surrogate pair but the two spaces may not, so we need 4 chars.
@@ -1471,7 +1481,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (canBeFollowedByDoubleSpacePeriod(firstCodePoint)) {
mHandler.cancelDoubleSpacePeriodTimer();
mConnection.deleteSurroundingText(2, 0);
- final String textToInsert = ". ";
+ final String textToInsert = new String(
+ new int[] { currentSettingsValues.mSentenceSeparator, Constants.CODE_SPACE },
+ 0, 2);
mConnection.commitText(textToInsert, 1);
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
ResearchLogger.latinIME_maybeDoubleSpacePeriod(textToInsert,
@@ -2955,11 +2967,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (!mConnection.resetCachesUponCursorMoveAndReturnSuccess(mLastSelectionStart, false)) {
if (0 < remainingTries) {
mHandler.postResetCaches(tryResumeSuggestions, remainingTries - 1);
+ return;
}
- return;
+ // If remainingTries is 0, we should stop waiting for new tries, but it's still
+ // better to load the keyboard (less things will be broken).
}
tryFixLyingCursorPosition();
- mKeyboardSwitcher.updateShiftState();
+ mKeyboardSwitcher.loadKeyboard(getCurrentInputEditorInfo(), mSettings.getCurrent());
if (tryResumeSuggestions) mHandler.postResumeSuggestions();
}