diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 94e0ac836..5236591f6 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -179,7 +179,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen public static class UIHandler extends StaticInnerHandlerWrapper<LatinIME> { private static final int MSG_UPDATE_SHIFT_STATE = 1; - private static final int MSG_SPACE_TYPED = 4; private static final int MSG_SET_BIGRAM_PREDICTIONS = 5; private static final int MSG_PENDING_IMS_CALLBACK = 6; private static final int MSG_UPDATE_SUGGESTIONS = 7; @@ -187,6 +186,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private int mDelayUpdateSuggestions; private int mDelayUpdateShiftState; private long mDoubleSpacesTurnIntoPeriodTimeout; + private long mDoubleSpaceTimerStart; public UIHandler(LatinIME outerInstance) { super(outerInstance); @@ -251,16 +251,16 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } public void startDoubleSpacesTimer() { - removeMessages(MSG_SPACE_TYPED); - sendMessageDelayed(obtainMessage(MSG_SPACE_TYPED), mDoubleSpacesTurnIntoPeriodTimeout); + mDoubleSpaceTimerStart = SystemClock.uptimeMillis(); } public void cancelDoubleSpacesTimer() { - removeMessages(MSG_SPACE_TYPED); + mDoubleSpaceTimerStart = 0; } public boolean isAcceptingDoubleSpaces() { - return hasMessages(MSG_SPACE_TYPED); + return SystemClock.uptimeMillis() - mDoubleSpaceTimerStart + < mDoubleSpacesTurnIntoPeriodTimeout; } // Working variables for the following methods. @@ -391,6 +391,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen Utils.GCUtils.getInstance().reset(); boolean tryGC = true; + // Shouldn't this be removed? I think that from Honeycomb on, the GC is now actually working + // as expected and this code is useless. for (int i = 0; i < Utils.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) { try { initSuggest(); @@ -449,7 +451,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen oldContactsDictionary = null; } mSuggest = new Suggest(this, subtypeLocale); - if (mCurrentSettings.mAutoCorrectEnabled) { + if (mCurrentSettings.isCorrectionOn()) { mSuggest.setAutoCorrectionThreshold(mCurrentSettings.mAutoCorrectionThreshold); } @@ -680,7 +682,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen loadSettings(); - if (mSuggest != null && mCurrentSettings.mAutoCorrectEnabled) { + if (mSuggest != null && mCurrentSettings.isCorrectionOn()) { mSuggest.setAutoCorrectionThreshold(mCurrentSettings.mAutoCorrectionThreshold); } @@ -762,6 +764,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen composingSpanEnd, mExpectingUpdateSelection, expectingUpdateSelectionFromLogger, mConnection); if (expectingUpdateSelectionFromLogger) { + // TODO: Investigate. Quitting now sounds wrong - we won't do the resetting work return; } } @@ -1072,12 +1075,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private boolean maybeDoubleSpace() { if (mCurrentSettings.mCorrectionMode == Suggest.CORRECTION_NONE) return false; + if (!mHandler.isAcceptingDoubleSpaces()) return false; final CharSequence lastThree = mConnection.getTextBeforeCursor(3, 0); if (lastThree != null && lastThree.length() == 3 && canBeFollowedByPeriod(lastThree.charAt(0)) && lastThree.charAt(1) == Keyboard.CODE_SPACE - && lastThree.charAt(2) == Keyboard.CODE_SPACE - && mHandler.isAcceptingDoubleSpaces()) { + && lastThree.charAt(2) == Keyboard.CODE_SPACE) { mHandler.cancelDoubleSpacesTimer(); mConnection.deleteSurroundingText(2, 0); mConnection.commitText(". ", 1); @@ -1553,8 +1556,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // not to auto correct, but accept the typed word. For instance, // in Italian dov' should not be expanded to dove' because the elision // requires the last vowel to be removed. - final boolean shouldAutoCorrect = mCurrentSettings.mAutoCorrectEnabled - && !mInputAttributes.mInputTypeNoAutoCorrect; + final boolean shouldAutoCorrect = mCurrentSettings.isCorrectionOn(); if (shouldAutoCorrect && primaryCode != Keyboard.CODE_SINGLE_QUOTE) { commitCurrentAutoCorrection(primaryCode); didAutoCorrect = true; @@ -1627,7 +1629,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen public boolean isSuggestionsRequested() { // TODO: move this method to mSettingsValues return mInputAttributes.mIsSettingsSuggestionStripOn - && (mCurrentSettings.mCorrectionMode > 0 || isShowingSuggestionsStrip()); + && (mCurrentSettings.isCorrectionOn() || isShowingSuggestionsStrip()); } public boolean isShowingPunctuationList() { @@ -1914,14 +1916,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mConnection.commitText(SuggestionSpanUtils.getTextWithSuggestionSpan( this, chosenWord, suggestedWords, mIsMainDictionaryAvailable), 1); - if (ProductionFlag.IS_EXPERIMENTAL) { - ResearchLogger.latinIME_commitText(chosenWord); - } } else { mConnection.commitText(chosenWord, 1); - if (ProductionFlag.IS_EXPERIMENTAL) { - ResearchLogger.latinIME_commitText(chosenWord); - } + } + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_commitText(chosenWord); } // Add the word to the user history dictionary final CharSequence prevWord = addToUserHistoryDictionary(chosenWord); @@ -2231,7 +2230,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen p.println(" mIsSuggestionsRequested=" + mInputAttributes.mIsSettingsSuggestionStripOn); p.println(" mCorrectionMode=" + mCurrentSettings.mCorrectionMode); p.println(" isComposingWord=" + mWordComposer.isComposingWord()); - p.println(" mAutoCorrectEnabled=" + mCurrentSettings.mAutoCorrectEnabled); + p.println(" isCorrectionOn=" + mCurrentSettings.isCorrectionOn()); p.println(" mSoundOn=" + mCurrentSettings.mSoundOn); p.println(" mVibrateOn=" + mCurrentSettings.mVibrateOn); p.println(" mKeyPreviewPopupOn=" + mCurrentSettings.mKeyPreviewPopupOn); |