{"id":3528,"url":"https://github.com/RedMadRobot/input-mask-android","last_synced_at":"2025-08-03T20:32:36.142Z","repository":{"id":12494414,"uuid":"71991744","full_name":"RedMadRobot/input-mask-android","owner":"RedMadRobot","description":"User input masking library repo.","archived":false,"fork":false,"pushed_at":"2023-12-02T13:00:42.000Z","size":2986,"stargazers_count":1218,"open_issues_count":9,"forks_count":116,"subscribers_count":26,"default_branch":"master","last_synced_at":"2024-12-01T12:04:01.707Z","etag":null,"topics":["android","formatter","kotlin","pattern","template","text","validator"],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RedMadRobot.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-26T10:18:48.000Z","updated_at":"2024-11-13T22:42:38.000Z","dependencies_parsed_at":"2024-11-15T17:33:35.454Z","dependency_job_id":"6e387000-8a29-4323-9c8f-1a3e4114de55","html_url":"https://github.com/RedMadRobot/input-mask-android","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedMadRobot%2Finput-mask-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedMadRobot%2Finput-mask-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedMadRobot%2Finput-mask-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedMadRobot%2Finput-mask-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RedMadRobot","download_url":"https://codeload.github.com/RedMadRobot/input-mask-android/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228567009,"owners_count":17937983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","formatter","kotlin","pattern","template","text","validator"],"created_at":"2024-01-05T20:16:44.069Z","updated_at":"2024-12-07T05:30:37.653Z","avatar_url":"https://github.com/RedMadRobot.png","language":"Kotlin","funding_links":[],"categories":["Libraries"],"sub_categories":["GUI"],"readme":"\u003cimg src=\"Documentation/Assets/logo.png\" alt=\"Input Mask\" /\u003e\r\n\r\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Input%20Mask-brightgreen.svg?style=for-the-badge)](https://android-arsenal.com/details/1/4642) [![](https://img.shields.io/jitpack/version/com.redmadrobot/input-mask-android?style=for-the-badge)](https://jitpack.io/#RedMadRobot/input-mask-android) [![Awesome](https://img.shields.io/badge/-mentioned_in_awesome_android-CCA6C4.svg?colorA=CCA6C4\u0026colorB=261120\u0026logoWidth=20\u0026logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMTAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI%2BICAgIDxwYXRoIGZpbGw9IiMyNjExMjAiIGQ9Ik0xOS4xNCA0LjVMMTQuMjMgMGwtLjY5Ljc1IDQuMDkgMy43NUgxLjUxTDUuNi43NSA0LjkxIDAgMCA0LjV2Mi45N0MwIDguODEgMS4yOSA5LjkgMi44OCA5LjloMy4wM2MxLjU5IDAgMi44OC0xLjA5IDIuODgtMi40M1Y1LjUyaDEuNTd2MS45NWMwIDEuMzQgMS4yOSAyLjQzIDIuODggMi40M2gzLjAzYzEuNTkgMCAyLjg4LTEuMDkgMi44OC0yLjQzbC0uMDEtMi45N3oiLz48L3N2Zz4%3D\u0026style=for-the-badge)](https://github.com/JStumpp/awesome-android) [![Actions](https://img.shields.io/github/actions/workflow/status/RedMadRobot/input-mask-android/android.yml?style=for-the-badge)](https://github.com/RedMadRobot/input-mask-android/actions/workflows/android.yml) [![iOS Version](https://img.shields.io/badge/-ios_version-red?color=teal\u0026logo=ios\u0026style=for-the-badge)](https://github.com/RedMadRobot/input-mask-ios) [![Telegram](https://img.shields.io/badge/-telegram_author-red?color=blue\u0026logo=telegram\u0026style=for-the-badge)](https://t.me/jeorge_taflanidi) [![license](https://img.shields.io/github/license/mashape/apistatus.svg?style=for-the-badge)](#license)\r\n\r\nInput masks restrict data input and allow you to guide users to enter correct values.  \r\nCheck out our [wiki](https://github.com/RedMadRobot/input-mask-android/wiki) for quick start and further reading.\r\n\r\n## ⚙️ Features\r\n\r\n- Apply formatting to your text fields, see [examples](#examples)\r\n- Filter out nonessential symbols (e.g. extract `0123456` from `+1 (999) 012-34-56`)\r\n- For international phone numbers \r\n    - guess the country from the entered digits\r\n    - apply corresponding value restrictions (e.g. a 🇺🇸US phone will have a format like `+1 201 456-7890`)\r\n- Apply number/currency formatting\r\n\r\n\u003ca name=\"examples\" /\u003e\r\n\r\n## 💳 Examples\r\n\r\n- Phone numbers: `+1 ([000]) [000] [00] [00]`\r\n- Dates: `[00]{.}[00]{.}[9900]`\r\n- Serial numbers: `[AA]-[00000099]`\r\n- IPv4: `[099]{.}[099]{.}[099]{.}[099]`\r\n- Visa/MasterCard numbers: `[0000] [0000] [0000] [0000]`\r\n- UK IBAN: `GB[00] [____] [0000] [0000] [0000] [00]`\r\n\r\n\u003ca name=\"installation\" /\u003e\r\n\r\n## 🛠️ Installation\r\n\r\n### Gradle\r\n\r\nMake sure you've added Kotlin support to your project.\r\n\r\n```gradle\r\nrepositories {\r\n    maven { url 'https://jitpack.io' }\r\n}\r\n\r\ndependencies {\r\n    implementation 'com.redmadrobot:input-mask-android:7.2.4'\r\n    \r\n    implementation 'org.jetbrains.kotlin:kotlin-stdlib:$latest_version'\r\n}\r\n```\r\n\r\n## 📢 Communication, Questions \u0026 Issues\r\n\r\nPlease take a closer look at our [Known issues](#knownissues) section before you incorporate our library into your project.\r\n\r\nFor your bugreports and feature requests please file new issues [via GitHub](https://github.com/RedMadRobot/input-mask-android/issues/new/choose).\r\n\r\nShould you have any questions, please search for closed [issues](https://github.com/RedMadRobot/input-mask-android/issues?q=is%3Aclosed) or ask questions at **[StackOverflow](https://stackoverflow.com/questions/tagged/input-mask)** with the `input-mask` tag.\r\n\r\n\u003ca name=\"knownissues\" /\u003e\r\n\r\n## ❗Known issues\r\n\r\n## InputMask vs. `NoClassDefFoundError`\r\n\r\n```\r\njava.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics;\r\n```\r\nReceiving 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:\r\n```\r\nimplementation 'org.jetbrains.kotlin:kotlin-stdlib:$latest_version'\r\n```\r\n— where `latest_version` is the current version of `kotlin-stdlib`.\r\n\r\n## InputMask vs. `android:inputType` and `IndexOutOfBoundsException`\r\n\r\nBe careful when specifying field's `android:inputType`. \r\nThe 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. \r\n\r\nFor 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.\r\n\r\nStill, you may use a workaround by putting the `android:digits` value beside your `android:inputType`; there, you should specify all the acceptable symbols:\r\n```xml\r\n\u003cEditText\r\n    android:inputType=\"number\"\r\n    android:digits=\"0123456789 -.\"\r\n    ... /\u003e\r\n```\r\n— such that, you'll have the SDK satisfied.\r\n\r\nAlternatively, if you are using a programmatic approach without XML files, you may consider configuring a `KeyListener` like this:\r\n```java\r\neditText.setInputType(InputType.TYPE_CLASS_NUMBER);\r\neditText.setKeyListener(DigitsKeyListener.getInstance(\"0123456789 -.\")); // modify character set for your case, e.g. add \"+()\"\r\n```\r\n\r\n## InputMask vs. autocorrection \u0026 prediction\r\n\u003e (presumably fixed by [PR50](https://github.com/RedMadRobot/input-mask-android/pull/50))\r\n\r\nSymptoms: \r\n* You've got a wildcard template like `[________]`, allowing user to write any kind of symbols;\r\n* Cursor jumps to the beginning of the line or to some random position while user input.\r\n\r\nIn this case text autocorrection \u0026 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.\r\n\r\nIf so, consider disabling text suggestions by using corresponding input type:\r\n```xml\r\n\u003cEditText\r\n    ...\r\n    android:inputType=\"textNoSuggestions\" /\u003e\r\n```\r\nAdditionally 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`.\r\n\r\n## InputMask vs. `android:textAllCaps`\r\n\u003e Kudos to [Weiyi Li](https://github.com/li2) for [reporting](https://github.com/RedMadRobot/input-mask-android/issues/85) this issue\r\n\r\nPlease be advised that `android:textAllCaps` is [not meant](https://developer.android.com/reference/android/widget/TextView.html#setAllCaps(boolean)) to work with `EditText` instances:\r\n\r\n\u003e This setting will be ignored if this field is editable or selectable.\r\n\r\nEnabling this setting on editable and/or selectable fields leads to weird and unpredictable behaviour and sometimes even [crashes](https://twitter.com/dimsuz/status/731117910337441793). Instead, consider using `android:inputType=\"textCapCharacters\"` or workaround by adding an `InputFilter`:\r\n\r\n```java\r\nfinal InputFilter[] filters = { new InputFilter.AllCaps() };\r\neditText.setFilters(filters);\r\n```\r\n\r\nBare in mind, you might have to befriend this solution with your existing `android:digits` [property](#inputmask-vs-androidinputtype-and-indexoutofboundsexception) in case your text field accepts both digits and letters. \r\n\r\n## 🙏 Special thanks\r\n\r\nThese folks rock:\r\n\r\n* Artem [Fi5t](https://github.com/Fi5t) Kulakov\r\n* Nikita [nbarishok](https://github.com/nbarishok) Barishok\r\n* Roman [yatsinar](https://github.com/yatsinar) Iatcyna\r\n* Alexander [xanderblinov](https://github.com/xanderblinov) Blinov\r\n* Vladislav [Shipaaaa](https://github.com/Shipaaaa) Shipugin\r\n* Vadim [vkotovv](https://github.com/vkotovv) Kotov\r\n\r\n## ♻️ License\r\n\r\nThe library is distributed under the MIT [LICENSE](https://github.com/RedMadRobot/input-mask-android/blob/master/LICENSE).\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRedMadRobot%2Finput-mask-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRedMadRobot%2Finput-mask-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRedMadRobot%2Finput-mask-android/lists"}