All Projects → RedMadRobot → Input Mask Android

RedMadRobot / Input Mask Android

Licence: mit
User input masking library repo.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Input Mask Android

Input Mask Ios
User input masking library repo.
Stars: ✭ 494 (-53.4%)
Mutual labels:  validator, text, formatter, pattern, template
Perun
A command-line validation tool for AWS Cloud Formation that allows to conquer the cloud faster!
Stars: ✭ 82 (-92.26%)
Mutual labels:  validator, template
Stringformatter
Simple Text Formetter (Credit Card Number, Phone Number, Serial Number etc.) Can be used in all text inputs according to the format pattern. If desired, large minor character restrictions can be made in the format pattern.
Stars: ✭ 231 (-78.21%)
Mutual labels:  validator, formatter
html-comment-regex
Regular expression for matching HTML comments
Stars: ✭ 15 (-98.58%)
Mutual labels:  text, pattern
Texttable
Swift package for easily rendering text tables. Inspired by the Python tabulate library.
Stars: ✭ 82 (-92.26%)
Mutual labels:  text, formatter
Swaggen
OpenAPI/Swagger 3.0 Parser and Swift code generator
Stars: ✭ 385 (-63.68%)
Mutual labels:  formatter, template
rust-phonenumber
Library for parsing, formatting and validating international phone numbers.
Stars: ✭ 99 (-90.66%)
Mutual labels:  formatter, validator
AutoFormatInputWatcher
This repository contains input watcher for auto formatting digits in edit text
Stars: ✭ 15 (-98.58%)
Mutual labels:  formatter, text
allot
Parse placeholder and wildcard text commands
Stars: ✭ 51 (-95.19%)
Mutual labels:  text, pattern
dockerfile-utils
A library and command line interface for formatting and linting Dockerfiles.
Stars: ✭ 17 (-98.4%)
Mutual labels:  formatter, validator
Gf
GoFrame is a modular, powerful, high-performance and enterprise-class application development framework of Golang.
Stars: ✭ 6,501 (+513.3%)
Mutual labels:  validator, template
Brazilian Utils
Utils library for specific Brazilian businesses
Stars: ✭ 1,023 (-3.49%)
Mutual labels:  validator, formatter
Bug Bounty Responses
A collection of response templates for invalid bug bounty reports.
Stars: ✭ 46 (-95.66%)
Mutual labels:  template
Sketch Textbox Fit Content
Set the height of a selected text layer or all text layers in a selected group to it's content's height.
Stars: ✭ 49 (-95.38%)
Mutual labels:  text
Text Split
Text wrapping for type animations.
Stars: ✭ 46 (-95.66%)
Mutual labels:  text
Latexcv
👔 A collection of cv and resume templates written in LaTeX. Leave an issue if your language is not supported!
Stars: ✭ 1,027 (-3.11%)
Mutual labels:  template
Design Systems Office Hours Playbook
A playbook for running Design Systems office hours or attending them as a Design System representative. Use this as a template for making your own company Design Systems office hours playbook!
Stars: ✭ 49 (-95.38%)
Mutual labels:  template
Insert Text At Cursor
Fast crossbrowser insertion of text at cursor position in a textarea / input
Stars: ✭ 49 (-95.38%)
Mutual labels:  text
Bentools Etl
PHP ETL (Extract / Transform / Load) library with SOLID principles + almost no dependency.
Stars: ✭ 45 (-95.75%)
Mutual labels:  pattern
Miraigo Template
A template for MiraiGo
Stars: ✭ 47 (-95.57%)
Mutual labels:  template
Input Mask

Awesome Android Arsenal Bintray codebeat badge license

PlatformAndroidiOSmacOS

Direct input
More GIFs [~3 MB] Direct input Direct input Direct input
Direct input Direct input

Migration Guide: v.6

This update brings breaking changes. Namely, the autocomplete flag is now a part of the CaretGravity enum, thus the Mask::apply call is now single-argument, as all the necessary information is included into the CaretString structure.

v.6 introduces the «autoskip» feature, which allows the cursor to jump over formatting blocks of symbols in the middle of the text as if they were a single char when hitting Backspace, and this feature also allows to trim formatting characters on backspacing at the end of the line.

Make sure to take a look at our CHANGELOG.

Description

Input Mask is an Android & iOS native library allowing to format user input on the fly.

The library provides you with a text field listener; when attached, it puts separators into the text while user types it in, and gets rid of unwanted symbols, all according to custom predefined pattern.

