Skip to content

DIG-/java-text-mask

Repository files navigation

Simple Text Mask for Java and Android

AppVeyor AppVeyor tests Maven Central License

Windows - Supported Linux - Supported MacOS - Partial

Apply/remove mask from text with some utilities out-of-box for Android EditText

How to use

  1. Include maven central as repository
  2. Import project dependency
dependencies {
    ⋮
    implementation "br.dev.dig.text.mask:text-mask:${lastest_version}"
    // FOR ANDROID:
    implementation "br.dev.dig.text.mask:text-mask-android:${lastest_version}"
    ⋮
}
  1. Create a TextMask instance
final TextMask mask = new TextMask("#### #### #### ####");
final CharSequence formatted = mask.format("12345678");
final CharSequence raw = mask.unformat("1234 5678 1234 5678");

For Android

  1. Create a TextMaskTextWatcher with an EditText and a TextMask, and apply (insert) into EditText.
final TextMaskTextWatcher watcher = new TextMaskTextWatcher(editText, new TextMask("#### #### #### ####")).insert();

License

CC BY-ND 4.0

  • You can use and re-dist freely.
  • You can also modify, but only for yourself.
  • You can use it as a part of your project, but without modifications in this project.