Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.tetra99:pflockscreen-android:1.0.0-Beta3-novibration'
}
dependencies {
implementation("com.github.tetra99:pflockscreen-android:1.0.0-Beta3-novibration")
}
<dependency>
<groupId>com.github.tetra99</groupId>
<artifactId>pflockscreen-android</artifactId>
<version>1.0.0-Beta3-novibration</version>
</dependency>
libraryDependencies += "com.github.tetra99" % "pflockscreen-android" % "1.0.0-Beta3-novibration"
:dependencies [[com.github.tetra99/pflockscreen-android "1.0.0-Beta3-novibration"]]
Feel free to ask questions add issues. If I don't responce in Issue or PR feel free to ping me or send me DM on twitter @thealeksandr
PFLockScreen - Lock Screen Library for Android Application. Library support pin code and fingerprint authorization for API level 23+.
<p align="center"> <img src="https://user-images.githubusercontent.com/1378730/37100456-9225c0c6-2255-11e8-972c-e365ef2659fa.png" alt="alt text" width="200" hspace="40"><img src="https://user-images.githubusercontent.com/1378730/36675641-2c16130a-1b3c-11e8-88ac-32038e5b3540.png" alt="alt text" width="200" hspace="40"><img src="https://user-images.githubusercontent.com/1378730/36675645-2c63823e-1b3c-11e8-8936-6db8c84333f1.png" alt="alt text" width="200" hspace="40"> </p>allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.thealeksandr:PFLockScreen-Android:1.0.0-beta2'
}
Creating lock screen fragment in create mode.
PFLockScreenFragment fragment = new PFLockScreenFragment();
PFFLockScreenConfiguration.Builder builder = new PFFLockScreenConfiguration.Builder(this)
.setMode(PFFLockScreenConfiguration.MODE_CREATE);
fragment.setConfiguration(builder.build());
fragment.setCodeCreateListener(new PFLockScreenFragment.OnPFLockScreenCodeCreateListener() {
@Override
public void onCodeCreated(String encodedCode) {
//TODO: save somewhere;
}
});
//TODO: show fragment;
After user created pin code. The library will encode it using Android Key Store and return an encoded string in PFLockScreenFragment.OnPFLockScreenCodeCreateListener. All you have to do is save encoded string somewhere - database, SharedPreferences, Android Account etc.
Creating lock screen fragment in authorization mode is same as in creation mode, but instead of MODE_CREATE use MODE_AUTH.
PFFLockScreenConfiguration.Builder(this).setMode(PFFLockScreenConfiguration.MODE_AUTH);
PFFLockScreenConfiguration.Builder builder = new PFFLockScreenConfiguration.Builder(this)
.setTitle("Unlock")
.setUseFingerprint(true).
.setMode(PFFLockScreenConfiguration.MODE_AUTH)
.setCodeLength(6)
.setLeftButton("Can't remeber",
new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
setTitle(String) - set custom string on the top of the screen. setUseFingerprint(boolean) - by default fingerprint button will be shown for all device 23+ with a fingerprint sensor. If you don't want use fingerprint at all set false. setMode(PFLockScreenMode) - MODE_CREATE or MODE_AUTH. See details above. setCodeLength(int) - set the length of the pin code. By default, length is 4. Minimum length is 4. setLeftButton(String, View.OnClickListener) - set string for the left button and ClickListener.
boolean isExist = PFFingerprintPinCodeHelper.getInstance().isPinCodeExist();
An encryption key is needed to encode/decode pin code and stored in Android KeyStore.
You need to delete encryption key if you delete/reset pin code.
PFFingerprintPinCodeHelper.getInstance().delete();
You can customize buttons, backgrounds etc. To do that use attributes in your activity theme:
pf_key_button - style object for key buttons (0-9) pf_lock_screen - style object for the background. Use it to set custom background. pf_fingerprint_button - style object for fingerprint button. You can set custom drawable, paddings, etc. pf_delete_button - style object for delete/backspace button. You can set custom drawable, paddings, etc. pf_code_view - style object to customize code view. (The view from the top of the screen). The view itself is set of check boxes. To customize it use a custom selector with checked states.
Examples:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Some of your styles. -->
<item name="pf_key_button">@style/MyLockScreenButtonStyle</item>
<item name="pf_fingerprint_button">@style/MyLockScreenFingerprintButtonStyle</item>
<item name="pf_delete_button">@style/MyLockScreenDeleteButtonStyle</item>
<item name="pf_lock_screen">@style/MyLockScreenStyle</item>
<item name="pf_code_view">@style/MyLockScreenCodeStyle</item>
</style>
<style name="MyLockScreenStyle">
<item name="android:background">@drawable/screen_background</item>
</style>
<style name="MyLockScreenButtonStyle">
<item name="android:textColor">@android:color/white</item>
<item name="android:textSize">18dp</item>
<item name="android:foreground">@drawable/key_foreground</item>
</style>
<style name="MyLockScreenFingerprintButtonStyle">
<item name="android:src">@drawable/fingerprint_icon</item>
</style>
<style name="MyLockScreenDeleteButtonStyle">
<item name="android:src">@drawable/delete_lockscreen</item>
</style>
<style name="MyLockScreenCodeStyle">
<item name="android:button">@drawable/code_selector</item>
</style>
The only important thing you can't change right now is the size of keys. But it's coming.
Feel free to ask questions add issues. If I don't responce in Issue or PR feel free to ping me or send me DM on twitter @thealeksandr