Skip to content

HBiSoft/Pinlockr

Repository files navigation

Creating and maintaining a library like this requires a significant amount of time and effort.

If you’d like to show your appreciation, you can do so below:

Buy Me A Coffee



Pinlockr

Lightweight screen lock Android library

Requires API level 24>


Demo:

Download the demo app here



Adding the library to your project:

Add the following in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }	    
    }
}

Implement library in your app level build.gradle:

dependencies {
    implementation 'com.github.HBiSoft:Pinlockr:0.0.5'
}

Implementing the library:

public class MainActivity extends AppCompatActivity {
    //Declare PinlockrView
    PinlockrView pinLockrView;

    //Declare IndicatorDots (Optional - It's the dots that show the pin progress)
    IndicatorDots mIndicatorDots;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Initialize PinlockrView
        pinLockrView = findViewById(R.id.pinLockrView);

        // Initialize IndicatorDots
        mIndicatorDots = findViewById(R.id.mIndicatorDots);

        // Setup
        // 1.) Activity - Activity is only used for BiometricManager
        // 2.) PinLockListener - To handle the callbacks
        // 3.) boolean - If this is set to "true", the pin will be saved in SharedPreferences
        //     If you don't set this, or set it to false - You have to handle the storing of the pin yourself
        // 4.) IndicatorDots - If you want to use the IndicatorDots, you have to pass it here, otherwise you have to pass null
        //     You have to setup IndicatorDots before passing it below.
        // 5.) int - Pin length
        pinLockrView.setupPinlockrView(this, mPinLockListener, mIndicatorDots, 5);
    }

    // PinlockrListener
    private final PinlockrListener mPinLockListener = new PinlockrListener() {
        @Override
        public void onComplete(String pin) {
        // Pin will be returned here
        // See the demo application 
    });
    
}

Add PinlockrView to layout

<com.hbisoft.pinlockr.PinlockrView
    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"/>

AND YOU ARE DONE!


Customisation:

This can be done in xml or in java.

If you set this in java and in xml, then java will be favoured

Java:

// Disable biometric
pinLockView.disableBiometricLogin(boolean);
// Customize the biometric texts
pinLockView.customizeBiometricDialog(titleText, subTitleText, buttonTitle);
// Set the text color of the numbers
pinLockView.setTextColor(int);
// Set the text size of the numbers
pinLockView.setTextSize(int);
// Set the size of the buttons the numbers are in
pinLockView.setButtonSize(int);
// Change the button background drawable
pinLockView.setButtonBackgroundDrawable(Drawable);
// Change the delete button drawable
pinLockView.setDeleteButtonDrawable(Drawable);
// Change the delete button size
pinLockView.setDeleteButtonSize(int);
// Show/Hide delete button
pinLockView.setShowDeleteButton(boolean);
// Set delete button pressed color
pinLockView.setDeleteButtonPressedColor(int);


// OTHER PUBLIC METHODS:

// Resets the view - returns boolean
pinLockView.resetPinlockrView();
// Check if the indicator dots are attached - returns boolean
pinLockView.isIndicatorDotsAttached();

xml:

  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"

Credit:

This library was built upon this one, which is no longer maintained

About

Lightweight screen lock Android library - With biometric integration

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages