Giter VIP home page Giter VIP logo

pin-lock-compose's Introduction

Pin Lock

Android Version License API

๐Ÿ” Light library that is beautiful Pin Lock screen for Jetpack Compose. The library handles saving pin in Encrypted file. Integration is very easy and fast.

Setup

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

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

Include below dependency in build.gradle of application and sync it:

implementation 'com.github.raheemadamboev:pin-lock-compose:1.0.1'

Implementation

Firstly, initialize the library on your onCreate of Application class:

PinManager.initialize(this)

To add Pin Lock screen, add the PinLock composable to your compose area:

PinLock(
  title = { pinExists ->
    Text(text = if (pinExists) "Enter your pin" else "Create pin")
  },
  color = MaterialTheme.colorScheme.primary,
  onPinCorrect = {
    // pin is correct, navigate or hide pin lock
  },
  onPinIncorrect = {
     // pin is incorrect, show error
  },
  onPinCreated = {
     // pin created for the first time, navigate or hide pin lock
  }
)

If there is no saved pin yet, it promtps the user to create pin. If there is saved pin, it promts the user to enter its pin:


It is also possible to change pin. Just add ChangePinLock composable to your compose area:

ChangePinLock(
  title = { authenticated ->
    Text(text = if (authenticated) "Enter new pin" else "Enter your pin")
  },
  color = MaterialTheme.colorScheme.primary,
  onPinIncorrect = {
    // pin is incorrect, show error
  },
  onPinChanged = {
    // pin changed, navigate or hide pin lock
  }
)

Use this only if there is already saved pin. If there is no saved pin, use simple PinLock instead for creating pin for the first time. When using ChangePinLock, firstly it prompts the user to enter original pin. After user succesfully authenticates using his original pin, it prompts the user to creat a new pin:


To check if saved pin exists:

val pinExists = PinManager.pinExists()

To clear saved pin so user can create brand new pin:

PinManager.clearPin()

Features

  • pin lock screen very easily
  • handles encryption and saving pin internally
  • change pin lock screen
  • customizable background color
  • robust to configuration changes
  • backspace to remove last entered pin number
  • incorrect indicator animation

Demo

You can install and try demo app. All the features are implemented in the demo from creating pin to changing pin.

Download demo

Projects using this library

Notepad: 40 000+ downloads.

Google Play Store

Github

Licence

Designed and developed by raheemadamboev (Raheem) 2023.

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.

pin-lock-compose's People

Contributors

raheemadamboev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pin-lock-compose's Issues

NoSuchMethodError for androidx.compose:compose-bom:2023.09.02

When I use PinLock() in MainActivity so app crashed with exception.

java.lang.NoSuchMethodError: No
static method AnimatedContent(Ljava/lang/Object;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function1;Landroidx/compose/ui/Alignment;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;II)V
 in class
  Landroidx/compose/animation/AnimatedContentKt; or
  its super classes (declaration of
 'androidx.compose.animation.AnimatedContentKt' appears

Library crashes my app, I think it has many bugs or was not properly tested

FATAL EXCEPTION: main
Process: com.mine.app, PID: 22559
java.lang.NoSuchMethodError: No static method AnimatedContent(Ljava/lang/Object;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function1;Landroidx/compose/ui/Alignment;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;II)V in class Landroidx/compose/animation/AnimatedContentKt; or its super classes (declaration of 'androidx.compose.animation.AnimatedContentKt' appears in /data/app/~~fTGKh1WwePjJ8HhiO6mY1Q==/commine.app-2XTrsyZLKNXVlP2htZsubA==/base.apk)
at xyz.teamgravity.pin_lock_compose.PinLockKt$BasePinLock-8V94_ZQ$$inlined$ConstraintLayout$2.invoke(ConstraintLayout.kt:1575)
at xyz.teamgravity.pin_lock_compose.PinLockKt$BasePinLock-8V94_ZQ$$inlined$ConstraintLayout$2.invoke(ConstraintLayout.kt:89)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.ui.layout.LayoutKt.MultiMeasureLayout(Layout.kt:443)
at xyz.teamgravity.pin_lock_compose.PinLockKt.BasePinLock-8V94_ZQ(PinLock.kt:458)
at xyz.teamgravity.pin_lock_compose.PinLockKt.PinLock-sW7UJKQ(PinLock.kt:53)
at com.XXXX.XXXX.screen.XXX.Keypad(Keypad.kt:46)
at com.appp.minw.navigation.ComposableSingletons$NavGraphKt$lambda-1$1.invoke(NavGraph.kt:36)
at com.app.minw.navigation.ComposableSingletons$NavGraphKt$lambda-1$1.invoke(NavGraph.kt:35)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:117)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.navigation.compose.NavHostKt$NavHost$4$1.invoke(NavHost.kt:150)
at androidx.navigation.compose.NavHostKt$NavHost$4$1.invoke(NavHost.kt:149)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.runtime.saveable.SaveableStateHolderImpl.SaveableStateProvider(SaveableStateHolder.kt:84)
at androidx.navigation.compose.NavBackStackEntryProviderKt.SaveableStateProvider(NavBackStackEntryProvider.kt:60)
at androidx.navigation.compose.NavBackStackEntryProviderKt.access$SaveableStateProvider(NavBackStackEntryProvider.kt:1)
at androidx.navigation.compose.NavBackStackEntryProviderKt$LocalOwnersProvider$1.invoke(NavBackStackEntryProvider.kt:52)
at androidx.navigation.compose.NavBackStackEntryProviderKt$LocalOwnersProvider$1.invoke(NavBackStackEntryProvider.kt:51)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.navigation.compose.NavBackStackEntryProviderKt.LocalOwnersProvider(NavBackStackEntryProvider.kt:47)
at androidx.navigation.compose.NavHostKt$NavHost$4.invoke(NavHost.kt:149)
at androidx.navigation.compose.NavHostKt$NavHost$4.invoke(NavHost.kt:142)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:117)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.animation.CrossfadeKt$Crossfade$5$1.invoke(Crossfade.kt:133)
at androidx.compose.animation.CrossfadeKt$Crossfade$5$1.invoke(Crossfade.kt:128)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.animation.CrossfadeKt.Crossfade(Crossfade.kt:142)
at androidx.compose.animation.CrossfadeKt.Crossfade(Crossfade.kt:73)

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.