Example usage for android.text InputType TYPE_MASK_VARIATION

List of usage examples for android.text InputType TYPE_MASK_VARIATION

Introduction

In this page you can find the example usage for android.text InputType TYPE_MASK_VARIATION.

Prototype

int TYPE_MASK_VARIATION

To view the source code for android.text InputType TYPE_MASK_VARIATION.

Click Source Link

Document

Mask of bits that determine the variation of the base content class.

Usage

From source file:Main.java

@SuppressLint("InlinedApi")
public static boolean isPasswordField(int inputType) {
    int inputClass = inputType & InputType.TYPE_MASK_CLASS;
    int inputVariation = inputType & InputType.TYPE_MASK_VARIATION;
    return inputClass == InputType.TYPE_CLASS_TEXT
            && (inputVariation == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
                    || inputVariation == InputType.TYPE_TEXT_VARIATION_PASSWORD
                    || inputVariation == InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD);
}

From source file:Main.java

public static boolean isVisiblePasswordInputType(int inputType) {
    final int maskedInputType = inputType & (InputType.TYPE_MASK_CLASS | InputType.TYPE_MASK_VARIATION);
    return maskedInputType == TEXT_VISIBLE_PASSWORD_INPUT_TYPE;
}

From source file:research.sg.edu.edapp.kb.KbSoftKeyboard.java

/**
 * This is the main point where we do our initialization of the input method
 * to begin operating on an application.  At this point we have been
 * bound to the client, and are now receiving all of the detailed information
 * about the target of our edits./*from  www .  j  a  va2  s  . c o m*/
 */
@Override
public void onStartInput(EditorInfo attribute, boolean restarting) {
    super.onStartInput(attribute, restarting);

    // Reset our state.  We want to do this even if restarting, because
    // the underlying state of the text editor could have changed in any way.
    mComposing.setLength(0);
    updateCandidates();

    if (!restarting) {
        // Clear shift states.
        mMetaState = 0;
    }

    mPredictionOn = false;
    mCompletionOn = false;
    mCompletions = null;

    // We are now going to initialize our state based on the type of
    // text being edited.
    switch (attribute.inputType & InputType.TYPE_MASK_CLASS) {
    case InputType.TYPE_CLASS_NUMBER:
    case InputType.TYPE_CLASS_DATETIME:
        // Numbers and dates default to the symbols keyboard, with
        // no extra features.
        mCurKeyboard = mSymbolsKeyboard;
        break;

    case InputType.TYPE_CLASS_PHONE:
        // Phones will also default to the symbols keyboard, though
        // often you will want to have a dedicated phone keyboard.
        mCurKeyboard = mSymbolsKeyboard;
        break;

    case InputType.TYPE_CLASS_TEXT:
        // This is general text editing.  We will default to the
        // normal alphabetic keyboard, and assume that we should
        // be doing predictive text (showing candidates as the
        // user types).
        mCurKeyboard = mQwertyKeyboard;
        mPredictionOn = true;
        //mPredictionOn = false;

        // We now look for a few special variations of text that will
        // modify our behavior.
        int variation = attribute.inputType & InputType.TYPE_MASK_VARIATION;
        if (variation == InputType.TYPE_TEXT_VARIATION_PASSWORD
                || variation == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) {
            // Do not display predictions / what the user is typing
            // when they are entering a password.
            mPredictionOn = false;
        }

        if (variation == InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
                || variation == InputType.TYPE_TEXT_VARIATION_URI
                || variation == InputType.TYPE_TEXT_VARIATION_FILTER) {
            // Our predictions are not useful for e-mail addresses
            // or URIs.
            mPredictionOn = false;
        }

        if ((attribute.inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE) != 0) {
            // If this is an auto-complete text view, then our predictions
            // will not be shown and instead we will allow the editor
            // to supply their own.  We only show the editor's
            // candidates when in fullscreen mode, otherwise relying
            // own it displaying its own UI.
            mPredictionOn = false;
            mCompletionOn = isFullscreenMode();
        }

        // We also want to look at the current state of the editor
        // to decide whether our alphabetic keyboard should start out
        // shifted.
        updateShiftKeyState(attribute);
        break;

    default:
        // For all unknown input types, default to the alphabetic
        // keyboard with no special features.
        mCurKeyboard = mQwertyKeyboard;
        updateShiftKeyState(attribute);
    }

    // Update the label on the enter key, depending on what the application
    // says it will do.
    mCurKeyboard.setImeOptions(getResources(), attribute.imeOptions);
}

From source file:com.rbware.github.androidcouchpotato.widget.GuidedAction.java

final static boolean isPasswordVariant(int inputType) {
    final int variation = inputType & InputType.TYPE_MASK_VARIATION;
    return variation == InputType.TYPE_TEXT_VARIATION_PASSWORD
            || variation == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
            || variation == InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD;
}

From source file:android.support.v17.leanback.widget.GuidedAction.java

final static boolean isPasswordVariant(int inputType) {
    final int variantion = inputType & InputType.TYPE_MASK_VARIATION;
    return variantion == InputType.TYPE_TEXT_VARIATION_PASSWORD
            || variantion == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
            || variantion == InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD;
}