diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index e67f0ea05..7272006a2 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -68,6 +68,7 @@ import com.android.inputmethod.keyboard.KeyboardId; import com.android.inputmethod.keyboard.KeyboardSwitcher; import com.android.inputmethod.keyboard.KeyboardView; import com.android.inputmethod.keyboard.LatinKeyboardView; +import com.android.inputmethod.latin.Utils.UsabilityStudyLogUtils; import com.android.inputmethod.latin.suggestions.SuggestionsView; import java.io.FileDescriptor; @@ -196,7 +197,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar private InputMethodManagerCompatWrapper mImm; private Resources mResources; private SharedPreferences mPrefs; - private final KeyboardSwitcher mKeyboardSwitcher; + /* package for tests */ final KeyboardSwitcher mKeyboardSwitcher; private final SubtypeSwitcher mSubtypeSwitcher; private VoiceProxy mVoiceProxy; private boolean mShouldSwitchToLastSubtype = true; @@ -438,6 +439,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); mPrefs = prefs; LatinImeLogger.init(this, prefs); + ResearchLogger.init(this, prefs); LanguageSwitcherProxy.init(this, prefs); InputMethodManagerCompatWrapper.init(this); SubtypeSwitcher.init(this); @@ -502,7 +504,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar private void initSuggest() { final String localeStr = mSubtypeSwitcher.getInputLocaleStr(); - final Locale keyboardLocale = LocaleUtils.constructLocaleFromString(localeStr); + final Locale keyboardLocale = mSubtypeSwitcher.getInputLocale(); final Resources res = mResources; final Locale savedLocale = LocaleUtils.setSystemLocale(res, keyboardLocale); @@ -527,7 +529,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar resetContactsDictionary(oldContactsDictionary); mUserHistoryDictionary - = new UserHistoryDictionary(this, this, localeStr, Suggest.DIC_USER_HISTORY); + = new UserHistoryDictionary(this, localeStr, Suggest.DIC_USER_HISTORY); mSuggest.setUserHistoryDictionary(mUserHistoryDictionary); LocaleUtils.setSystemLocale(res, savedLocale); @@ -566,8 +568,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } /* package private */ void resetSuggestMainDict() { - final String localeStr = mSubtypeSwitcher.getInputLocaleStr(); - final Locale keyboardLocale = LocaleUtils.constructLocaleFromString(localeStr); + final Locale keyboardLocale = mSubtypeSwitcher.getInputLocale(); int mainDicResId = DictionaryFactory.getMainDictionaryResourceId(mResources); mSuggest.resetMainDict(this, mainDicResId, keyboardLocale); } @@ -1006,10 +1007,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar final int touchHeight = inputView.getHeight() + extraHeight // Extend touchable region below the keyboard. + EXTENDED_TOUCHABLE_REGION_HEIGHT; - if (DEBUG) { - Log.d(TAG, "Touchable region: y=" + touchY + " width=" + touchWidth - + " height=" + touchHeight); - } setTouchableRegionCompat(outInsets, 0, touchY, touchWidth, touchHeight); } outInsets.contentTopInsets = touchY; @@ -1266,6 +1263,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mDeleteCount = 0; } mLastKeyTime = when; + + if (ResearchLogger.sIsLogging) { + ResearchLogger.getInstance().logKeyEvent(primaryCode, x, y); + } + final KeyboardSwitcher switcher = mKeyboardSwitcher; // The space state depends only on the last character pressed and its own previous // state. Here, we revert the space state to neutral if the key is actually modifying @@ -1989,7 +1991,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } private void addToUserHistoryDictionary(final CharSequence suggestion) { - if (suggestion == null || suggestion.length() < 1) return; + if (TextUtils.isEmpty(suggestion)) return; // Only auto-add to dictionary if auto-correct is ON. Otherwise we'll be // adding words in situations where the user or application really didn't @@ -2007,8 +2009,14 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } else { prevWord = null; } + final String secondWord; + if (mWordComposer.isAutoCapitalized() && !mWordComposer.isMostlyCaps()) { + secondWord = suggestion.toString().toLowerCase(mSubtypeSwitcher.getInputLocale()); + } else { + secondWord = suggestion.toString(); + } mUserHistoryDictionary.addToUserHistory(null == prevWord ? null : prevWord.toString(), - suggestion.toString()); + secondWord); } } @@ -2249,10 +2257,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mFeedbackManager.vibrate(mKeyboardSwitcher.getKeyboardView()); } - public boolean isAutoCapitalized() { - return mWordComposer.isAutoCapitalized(); - } - private void updateCorrectionMode() { // TODO: cleanup messy flags final boolean shouldAutoCorrect = mSettingsValues.mAutoCorrectEnabled |