Skip to content

A very lightweight library which serves the purpose of entering a 6 digit pix like OTP from an SMS. Uses latest Material IO and theming is picked up from whatever is set in the app

License

Notifications You must be signed in to change notification settings

ubarua123/SixDigitPinView

Repository files navigation

SixDigitPinView

A very lightweight library which serves the purpose of entering a 6 digit pix like OTP from an SMS. Uses latest Material IO and theming is picked up from whatever is set in the app.

How to use:

Clone it and include the module

:sixdigitpinview

Not really got around uploading to maven :D

Include it in the layout as follows:

<com.wonderquill.sixdigitpinview.SixDigitPinView
android:id=@+id/sixDigitPinView
    android:layout_width=0dp
    android:layout_height=wrap_content/>

Reference it the usual way

val pinView = findViewById<SixDigitPinView>(R.id.sixDigitPinView)

To get the entered pin, call:

val pin = pinView.getEnteredPin()

I purposely didn’t implement fetching data from the clip board service since sometimes you might want to auto detect the sms and paste it.

To paste a 6 digit pin:

pinView.pastePin("123456")

Example of getting from the clipboard

val clipboardManager = getSystemService(Context.CLIPBOARD_SERVICE)  as ClipboardManager
clipboardManager.primaryClip?.let.{
if(it.itemCount> 0)
        pinView.pastePin(it.getItemAt(0).text.toString())
}

You can enable or disable the reset button

You can use your own button and call

pinView.reset()

to reset the entered pin

To Enable the built in reset button, use app:show_reset_button=true

It is disabled by default.

Feel free to fork it, clone it, edit it!

About

A very lightweight library which serves the purpose of entering a 6 digit pix like OTP from an SMS. Uses latest Material IO and theming is picked up from whatever is set in the app

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages