diff options
author | mlamouri <mlamouri@chromium.org> | 2015-03-26 10:42:17 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-26 17:42:58 +0000 |
commit | d1421a5faf9dc2d3b3cad10640576b24a092d9ba (patch) | |
tree | a5b2606910c3f5178dc05da8213501a57cff0b9c /content/public/android/java | |
parent | c72f158ec9163f075114451fc96ae5e336eca935 (diff) | |
download | chromium_src-d1421a5faf9dc2d3b3cad10640576b24a092d9ba.zip chromium_src-d1421a5faf9dc2d3b3cad10640576b24a092d9ba.tar.gz chromium_src-d1421a5faf9dc2d3b3cad10640576b24a092d9ba.tar.bz2 |
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}
Diffstat (limited to 'content/public/android/java')
-rw-r--r-- | content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java b/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java index 249a37b..6333b78 100644 --- a/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java +++ b/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java @@ -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; |