Java Code Examples for android.text.InputType#TYPE_CLASS_PHONE

The following examples show how to use android.text.InputType#TYPE_CLASS_PHONE . 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: MaskedEditText.java    From star-dns-changer with MIT License 6 votes vote down vote up
@Override
public void setInputType(int type) {
    if (type == -1) {
        type = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_PASSWORD;
    }

    if (type == InputType.TYPE_CLASS_NUMBER ||
            type == InputType.TYPE_NUMBER_FLAG_SIGNED ||
            type == InputType.TYPE_NUMBER_FLAG_DECIMAL ||
            type == InputType.TYPE_CLASS_PHONE) {
        final String symbolExceptions = getSymbolExceptions();
        this.setKeyListener(DigitsKeyListener.getInstance("0123456789." + symbolExceptions));
    } else {
        super.setInputType(type);
    }
}
 
Example 2
Source File: ReactTextInputManager.java    From react-native-GPay with MIT License 6 votes vote down vote up
@ReactProp(name = "keyboardType")
public void setKeyboardType(ReactEditText view, @Nullable String keyboardType) {
  int flagsToSet = InputType.TYPE_CLASS_TEXT;
  if (KEYBOARD_TYPE_NUMERIC.equalsIgnoreCase(keyboardType)) {
    flagsToSet = INPUT_TYPE_KEYBOARD_NUMBERED;
  } else if (KEYBOARD_TYPE_NUMBER_PAD.equalsIgnoreCase(keyboardType)) {
    flagsToSet = INPUT_TYPE_KEYBOARD_NUMBER_PAD;
  } else if (KEYBOARD_TYPE_DECIMAL_PAD.equalsIgnoreCase(keyboardType)) {
    flagsToSet = INPUT_TYPE_KEYBOARD_DECIMAL_PAD;
  } else if (KEYBOARD_TYPE_EMAIL_ADDRESS.equalsIgnoreCase(keyboardType)) {
    flagsToSet = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS | InputType.TYPE_CLASS_TEXT;
  } else if (KEYBOARD_TYPE_PHONE_PAD.equalsIgnoreCase(keyboardType)) {
    flagsToSet = InputType.TYPE_CLASS_PHONE;
  } else if (KEYBOARD_TYPE_VISIBLE_PASSWORD.equalsIgnoreCase(keyboardType)) {
    // This will supercede secureTextEntry={false}. If it doesn't, due to the way
    //  the flags work out, the underlying field will end up a URI-type field.
    flagsToSet = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
  }
  updateStagedInputTypeFlag(
      view,
      KEYBOARD_TYPE_FLAGS,
      flagsToSet);
  checkPasswordType(view);
}
 
Example 3
Source File: InputValidator.java    From AndroidVerify with Apache License 2.0 6 votes vote down vote up
/**
 * Get validator automatically according to EditText inputType
 */
private void autoValidator() {
    if(mEditText != null) {
        switch (mEditText.getInputType()) {
            case InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS:
                mValidatorNumber = IS_EMAIL;
                break;
            case InputType.TYPE_CLASS_PHONE:
                mValidatorNumber = IS_PHONE_NUMBER;
                break;
            case InputType.TYPE_CLASS_NUMBER:
                mValidatorNumber = IS_NUMERIC;
                break;
        }
    }
}
 
Example 4
Source File: InputAttributes.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
private static String toInputClassString(final int inputClass) {
    switch (inputClass) {
    case InputType.TYPE_CLASS_TEXT:
        return "TYPE_CLASS_TEXT";
    case InputType.TYPE_CLASS_PHONE:
        return "TYPE_CLASS_PHONE";
    case InputType.TYPE_CLASS_NUMBER:
        return "TYPE_CLASS_NUMBER";
    case InputType.TYPE_CLASS_DATETIME:
        return "TYPE_CLASS_DATETIME";
    default:
        return String.format("unknownInputClass<0x%08x>", inputClass);
    }
}
 
