Giter Club home page Giter Club logo

pinlockview's Introduction

PinLockView

A clean, minimalistic, easy-to-use and highly customizable pin lock custom view for Android.

Specs

Download API License Android Arsenal

PinLockView

This library allows you to implement a pin lock mechanism in your app easily and quickly. There are plenty of customization options available to change the look-and-feel of this view to match your app's theme.

You can also use it as a dial pad to dial numbers. There are several other use cases of this library and is not restricted to only pin locking.

PinLockView

Download

This library is available in jCenter which is the default Maven repository used in Android Studio.

Gradle

dependencies {
    // other dependencies here
    
    implementation 'com.andrognito.pinlockview:pinlockview:2.1.0'
}

Maven

<dependency>
  <groupId>com.andrognito.pinlockview</groupId>
  <artifactId>pinlockview</artifactId>
  <version>2.1.0</version>
  <type>pom</type>
</dependency>

Usage

We recommend you to check the sample app to get a complete understanding of the library. The step-by-step implementation guide is as follows.

Step 1

Place the view in your XML layout file.

    <com.andrognito.pinlockview.PinLockView
        android:id="@+id/pin_lock_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

Step 2

Reference the view in code and add a listener to it.

    mPinLockView = (PinLockView) findViewById(R.id.pin_lock_view);
    mPinLockView.setPinLockListener(mPinLockListener);

Implement the listener interface as follows,

private PinLockListener mPinLockListener = new PinLockListener() {
    @Override
    public void onComplete(String pin) {
        Log.d(TAG, "Pin complete: " + pin);
     }

    @Override
    public void onEmpty() {
        Log.d(TAG, "Pin empty");
    }

    @Override
    public void onPinChange(int pinLength, String intermediatePin) {
         Log.d(TAG, "Pin changed, new length " + pinLength + " with intermediate pin " + intermediatePin);
    }
};

And that's it! Your PinLockView is ready to rock.

But the good thing is that the PinLockView comes with a whole lot of customization options which you can use to customize the view in any way you want.

Customization

IndicatorDots (Addon)

PinLockView comes bundled with an addon view, IndicatorDots which can be optionally attached with the PinLockView to indicate pin changes visually to the user.

This view has been decoupled from the PinLockView so that you can optionally add it, if necessary. Suppose you are implementing a dial pad, then you will certainly not need this IndicatorView.

Add the view to you XML layout, generally placed above your PinLockView,

 <com.andrognito.pinlockview.IndicatorDots
        android:id="@+id/indicator_dots"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

then find a reference to the view and attach it to the parent PinLockView,

mIndicatorDots = (IndicatorDots) findViewById(R.id.indicator_dots);
mPinLockView.attachIndicatorDots(mIndicatorDots);

You MUST attach it to the PinLockView, otherwise it will be simply ignored.

Theming

There are several theming options available through XML attributes which you can use to completely change the look-and-feel of this view to match the theme of your app.

  app:pinLength="6"                                       // Change the pin length
  app:keypadTextColor="#E6E6E6"                           // Change the color of the keypad text
  app:keypadTextSize="16dp"                               // Change the text size in the keypad
  app:keypadButtonSize="72dp"                             // Change the size of individual keys/buttons
  app:keypadVerticalSpacing="24dp"                        // Alters the vertical spacing between the keypad buttons
  app:keypadHorizontalSpacing="36dp"                      // Alters the horizontal spacing between the keypad buttons
  app:keypadButtonBackgroundDrawable="@drawable/bg"       // Set a custom background drawable for the buttons
  app:keypadDeleteButtonDrawable="@drawable/ic_back"      // Set a custom drawable for the delete button
  app:keypadDeleteButtonSize="16dp"                       // Change the size of the delete button icon in the keypad
  app:keypadShowDeleteButton="false"                      // Should show the delete button, default is true
  app:keypadDeleteButtonPressedColor="#C8C8C8"            // Change the pressed/focused state color of the delete button
  
  app:dotEmptyBackground="@drawable/empty"                // Customize the empty state of the dots
  app:dotFilledBackground"@drawable/filled"               // Customize the filled state of the dots
  app:dotDiameter="12dp"                                  // Change the diameter of the dots
  app:dotSpacing="16dp"                                   // Change the spacing between individual dots
  app:indicatorType="fillWithAnimation"                   // Choose between "fixed", "fill" and "fillWithAnimation"

Contribution

This library is quite exhaustive and offers a lot of customization options. If you find a bug or would like to improve any aspect of it, feel free to contribute with pull requests.

About The Author

Aritra Roy

