Library for passcode implementation along with an optional additional feature to ask for passcode when your app resumes from background. (Works with minSDK >= 21)
In order to use the library
1. Gradle dependency
- Add the following to your project level
build.gradle
:
allprojects {
repositories {
jcenter()
}
}
- Add this to your app
build.gradle
:
dependencies {
implementation 'com.github.openMF.mifos-passcode:compose:1.0.3'
}
passcode.lib.rec.mp4
For a basic implementation of the PassCode Screen
-
Inject the
PasscodeRepository
in your activity which is essentially abstracting the operations related to saving, retrieving, and validating the passcode -
Import
PasscodeScreen
to your project which has 4 parameters mentioned below:onForgotButton
: This will allow to handle the case when the user isn't able to log into the app. In our project we are redirecting the user to login pageonSkipButton
: This offers users the flexibility to bypass the passcode setup process, granting them immediate access to the desired screenonPasscodeConfirm
: This allows you to pass a function that accepts a string parameteronPasscodeRejected
: This can be used to handle the event when user has entered a wrong passcode
-
This is how a typical implementation would look like
@Inject
lateinit var passcodeRepository: PasscodeRepository
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MifosPasscodeTheme {
PasscodeScreen(
onForgotButton = {},
onSkipButton = {},
onPasscodeConfirm = {},
onPasscodeRejected = {}
)
}
}
}
- You can now define functions of your own and pass them to their respective fields. You can find the entire implementation in the
PasscodeActivity
of:app
module
- Here are some screenshots of the app