Git Product home page Git Product logo

maskededittext's Introduction

Android Arsenal

MaskedEditText

It allows you to add a mask to EditText

GIF of its use

Version

3.0.4

Installation

To use this library in your android project, just simply add the following dependency into your build.gradle

dependencies {
    implementation 'com.vicmikhailau:MaskedEditText:3.0.4'
}

Usage

Just add in xml custom MaskedEditText with attribute app:mask="your_mask" like below:

<com.vicmikhailau.maskededittext.MaskedEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:mask="your_mask" />

Or add TextChangedListener for your EditText like in following code:

MaskedFormatter formatter = new MaskedFormatter("your_mask");
mEditText.addTextChangedListener(new MaskedWatcher(formatter, mEditText));

Object of MaskedWatcher class has got a weakreference to formatter object, so you must to conside this.

For create your mask you need to use following keys:

ANYTHING KEY = *;
DIGIT KEY = #;
UPPERCASE KEY = U;
LOWERCASE KEY = L;
ALPHA NUMERIC KEY = A;
CHARACTER KEY = ?;
HEX KEY = H;

For example: you would like create a mask for a mobile number in format (029)777-77-77. Just use the simple mask "(###)###-##-##".

If you want to get text without mask just use following code:

  • For getting unmasked text for MaskedEditText mEdtMaskedCustom just use

    String unamskedString = mEdtMaskedCustom.getUnMaskedString();
  • For getting unmasked text for default EditText just use

    String text = mEditText.getText().toString();
    String unmaskedString = formatter.formatString(text).getUnMaskedString();

Fixes and updates

Unfortunately, there is no way to devote much time to the project. Please feel free to Fork the project and add Pull requests. Thanks a lot!

Change Logs

v3.0.4

Fixes (Pull Request #26).

v3.0.3

Removed private attribute of the setMask function (Pull Request #25).

v3.0.2

Changed asserts to safe call (Pull Request #23).

v3.0.1

Moved library to androidx and kotlin.

v2.0.4

Updated support version.

v2.0.3

Bug with getting сredit сard mask was fixed (issue #13).

v2.0.2

Bug with getting unmasked string was fixed (issue #11).

v2.0.1

Bug with mask was fixed.

v2.0.0

Main logic was updated. Bugs with deleting and changing characters inside masked EditText was fixed

v1.1.2

Fixed crash for getting unmasked text

v1.1.1

Superclass for MaskedEditText was changed to AppCompatEditText, which supports compatible features on older version of the platform

v1.1.0

Ability to get unmasked text (text without mask) was added

v1.0.0

Initial version

Licence

Copyright 2016 Vic Mikhailau

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

maskededittext's People

Contributors

vicmikhailau avatar mixser avatar daniellaspaiva avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.