Commit d1421a5f authored by mlamouri's avatar mlamouri Committed by Commit bot

Send autocapitalize flags to the Android virtual keyboard based on Blink hints.

This changes the behaviour of AdapterInputConnection to pass a
InputType.TYPE_TEXT_FLAG_CAP_* based on the
WebTextInputFlags.Autocapitalize* instead of doing it purely based on the
element's type.

This CL requires the following Blink CL:
https://codereview.chromium.org/995363002

BUG=466930

Review URL: https://codereview.chromium.org/1003143002

Cr-Commit-Position: refs/heads/master@{#322414}
parent c72f158e
......@@ -83,9 +83,7 @@ public class AdapterInputConnection extends BaseInputConnection {
}
} else if (inputType == TextInputType.TEXT_AREA
|| inputType == TextInputType.CONTENT_EDITABLE) {
// TextArea or contenteditable.
outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE
| EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES;
outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE;
if ((inputFlags & WebTextInputFlags.AutocorrectOff) == 0) {
outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT;
}
......@@ -122,6 +120,23 @@ public class AdapterInputConnection extends BaseInputConnection {
| InputType.TYPE_NUMBER_FLAG_DECIMAL;
outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT;
}
// Handling of autocapitalize. Blink will send the flag taking into account the element's
// type. This is not using AutocapitalizeNone because Android does not autocapitalize by
// default and there is no way to express no capitalization.
// Autocapitalize is meant as a hint to the virtual keyboard.
if ((inputFlags & WebTextInputFlags.AutocapitalizeCharacters) != 0) {
outAttrs.inputType |= InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS;
} else if ((inputFlags & WebTextInputFlags.AutocapitalizeWords) != 0) {
outAttrs.inputType |= InputType.TYPE_TEXT_FLAG_CAP_WORDS;
} else if ((inputFlags & WebTextInputFlags.AutocapitalizeSentences) != 0) {
outAttrs.inputType |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
}
// Content editable doesn't use autocapitalize so we need to set it manually.
if (inputType == TextInputType.CONTENT_EDITABLE) {
outAttrs.inputType |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
}
outAttrs.initialSelStart = Selection.getSelectionStart(mEditable);
outAttrs.initialSelEnd = Selection.getSelectionEnd(mEditable);
mLastUpdateSelectionStart = outAttrs.initialSelStart;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment