Java Code Examples for android.view.inputmethod.EditorInfo#TYPE_CLASS_TEXT

The following examples show how to use android.view.inputmethod.EditorInfo#TYPE_CLASS_TEXT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MongolEditText.java    From mongol-library with MIT License 6 votes vote down vote up
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {

    if (onCheckIsTextEditor() && isEnabled()) {
        outAttrs.inputType = getInputType();
        if (mInputContentType != null) {
            outAttrs.imeOptions = mInputContentType.imeOptions;
            outAttrs.privateImeOptions = mInputContentType.privateImeOptions;
            outAttrs.actionLabel = mInputContentType.imeActionLabel;
            outAttrs.actionId = mInputContentType.imeActionId;
            outAttrs.extras = mInputContentType.extras;
        } else {
            outAttrs.imeOptions = EditorInfo.TYPE_CLASS_TEXT;
        }
    }

    outAttrs.initialSelStart = getSelectionStart();
    outAttrs.initialSelEnd = getSelectionEnd();

    return new MetInputConnection(this, true);
}
 
Example 2
Source File: PinView.java    From PinView with Apache License 2.0 5 votes vote down vote up
private static boolean isPasswordInputType(int inputType) {
    final int variation =
            inputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION);
    return variation
            == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD)
            || variation
            == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_WEB_PASSWORD)
            || variation
            == (EditorInfo.TYPE_CLASS_NUMBER | EditorInfo.TYPE_NUMBER_VARIATION_PASSWORD);
}
 
Example 3
Source File: OtpView.java    From android-otpview-pinview with MIT License 5 votes vote down vote up
private static boolean isPasswordInputType(int inputType) {
  final int variation =
      inputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION);
  return variation
      == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD)
      || variation
      == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_WEB_PASSWORD)
      || variation
      == (EditorInfo.TYPE_CLASS_NUMBER | EditorInfo.TYPE_NUMBER_VARIATION_PASSWORD);
}
 
Example 4
Source File: InputMethodService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
void startExtractingText(boolean inputChanged) {
    final ExtractEditText eet = mExtractEditText;
    if (eet != null && getCurrentInputStarted()
            && isFullscreenMode()) {
        mExtractedToken++;
        ExtractedTextRequest req = new ExtractedTextRequest();
        req.token = mExtractedToken;
        req.flags = InputConnection.GET_TEXT_WITH_STYLES;
        req.hintMaxLines = 10;
        req.hintMaxChars = 10000;
        InputConnection ic = getCurrentInputConnection();
        mExtractedText = ic == null? null
                : ic.getExtractedText(req, InputConnection.GET_EXTRACTED_TEXT_MONITOR);
        if (mExtractedText == null || ic == null) {
            Log.e(TAG, "Unexpected null in startExtractingText : mExtractedText = "
                    + mExtractedText + ", input connection = " + ic);
        }
        final EditorInfo ei = getCurrentInputEditorInfo();
        
        try {
            eet.startInternalChanges();
            onUpdateExtractingVisibility(ei);
            onUpdateExtractingViews(ei);
            int inputType = ei.inputType;
            if ((inputType&EditorInfo.TYPE_MASK_CLASS)
                    == EditorInfo.TYPE_CLASS_TEXT) {
                if ((inputType&EditorInfo.TYPE_TEXT_FLAG_IME_MULTI_LINE) != 0) {
                    inputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE;
                }
            }
            eet.setInputType(inputType);
            eet.setHint(ei.hintText);
            if (mExtractedText != null) {
                eet.setEnabled(true);
                eet.setExtractedText(mExtractedText);
            } else {
                eet.setEnabled(false);
                eet.setText("");
            }
        } finally {
            eet.finishInternalChanges();
        }
        
        if (inputChanged) {
            onExtractingInputChanged(ei);
        }
    }
}
 
Example 5
Source File: CodenameOneView.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public void setInputType(EditorInfo editorInfo) {

        /**
         * do not use the enter key to fire some kind of action!
         */
//        editorInfo.imeOptions |= EditorInfo.IME_ACTION_NONE;
        Component txtCmp = Display.getInstance().getCurrent().getFocused();
        if (txtCmp != null && txtCmp instanceof TextArea) {
            TextArea txt = (TextArea) txtCmp;
            if (txt.isSingleLineTextArea()) {
                editorInfo.imeOptions |= EditorInfo.IME_ACTION_DONE;

            } else {
                editorInfo.imeOptions |= EditorInfo.IME_ACTION_NONE;
            }
            int inputType = 0;
            int constraint = txt.getConstraint();
            if ((constraint & TextArea.PASSWORD) == TextArea.PASSWORD) {
                constraint = constraint ^ TextArea.PASSWORD;
            }
            switch (constraint) {
                case TextArea.NUMERIC:
                    inputType = EditorInfo.TYPE_CLASS_NUMBER | EditorInfo.TYPE_NUMBER_FLAG_SIGNED;
                    break;
                case TextArea.DECIMAL:
                    inputType = EditorInfo.TYPE_CLASS_NUMBER | EditorInfo.TYPE_NUMBER_FLAG_DECIMAL;
                    break;
                case TextArea.PHONENUMBER:
                    inputType = EditorInfo.TYPE_CLASS_PHONE;
                    break;
                case TextArea.EMAILADDR:
                    inputType = EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
                    break;
                case TextArea.URL:
                    inputType = EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_URI;
                    break;
                default:
                    inputType = EditorInfo.TYPE_CLASS_TEXT;
                    break;

            }

            editorInfo.inputType = inputType;
        }
    }
 
Example 6
Source File: AdapterInputConnection.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@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();
}
 
Example 7
Source File: AdapterInputConnection.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@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();
}