Use temporary variables for computing editor attributes
The ultimate intent is to make these variables final, which will allow to move the computing function to the InputAttributes class. Change-Id: Ifb1fc7321a19b10d60aa63fa0daaa2708deda2cfmain
parent
dc9d0fcc11
commit
4e8922f1be
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue