Giter Site home page Giter Site logo

mukeshsolanki / android-otpview-pinview Goto Github PK

View Code? Open in Web Editor NEW
668.0 668.0 207.0 559 KB

A custom view to enter otp of different sizes used usually in cases of authentication.

License: MIT License

Kotlin 27.86% Java 72.14%
android android-library android-pinview authentication compose compose-library custom-view jetpack-compose otp otpview

android-otpview-pinview's Introduction

Hi, I'm Mukesh Solanki!

Linkedin Badge Twitter Badge Medium Badge Website Badge

Typing SVG

About Me

  • ⚡ Contribuing to a whole bunch of opensource projects.
  • 🖨️ I write tech articles almost every week on Medium.
  • 🌱 Always experimenting with bleading edge tech.
  • ⛰️ Love exploring and going on hikes

Latest Blog Posts

Github Stats

Mukesh Solanki's Github Stats Mukesh Solanki's Top Languages

android-otpview-pinview's People

Contributors

aantoniv avatar hazem-madkour avatar lisovyidk avatar msandeep96 avatar mukeshsolanki avatar vgupta98 avatar williamtan89 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-otpview-pinview's Issues

Project fails to build with v2.0.1

I am trying to use the app in my project but the project doesn't build.

I am using compile and target sdk version 28 and buildToolsVersion 28.0.3. The support libraries are all version 28.0.0

This is the error stacktrace that I get when I try to build the project.

Android resource linking failed
Output:  C:\Users\me\androidProject\kite\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:8642: error: style attribute 'attr/textColorError (aka com.app.kite:attr/textColorError)' not found.
error: failed linking references.

Command: C:\Users\me\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\355577d385562aabb3c69eea7f88a383\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\
        C:\Users\me\AppData\Local\Android\Sdk\platforms\android-28\android.jar\
        --manifest\
        C:\Users\me\androidProject\kite\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
        -o\
        C:\Users\me\androidProject\kite\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
        -R\
        @C:\Users\me\androidProject\kite\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
        --auto-add-overlay\
        --java\
        C:\Users\me\androidProject\kite\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
        --proguard-main-dex\
        C:\Users\me\androidProject\kite\build\intermediates\legacy_multidex_aapt_derived_proguard_rules\debug\processDebugResources\manifest_keep.txt\
        --custom-package\
        com.app.kite\
        -0\
        apk\
        --output-text-symbols\
        C:\Users\me\androidProject\kite\build\intermediates\symbols\debug\R.txt\
        --no-version-vectors
Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #0

The First backspace press

Hi,
When I enter my 4 digit OTP code and click again on the last digit to delete a number, the cursor jumps back to the first number, (instead of remaining at the last number).

Kindly let me know if there is some way to correct this issue. Thanks.

unable to integrate app in project

implementation 'com.github.mukeshsolanki:android-otpview-pinview:<latest-version>' gives error Failed to resolve: com.github

implementation 'com.github.mukeshsolanki:android-otpview-pinview:1.1.0' gives error Failed to resolve: com.github.mukeshsolanki:android-otpview-pinview:1.1.0

Backpress dont works

When i use this library, everythings works perfectly but not the Backpress key.. What should i do for this?

In RTL OTP View strange Behaviour

I Change it to RTL and OTP view focus also changed now its focusing 2nd box first and then after it is focusing on the first view and then third. Please help me how can i overcome this issue for RTL?
Thanks for sharing this. need your support.

Direction issue in arabic

Subject of the issue

In arabic OTP view should start from right to left.

Steps to reproduce

Change language from english to arabic.

Expected behaviour

It should start from right to left in arabic.

Actual behaviour

It's starting from left to right in arabic.

Keyboard is not showing

As per the example you provided, the keyboard is not showing to type.

<com.mukesh.OtpView android:id="@+id/otp_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/input_layout" android:layout_marginTop="@dimen/dimen_16dp" android:inputType="number" android:layout_centerHorizontal="true" android:textColor="@android:color/white" app:itemCount="4" android:focusable="true" app:lineColor="@color/colorPrimary" app:viewType="line" android:cursorVisible="true" />

PIN view is unavailable

Only OTP VIEW is available and PIN view is not available.
Provide PIN VIEW or Remove Misleading Screenshot

1.0.5 not working

