diff options
Diffstat (limited to 'java/src')
4 files changed, 40 insertions, 29 deletions
diff --git a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java index af1575f06..00b6f0a43 100644 --- a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java @@ -296,7 +296,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha final SoftReference<LatinKeyboard> ref = mKeyboardCache.get(id); LatinKeyboard keyboard = (ref == null) ? null : ref.get(); if (keyboard == null) { - final Resources res = mInputMethodService.getResources(); final Locale savedLocale = mSubtypeSwitcher.changeSystemLocale( mSubtypeSwitcher.getInputLocale()); @@ -668,11 +667,12 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha return mInputView; } - public void loadKeyboardView() { - loadKeyboardViewInternal(mLayoutId, true); + public LatinKeyboardView onCreateInputView() { + createInputViewInternal(mLayoutId, true); + return mInputView; } - private void loadKeyboardViewInternal(int newLayout, boolean forceReset) { + private void createInputViewInternal(int newLayout, boolean forceReset) { if (mLayoutId != newLayout || mInputView == null || forceReset) { if (mInputView != null) { mInputView.closing(); @@ -701,24 +701,31 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha mInputView.setOnKeyboardActionListener(mInputMethodService); mLayoutId = newLayout; } - // TODO: Not to post if this function was called from loadKeyboardView + } + + private void postSetInputView() { mInputMethodService.mHandler.post(new Runnable() { + @Override public void run() { if (mInputView != null) { mInputMethodService.setInputView(mInputView); } mInputMethodService.updateInputViewShown(); - }}); + } + }); } + @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (PREF_KEYBOARD_LAYOUT.equals(key)) { final int layoutId = Integer.valueOf( sharedPreferences.getString(key, DEFAULT_LAYOUT_ID)); - loadKeyboardViewInternal(layoutId, false); + createInputViewInternal(layoutId, false); + postSetInputView(); } else if (LatinIMESettings.PREF_SETTINGS_KEY.equals(key)) { mHasSettingsKey = getSettingsKeyMode(sharedPreferences, mInputMethodService); - loadKeyboardViewInternal(mLayoutId, true); + createInputViewInternal(mLayoutId, true); + postSetInputView(); } } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index cc8dfebe2..36c77efaf 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -464,7 +464,8 @@ public class LatinIME extends InputMethodService @Override public void onConfigurationChanged(Configuration conf) { mSubtypeSwitcher.onConfigurationChanged(conf); - onKeyboardLanguageChanged(); + if (mSubtypeSwitcher.isKeyboardMode()) + onKeyboardLanguageChanged(); updateAutoTextEnabled(); // If orientation changed while predicting, commit the change @@ -489,8 +490,7 @@ public class LatinIME extends InputMethodService @Override public View onCreateInputView() { - mKeyboardSwitcher.loadKeyboardView(); - return mKeyboardSwitcher.getInputView(); + return mKeyboardSwitcher.onCreateInputView(); } @Override @@ -524,7 +524,7 @@ public class LatinIME extends InputMethodService return; } - SubtypeSwitcher.getInstance().updateParametersOnStartInputView(); + mSubtypeSwitcher.updateParametersOnStartInputView(); if (mRefreshKeyboardRequired) { mRefreshKeyboardRequired = false; @@ -614,9 +614,12 @@ public class LatinIME extends InputMethodService mJustAddedAutoSpace = false; loadSettings(attribute); - switcher.loadKeyboard(mode, attribute.imeOptions, mVoiceConnector.isVoiceButtonEnabled(), - mVoiceConnector.isVoiceButtonOnPrimary()); - switcher.updateShiftState(); + if (mSubtypeSwitcher.isKeyboardMode()) { + switcher.loadKeyboard(mode, attribute.imeOptions, + mVoiceConnector.isVoiceButtonEnabled(), + mVoiceConnector.isVoiceButtonOnPrimary()); + switcher.updateShiftState(); + } setCandidatesViewShownInternal(isCandidateStripVisible(), false /* needsInputViewShown */ ); @@ -641,7 +644,7 @@ public class LatinIME extends InputMethodService } private void checkReCorrectionOnStart() { - if (mReCorrectionEnabled && isPredictionOn()) { + if (mReCorrectionEnabled && isSuggestionShown() && isPredictionOn()) { // First get the cursor position. This is required by setOldSuggestions(), so that // it can pass the correct range to setComposingRegion(). At this point, we don't // have valid values for mLastSelectionStart/Stop because onUpdateSelection() has @@ -745,7 +748,7 @@ public class LatinIME extends InputMethodService mLastSelectionStart = newSelStart; mLastSelectionEnd = newSelEnd; - if (mReCorrectionEnabled) { + if (mReCorrectionEnabled && isSuggestionShown()) { // Don't look for corrections if the keyboard is not visible if (mKeyboardSwitcher.isInputViewShown()) { // Check if we should go in or out of correction mode. diff --git a/java/src/com/android/inputmethod/latin/PointerTracker.java b/java/src/com/android/inputmethod/latin/PointerTracker.java index 4d9133045..327fef107 100644 --- a/java/src/com/android/inputmethod/latin/PointerTracker.java +++ b/java/src/com/android/inputmethod/latin/PointerTracker.java @@ -301,19 +301,23 @@ public class PointerTracker { if (mKeyAlreadyProcessed) return; KeyState keyState = mKeyState; - int keyIndex = keyState.onMoveKey(x, y); - Key key = getKey(keyIndex); - if (key != null) { - if (keyState.getKeyIndex() == NOT_A_KEY) { + final int keyIndex = keyState.onMoveKey(x, y); + final Key oldKey = getKey(keyState.getKeyIndex()); + if (isValidKeyIndex(keyIndex)) { + if (oldKey == null) { keyState.onMoveToNewKey(keyIndex, x, y); startLongPressTimer(keyIndex); } else if (!isMinorMoveBounce(x, y, keyIndex)) { + if (mListener != null) + mListener.onRelease(oldKey.codes[0]); resetMultiTap(); keyState.onMoveToNewKey(keyIndex, x, y); startLongPressTimer(keyIndex); } } else { - if (keyState.getKeyIndex() != NOT_A_KEY) { + if (oldKey != null) { + if (mListener != null) + mListener.onRelease(oldKey.codes[0]); keyState.onMoveToNewKey(keyIndex, x ,y); mHandler.cancelLongPressTimers(); } else if (!isMinorMoveBounce(x, y, keyIndex)) { @@ -405,7 +409,7 @@ public class PointerTracker { private void showKeyPreviewAndUpdateKeyGraphics(int keyIndex) { updateKeyGraphics(keyIndex); // The modifier key, such as shift key, should not be shown as preview when multi-touch is - // supported. On thge other hand, if multi-touch is not supported, the modifier key should + // supported. On the other hand, if multi-touch is not supported, the modifier key should // be shown as preview. if (mHasDistinctMultitouch && isModifier()) { mProxy.showPreview(NOT_A_KEY, this); diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java index 0e739e2f5..103443e6d 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java @@ -39,7 +39,7 @@ public class SubtypeSwitcher { // We may or may not draw the current language on space bar regardless of this flag. public static final boolean USE_SPACEBAR_LANGUAGE_SWITCHER = false; private static final boolean DBG = false; - private static final String TAG = "InputMethodSubtypeSwitcher"; + private static final String TAG = "SubtypeSwitcher"; private static final char LOCALE_SEPARATER = '_'; private static final String KEYBOARD_MODE = "keyboard"; @@ -153,9 +153,9 @@ public class SubtypeSwitcher { final String newLocale; final String newMode; if (newSubtype == null) { - // Normally, newSubtype shouldn't be null. But just in case if newSubtype was null, + // Normally, newSubtype shouldn't be null. But just in case newSubtype was null, // fallback to the default locale and mode. - Log.e(TAG, "Couldn't get the current subtype."); + Log.w(TAG, "Couldn't get the current subtype."); newLocale = "en_US"; newMode =KEYBOARD_MODE; } else { @@ -345,14 +345,11 @@ public class SubtypeSwitcher { public boolean setVoiceInput(VoiceInput vi) { if (mVoiceInput == null && vi != null) { - // TODO: Remove requirements to construct KeyboardSwitcher - // when IME was enabled with Voice mode mVoiceInput = vi; if (isVoiceMode()) { if (DBG) { Log.d(TAG, "Set and call voice input."); } - mService.onKeyboardLanguageChanged(); mService.onKey(LatinKeyboardView.KEYCODE_VOICE, null, 0, 0); return true; } |