Java Code Examples for android.text.InputFilter#AllCaps
The following examples show how to use
android.text.InputFilter#AllCaps .
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: HashCalculatorFragment.java From hash-checker with Apache License 2.0 | 6 votes |
private void validateTextCase() { boolean useUpperCase = SettingsHelper.useUpperCase(context); InputFilter[] fieldFilters = useUpperCase ? new InputFilter[]{new InputFilter.AllCaps()} : new InputFilter[]{}; etCustomHash.setFilters(fieldFilters); etGeneratedHash.setFilters(fieldFilters); if (useUpperCase) { TextTools.convertToUpperCase(etCustomHash); TextTools.convertToUpperCase(etGeneratedHash); } else { TextTools.convertToLowerCase(etCustomHash); TextTools.convertToLowerCase(etGeneratedHash); } etCustomHash.setSelection( etCustomHash.getText().length() ); etGeneratedHash.setSelection( etGeneratedHash.getText().length() ); }
Example 2
Source File: DialerFilter.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override protected void onFinishInflate() { super.onFinishInflate(); // Setup the filter view mInputFilters = new InputFilter[] { new InputFilter.AllCaps() }; mHint = (EditText) findViewById(com.android.internal.R.id.hint); if (mHint == null) { throw new IllegalStateException("DialerFilter must have a child EditText named hint"); } mHint.setFilters(mInputFilters); mLetters = mHint; mLetters.setKeyListener(TextKeyListener.getInstance()); mLetters.setMovementMethod(null); mLetters.setFocusable(false); // Setup the digits view mPrimary = (EditText) findViewById(com.android.internal.R.id.primary); if (mPrimary == null) { throw new IllegalStateException("DialerFilter must have a child EditText named primary"); } mPrimary.setFilters(mInputFilters); mDigits = mPrimary; mDigits.setKeyListener(DialerKeyListener.getInstance()); mDigits.setMovementMethod(null); mDigits.setFocusable(false); // Look for an icon mIcon = (ImageView) findViewById(com.android.internal.R.id.icon); // Setup focus & highlight for this view setFocusable(true); // XXX Force the mode to QWERTY for now, since 12-key isn't supported mIsQwerty = true; setMode(DIGITS_AND_LETTERS); }
Example 3
Source File: ReactTextInputPropertyTest.java From react-native-GPay with MIT License | 5 votes |
@Test public void testMaxLength() { ReactEditText view = mManager.createViewInstance(mThemedContext); InputFilter[] filters = new InputFilter[] { new InputFilter.AllCaps() }; view.setFilters(filters); mManager.setMaxLength(view, null); assertThat(view.getFilters()).isEqualTo(filters); }
Example 4
Source File: TextInputSpec.java From litho with Apache License 2.0 | 5 votes |
/** LengthFilter and AllCaps do not implement isEqual. Correct for the deficiency. */ private static boolean equalInputFilters(List<InputFilter> a, List<InputFilter> b) { if (a == null && b == null) { return true; } if (a == null || b == null) { return false; } if (a.size() != b.size()) { return false; } for (int i = 0; i < a.size(); i++) { InputFilter fa = a.get(i); InputFilter fb = b.get(i); if (fa instanceof InputFilter.AllCaps && fb instanceof InputFilter.AllCaps) { continue; // equal, AllCaps has no configuration } if (SDK_INT >= LOLLIPOP) { // getMax added in lollipop if (fa instanceof InputFilter.LengthFilter && fb instanceof InputFilter.LengthFilter) { if (((InputFilter.LengthFilter) fa).getMax() != ((InputFilter.LengthFilter) fb).getMax()) { return false; } continue; // equal, same max } } // Best we can do in this case is call equals(). if (!equals(fa, fb)) { return false; } } return true; }