Implemented with dependency 1.0.5 and tried for appx 2 hours but the screen was blank, wasn't able to see anything then I changed it to 1.0.4 and It was working fine.

Please check the same.

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference

if i write like below
<com.mukesh.OtpView android:id="@+id/otp_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginTop="@dimen/margin_30dp" android:inputType="number" android:textColor="@color/login" app:length="4" app:otp="1234" android:background="@color/white" >

its working with above code and if i remove app:otp="1234" this line it willl crash with below logs..
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2821) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1541) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:181) at android.app.ActivityThread.main(ActivityThread.java:6295) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:793) Caused by: android.view.InflateException: Binary XML file line #66: Binary XML file line #66: Error inflating class com.mukesh.OtpView Caused by: android.view.InflateException: Binary XML file line #66: Error inflating class com.mukesh.OtpView Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:430) at android.view.LayoutInflater.createView(LayoutInflater.java:654) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:832) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:772) at android.view.LayoutInflater.rInflate(LayoutInflater.java:903) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:866) at android.view.LayoutInflater.rInflate(LayoutInflater.java:906) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:866) at android.view.LayoutInflater.rInflate(LayoutInflater.java:906) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:866) at android.view.LayoutInflater.inflate(LayoutInflater.java:524) at android.view.LayoutInflater.inflate(LayoutInflater.java:432) at android.view.LayoutInflater.inflate(LayoutInflater.java:383) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) at com.pharma.app.activities.OtpVerification.onCreate(OtpVerification.java:51) at android.app.Activity.performCreate(Activity.java:6862) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2713) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2821) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1541) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:181) at android.app.ActivityThread.main(ActivityThread.java:6295) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:793) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference at com.mukesh.OtpView.setOTP(OtpView.java:95) at com.mukesh.OtpView.generateViews(OtpView.java:147) at com.mukesh.OtpView.styleEditTexts(OtpView.java:108) at com.mukesh.OtpView.init(OtpView.java:49) at com.mukesh.OtpView.<init>(OtpView.java:39) at java.lang.reflect.Constructor.newInstance0(Native Method)  at java.lang.reflect.Constructor.newInstance(Constructor.java:430)  at android.view.LayoutInflater.createView(LayoutInflater.java:654)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:832)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:772)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:903)  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:866)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:906)  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:866)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:906)  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:866)  at android.view.LayoutInflater.inflate(LayoutInflater.java:524)  at android.view.LayoutInflater.inflate(LayoutInflater.java:432)  at android.view.LayoutInflater.inflate(LayoutInflater.java:383)  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)  at com.pharma.app.activities.OtpVerification.onCreate(OtpVerification.java:51)  at android.app.Activity.performCreate(Activity.java:6862)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2713)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2821)  at android.app.ActivityThread.-wrap12(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1541)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:181)  at android.app.ActivityThread.main(ActivityThread.java:6295)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:793) 

and solved by adding 4 space app:otp=" " like this this shouldn't be happened

Changing textsize

How to change the size of the number input in the otp view? The parameters app:width, app:height have no effect on this.

setOnFocusChangeListener Method is not working in android.

i want one view visible when i focus on otpView. and view disable when i focus off otpView.

my Code is

    otpView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (b) {
                showImageVisibleView();
                } else {
                showImageInvisibleView();
                }
            }
        }
    });

Give here answer if as soon as possible.

Caused by java.lang.NullPointerException

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.developer.odoc/com.developer.odoc.register.SignUpPhase3Activity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.text.Editable android.widget.EditText.getText()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3319)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
### Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'android.text.Editable android.widget.EditText.getText()' on a null object reference
at com.mukesh.OtpView$4.afterTextChanged(OtpView.java:199)

at android.widget.TextView.sendAfterTextChanged(TextView.java:9303)
at android.widget.TextView.setText(TextView.java:5018)
at android.widget.TextView.setText(TextView.java:4834)
at android.widget.EditText.setText(EditText.java:117)
at android.widget.TextView.setText(TextView.java:4809)
at android.widget.TextView.onRestoreInstanceState(TextView.java:4702)
at android.view.View.dispatchRestoreInstanceState(View.java:16092)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3441)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3441)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3441)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3441)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3441)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3441)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3441)
at android.view.View.restoreHierarchyState(View.java:16070)
at com.android.internal.policy.PhoneWindow.restoreHierarchyState(PhoneWindow.java:2337)
at android.app.Activity.onRestoreInstanceState(Activity.java:1177)
at android.app.Activity.performRestoreInstanceState(Activity.java:1122)
at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1192)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3286)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

