Java Code Examples for android.widget.EditText#getInputType()
The following examples show how to use
android.widget.EditText#getInputType() .
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: ReactTextInputLocalData.java From react-native-GPay with MIT License | 6 votes |
public ReactTextInputLocalData(EditText editText) { mText = new SpannableStringBuilder(editText.getText()); mTextSize = editText.getTextSize(); mInputType = editText.getInputType(); mPlaceholder = editText.getHint(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { mMinLines = editText.getMinLines(); mMaxLines = editText.getMaxLines(); } else { mMinLines = 1; mMaxLines = 1; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { mBreakStrategy = editText.getBreakStrategy(); } else { mBreakStrategy = 0; } }
Example 2
Source File: PasswordToggleEndIconDelegate.java From material-components-android with Apache License 2.0 | 5 votes |
private static boolean isInputTypePassword(EditText editText) { return editText != null && (editText.getInputType() == InputType.TYPE_NUMBER_VARIATION_PASSWORD || editText.getInputType() == InputType.TYPE_TEXT_VARIATION_PASSWORD || editText.getInputType() == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD || editText.getInputType() == InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD); }
Example 3
Source File: CreatePinActivity.java From commcare-android with Apache License 2.0 | 5 votes |
private static void setTextEntryKeyboardAction(EditText textEntry, int action) { // bug/feature that requires setting the input type to null then changing the action type int inputType = textEntry.getInputType(); textEntry.setInputType(InputType.TYPE_NULL); textEntry.setImeOptions(action); textEntry.setInputType(inputType); }
Example 4
Source File: EntryKeyboardView.java From bither-android with Apache License 2.0 | 5 votes |
@Override public boolean onTouch(View v, MotionEvent event) { if (v instanceof EditText) { EditText edittext = (EditText) v; int inType = edittext.getInputType(); // Backup the input type edittext.setInputType(InputType.TYPE_NULL); // Disable standard keyboard edittext.onTouchEvent(event); // Call native handler edittext.setInputType(inType); // Restore input type edittext.setSelection(edittext.getText().length()); return true; } return false; }
Example 5
Source File: SettingsFragment.java From NoiseCapture with GNU General Public License v3.0 | 5 votes |
@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 6
Source File: EditTextUtil.java From AndroidBasicProject with MIT License | 5 votes |
/** * 设置密码是否可见 */ public static void passwordVisibleToggle(EditText editText) { if (editText.getInputType() == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) { editText.setInputType( InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_CLASS_TEXT); } else { editText.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); } }
Example 7
Source File: UrlFieldEditor.java From opentasks with Apache License 2.0 | 5 votes |
@Override protected void onFinishInflate() { super.onFinishInflate(); mText = (EditText) findViewById(R.id.text); if (mText != null) { mText.addTextChangedListener(this); int inputType = mText.getInputType(); mText.setInputType(inputType | InputType.TYPE_TEXT_VARIATION_URI); } }
Example 8
Source File: RichEditorViewTest.java From Spyglass with Apache License 2.0 | 5 votes |
@Test public void testSuggestionsListDisablesSpellingSuggestions() throws Exception { EditText input = TestUtils.getPrivateField(mRichEditor, "mMentionsEditText"); int originalInputType = input.getInputType(); mRichEditor.displaySuggestions(true); // should be no suggestions assertEquals(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS, input.getInputType()); mRichEditor.displaySuggestions(false); // should be back to original type assertEquals(originalInputType, input.getInputType()); }
Example 9
Source File: EditTextUtil.java From zone-sdk with MIT License | 5 votes |
/** * 设置密码是否可见 */ public static void passwordVisibleToggle(EditText editText) { Log.d("input", "passwordVisibleToggle " + editText.getInputType()); if (editText.getInputType() == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) { editText.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_CLASS_TEXT); } else { editText.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); } }
Example 10
Source File: EditTimerActivity.java From ClockPlus with GNU General Public License v3.0 | 5 votes |
@OnTouch({ R.id.hour, R.id.minute, R.id.second }) boolean switchField(EditText field, MotionEvent event) { int inType = field.getInputType(); // backup the input type field.setInputType(InputType.TYPE_NULL); // disable soft input boolean result = field.onTouchEvent(event); // call native handler field.setInputType(inType); // restore input type (to show cursor) return result; }
Example 11
Source File: MaskFormatter.java From MaskFormatter with Apache License 2.0 | 5 votes |
private int getPasswordMask(EditText maskedField) { int inputType = maskedField.getInputType(); int maskedFieldPasswordMask = (inputType & InputType.TYPE_TEXT_VARIATION_PASSWORD | inputType & InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { maskedFieldPasswordMask |= inputType & InputType.TYPE_NUMBER_VARIATION_PASSWORD; maskedFieldPasswordMask |= inputType & InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD; } return maskedFieldPasswordMask; }
Example 12
Source File: FieldValidator.java From tapchat-android with Apache License 2.0 | 5 votes |
private static boolean validateEditText(EditText editText) { boolean valid = true; String text = editText.getText().toString(); boolean isEmail = (editText.getInputType() & InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS) == InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; boolean isNumeric = (editText.getInputType() & InputType.TYPE_NUMBER_FLAG_DECIMAL) == InputType.TYPE_NUMBER_FLAG_DECIMAL; if (TextUtils.isEmpty(text)) { if (!isNumeric || !TextUtils.isDigitsOnly(editText.getHint())) { valid = false; } } else if (isEmail) { valid = android.util.Patterns.EMAIL_ADDRESS.matcher(text).matches(); } if (!valid) { Context context = editText.getContext(); if (isEmail) { editText.setError(context.getString(R.string.error_invalid_email)); } else { editText.setError(context.getString(R.string.error_blank)); } return false; } editText.setError(null); return true; }
Example 13
Source File: EditTextUtil.java From BaseProject with MIT License | 5 votes |
/** * 设置密码是否可见 */ public static void passwordVisibleToggle(@NonNull EditText editText) { if (editText.getInputType() == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) { editText.setInputType( InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_CLASS_TEXT); } else { editText.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); } }
Example 14
Source File: GiphyActivityToolbar.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
public static boolean isTextInput(EditText editText) { return (editText.getInputType() & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_TEXT; }
Example 15
Source File: ContactSelectionActivity.java From Silence with GNU General Public License v3.0 | 4 votes |
public static boolean isPhoneInput(EditText editText) { return (editText.getInputType() & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_PHONE; }
Example 16
Source File: TextInputSpec.java From litho with Apache License 2.0 | 4 votes |
private static void setInputTypeIfChanged(EditText editText, int inputType) { // Avoid redundant call to InputMethodManager#restartInput. if (inputType != editText.getInputType()) { editText.setInputType(inputType); } }
Example 17
Source File: ViewMatchers.java From android-test with Apache License 2.0 | 4 votes |
@Override protected boolean matchesSafely(EditText view) { return view.getInputType() == inputType; }
Example 18
Source File: ContactFilterToolbar.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
static boolean isPhoneInput(EditText editText) { return (editText.getInputType() & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_PHONE; }
Example 19
Source File: ContactFilterToolbar.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
static boolean isTextInput(EditText editText) { return (editText.getInputType() & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_TEXT; }
Example 20
Source File: GiphyActivityToolbar.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
public static boolean isPhoneInput(EditText editText) { return (editText.getInputType() & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_PHONE; }