android.view.inputmethod.EditorInfo#TYPE_TEXT_VARIATION_WEB_EDIT_TEXT源码实例Demo

下面列出了android.view.inputmethod.EditorInfo#TYPE_TEXT_VARIATION_WEB_EDIT_TEXT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android-chromium   文件: AdapterInputConnection.java
@VisibleForTesting
AdapterInputConnection(View view, ImeAdapter imeAdapter, EditorInfo outAttrs) {
    super(view, true);
    mInternalView = view;
    mImeAdapter = imeAdapter;
    mImeAdapter.setInputConnection(this);
    mSingleLine = true;
    outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN
            | EditorInfo.IME_FLAG_NO_EXTRACT_UI;
    outAttrs.inputType = EditorInfo.TYPE_CLASS_TEXT
            | EditorInfo.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT;

    if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeText) {
        // Normal text field
        outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT;
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeTextArea ||
            imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeContentEditable) {
        // TextArea or contenteditable.
        outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE
                | EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES
                | EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT;
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_NONE;
        mSingleLine = false;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypePassword) {
        // Password
        outAttrs.inputType = InputType.TYPE_CLASS_TEXT
                | InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD;
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeSearch) {
        // Search
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_SEARCH;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeUrl) {
        // Url
        // TYPE_TEXT_VARIATION_URI prevents Tab key from showing, so
        // exclude it for now.
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeEmail) {
        // Email
        outAttrs.inputType = InputType.TYPE_CLASS_TEXT
                | InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS;
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeTel) {
        // Telephone
        // Number and telephone do not have both a Tab key and an
        // action in default OSK, so set the action to NEXT
        outAttrs.inputType = InputType.TYPE_CLASS_PHONE;
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeNumber) {
        // Number
        outAttrs.inputType = InputType.TYPE_CLASS_NUMBER
                | InputType.TYPE_NUMBER_VARIATION_NORMAL;
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT;
    }
    outAttrs.initialSelStart = imeAdapter.getInitialSelectionStart();
    outAttrs.initialSelEnd = imeAdapter.getInitialSelectionEnd();
    mLastUpdateSelectionStart = imeAdapter.getInitialSelectionStart();
    mLastUpdateSelectionEnd = imeAdapter.getInitialSelectionEnd();
}
 
源代码2 项目: android-chromium   文件: AdapterInputConnection.java
@VisibleForTesting
AdapterInputConnection(View view, ImeAdapter imeAdapter, EditorInfo outAttrs) {
    super(view, true);
    mInternalView = view;
    mImeAdapter = imeAdapter;
    mImeAdapter.setInputConnection(this);
    mSingleLine = true;
    outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN
            | EditorInfo.IME_FLAG_NO_EXTRACT_UI;
    outAttrs.inputType = EditorInfo.TYPE_CLASS_TEXT
            | EditorInfo.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT;

    if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeText) {
        // Normal text field
        outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT;
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeTextArea ||
            imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeContentEditable) {
        // TextArea or contenteditable.
        outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE
                | EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES
                | EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT;
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_NONE;
        mSingleLine = false;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypePassword) {
        // Password
        outAttrs.inputType = InputType.TYPE_CLASS_TEXT
                | InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD;
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeSearch) {
        // Search
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_SEARCH;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeUrl) {
        // Url
        // TYPE_TEXT_VARIATION_URI prevents Tab key from showing, so
        // exclude it for now.
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeEmail) {
        // Email
        outAttrs.inputType = InputType.TYPE_CLASS_TEXT
                | InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS;
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeTel) {
        // Telephone
        // Number and telephone do not have both a Tab key and an
        // action in default OSK, so set the action to NEXT
        outAttrs.inputType = InputType.TYPE_CLASS_PHONE;
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeNumber) {
        // Number
        outAttrs.inputType = InputType.TYPE_CLASS_NUMBER
                | InputType.TYPE_NUMBER_VARIATION_NORMAL;
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT;
    }
    outAttrs.initialSelStart = imeAdapter.getInitialSelectionStart();
    outAttrs.initialSelEnd = imeAdapter.getInitialSelectionEnd();
    mLastUpdateSelectionStart = imeAdapter.getInitialSelectionStart();
    mLastUpdateSelectionEnd = imeAdapter.getInitialSelectionEnd();
}