OTP length

Subject of the issue

When we enter fill all the places then remove them, previous values still persist.

Steps to reproduce

Lets say length of my otp view is 5 ,
I entered 5 digits , then i removed 5 th digit , then even if my otp view has 4 digits showing it will take value of 5 th digit which i removed.
eg: 12345 is my otp , i entered it to otp view , then i removed 5 , when i submits otp it will take 12345 . (5 do not get deleted from last storedvalue)

Expected behaviour

When we delete some otp value then it must also get removed from stored value,

Actual behaviour

It must return value what user in giving input

Its very slow

When I typing its not type words, skips some words while typing. So its very slow.

How to increase text size of mumber password input type ?

Hi @mukeshsolanki

I have been implementing through your library. Everything seems to be working perfect.

I have one query is their any possibility to be increase TextSize i mean i am using numberPassword and i wanted dots to be look more bigger then default.

Can you able to check if we can add TextSize property in same.

Is their any possibility you can look into this ? it will be great!!

setOTP exception

Calling setOTP on the otpView produces an exception.

E/AndroidRuntime: FATAL EXCEPTION: main
                                                                      
                                                                      android.content.res.Resources$NotFoundException: String resource ID #0x30
                                                                          at android.content.res.Resources.getText(Resources.java:354)
                                                                          at android.widget.TextView.setText(TextView.java:4167)
                                                                          at com.mukesh.OtpView.setOTP(OtpView.java:95)
                                                                          at android.support.v4.app.Fragment.performCreateView(Fragment.java:2343)
                                                                          at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1419)
                                                                          at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740)
                                                                          at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809)
                                                                          at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799)
                                                                          at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580)
                                                                          at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367)
                                                                          at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322)
                                                                          at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2229)
                                                                          at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:700)
                                                                          at android.os.Handler.handleCallback(Handler.java:815)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:104)
                                                                          at android.os.Looper.loop(Looper.java:194)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5637)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at java.lang.reflect.Method.invoke(Method.java:372)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

AndroidX issue

OtpView not working

create new project and check on support androidX
add the gradle dependence of OtpView try to use it run the app it 's not working

Delete Issue

Hi, your lib is good but I am not getting any call back when the user has deleted all the otp content. You should send the call back on your setOtpCompletionListener.

Try to add OTP and then backspace/Delete them. You won't get any call back from it. I want to check that user has entered OTP or not.

Does this library work in kotlin?

I am trying to integrate this into my Kotlin app and can create the view but can not press on the boxes to enter input or assign a listener properly. I have followed the instructions on the read-me exactly and am presuming it is a kotlin to java issue?

Set custom OTP count

How to add OTP count in OTP view.
it takes default 4 numbers but I want 6 numbers in OTP.

OTP for Diff Length

hi i want to set it for 6 digit OTP ,changed in XML ,and changed in code to ,but when page display it is 6 edittext but when i set OTP it is showing Only 4

Font Family - Not Updating

I have tried to update the font family, its not getting updated. Is that possible?

<style name="OtpWidget.OtpView" parent="Widget.AppCompat.EditText"> 18sp @font/the_sans_arabic_plain #FFFFFF </style>

OTP values.

When we enter fill all the places then remove them, previous values still persist.

OtpView is not gaining focus and not showing keypad.

I am using the latest version of OtpView and here is my code:-

<com.mukesh.OtpView android:id="@+id/otp_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="number" android:textColor="@android:color/white" app:itemCount="4" app:lineColor="@color/colorPrimaryDark" app:viewType="line" app:itemSpacing="25dp" app:hideLineWhenFilled="true" />
I don't know what is happening but somehow keypad is not opening for typing,I think the recent update you have done 20 days ago has something to do with this BUG.

How to change to dash view?

I have tried changing the view type to "line" by doing app:viewType="line" but it always shows Box View. It doesn't matter what I select.

Can't clear opt Values

Can't clear opt ValuesDescribe your issue here.
If user wants to clear the opt value one by one there is no listener for that

Clear codes

Subject of the issue

@mukeshsolanki First of all thanks for this amazing library....good work!!
How I can clear all codes ??
Thanks again ;)

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.