Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

## Min SDK Version - 15

PFLockScreen - Lock Screen Library for Android Application. Library support **pin code** and **fingerprint** authorization for API level 23+.
PFLockScreen - Lock Screen Library for Android Application. Library support **pin code** and **biometric** 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">
Expand Down Expand Up @@ -72,7 +72,7 @@ PFFLockScreenConfiguration.Builder(this).setMode(PFFLockScreenConfiguration.MODE
```java
PFFLockScreenConfiguration.Builder builder = new PFFLockScreenConfiguration.Builder(this)
.setTitle("Unlock")
.setUseFingerprint(true).
.setUseBiometric(true).
.setMode(PFFLockScreenConfiguration.MODE_AUTH)
.setCodeLength(6)
.setLeftButton("Can't remeber",
Expand All @@ -87,7 +87,7 @@ PFFLockScreenConfiguration.Builder builder = new PFFLockScreenConfiguration.Buil


*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*.
*setUseBiometric(boolean)* - by default fingerprint(biometric authentication) button will be shown for all device 23+ with a fingerprint sensor and/or face recognition. If you don't want use biometric authentication 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.
Expand Down
12 changes: 6 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.2-alpha01'
androidTestImplementation 'androidx.test:runner:1.1.2-alpha01'
androidTestImplementation 'androidx.test:rules:1.1.2-alpha01'
implementation 'androidx.appcompat:appcompat:1.3.0-alpha01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta6'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-rc01'
androidTestImplementation 'androidx.test:runner:1.3.0-rc01'
androidTestImplementation 'androidx.test:rules:1.3.0-rc01'
implementation project(':pflockscreen')
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ public void onNewCodeValidationFailed() {

@Override
public void onCodeInputSuccessful() {
Toast.makeText(MainActivity.this, "Code successfull", Toast.LENGTH_SHORT).show();
Toast.makeText(MainActivity.this, "Code successful", Toast.LENGTH_SHORT).show();
showMainFragment();
}

@Override
public void onFingerprintSuccessful() {
Toast.makeText(MainActivity.this, "Fingerprint successfull", Toast.LENGTH_SHORT).show();
public void onBiometricAuthSuccessful() {
Toast.makeText(MainActivity.this, "Biometric authentication successful", Toast.LENGTH_SHORT).show();
showMainFragment();
}

Expand All @@ -58,8 +58,8 @@ public void onPinLoginFailed() {
}

@Override
public void onFingerprintLoginFailed() {
Toast.makeText(MainActivity.this, "Fingerprint failed", Toast.LENGTH_SHORT).show();
public void onBiometricAuthLoginFailed() {
Toast.makeText(MainActivity.this, "Biometric authentication failed", Toast.LENGTH_SHORT).show();
}
};

Expand Down Expand Up @@ -89,7 +89,8 @@ private void showLockScreenFragment(boolean isPinExist) {
.setLeftButton("Can't remeber")
.setNewCodeValidation(true)
.setNewCodeValidationTitle("Please input code again")
.setUseFingerprint(true);
.setAutoShowBiometric(true)
.setUseBiometric(true);
final PFLockScreenFragment fragment = new PFLockScreenFragment();

fragment.setOnLeftButtonClickListener(new View.OnClickListener() {
Expand Down
2 changes: 2 additions & 0 deletions pflockscreen/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ dependencies {

implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'

implementation "androidx.biometric:biometric:1.0.1"

//Livecycles & ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ public class PFFLockScreenConfiguration implements Serializable {

private String mLeftButton = "";
private String mNextButton = "";
private boolean mUseFingerprint = false;
private boolean mAutoShowFingerprint = false;
private boolean mUseBiometric = false;
private boolean mAutoShowBiometric = false;
private int mBiometricBackground = -1;
private String mTitle = "";
private int mMode = MODE_AUTH;
private int mCodeLength = 4;
Expand All @@ -29,8 +30,9 @@ public class PFFLockScreenConfiguration implements Serializable {
private PFFLockScreenConfiguration(Builder builder) {
mLeftButton = builder.mLeftButton;
mNextButton = builder.mNextButton;
mUseFingerprint = builder.mUseFingerprint;
mAutoShowFingerprint = builder.mAutoShowFingerprint;
mUseBiometric = builder.mUseBiometric;
mAutoShowBiometric = builder.mAutoShowBiometric;
mBiometricBackground = builder.mBiometricBackground;
mTitle = builder.mTitle;
mMode = builder.mMode;
mCodeLength = builder.mCodeLength;
Expand All @@ -49,12 +51,16 @@ public String getNextButton() {
return mNextButton;
}

public boolean isUseFingerprint() {
return mUseFingerprint;
public boolean isUseBiometric() {
return mUseBiometric;
}

public boolean isAutoShowFingerprint() {
return mAutoShowFingerprint;
public boolean isAutoShowBiometric() {
return mAutoShowBiometric;
}

public int getBiometricBackground() {
return mBiometricBackground;
}

public String getTitle() {
Expand Down Expand Up @@ -94,8 +100,9 @@ public static class Builder {

private String mLeftButton = "";
private String mNextButton = "";
private boolean mUseFingerprint = false;
private boolean mAutoShowFingerprint = false;
private boolean mUseBiometric = false;
private boolean mAutoShowBiometric = false;
private int mBiometricBackground = -1;
private String mTitle = "";
private int mMode = 0;
private int mCodeLength = 4;
Expand Down Expand Up @@ -125,13 +132,18 @@ public Builder setNextButton(String nextButton) {
return this;
}

public Builder setUseFingerprint(boolean useFingerprint) {
mUseFingerprint = useFingerprint;
public Builder setUseBiometric(boolean useBiometric) {
mUseBiometric = useBiometric;
return this;
}

public Builder setAutoShowBiometric(boolean autoShowBiometric) {
mAutoShowBiometric = autoShowBiometric;
return this;
}

public Builder setAutoShowFingerprint(boolean autoShowFingerprint) {
mAutoShowFingerprint = autoShowFingerprint;
public Builder setBiometricBackground(int biometricBackground) {
mBiometricBackground = biometricBackground;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.beautycoder.pflockscreen.fragments;

import android.content.Context;
import android.content.res.Resources;

import androidx.biometric.BiometricManager;
import androidx.biometric.BiometricPrompt;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;

import com.beautycoder.pflockscreen.R;

import java.util.concurrent.Executor;

public class BiometricUIStarter {
private final BiometricManager biometricManager;
private final BiometricPrompt biometricPrompt;
private String title = "Biometric Authentication";
private String description;
private boolean confirmationRequired;
private String usePin;

public BiometricUIStarter(BiometricManager bioManager, Context context, Fragment fragment, BiometricPrompt.AuthenticationCallback callback) {
biometricManager = bioManager;
usePin = context.getResources().getString(R.string.use_pin_pf);
biometricPrompt = instanceOfBiometricPrompt(context, fragment, callback);
}

private BiometricPrompt instanceOfBiometricPrompt(Context context, Fragment fragment, BiometricPrompt.AuthenticationCallback callback) {
Executor executor = ContextCompat.getMainExecutor(context);
return new BiometricPrompt(fragment, executor ,callback);
}

public boolean isBiometricAuthAvailable() {
return biometricManager.canAuthenticate() == BiometricManager.BIOMETRIC_SUCCESS;
}

public boolean isBiometricAuthNotSet() {
return biometricManager.canAuthenticate() == BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED;
}

private BiometricPrompt.PromptInfo getPromptInfo() {
return new BiometricPrompt.PromptInfo.Builder()
.setTitle(title)
.setDescription(description)
.setDeviceCredentialAllowed(false)
.setNegativeButtonText(usePin)
.setConfirmationRequired(confirmationRequired)
.build();
}

public void startUI() {
biometricPrompt.authenticate(getPromptInfo());
}

public void setTitle(String title) {
this.title = title;
}

public void setDescription(String description) {
this.description = description;
}

public void setConfirmationRequired(boolean confirmationRequired) {
this.confirmationRequired = confirmationRequired;
}
}

This file was deleted.

Loading