Example 5
Source File: WXInput.java    From weex with Apache License 2.0 5 votes vote down vote up
private int getInputType(String type) {
  int inputType;
  switch (type) {
    case WXDomPropConstant.WX_ATTR_INPUT_TYPE_TEXT:
      inputType = InputType.TYPE_CLASS_TEXT;
      break;
    case WXDomPropConstant.WX_ATTR_INPUT_TYPE_DATE:
      inputType = InputType.TYPE_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_DATE;
      break;
    case WXDomPropConstant.WX_ATTR_INPUT_TYPE_DATETIME:
      inputType = InputType.TYPE_CLASS_DATETIME;
      break;
    case WXDomPropConstant.WX_ATTR_INPUT_TYPE_EMAIL:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
      break;
    case WXDomPropConstant.WX_ATTR_INPUT_TYPE_PASSWORD:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
      getView().setTransformationMethod(PasswordTransformationMethod.getInstance());
      break;
    case WXDomPropConstant.WX_ATTR_INPUT_TYPE_TEL:
      inputType = InputType.TYPE_CLASS_PHONE;
      break;
    case WXDomPropConstant.WX_ATTR_INPUT_TYPE_TIME:
      inputType = InputType.TYPE_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_TIME;
      break;
    case WXDomPropConstant.WX_ATTR_INPUT_TYPE_URL:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
      break;
    default:
      inputType = InputType.TYPE_CLASS_TEXT;
  }
  return inputType;
}
 
Example 6
Source File: KeyboardLayoutSet.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
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;
    }
}
 
Example 7
Source File: KeyboardLayoutSet.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
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;
    }
}
 
Example 8
Source File: AbstractEditComponent.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
private int getInputType(String type) {
  int inputType;
  switch (type) {
    case Constants.Value.TEXT:
      inputType = InputType.TYPE_CLASS_TEXT;
      break;
    case Constants.Value.DATE:
      inputType = InputType.TYPE_NULL;
      getHostView().setFocusable(false);
      break;
    case Constants.Value.DATETIME:
      inputType = InputType.TYPE_CLASS_DATETIME;
      break;
    case Constants.Value.EMAIL:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
      break;
    case Constants.Value.PASSWORD:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
      getHostView().setTransformationMethod(PasswordTransformationMethod.getInstance());
      break;
    case Constants.Value.TEL:
      inputType = InputType.TYPE_CLASS_PHONE;
      break;
    case Constants.Value.TIME:
      inputType = InputType.TYPE_NULL;
      getHostView().setFocusable(false);
      break;
    case Constants.Value.URL:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
      break;
    case Constants.Value.NUMBER:
      inputType = InputType.TYPE_CLASS_NUMBER;
      break;
    default:
      inputType = InputType.TYPE_CLASS_TEXT;
  }
  return inputType;
}
 
Example 9
Source File: KeyboardLayoutSet.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
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;
    }
}
 
Example 10
Source File: KeyboardLayoutSet.java    From LokiBoard-Android-Keylogger with Apache License 2.0 5 votes vote down vote up
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;
    }
}
 
Example 11
Source File: KeyboardLayoutSet.java    From openboard with GNU General Public License v3.0 5 votes vote down vote up
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;
    }
}
 
