aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/src/com/android/inputmethod/latin/KeyboardSwitcher.java23
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java17
-rw-r--r--java/src/com/android/inputmethod/latin/SubtypeSwitcher.java9
3 files changed, 28 insertions, 21 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 4ef19e831..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 */ );
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;
}