Giter Site home page Giter Site logo

hipo-maskededittext-android's Introduction

Masked Edit Text

Bintray

implementation 'com.hipo.maskededittext:maskededittext:$latestVersion'

To release new version, please check maskededittext/VERSION_GUIDE

Simple Phone, Date and SSN masker.

There are 4 options;

  • Phone -> (###) ###-####
  • Date -> ####/##/##
  • SSN -> ###-##-####
  • Currency -> {yourMaskPattern}##,###,###.## - Example: $123,141.20
  • Static Text -> $... - Now you can set static text
  • Custom -> However you want it to be!

** Also you can use it in a TextInputLayout!

To be able to get parsed text, input count must be the same as output count. Otherwise getParsedText()returns null.

How to use

XML

You can simply specify mask type with maskTypeattribute.

<com.hipo.maskededittext.MaskedEditText
        android:id="@+id/maskedEditText"
        ...
        app:maskType="date" />

VIEW

// input = 10/10/2020
val parsedText = maskedEditText.getParsedText() // output = 2020-10-10

val maskedText = maskedEditText.text.toString() // output = 10/10/2020

Custom Mask

Define your maskPattern and returnPattern using # in XML

<com.hipo.maskededittext.MaskedEditText
    ...
    app:maskPattern="#++###!$#3312s#"
    app:returnPattern="#---#####"
    app:maskType="custom" />

Static Text

Define your static text with maskPattern. Defined text will not be removable by user.

<com.hipo.maskededittext.MaskedEditText
    ...
    app:maskPattern="$"
    app:maskType="static_text" />

To use custom mask, you need to follow some rules;

  • maskPattern and returnPattern must be defined
  • Pound (#) count must be the same for maskPattern and returnPattern

hipo-maskededittext-android's People

Contributors

artizco avatar mitsinsar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

hipo-maskededittext-android's Issues

Long backspace and "lag" issue

Hello!

I have a similar solution in my application and ran into some issues regarding long backspace and user input lagging which causes some inputs to be missed. I couldn't really fix my solution so I started looking for other solutions when I found this library. Tried the demo app and it has a same issues:

  • The main issue is that on some devices when you hold the backspace button down it will delete only the last character and formats the remaining text (and sets the value back in the EditText) which causes the backspace button to be released (even though user still holds it down).

  • The other issues is that when the user types fast (reasonably fast, not talking about pressing random buttons as fast as possible) some of the user inputs are missed because of the text formatting which forces the user to type slower and it feels really weird.

I tested your solution on Nexus 5x - Android 8.1.0 and Samsung S10+ - Android 9.0 and it has the same issues as my solution. Nexus has standard Google versions (keyboard, OS, everything) and the Samsung has standard Samsung versions of everything.

Don't know if you ran into this issue or have any idea of how to avoid it I just wanted to let you know for if I had found this library sooner I could have skipped my own implementation.

Thanks in advance!

ps: Let me know if you can't replicate I can send some video footage of what's happening on these two devices.

Date depend on locale

Does the mask support format dd/MM/yyyy and MM/dd/yyyy depending on locale?

I see in source that dd/MM/yyyy mising

companion object {
        private const val INPUT_DATE_FORMAT = "MM / dd / yyyy"
        private const val OUTPUT_DATE_FORMAT = "yyyy-MM-dd"
    }

Does the mask support HH:mm time format?

hello, i want to use this library, but can this library support HH:mm time format? or how can i costum it so that i can use it with HH:mm format that return time?

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.