当前位置: 首页>>代码示例>>Java>>正文


Java InputType.TYPE_MASK_CLASS属性代码示例

本文整理汇总了Java中android.text.InputType.TYPE_MASK_CLASS属性的典型用法代码示例。如果您正苦于以下问题:Java InputType.TYPE_MASK_CLASS属性的具体用法?Java InputType.TYPE_MASK_CLASS怎么用?Java InputType.TYPE_MASK_CLASS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.text.InputType的用法示例。


在下文中一共展示了InputType.TYPE_MASK_CLASS属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateSearchAutoComplete

/**
 * Updates the auto-complete text view.
 */
private void updateSearchAutoComplete() {
    // TODO mQueryTextView.setDropDownAnimationStyle(0); // no animation
    mQueryTextView.setThreshold(mSearchable.getSuggestThreshold());
    mQueryTextView.setImeOptions(mSearchable.getImeOptions());
    int inputType = mSearchable.getInputType();
    // We only touch this if the input type is set up for text (which it almost certainly
    // should be, in the case of search!)
    if ((inputType & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_TEXT) {
        // The existence of a suggestions authority is the proxy for "suggestions
        // are available here"
        inputType &= ~InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
        if (mSearchable.getSuggestAuthority() != null) {
            inputType |= InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
            // TYPE_TEXT_FLAG_AUTO_COMPLETE means that the text editor is performing
            // auto-completion based on its own semantics, which it will present to the user
            // as they type. This generally means that the input method should not show its
            // own candidates, and the spell checker should not be in action. The text editor
            // supplies its candidates by calling InputMethodManager.displayCompletions(),
            // which in turn will call InputMethodSession.displayCompletions().
            inputType |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
        }
    }
    mQueryTextView.setInputType(inputType);
    if (mSuggestionsAdapter != null) {
        mSuggestionsAdapter.changeCursor(null);
    }
    // attach the suggestions adapter, if suggestions are available
    // The existence of a suggestions authority is the proxy for "suggestions available here"
    if (mSearchable.getSuggestAuthority() != null) {
        mSuggestionsAdapter = new SuggestionsAdapter(getContext(),
                this, mSearchable, mOutsideDrawablesCache);
        mQueryTextView.setAdapter(mSuggestionsAdapter);
        ((SuggestionsAdapter) mSuggestionsAdapter).setQueryRefinement(
                mQueryRefinement ? SuggestionsAdapter.REFINE_ALL
                : SuggestionsAdapter.REFINE_BY_ENTRY);
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:40,代码来源:SearchView.java

示例2: getKeyboardMode

private static int getKeyboardMode(final EditorInfo editorInfo) {
    final int inputType = editorInfo.inputType;
    final int variation = inputType & InputType.TYPE_MASK_VARIATION;

    switch (inputType & InputType.TYPE_MASK_CLASS) {
    case InputType.TYPE_CLASS_NUMBER:
        return KeyboardId.MODE_NUMBER;
    case InputType.TYPE_CLASS_DATETIME:
        switch (variation) {
        case InputType.TYPE_DATETIME_VARIATION_DATE:
            return KeyboardId.MODE_DATE;
        case InputType.TYPE_DATETIME_VARIATION_TIME:
            return KeyboardId.MODE_TIME;
        default: // InputType.TYPE_DATETIME_VARIATION_NORMAL
            return KeyboardId.MODE_DATETIME;
        }
    case InputType.TYPE_CLASS_PHONE:
        return KeyboardId.MODE_PHONE;
    case InputType.TYPE_CLASS_TEXT:
        if (InputTypeUtils.isEmailVariation(variation)) {
            return KeyboardId.MODE_EMAIL;
        } else if (variation == InputType.TYPE_TEXT_VARIATION_URI) {
            return KeyboardId.MODE_URL;
        } else if (variation == InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE) {
            return KeyboardId.MODE_IM;
        } else if (variation == InputType.TYPE_TEXT_VARIATION_FILTER) {
            return KeyboardId.MODE_TEXT;
        } else {
            return KeyboardId.MODE_TEXT;
        }
    default:
        return KeyboardId.MODE_TEXT;
    }
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:34,代码来源:KeyboardLayoutSet.java

示例3: setInputType

private void setInputType() {

        /** Checks the preferences for the default keyboard layout.
         * If qwerty, we start out whether in qwerty or numbers, depending on the input type.
         * */

        EditorInfo attribute = getCurrentInputEditorInfo();

        if (PreferenceManager.getDefaultSharedPreferences(getBaseContext()).getString("start", "1").equals("1")) {
            switch (attribute.inputType & InputType.TYPE_MASK_CLASS) {
                case InputType.TYPE_CLASS_NUMBER:
                case InputType.TYPE_CLASS_DATETIME:
                case InputType.TYPE_CLASS_PHONE:
                    currentKeyboard = new LatinKeyboard(this, R.xml.numbers);
                    break;
                case InputType.TYPE_CLASS_TEXT:
                    int webInputType = attribute.inputType & InputType.TYPE_MASK_VARIATION;

                    if (webInputType == InputType.TYPE_TEXT_VARIATION_URI ||
                            webInputType == InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT ||
                            webInputType == InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
                            || webInputType == InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS) {
                        currentKeyboard = new LatinKeyboard(this, qwertyKeyboardID);
                    } else {
                        currentKeyboard = new LatinKeyboard(this, qwertyKeyboardID);
                    }

                    break;

                default:
                    currentKeyboard = new LatinKeyboard(this, qwertyKeyboardID);
                    break;
            }
        } else {
            setDefaultKeyboard();
        }
        if (kv != null) {
            kv.setKeyboard(currentKeyboard);
        }
    }
 
开发者ID:VladThodo,项目名称:behe-keyboard,代码行数:40,代码来源:PCKeyboard.java

示例4: getKeyboardMode

/**
 * 获取输入法键盘类型.
 */
private int getKeyboardMode(final EditorInfo editorInfo) {
    if (editorInfo == null) {
        return KeyBoardID.MODE_TEXT;
    }
    //
    final int inputType = editorInfo.inputType;
    final int variation = inputType & InputType.TYPE_MASK_VARIATION;
    // 根据 eidttext inputtype 返回软键盘类型.
    switch (inputType & InputType.TYPE_MASK_CLASS) {
        case InputType.TYPE_CLASS_NUMBER: // 数字键盘.
            // return KeyBoardID.MODE_NUMBER;
        case InputType.TYPE_CLASS_PHONE: // 显示符号键盘. phone拨号.
            // return KeyBoardID.MODE_PHONE;
        case InputType.TYPE_CLASS_DATETIME: // 日期,时间. 文本输入框要求输入数字或日期时.
            switch (variation) {
                case InputType.TYPE_DATETIME_VARIATION_DATE: // 多一个 "/"
                    return KeyBoardID.MODE_DATE;
                case InputType.TYPE_DATETIME_VARIATION_TIME: // 多一个 ":"
                    return KeyBoardID.MODE_TIME;
                default: // InputType.TYPE_DATETIME_VARIATION_NORMAL
                    return KeyBoardID.MODE_DATETIME; // 多两个 "/",":"
            }
        case InputType.TYPE_CLASS_TEXT: // 显示输入字母的软键盘.
            if (KeyBoardUtils.isEmailVariation(variation)) {
                return KeyBoardID.MODE_EMAIL;
            } else if (variation == InputType.TYPE_TEXT_VARIATION_URI) {
                return KeyBoardID.MODE_URL;
            } else if (variation == InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE) {
                return KeyBoardID.MODE_IM;
            } else if (variation == InputType.TYPE_TEXT_VARIATION_FILTER) {
                return KeyBoardID.MODE_TEXT;
            } else {
                return KeyBoardID.MODE_TEXT;
            }
        default:
            return KeyBoardID.MODE_TEXT;
    }
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:41,代码来源:EmojiIME.java

示例5: dumpFlags

@SuppressWarnings("unused")
private void dumpFlags(final int inputType) {
    final int inputClass = inputType & InputType.TYPE_MASK_CLASS;
    final String inputClassString = toInputClassString(inputClass);
    final String variationString = toVariationString(
            inputClass, inputType & InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
    final String flagsString = toFlagsString(inputType & InputType.TYPE_MASK_FLAGS);
    Log.i(TAG, "Input class: " + inputClassString);
    Log.i(TAG, "Variation: " + variationString);
    Log.i(TAG, "Flags: " + flagsString);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:11,代码来源:InputAttributes.java

示例6: isTextInput

public static boolean isTextInput(EditText editText) {
  return (editText.getInputType() & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_TEXT;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:3,代码来源:GiphyActivityToolbar.java

示例7: isPhoneInput

public static boolean isPhoneInput(EditText editText) {
  return (editText.getInputType() & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_PHONE;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:3,代码来源:GiphyActivityToolbar.java

示例8: isTextInput

static boolean isTextInput(EditText editText) {
  return (editText.getInputType() & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_TEXT;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:3,代码来源:ContactFilterToolbar.java

示例9: isPhoneInput

static boolean isPhoneInput(EditText editText) {
  return (editText.getInputType() & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_PHONE;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:3,代码来源:ContactFilterToolbar.java

示例10: InputAttributes

public InputAttributes(final EditorInfo editorInfo, final boolean isFullscreenMode) {
    mTargetApplicationPackageName = null != editorInfo ? editorInfo.packageName : null;
    final int inputType = null != editorInfo ? editorInfo.inputType : 0;
    final int inputClass = inputType & InputType.TYPE_MASK_CLASS;
    mInputType = inputType;
    mIsPasswordField = InputTypeUtils.isPasswordInputType(inputType)
            || InputTypeUtils.isVisiblePasswordInputType(inputType);
    if (inputClass != InputType.TYPE_CLASS_TEXT) {
        // If we are not looking at a TYPE_CLASS_TEXT field, the following strange
        // cases may arise, so we do a couple sanity checks for them. If it's a
        // TYPE_CLASS_TEXT field, these special cases cannot happen, by construction
        // of the flags.
        if (null == editorInfo) {
            Log.w(TAG, "No editor info for this field. Bug?");
        } else if (InputType.TYPE_NULL == inputType) {
            // TODO: We should honor TYPE_NULL specification.
            Log.i(TAG, "InputType.TYPE_NULL is specified");
        } else if (inputClass == 0) {
            // TODO: is this check still necessary?
            Log.w(TAG, String.format("Unexpected input class: inputType=0x%08x"
                    + " imeOptions=0x%08x", inputType, editorInfo.imeOptions));
        }
        mShouldShowSuggestions = false;
        mInputTypeNoAutoCorrect = false;
        mApplicationSpecifiedCompletionOn = false;
        mShouldInsertSpacesAutomatically = false;
        return;
    }
    // inputClass == InputType.TYPE_CLASS_TEXT
    final int variation = inputType & InputType.TYPE_MASK_VARIATION;
    final boolean flagNoSuggestions =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    final boolean flagMultiLine =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    final boolean flagAutoCorrect =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    final boolean flagAutoComplete =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);

    // TODO: Have a helper method in InputTypeUtils
    // Make sure that passwords are not displayed in {@link SuggestionStripView}.
    final boolean shouldSuppressSuggestions = mIsPasswordField
            || InputTypeUtils.isEmailVariation(variation)
            || InputType.TYPE_TEXT_VARIATION_URI == variation
            || InputType.TYPE_TEXT_VARIATION_FILTER == variation
            || flagNoSuggestions
            || flagAutoComplete;
    mShouldShowSuggestions = !shouldSuppressSuggestions;

    mShouldInsertSpacesAutomatically = InputTypeUtils.isAutoSpaceFriendlyType(inputType);

    // If it's a browser edit field and auto correct is not ON explicitly, then
    // disable auto correction, but keep suggestions on.
    // If NO_SUGGESTIONS is set, don't do prediction.
    // If it's not multiline and the autoCorrect flag is not set, then don't correct
    mInputTypeNoAutoCorrect =
            (variation == InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT && !flagAutoCorrect)
            || flagNoSuggestions
            || (!flagAutoCorrect && !flagMultiLine);

    mApplicationSpecifiedCompletionOn = flagAutoComplete && isFullscreenMode;
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:62,代码来源:InputAttributes.java

示例11: onStartInput

/**
 * 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.
 */
@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();

    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 = mArabicKeyboard;
            mPredictionOn = true;

            // 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();
            }
            break;
            
        default:
            // For all unknown input types, default to the alphabetic
            // keyboard with no special features.
            mCurKeyboard = mArabicKeyboard;
    }

    // Update the label on the enter key, depending on what the application
    // says it will do.
    mCurKeyboard.setImeOptions(this, attribute.imeOptions);
}
 
开发者ID:cdjalel,项目名称:QuranKeyboard,代码行数:81,代码来源:QuranKeyboardIME.java

示例12: onStartInput

@Override
public void onStartInput(EditorInfo attribute, boolean restarting) {
    super.onStartInput(attribute, restarting);

    //get settings
    MyConfig.setSoundOn(sharedPref.getBoolean("play_sound", true));
    MyConfig.setSwitchIme(sharedPref.getBoolean("switch_ime", false));

    mComposing.setLength(0);

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

    mPredictionOn = false;
    mCompletionOn = false;

    //initializing state base 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
            mCurKeyboard = getSymbolsKeyboard(getLocaleId());
            break;
        case InputType.TYPE_CLASS_PHONE:
            //Phones will default to phone keyboard
            switch (getLocaleId()) {
                case 1:
                    mCurKeyboard = enSymbolsKeyboard;
                    break;
                case 2:
                    mCurKeyboard = mySymbolsShiftedKeyboard;
                    break;
            }
            break;
        case InputType.TYPE_CLASS_TEXT:
            // for general text editing, default to normal alphabetic keyboard and doing predictive text
            mCurKeyboard = getKeyboard(getLocaleId());
            mPredictionOn = true;

            //looking for variation of text to modify the 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 prediction
                mPredictionOn = false;
            }

            if (variation == InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS || variation == InputType.TYPE_TEXT_VARIATION_URI || variation == InputType.TYPE_TEXT_VARIATION_FILTER) {
                //prediction will not be useful for e-mail and URIs.
                mPredictionOn = false;
            }

            if ((attribute.inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE) != 0) {
                //displaying prediction supplied by the editor if the input field is auto complete text view
                mPredictionOn = false;
                mCompletionOn = isFullscreenMode();
            }

            //looking at the current state of the editor to decide whether alphabetic keyboard should start out shifted
            updateShiftKeyState(attribute);
            break;

        default:
            //for all other input types, default to alphabetic keyboard of appropriate subtype
            mCurKeyboard = getKeyboard(getLocaleId());
            updateShiftKeyState(attribute);
    }
    //updating the label on enter key depending on what the application says it will do
    mCurKeyboard.setImeOptions(getResources(), attribute.imeOptions);
}
 
开发者ID:YehtutHl,项目名称:myan,代码行数:71,代码来源:SmartMyan.java


注:本文中的android.text.InputType.TYPE_MASK_CLASS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。