am 2ad14a2e: Merge "Use temporary variables for computing editor attributes"

* commit '2ad14a2ea77b5becf8c462dd9dccbaf65d970854':
  Use temporary variables for computing editor attributes
main
Jean Chalard 2011-12-16 01:10:09 -08:00 committed by Android Git Automerger
commit a48c1d7b70
1 changed files with 24 additions and 17 deletions

View File

@ -797,6 +797,12 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
private void initializeInputAttributes(final EditorInfo editorInfo) { private void initializeInputAttributes(final EditorInfo editorInfo) {
mInputAttributes = new InputAttributes(editorInfo); mInputAttributes = new InputAttributes(editorInfo);
boolean insertSpaceOnPickSuggestionManually = false;
boolean inputTypeNoAutoCorrect = false;
boolean isSettingsSuggestionStripOn = false;
boolean applicationSpecifiedCompletionOn = false;
if (editorInfo == null) if (editorInfo == null)
return; return;
final int inputType = editorInfo.inputType; final int inputType = editorInfo.inputType;
@ -811,56 +817,57 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
inputType, editorInfo.imeOptions)); inputType, editorInfo.imeOptions));
} }
mInputAttributes.mInsertSpaceOnPickSuggestionManually = false;
mInputAttributes.mInputTypeNoAutoCorrect = false;
mInputAttributes.mIsSettingsSuggestionStripOn = false;
mInputAttributes.mApplicationSpecifiedCompletionOn = false;
mApplicationSpecifiedCompletions = null; mApplicationSpecifiedCompletions = null;
if (inputClass == InputType.TYPE_CLASS_TEXT) { if (inputClass == InputType.TYPE_CLASS_TEXT) {
mInputAttributes.mIsSettingsSuggestionStripOn = true; isSettingsSuggestionStripOn = true;
// Make sure that passwords are not displayed in {@link SuggestionsView}. // Make sure that passwords are not displayed in {@link SuggestionsView}.
if (InputTypeCompatUtils.isPasswordInputType(inputType) if (InputTypeCompatUtils.isPasswordInputType(inputType)
|| InputTypeCompatUtils.isVisiblePasswordInputType(inputType)) { || InputTypeCompatUtils.isVisiblePasswordInputType(inputType)) {
mInputAttributes.mIsSettingsSuggestionStripOn = false; isSettingsSuggestionStripOn = false;
} }
if (InputTypeCompatUtils.isEmailVariation(variation) if (InputTypeCompatUtils.isEmailVariation(variation)
|| variation == InputType.TYPE_TEXT_VARIATION_PERSON_NAME) { || variation == InputType.TYPE_TEXT_VARIATION_PERSON_NAME) {
// The point in turning this off is that we don't want to insert a space after // The point in turning this off is that we don't want to insert a space after
// a name when filling a form: we can't delete trailing spaces when changing fields // a name when filling a form: we can't delete trailing spaces when changing fields
mInputAttributes.mInsertSpaceOnPickSuggestionManually = false; insertSpaceOnPickSuggestionManually = false;
} else { } else {
mInputAttributes.mInsertSpaceOnPickSuggestionManually = true; insertSpaceOnPickSuggestionManually = true;
} }
if (InputTypeCompatUtils.isEmailVariation(variation)) { if (InputTypeCompatUtils.isEmailVariation(variation)) {
mInputAttributes.mIsSettingsSuggestionStripOn = false; isSettingsSuggestionStripOn = false;
} else if (variation == InputType.TYPE_TEXT_VARIATION_URI) { } else if (variation == InputType.TYPE_TEXT_VARIATION_URI) {
mInputAttributes.mIsSettingsSuggestionStripOn = false; isSettingsSuggestionStripOn = false;
} else if (variation == InputType.TYPE_TEXT_VARIATION_FILTER) { } else if (variation == InputType.TYPE_TEXT_VARIATION_FILTER) {
mInputAttributes.mIsSettingsSuggestionStripOn = false; isSettingsSuggestionStripOn = false;
} else if (variation == InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT) { } else if (variation == InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT) {
// 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 ((inputType & InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) == 0) { if ((inputType & InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) == 0) {
mInputAttributes.mInputTypeNoAutoCorrect = true; inputTypeNoAutoCorrect = true;
} }
} }
// If NO_SUGGESTIONS is set, don't do prediction. // If NO_SUGGESTIONS is set, don't do prediction.
if ((inputType & InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) != 0) { if ((inputType & InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) != 0) {
mInputAttributes.mIsSettingsSuggestionStripOn = false; isSettingsSuggestionStripOn = false;
mInputAttributes.mInputTypeNoAutoCorrect = true; inputTypeNoAutoCorrect = 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 ((inputType & InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) == 0 if ((inputType & InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) == 0
&& (inputType & InputType.TYPE_TEXT_FLAG_MULTI_LINE) == 0) { && (inputType & InputType.TYPE_TEXT_FLAG_MULTI_LINE) == 0) {
mInputAttributes.mInputTypeNoAutoCorrect = true; inputTypeNoAutoCorrect = true;
} }
if ((inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE) != 0) { if ((inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE) != 0) {
mInputAttributes.mIsSettingsSuggestionStripOn = false; isSettingsSuggestionStripOn = false;
mInputAttributes.mApplicationSpecifiedCompletionOn = isFullscreenMode(); applicationSpecifiedCompletionOn = isFullscreenMode();
} }
} }
mInputAttributes.mInsertSpaceOnPickSuggestionManually = insertSpaceOnPickSuggestionManually;
mInputAttributes.mInputTypeNoAutoCorrect = inputTypeNoAutoCorrect;
mInputAttributes.mIsSettingsSuggestionStripOn = isSettingsSuggestionStripOn;
mInputAttributes.mApplicationSpecifiedCompletionOn = applicationSpecifiedCompletionOn;
} }
@Override @Override