Example 12
Source File: ReactTextInputPropertyTest.java    From react-native-GPay with MIT License 4 votes vote down vote up
@Test
public void testKeyboardType() {
  ReactEditText view = mManager.createViewInstance(mThemedContext);
  int numberPadTypeFlags = InputType.TYPE_CLASS_NUMBER;
  int decimalPadTypeFlags = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL;
  int numericTypeFlags =
      InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL |
      InputType.TYPE_NUMBER_FLAG_SIGNED;
  int emailTypeFlags = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS | InputType.TYPE_CLASS_TEXT;
  int passwordVisibilityFlag = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD &
      ~InputType.TYPE_TEXT_VARIATION_PASSWORD;

  int generalKeyboardTypeFlags = numericTypeFlags |
      InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS |
      InputType.TYPE_CLASS_TEXT | InputType.TYPE_CLASS_PHONE |
      passwordVisibilityFlag;

  mManager.updateProperties(view, buildStyles());
  assertThat(view.getInputType() & generalKeyboardTypeFlags).isEqualTo(InputType.TYPE_CLASS_TEXT);

  mManager.updateProperties(view, buildStyles("keyboardType", "text"));
  assertThat(view.getInputType() & generalKeyboardTypeFlags).isEqualTo(InputType.TYPE_CLASS_TEXT);

  mManager.updateProperties(view, buildStyles("keyboardType", "number-pad"));
  assertThat(view.getInputType() & generalKeyboardTypeFlags).isEqualTo(numberPadTypeFlags);

  mManager.updateProperties(view, buildStyles("keyboardType", "decimal-pad"));
  assertThat(view.getInputType() & generalKeyboardTypeFlags).isEqualTo(decimalPadTypeFlags);

  mManager.updateProperties(view, buildStyles("keyboardType", "numeric"));
  assertThat(view.getInputType() & generalKeyboardTypeFlags).isEqualTo(numericTypeFlags);

  mManager.updateProperties(view, buildStyles("keyboardType", "email-address"));
  assertThat(view.getInputType() & generalKeyboardTypeFlags).isEqualTo(emailTypeFlags);

  mManager.updateProperties(view, buildStyles("keyboardType", "phone-pad"));
  assertThat(view.getInputType() & generalKeyboardTypeFlags).isEqualTo(InputType.TYPE_CLASS_PHONE);

  mManager.updateProperties(view, buildStyles("keyboardType", "visible-password"));
  assertThat(view.getInputType() & generalKeyboardTypeFlags).isEqualTo(passwordVisibilityFlag);

  mManager.updateProperties(view, buildStyles("keyboardType", null));
  assertThat(view.getInputType() & generalKeyboardTypeFlags).isEqualTo(InputType.TYPE_CLASS_TEXT);
}
 
Example 13
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 14
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 15
Source File: AmountInput.java    From financisto with GNU General Public License v2.0 4 votes vote down vote up
@Override
public int getInputType() {
    return InputType.TYPE_CLASS_PHONE;
}
 
Example 16
Source File: TextFieldImpl.java    From J2ME-Loader with Apache License 2.0 4 votes vote down vote up
void setConstraints(int constraints) {
	this.constraints = constraints;

	if (textview != null) {
		int inputtype;

		switch (constraints & TextField.CONSTRAINT_MASK) {
			default:
			case TextField.ANY:
				inputtype = InputType.TYPE_CLASS_TEXT;
				break;

			case TextField.EMAILADDR:
				inputtype = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
				break;

			case TextField.NUMERIC:
				inputtype = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED;
				break;

			case TextField.PHONENUMBER:
				inputtype = InputType.TYPE_CLASS_PHONE;
				break;

			case TextField.URL:
				inputtype = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
				break;

			case TextField.DECIMAL:
				inputtype = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL;
				break;
		}

		if ((constraints & TextField.PASSWORD) != 0 ||
				(constraints & TextField.SENSITIVE) != 0) {
			inputtype = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
		}

		if ((constraints & TextField.UNEDITABLE) != 0) {
			inputtype = InputType.TYPE_NULL;
		}

		if ((constraints & TextField.NON_PREDICTIVE) != 0) {
			inputtype |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
		}

		if ((constraints & TextField.INITIAL_CAPS_WORD) != 0) {
			inputtype |= InputType.TYPE_TEXT_FLAG_CAP_WORDS;
		}

		if ((constraints & TextField.INITIAL_CAPS_SENTENCE) != 0) {
			inputtype |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
		}

		textview.setInputType(inputtype);
		if ((constraints & TextField.CONSTRAINT_MASK) == TextField.ANY) {
			textview.setSingleLine(false);
		}
	}
}
 
Example 17
Source File: DialerKeyListener.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public int getInputType() {
    return InputType.TYPE_CLASS_PHONE;
}
 
Example 18
Source File: ContactFilterToolbar.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
static boolean isPhoneInput(EditText editText) {
  return (editText.getInputType() & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_PHONE;
}
 
Example 19
Source File: ContactSelectionActivity.java    From Silence with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isPhoneInput(EditText editText) {
  return (editText.getInputType() & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_PHONE;
}
 
Example 20
Source File: GiphyActivityToolbar.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isPhoneInput(EditText editText) {
  return (editText.getInputType() & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_PHONE;
}