This allows to reformat whole strings pasted from the clipboard, e.g. turning pasted 8 800 123-45-67 into
8 (800) 123 45 67.

Each pattern allows to extract valuable symbols from the entered text, returning you the immediate result with the text field listener's callback when the text changes. Such that, you'll be able to extract 1234567 from 8 (800) 123 45 67 or 19991234567 from 1 (999) 123 45 67 with two different patterns.

All separators and valuable symbol placeholders have their own syntax. We call such patterns "masks".

Mask examples:

  1. International phone numbers: +1 ([000]) [000] [00] [00]
  2. Local phone numbers: ([000]) [000]-[00]-[00]
  3. Names: [A][-----------------------------------------------------]
  4. Text: [A…]
  5. Dates: [00]{.}[00]{.}[9900]
  6. Serial numbers: [AA]-[00000099]
  7. IPv4: [099]{.}[099]{.}[099]{.}[099]
  8. Visa card numbers: [0000] [0000] [0000] [0000]
  9. MM/YY: [00]{/}[00]
  10. UK IBAN: GB[00] [____] [0000] [0000] [0000] [00]

Questions & Issues

Check out our wiki for further reading.
Please also take a closer look at our Known issues section before you incorporate our library into your project.

For your bugreports and feature requests please file new issues as usually.

Should you have any questions, search for closed issues or open new ones at StackOverflow with the input-mask tag.

We also have a community-driven cookbook of recipes, be sure to check it out, too.

Installation

Gradle

Make sure you've added Kotlin support to your project.

repositories {
    jcenter()
}

dependencies {
    implementation 'com.redmadrobot:input-mask-android:6.0.0'
    
    implementation 'org.jetbrains.kotlin:kotlin-stdlib:$latest_version'
}

Known issues

InputMask vs. NoClassDefFoundError

java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics;

Receiving this error might mean you haven't configured Kotlin for your Java only project. Consider explicitly adding the following to the list of your project dependencies:

implementation 'org.jetbrains.kotlin:kotlin-stdlib:$latest_version'

— where latest_version is the current version of kotlin-stdlib.

InputMask vs. android:inputType and IndexOutOfBoundsException

Be careful when specifying field's android:inputType. The library uses native Editable variable received on afterTextChange event in order to replace text efficiently. Because of that, field's inputType is actually considered when the library is trying to mutate the text.

For instance, having a field with android:inputType="numeric", you cannot put spaces and dashes into the mentioned Editable variable by default. Doing so will cause an out of range exception when the MaskedTextChangedListener will try to reposition the cursor.

Still, you may use a workaround by putting the android:digits value beside your android:inputType; there, you should specify all the acceptable symbols:

<EditText
    android:inputType="number"
    android:digits="0123456789 -."
    ... />

— such that, you'll have the SDK satisfied.

Alternatively, if you are using a programmatic approach without XML files, you may consider configuring a KeyListener like this:

editText.setInputType(InputType.TYPE_CLASS_NUMBER);
editText.setKeyListener(DigitsKeyListener.getInstance("0123456789 -.")); // modify character set for your case, e.g. add "+()"

InputMask vs. autocorrection & prediction

(presumably fixed by PR50)

Symptoms:

  • You've got a wildcard template like [________], allowing user to write any kind of symbols;
  • Cursor jumps to the beginning of the line or to some random position while user input.

In this case text autocorrection & prediction might be a root cause of your problem, as it behaves somewhat weirdly in case when field listener tries to change the text during user input.

If so, consider disabling text suggestions by using corresponding input type:

<EditText
    ...
    android:inputType="textNoSuggestions" />

Additionally be aware that some of the third-party keyboards ignore textNoSuggestions setting; the recommendation is to use an extra workaround by setting the inputType to textVisiblePassword.

InputMask vs. android:textAllCaps

Kudos to Weiyi Li for reporting this issue

Please be advised that android:textAllCaps is not meant to work with EditText instances:

This setting will be ignored if this field is editable or selectable.

Enabling this setting on editable and/or selectable fields leads to weird and unpredictable behaviour and sometimes even crashes. Instead, consider using android:inputType="textCapCharacters" or workaround by adding an InputFilter:

final InputFilter[] filters = { new InputFilter.AllCaps() };
editText.setFilters(filters);

Bare in mind, you might have to befriend this solution with your existing android:digits property in case your text field accepts both digits and letters.

References

The list of projects that are using this library which were kind enough to share that information.

Feel free to add yours below.

Special thanks

These folks rock:

License

The library is distributed under the MIT LICENSE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].