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

The following examples show how to use android.view.inputmethod.EditorInfo#TYPE_CLASS_NUMBER . 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: KeyboardWidget.java    From FirefoxReality with Mozilla Public License 2.0 5 votes vote down vote up
private void resetKeyboardLayout() {
    if ((mEditorInfo.inputType & EditorInfo.TYPE_CLASS_NUMBER) == EditorInfo.TYPE_CLASS_NUMBER) {
        mKeyboardView.setKeyboard(getSymbolsKeyboard());
    } else {
        mKeyboardView.setKeyboard(mCurrentKeyboard.getAlphabeticKeyboard());
    }
    handleShift(false);
    updateCandidates();
}
 
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: SettingsFragment.java    From NoiseCapture with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    if(preference instanceof EditTextPreference && newValue instanceof String) {
        EditText prefText = ((EditTextPreference) preference).getEditText();
        int editorType = prefText.getInputType();
        if(EditorInfo.TYPE_CLASS_NUMBER == (EditorInfo.TYPE_CLASS_NUMBER & editorType)) {
            // Try to convert to double
            double res;
            try {
                res = Double.valueOf((String)newValue);
            } catch (NumberFormatException ex) {
                return false;
            }
            if(EditorInfo.TYPE_NUMBER_FLAG_SIGNED != (EditorInfo.TYPE_NUMBER_FLAG_SIGNED & editorType)) {
                // Must be superior than 0
                if(res < 0) {
                    return false;
                }
            }
            if(EditorInfo.TYPE_NUMBER_FLAG_SIGNED != (EditorInfo.TYPE_NUMBER_FLAG_SIGNED & editorType)) {
                // Must be an integer
                if(Double.compare(res % 1,0) != 0) {
                    return false;
                }
            }
        }
        return true;
    }
    return true;
}
 
Example 5
Source File: OtpView.java    From android-otpview-pinview with MIT License 4 votes vote down vote up
private static boolean isNumberInputType(int inputType) {
  return inputType == EditorInfo.TYPE_CLASS_NUMBER;
}
 
Example 6
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;
        }
    }