Enabling Gesture-Based Security with PatternLockView Library

In the quest for enhanced security and user-friendly interfaces within Android applications, aritraroy has brought forth an open-source library, PatternLockView. This library, built with Kotlin and Jetpack Compose, seamlessly introduces gesture-based password locks into Android apps, embodying simplicity and ease of implementation.

Here are the hallmark features of PatternLockView:

  1. It supports a variety of gesture password formats such as 3x3, 4x4, and 5x5, providing a versatile foundation for security layouts.
  2. Customizability shines through, allowing for personalized gesture password styles to match the app's theme.
  3. Verification and unlocking using the gesture password are straightforward, ensuring a user-friendly experience.

Kickstarting with PatternLockView involves adding the following dependency to your Android project:

dependencies {
    implementation 'com.github.aritraroy:patternlockview:1.5.1'
}

Below is a snippet showcasing the implementation of PatternLockView:

// Initializing the gesture password lock
val patternLockView = PatternLockView(requireContext())

// Setting the format
patternLockView.setFormat(3, 3)

// Defining the style
patternLockView.setStyle(
    primaryColor = Color.RED,
    secondaryColor = Color.BLACK,
    lineColor = Color.BLUE,
    dotColor = Color.GREEN,
    errorColor = Color.RED,
)

// Displaying the gesture password lock
patternLockView.show()

// Verifying the gesture password
patternLockView.checkPattern(pattern)

// Unlocking using the gesture password
patternLockView.unlock()

Upon running this snippet, a dialog featuring the gesture password lock appears, enabling the drawing of the gesture password for verification or unlocking.

Furthermore, PatternLockView extends the styling customization through the modification of the style attribute, adjusting the background color, line color, and dot color of the gesture password lock:

// Customizing the style
patternLockView.style = PatternLockViewStyle(
    background = Color.Yellow,
    lineColor = Color.Black,
    dotColor = Color.White,
)

PatternLockView stands as a simplistic yet efficient tool to swiftly introduce gesture password lock functionality within your Android applications.