Android & Backend Developer. Blogger. Designer. Fitness Enthusiast.

License

Copyright 2017 aritraroy

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.

pinlockview's People

Contributors

aritraroy avatar idish avatar shpp-vsmaga avatar tatocaster 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pinlockview's Issues

how to implement ripple effect on pressed

`
<com.andrognito.pinlockview.IndicatorDots

    android:id="@+id/indicator_dots"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/profile_name"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="36dp"
    app:dotDiameter="12dp"
    app:dotSpacing="16dp" />

<com.andrognito.pinlockview.PinLockView
    android:id="@+id/pin_lock_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/indicator_dots"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="16dp"
    app:dotFilledBackground="@drawable/dot_filled"
    app:keypadButtonSize="72dp"

    app:keypadDeleteButtonPressedColor="#C8C8C8"
    app:keypadDeleteButtonSize="16dp"
    app:keypadShowDeleteButton="true"
    app:keypadTextColor="@color/white"
    app:keypadTextSize="18dp" />`

Crash when set pin length only on xml layout

I set PinLockView widget's pinlenght = 6. It'll crash when entering the 5th digits. It seems default PIN length is 4.
Error log below

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setBackgroundResource(int)' on a null object reference at com.andrognito.pinlockview.IndicatorDots.fillDot(IndicatorDots.java:148) at com.andrognito.pinlockview.IndicatorDots.updateDot(IndicatorDots.java:107) at com.andrognito.pinlockview.PinLockView$1.onNumberClicked(PinLockView.java:46) at com.andrognito.pinlockview.PinLockAdapter$NumberViewHolder$1.onClick(PinLockAdapter.java:191)

Fatal exception on Android 4.4

Fatal crash while opening activity. Crash detail:

android.view.InflateException: Binary XML file line #0: Error inflating class ImageView
                                                                             at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:714)
                                                                             at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
                                                                             at android.view.LayoutInflater.rInflate(LayoutInflater.java:759)
                                                                             at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
                                                                             at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
                                                                             at com.andrognito.pinlockview.PinLockAdapter.onCreateViewHolder(PinLockAdapter.java:47)
                                                                             at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6519)
                                                                             at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5706)
                                                                             at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5589)
                                                                             at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5585)
                                                                             at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2231)
                                                                             at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:556)
                                                                             at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1518)
                                                                             at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:610)
                                                                             at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170)
                                                                             at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3719)
                                                                             at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3135)
                                                                             at android.view.View.measure(View.java:16497)
                                                                             at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
                                                                             at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
                                                                             at android.view.View.measure(View.java:16497)

My layout file:

<com.andrognito.pinlockview.PinLockView
        android:id="@+id/pin_lock_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/indicator_dots"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="16dp"
        app:keypadButtonSize="72dp"
        app:keypadShowDeleteButton="true"
        app:keypadDeleteButtonDrawable="@mipmap/ic_imgbackspace"
        app:keypadButtonBackgroundDrawable="@mipmap/ic_pinfull"
        app:keypadTextColor="@color/colorAccent"
        app:keypadTextSize="18dp" />

    <Button
        android:id="@+id/forgot_pin"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginStart="10dp"
        android:background="@null"
        android:text="@string/forgot_pin"
        android:textColor="@color/colorAccent" />

Please help. You have built a great library

Back button isn't being shown

No matter what I do. The back button is not being shown.

<com.andrognito.pinlockview.PinLockView android:id="@+id/pin_lock_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/indicator_dots" app:keypadButtonSize="72dp" app:keypadTextSize="18dp" app:keypadShowDeleteButton="true" app:keypadTextColor="@color/white" android:layout_centerHorizontal="true" android:layout_marginTop="16dp" />

androidx support

Hi,

is there any plan to migrate to androidx libraries instead of the old support libraries. currently we cannot use your library unless we enable Jetifier which is not preferred as permanent solution

keypadButtonBackgroundDrawable

Hello
Your lib is great
But keypadButtonBackgroundDrawable does not apply correctly
Even when I set

app:keypadButtonBackgroundDrawable="?attr/selectableItemBackgroundBorderless"

it's apply only to zero button

Zero always "clicked" with selector drawable background

A GIF is worth a thousand words:
giphy

Here is the drawable (set by app:keypadButtonBackgroundDrawable):

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/list_item_active" android:state_pressed="true"/>
    <item android:drawable="@color/list_item_inactive"/>
</selector>

Change Ripple Background Runtime

Hi @aritraroy

it is possible to change the color of ripple effect on click at run time, if yes then how? please help to solve this issue.

**XML UI Like : **

<com.andrognito.pinlockview.PinLockView android:id="@+id/pin_lock_view" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/indicator_dots" android:layout_centerHorizontal="true" android:layout_margin="16dp" app:keypadButtonSize="72dp" app:keypadDeleteButtonDrawable="@drawable/ic_backspace" app:keypadDeleteButtonSize="30dp" app:keypadShowDeleteButton="true" app:keypadTextColor="@color/white" app:keypadTextSize="26dp" />

Thanks.

PinlockView not Displayed in custom Dialog

i tried to put the PinlockView in a dialog . but it the dialog showed up blank.

Dialog Layout :
`

<com.andrognito.pinlockview.PinLockView
    android:id="@+id/pin_lock_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

`

Method to Display it :
public void showDialog(Activity activity) {
final Dialog dialog = new Dialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(false);
dialog.setContentView(R.layout.pindialogue);

    final PinLockView mPinLockView = (PinLockView) dialog.findViewById(R.id.pin_lock_view);
    mPinLockView.setPinLength(4);
    mPinLockView.setPinLockListener(new PinLockListener() {
        @Override
        public void onComplete(String pin) {
            if (pin.equals("1234")) {
                dialog.hide();
            }
            else {
                YoYo.with(Techniques.Shake).duration(700).playOn(mPinLockView);
            }
        }

        @Override
        public void onEmpty() {

        }

        @Override
        public void onPinChange(int pinLength, String intermediatePin) {

        }
    });


    dialog.show();
}

FATAL EXCEPTION

How to fix?
android.view.InflateException: Binary XML file line #9: Error inflating class android.widget.Button at android.view.LayoutInflater.createView(LayoutInflater.java:640) at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748) at android.view.LayoutInflater.rInflate(LayoutInflater.java:813) at android.view.LayoutInflater.inflate(LayoutInflater.java:511) at android.view.LayoutInflater.inflate(LayoutInflater.java:415) at com.andrognito.pinlockview.PinLockAdapter.onCreateViewHolder(PinLockAdapter.java:41)

Error here:
PinLockAdapter.class
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { RecyclerView.ViewHolder viewHolder; if (viewType == VIEW_TYPE_NUMBER) { View view = View.inflate(parent.getContext(),R.layout.layout_number_item, null); viewHolder = new NumberViewHolder(view); } else { View view = View.inflate(parent.getContext(),R.layout.layout_delete_item, null); viewHolder = new DeleteViewHolder(view); } return viewHolder; }

Error when:
...
//from service:
view_pin = View.inflate(this, R.layout.activity_lock_pin, null);
...
<com.andrognito.pinlockview.PinLockView android:id="@+id/pin_lock_view_Pin" android:layout_width="300dp" android:layout_height="wrap_content" />

Clear indicator dots

Hi, thanks for your good job.
I've implemented this in an application and I like to clear indicator dots when the entered pin is incorrect.
how can I do so?

java.lang.ArrayIndexOutOfBoundsException

java.lang.ArrayIndexOutOfBoundsException:
at com.andrognito.pinlockview.PinLockAdapter.configureNumberButtonHolder (PinLockAdapter.java:69)
at com.andrognito.pinlockview.PinLockAdapter.onBindViewHolder (PinLockAdapter.java:57)
at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder (RecyclerView.java:6781)
at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder (RecyclerView.java:6823)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline (RecyclerView.java:5752)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline (RecyclerView.java:6019)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:5858)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:5854)
at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next (LinearLayoutManager.java:2230)
at androidx.recyclerview.widget.GridLayoutManager.layoutChunk (GridLayoutManager.java:557)
at androidx.recyclerview.widget.LinearLayoutManager.fill (LinearLayoutManager.java:1517)
at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren (LinearLayoutManager.java:612)
at androidx.recyclerview.widget.GridLayoutManager.onLayoutChildren (GridLayoutManager.java:171)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2 (RecyclerView.java:3924)
at androidx.recyclerview.widget.RecyclerView.onMeasure (RecyclerView.java:3336)
at android.view.View.measure (View.java:23393)
at android.widget.RelativeLayout.measureChildHorizontal (RelativeLayout.java:715)
at android.widget.RelativeLayout.onMeasure (RelativeLayout.java:461)
at android.view.View.measure (View.java:23393)
at android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6966)
at android.widget.FrameLayout.onMeasure (FrameLayout.java:185)
at android.view.View.measure (View.java:23393)
at android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6966)
at android.widget.FrameLayout.onMeasure (FrameLayout.java:185)
at androidx.appcompat.widget.ContentFrameLayout.onMeasure (ContentFrameLayout.java:143)
at android.view.View.measure (View.java:23393)
at android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6966)
at android.widget.LinearLayout.measureChildBeforeLayout (LinearLayout.java:1514)
at android.widget.LinearLayout.measureVertical (LinearLayout.java:806)
at android.widget.LinearLayout.onMeasure (LinearLayout.java:685)
at android.view.View.measure (View.java:23393)
at android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6966)
at android.widget.FrameLayout.onMeasure (FrameLayout.java:185)
at android.view.View.measure (View.java:23393)
at android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6966)
at android.widget.LinearLayout.measureChildBeforeLayout (LinearLayout.java:1514)
at android.widget.LinearLayout.measureVertical (LinearLayout.java:806)
at android.widget.LinearLayout.onMeasure (LinearLayout.java:685)
at android.view.View.measure (View.java:23393)
at android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6966)
at android.widget.FrameLayout.onMeasure (FrameLayout.java:185)
at com.android.internal.policy.DecorView.onMeasure (DecorView.java:915)
at android.view.View.measure (View.java:23393)
at android.view.ViewRootImpl.performMeasure (ViewRootImpl.java:2952)
at android.view.ViewRootImpl.measureHierarchy (ViewRootImpl.java:1977)
at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2236)
at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1843)
at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:7978)
at android.view.Choreographer$CallbackRecord.run (Choreographer.java:911)
at android.view.Choreographer.doCallbacks (Choreographer.java:723)
at android.view.Choreographer.doFrame (Choreographer.java:658)
at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:897)
at android.os.Handler.handleCallback (Handler.java:790)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:164)
at android.app.ActivityThread.main (ActivityThread.java:7002)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1408)

AnimatorCompatHelper Class Not Found Exception using AppCompat 27.0.0

When using compat library 27.0.0 the app crash when call animatorCompatHelper

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/animation/AnimatorCompatHelper;
                                                       at android.support.v7.widget.DefaultItemAnimator.resetAnimation(DefaultItemAnimator.java:515)
                                                       at android.support.v7.widget.DefaultItemAnimator.animateChange(DefaultItemAnimator.java:322)
                                                       at android.support.v7.widget.SimpleItemAnimator.animateChange(SimpleItemAnimator.java:149)
                                                       at android.support.v7.widget.RecyclerView.animateChange(RecyclerView.java:3836)

Show background as key pressed

Hi, how can I show a circle background for only the pressed key (as shown in Readme second picture)? I used the keypadButtonBackgroundDrawable attribute but it shows constant background for all buttons.

Error Label?

Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : Attribute application@label value=(CORRIERE) from AndroidManifest.xml:16:9-33
  	is also present at [com.andrognito.pinlockview:pinlockview:2.1.0] AndroidManifest.xml:11:18-50 value=(@string/app_name).
  	Suggestion: add 'tools:replace="android:label"' to <application> element at AndroidManifest.xml:13:5-39:19 to override.

Delete button turns white after first touch

Hello,

I noticed an issue where the back button changes to white when I tap it. This is problematic because I'd like to have a white background. I'm attaching three screenshots that show the keypad before I enter anything, after I've entered three numbers, and after I've pressed the delete button one time. I turned the background color blue to show what I mean.

Before
screen shot 2017-07-18 at 3 23 18 pm

During
screen shot 2017-07-18 at 3 23 32 pm

After deleting one
screen shot 2017-07-18 at 3 23 42 pm

Any ideas? Thanks!

Unable to change dotDiameter

Changing the "app:dotDiameter" doesn't seem to have any effect and it stays the default diameter. The parameter is not available programmatically. Please look into this.

change pressed style

how change pressed style from squarer to circle like as second screenshot in readme?

Different inputType

A question, how can one change the input type from password to number in case it is a dial pad

setTypeface to buttons

Hi,is it possible to add setTypeface methode for buttons in java code? just for setting typeface to buttons i have copied your library file into my project to customize the typeface. I want to add your library in gradle of my project.

thank you

manifest issues

Is it possible to remove supportsRtl and allowbackup attributes in the manifest file? Gradle sync fails when trying to use this project if my attributes are different.

Button Pressed Style

I need to change the button style for button pressed status. I can not find a way to do it in XML. Is there a way to do that?
Thanks.

Can't change IndicatorDots colors

I can't change the color of empty or filled state of the IndicatorDots neither using "dotEmptyBackground" nor "dotFilledBackground"

How clear indicator dot?

can i clear indicatordot? i wanna use indicatordot for verif my pin, so when pin i was input wrong indicatordot will clear. please help

resetPinLockView() breaks delete

Hi, I have noticed this behavior when implementing the pinLockView.resetPinLockView() method, when there is no pin entered or all the characters have been deleted via the backspace button.

After the aforementioned method clears the input (as expected), any subsequent input works as well, but the backspace button does not trigger as far as I can tell and no characters get deleted.

The listener works as well and all three methods get triggered as expected.

My workaround, for now, has been to implement an isPinResettable flag.

The logic with resetting the pin view is as follows

if (isPinResettable)
    pinLockView.resetPinLockView()

And my PinLockListener object looks like this

private val pinLockListener: PinLockListener = object : PinLockListener {

    override fun onEmpty() {
        isPinResettable = false
    }

    override fun onComplete(pin: String?) {
       // DO SOME WORK WITH PIN
    }

    override fun onPinChange(pinLength: Int, intermediatePin: String?) {
        if (pinLength > 0)
            isPinResettable = true
    }

}

Expose access to the pin (or at least its current length) from the PinLockView object

I'm aware of that I can access the pin via listeners like onComplete, onProgress and so on..
However, some scenarios require accessing the pin or its length on demand.

Use case:
UI shows PinLockView and "next" button.

User clicks the next button.
It is obvious now that I shouldn't let the user go through to the next activity because the pin is not completed yet.

The current way to deal with this scenario is to set a boolean state flag that indicates if the user can go to the next activity, it will be set to True when the onComplete is called.
However, I'll then have to reset this boolean flag once the user has clicked the "next" button

Better way:
Each time user clicks the next button, I'll be able check the PinLockView and check if the current pin length is as defined, if yes, the user is eligible to move next.
That way, there will be no need to keep a statefull boolean which might be buggy solution as well..

What About Convert to Kotlin with Refactoring?

Hi, I'm Minseok from Korea.

I like your project, but to import this in my project, I have to refactor some code.
So, I forked this on my repository and converted to kotlin with refactoring code structure.

You can see the code HERE
What about make it new version? :)

Thank you

the number 4 is not visible.

first of all, thank you for your library!

the PinLockView does not visible number 4 my LG G3.Cat6 device.
i think, can you solve it with little edit to PinLockAdapter.

please see below lines(PinLockAdapter.java: 70):

if (position == 10) {
  holder.mNumberButton.setText("0");
} else if (position == 9) {
  holder.mNumberButton.setVisibility(View.INVISIBLE);
} else {
  holder.mNumberButton.setText(String.valueOf((position + 1) % 10));
}

edit to:

if (position == 10) {
  holder.mNumberButton.setText("0");
  holder.mNumberButton.setVisibility(View.VISIBLE);
} else if (position == 9) {
  holder.mNumberButton.setVisibility(View.INVISIBLE);
} else {
  holder.mNumberButton.setText(String.valueOf((position + 1) % 10));
  holder.mNumberButton.setVisibility(View.VISIBLE);
}

how think about it?

dotFilledBackground drawable not changing

<com.andrognito.pinlockview.IndicatorDots
        android:id="@+id/indicator_dots"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        />

<com.andrognito.pinlockview.PinLockView
        android:id="@+id/pin_lock_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:keypadTextColor="#1565C0"
        app:keypadTextSize="20sp"
        app:pinLength="4"
        app:dotFilledBackground="@drawable/img_indicator_active"/>

Drawable is not changing.

Delete button not clickable when visible

I have encountered a strange bug. In one of my activities the keypad delete button cannot be used even though it is set to true in the XML and is visible. This only occurs in one activity, all other activities function correctly.

This is my xml for the layout (identical to one that works in another activity):

<com.andrognito.pinlockview.PinLockView
            android:id="@+id/activeTaskViewPinLockView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="48dp"
            app:keypadButtonSize="72dp"
            app:keypadShowDeleteButton="true"
            app:keypadTextColor="@color/white"
            app:keypadTextSize="18dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent" />

in onCreate I set it up:

pinLockView.attachIndicatorDots(pinLockIndicatorDots);
pinLockView.resetPinLockView();
pinLockListener = new PinLockListener() {
      @Override
       public void onComplete(String pin) {
           //do stuff
        }

       @Override
        public void onEmpty() {
              
        }

        @Override
        public void onPinChange(int pinLength, String intermediatePin) {
              
        }
  };
pinLockView.setPinLockListener(pinLockListener);

This code is identical to that of a working activity. So I am stumped as to what is causing it.

Any ideas?

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.