Load keyboard only when subtype is keyboard mode
Bug: 3224990 Change-Id: I1ae1d86dce923464d4474fc7ce02f2ff22067603main
parent
dedb26f639
commit
8d7ecc70a6
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -464,6 +464,7 @@ public class LatinIME extends InputMethodService
|
|||
@Override
|
||||
public void onConfigurationChanged(Configuration conf) {
|
||||
mSubtypeSwitcher.onConfigurationChanged(conf);
|
||||
if (mSubtypeSwitcher.isKeyboardMode())
|
||||
onKeyboardLanguageChanged();
|
||||
updateAutoTextEnabled();
|
||||
|
||||
|
@ -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(),
|
||||
if (mSubtypeSwitcher.isKeyboardMode()) {
|
||||
switcher.loadKeyboard(mode, attribute.imeOptions,
|
||||
mVoiceConnector.isVoiceButtonEnabled(),
|
||||
mVoiceConnector.isVoiceButtonOnPrimary());
|
||||
switcher.updateShiftState();
|
||||
}
|
||||
|
||||
setCandidatesViewShownInternal(isCandidateStripVisible(),
|
||||
false /* needsInputViewShown */ );
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue