Merge "Load keyboard correctly when subtype has been changed to keyboard" into honeycomb
commit
26df6b508a
|
@ -133,14 +133,17 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
private Resources mResources;
|
private Resources mResources;
|
||||||
private SharedPreferences mPrefs;
|
private SharedPreferences mPrefs;
|
||||||
|
|
||||||
|
// These variables are initialized according to the {@link EditorInfo#inputType}.
|
||||||
|
private boolean mAutoSpace;
|
||||||
|
private boolean mInputTypeNoAutoCorrect;
|
||||||
|
private boolean mIsSettingsSuggestionStripOn;
|
||||||
|
private boolean mApplicationSpecifiedCompletionOn;
|
||||||
|
|
||||||
private final StringBuilder mComposing = new StringBuilder();
|
private final StringBuilder mComposing = new StringBuilder();
|
||||||
private WordComposer mWord = new WordComposer();
|
private WordComposer mWord = new WordComposer();
|
||||||
private CharSequence mBestWord;
|
private CharSequence mBestWord;
|
||||||
private boolean mHasValidSuggestions;
|
private boolean mHasValidSuggestions;
|
||||||
private boolean mIsSettingsSuggestionStripOn;
|
|
||||||
private boolean mApplicationSpecifiedCompletionOn;
|
|
||||||
private boolean mHasDictionary;
|
private boolean mHasDictionary;
|
||||||
private boolean mAutoSpace;
|
|
||||||
private boolean mJustAddedAutoSpace;
|
private boolean mJustAddedAutoSpace;
|
||||||
private boolean mAutoCorrectEnabled;
|
private boolean mAutoCorrectEnabled;
|
||||||
private boolean mReCorrectionEnabled;
|
private boolean mReCorrectionEnabled;
|
||||||
|
@ -164,9 +167,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
private int mLastSelectionEnd;
|
private int mLastSelectionEnd;
|
||||||
private SuggestedWords mSuggestPuncList;
|
private SuggestedWords mSuggestPuncList;
|
||||||
|
|
||||||
// Input type is such that we should not auto-correct
|
|
||||||
private boolean mInputTypeNoAutoCorrect;
|
|
||||||
|
|
||||||
// Indicates whether the suggestion strip is to be on in landscape
|
// Indicates whether the suggestion strip is to be on in landscape
|
||||||
private boolean mJustAccepted;
|
private boolean mJustAccepted;
|
||||||
private boolean mJustReverted;
|
private boolean mJustReverted;
|
||||||
|
@ -507,24 +507,62 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
|
|
||||||
if (mRefreshKeyboardRequired) {
|
if (mRefreshKeyboardRequired) {
|
||||||
mRefreshKeyboardRequired = false;
|
mRefreshKeyboardRequired = false;
|
||||||
onKeyboardLanguageChanged();
|
onRefreshKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEntryState.newSession(this);
|
TextEntryState.newSession(this);
|
||||||
|
|
||||||
// Most such things we decide below in the switch statement, but we need to know
|
// Most such things we decide below in initializeInputAttributesAndGetMode, but we need to
|
||||||
// now whether this is a password text field, because we need to know now (before
|
// know now whether this is a password text field, because we need to know now whether we
|
||||||
// the switch statement) whether we want to enable the voice button.
|
// want to enable the voice button.
|
||||||
int variation = attribute.inputType & InputType.TYPE_MASK_VARIATION;
|
mVoiceConnector.resetVoiceStates(isPasswordVariation(
|
||||||
mVoiceConnector.resetVoiceStates(isPasswordVariation(variation));
|
attribute.inputType & InputType.TYPE_MASK_VARIATION));
|
||||||
|
|
||||||
|
final int mode = initializeInputAttributesAndGetMode(attribute.inputType);
|
||||||
|
|
||||||
|
inputView.closing();
|
||||||
|
mEnteredText = null;
|
||||||
|
mComposing.setLength(0);
|
||||||
|
mHasValidSuggestions = false;
|
||||||
|
mDeleteCount = 0;
|
||||||
|
mJustAddedAutoSpace = false;
|
||||||
|
|
||||||
|
loadSettings(attribute);
|
||||||
|
if (mSubtypeSwitcher.isKeyboardMode()) {
|
||||||
|
switcher.loadKeyboard(mode, attribute.imeOptions,
|
||||||
|
mVoiceConnector.isVoiceButtonEnabled(),
|
||||||
|
mVoiceConnector.isVoiceButtonOnPrimary());
|
||||||
|
switcher.updateShiftState();
|
||||||
|
}
|
||||||
|
|
||||||
|
setCandidatesViewShownInternal(isCandidateStripVisible(),
|
||||||
|
false /* needsInputViewShown */ );
|
||||||
|
// Delay updating suggestions because keyboard input view may not be shown at this point.
|
||||||
|
mHandler.postUpdateSuggestions();
|
||||||
|
|
||||||
|
updateCorrectionMode();
|
||||||
|
|
||||||
|
inputView.setPreviewEnabled(mPopupOn);
|
||||||
|
inputView.setProximityCorrectionEnabled(true);
|
||||||
|
// If we just entered a text field, maybe it has some old text that requires correction
|
||||||
|
checkReCorrectionOnStart();
|
||||||
|
inputView.setForeground(true);
|
||||||
|
|
||||||
|
mVoiceConnector.onStartInputView(inputView.getWindowToken());
|
||||||
|
|
||||||
|
if (TRACE) Debug.startMethodTracing("/data/trace/latinime");
|
||||||
|
}
|
||||||
|
|
||||||
|
private int initializeInputAttributesAndGetMode(int inputType) {
|
||||||
|
final int variation = inputType & InputType.TYPE_MASK_VARIATION;
|
||||||
|
mAutoSpace = false;
|
||||||
mInputTypeNoAutoCorrect = false;
|
mInputTypeNoAutoCorrect = false;
|
||||||
mIsSettingsSuggestionStripOn = false;
|
mIsSettingsSuggestionStripOn = false;
|
||||||
mApplicationSpecifiedCompletionOn = false;
|
mApplicationSpecifiedCompletionOn = false;
|
||||||
mApplicationSpecifiedCompletions = null;
|
mApplicationSpecifiedCompletions = null;
|
||||||
mEnteredText = null;
|
|
||||||
|
|
||||||
final int mode;
|
final int mode;
|
||||||
switch (attribute.inputType & InputType.TYPE_MASK_CLASS) {
|
switch (inputType & InputType.TYPE_MASK_CLASS) {
|
||||||
case InputType.TYPE_CLASS_NUMBER:
|
case InputType.TYPE_CLASS_NUMBER:
|
||||||
case InputType.TYPE_CLASS_DATETIME:
|
case InputType.TYPE_CLASS_DATETIME:
|
||||||
mode = KeyboardId.MODE_NUMBER;
|
mode = KeyboardId.MODE_NUMBER;
|
||||||
|
@ -559,7 +597,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
mode = KeyboardId.MODE_WEB;
|
mode = KeyboardId.MODE_WEB;
|
||||||
// If it's a browser edit field and auto correct is not ON explicitly, then
|
// If it's a browser edit field and auto correct is not ON explicitly, then
|
||||||
// disable auto correction, but keep suggestions on.
|
// disable auto correction, but keep suggestions on.
|
||||||
if ((attribute.inputType & InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) == 0) {
|
if ((inputType & InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) == 0) {
|
||||||
mInputTypeNoAutoCorrect = true;
|
mInputTypeNoAutoCorrect = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -567,16 +605,16 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
|
|
||||||
// If NO_SUGGESTIONS is set, don't do prediction.
|
// If NO_SUGGESTIONS is set, don't do prediction.
|
||||||
if ((attribute.inputType & InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) != 0) {
|
if ((inputType & InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) != 0) {
|
||||||
mIsSettingsSuggestionStripOn = false;
|
mIsSettingsSuggestionStripOn = false;
|
||||||
mInputTypeNoAutoCorrect = true;
|
mInputTypeNoAutoCorrect = true;
|
||||||
}
|
}
|
||||||
// If it's not multiline and the autoCorrect flag is not set, then don't correct
|
// If it's not multiline and the autoCorrect flag is not set, then don't correct
|
||||||
if ((attribute.inputType & InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) == 0 &&
|
if ((inputType & InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) == 0 &&
|
||||||
(attribute.inputType & InputType.TYPE_TEXT_FLAG_MULTI_LINE) == 0) {
|
(inputType & InputType.TYPE_TEXT_FLAG_MULTI_LINE) == 0) {
|
||||||
mInputTypeNoAutoCorrect = true;
|
mInputTypeNoAutoCorrect = true;
|
||||||
}
|
}
|
||||||
if ((attribute.inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE) != 0) {
|
if ((inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE) != 0) {
|
||||||
mIsSettingsSuggestionStripOn = false;
|
mIsSettingsSuggestionStripOn = false;
|
||||||
mApplicationSpecifiedCompletionOn = isFullscreenMode();
|
mApplicationSpecifiedCompletionOn = isFullscreenMode();
|
||||||
}
|
}
|
||||||
|
@ -585,40 +623,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
mode = KeyboardId.MODE_TEXT;
|
mode = KeyboardId.MODE_TEXT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
inputView.closing();
|
return mode;
|
||||||
mComposing.setLength(0);
|
|
||||||
mHasValidSuggestions = false;
|
|
||||||
mDeleteCount = 0;
|
|
||||||
mJustAddedAutoSpace = false;
|
|
||||||
|
|
||||||
loadSettings(attribute);
|
|
||||||
if (mSubtypeSwitcher.isKeyboardMode()) {
|
|
||||||
switcher.loadKeyboard(mode, attribute.imeOptions,
|
|
||||||
mVoiceConnector.isVoiceButtonEnabled(),
|
|
||||||
mVoiceConnector.isVoiceButtonOnPrimary());
|
|
||||||
switcher.updateShiftState();
|
|
||||||
}
|
|
||||||
|
|
||||||
setCandidatesViewShownInternal(isCandidateStripVisible(),
|
|
||||||
false /* needsInputViewShown */ );
|
|
||||||
// Delay updating suggestions because keyboard input view may not be shown at this point.
|
|
||||||
mHandler.postUpdateSuggestions();
|
|
||||||
|
|
||||||
// If the dictionary is not big enough, don't auto correct
|
|
||||||
mHasDictionary = mSuggest.hasMainDictionary();
|
|
||||||
|
|
||||||
updateCorrectionMode();
|
|
||||||
|
|
||||||
inputView.setPreviewEnabled(mPopupOn);
|
|
||||||
inputView.setProximityCorrectionEnabled(true);
|
|
||||||
mIsSettingsSuggestionStripOn &= (mCorrectionMode > 0 || isShowingSuggestionsStrip());
|
|
||||||
// If we just entered a text field, maybe it has some old text that requires correction
|
|
||||||
checkReCorrectionOnStart();
|
|
||||||
inputView.setForeground(true);
|
|
||||||
|
|
||||||
mVoiceConnector.onStartInputView(inputView.getWindowToken());
|
|
||||||
|
|
||||||
if (TRACE) Debug.startMethodTracing("/data/trace/latinime");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkReCorrectionOnStart() {
|
private void checkReCorrectionOnStart() {
|
||||||
|
@ -1387,7 +1392,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSuggestionsRequested() {
|
private boolean isSuggestionsRequested() {
|
||||||
return mIsSettingsSuggestionStripOn;
|
return mIsSettingsSuggestionStripOn
|
||||||
|
&& (mCorrectionMode > 0 || isShowingSuggestionsStrip());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isShowingPunctuationList() {
|
private boolean isShowingPunctuationList() {
|
||||||
|
@ -1859,9 +1865,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
return mWord.isFirstCharCapitalized();
|
return mWord.isFirstCharCapitalized();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify that Language has been changed and toggleLanguage will update KeyboaredID according
|
// Notify that language or mode have been changed and toggleLanguage will update KeyboaredID
|
||||||
// to new Language.
|
// according to new language or mode.
|
||||||
public void onKeyboardLanguageChanged() {
|
public void onRefreshKeyboard() {
|
||||||
toggleLanguage(true, true);
|
toggleLanguage(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1872,8 +1878,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
// Reload keyboard because the current language has been changed.
|
// Reload keyboard because the current language has been changed.
|
||||||
KeyboardSwitcher switcher = mKeyboardSwitcher;
|
KeyboardSwitcher switcher = mKeyboardSwitcher;
|
||||||
final int mode = switcher.getKeyboardMode();
|
|
||||||
final EditorInfo attribute = getCurrentInputEditorInfo();
|
final EditorInfo attribute = getCurrentInputEditorInfo();
|
||||||
|
final int mode = initializeInputAttributesAndGetMode((attribute != null)
|
||||||
|
? attribute.inputType : 0);
|
||||||
final int imeOptions = (attribute != null) ? attribute.imeOptions : 0;
|
final int imeOptions = (attribute != null) ? attribute.imeOptions : 0;
|
||||||
switcher.loadKeyboard(mode, imeOptions, mVoiceConnector.isVoiceButtonEnabled(),
|
switcher.loadKeyboard(mode, imeOptions, mVoiceConnector.isVoiceButtonEnabled(),
|
||||||
mVoiceConnector.isVoiceButtonOnPrimary());
|
mVoiceConnector.isVoiceButtonOnPrimary());
|
||||||
|
|
|
@ -187,7 +187,7 @@ public class SubtypeSwitcher {
|
||||||
// fallback to the default locale and mode.
|
// fallback to the default locale and mode.
|
||||||
Log.w(TAG, "Couldn't get the current subtype.");
|
Log.w(TAG, "Couldn't get the current subtype.");
|
||||||
newLocale = "en_US";
|
newLocale = "en_US";
|
||||||
newMode =KEYBOARD_MODE;
|
newMode = KEYBOARD_MODE;
|
||||||
} else {
|
} else {
|
||||||
newLocale = newSubtype.getLocale();
|
newLocale = newSubtype.getLocale();
|
||||||
newMode = newSubtype.getMode();
|
newMode = newSubtype.getMode();
|
||||||
|
@ -217,8 +217,8 @@ public class SubtypeSwitcher {
|
||||||
mVoiceInput.cancel();
|
mVoiceInput.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (languageChanged) {
|
if (modeChanged || languageChanged) {
|
||||||
mService.onKeyboardLanguageChanged();
|
mService.onRefreshKeyboard();
|
||||||
}
|
}
|
||||||
} else if (isVoiceMode()) {
|
} else if (isVoiceMode()) {
|
||||||
// If needsToShowWarningDialog is true, voice input need to show warning before
|
// If needsToShowWarningDialog is true, voice input need to show warning before
|
||||||
|
|
Loading…
Reference in New Issue