Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
yangfeng1994 committed Feb 26, 2020
2 parents d305dfc + 0fa1944 commit e81541c
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 49 deletions.
61 changes: 35 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# Android-FingerprintVerify

[![](https://jitpack.io/v/yangfeng1994/Android-FingerprintVerify.svg)](https://jitpack.io/#yangfeng1994/Android-FingerprintVerify)

#### 项目介绍

### 一个用于Android手机指纹验证与密码锁验证的项目,使用建造者模式,创建指纹密钥的实例
,调用弹出验证框进行验证。
### 一个用于Android手机指纹验证与密码锁验证的项目,使用建造者模式,创建指纹密钥的实例或者调用手机密码进行验证。

项目支持 androidx 或者 support

本项目没有引入任何第三方库,不会对您的项目有任何的代码侵入

# 项目截图

![image](https://github.com/yangfeng1994/Android-FingerprintVerify/blob/dev/app/pic/finger_gif.gif)
<img src="/app/pic/finger_pic_screen.jpg" alt="图-2:finger_pic_screen" width="380px"></img>

#### 导入方法

Expand Down Expand Up @@ -91,18 +100,8 @@


# 2. 可以进行手机自带密码锁的验证
#### 初始化密码验证
####部分方法介绍
```
codedLockAuthenticatedCharacter = CodedLockAuthenticatedStepBuilder
.newBuilder()
.setActivity(MainActivity.this)
.getKeyguardManager()
.setKeystoreAlias("my_key")
.setUserAuthenticationValidityDurationSeconds(3)
.getKeyStore()
.setAuthenticationScreenCallBack(MainActivity.this)
.build();
1. setActivity()设置activity 上下文对象,用来获取密码管理类
2. setKeystoreAlias("") 添加你应用的密码库的别名
Expand All @@ -127,11 +126,28 @@ codedLockAuthenticatedCharacter = CodedLockAuthenticatedStepBuilder
```
#### 初始化密码验证
```
codedLockAuthenticatedCharacter = CodedLockAuthenticatedStepBuilder
.newBuilder()
.setActivity(MainActivity.this)
.getKeyguardManager()
.setKeystoreAlias("my_key")//可随便填写
.setUserAuthenticationValidityDurationSeconds(3)
.getKeyStore()
.setAuthenticationScreenCallBack(MainActivity.this)
.build();
```
####跳到密码验证界面,去验证密码
```
if (codedLockAuthenticatedCharacter.isKeyguardSecure()) {
codedLockAuthenticatedCharacter.onValidate();
}
}else{
Toast.makeText(MainActivity.this, "没有设置密码锁", Toast.LENGTH_SHORT).show();
}
```
Expand Down Expand Up @@ -172,18 +188,11 @@ codedLockAuthenticatedCharacter = CodedLockAuthenticatedStepBuilder
Toast.makeText(this, "密码验证取消", Toast.LENGTH_SHORT).show();
}
```
###如有问题 请联系微信 yf2921
###项目如需混淆
```
-keep class com.yf.verify.** {*;}

```
###如有问题 请联系微信 yf2921
10 changes: 6 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,22 @@ android {
}
signingConfigs {
config {
keyAlias 'finger'
keyPassword '123456'
keyAlias 'qwer'
keyPassword 'qwer123'
storeFile file('finger_print_verify.jks')
storePassword '123456'
storePassword 'qwer123'
}
}

buildTypes {
release {
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}

debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
Expand Down
Binary file modified app/finger_print_verify.jks
Binary file not shown.
Binary file added app/pic/finger_gif.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/pic/finger_pic_screen.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile



-keep class com.yf.verify.** {*;}
Binary file added app/release/app-release.apk
Binary file not shown.
8 changes: 6 additions & 2 deletions fingerprint/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ android {
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
consumerProguardFiles 'proguard-rules.pro'
}
debug {
minifyEnabled false
consumerProguardFiles 'proguard-rules.pro'
}
}
lintOptions {
Expand All @@ -31,7 +35,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

compileOnly 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
}
repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yf.verify.fingerprint.factory;
package com.yf.verify.base;

public interface BaseBiometricPrompt {
void show();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package com.yf.verify.fingerprint.factory;
package com.yf.verify.fingerprint;

import android.support.v4.app.FragmentActivity;
import android.support.v4.hardware.fingerprint.FingerprintManagerCompat;

import com.yf.verify.base.BaseBiometricPrompt;
import com.yf.verify.callback.FingerprintAuthenticatedCallback;
import com.yf.verify.fingerprint.FingerprintBottomDialogFragment;

import javax.crypto.Cipher;

public class BaseBiometricPrompt28 implements BaseBiometricPrompt {
public class BiometricPrompt28 implements BaseBiometricPrompt {
private FragmentActivity activity;
private Cipher cipher;
private FingerprintManagerCompat mFingerprintManager;
private FingerprintAuthenticatedCallback fingerprintCallback;

public BaseBiometricPrompt28(FragmentActivity activity, Cipher cipher, FingerprintManagerCompat mFingerprintManager, FingerprintAuthenticatedCallback fingerprintCallback) {
public BiometricPrompt28(FragmentActivity activity, Cipher cipher, FingerprintManagerCompat mFingerprintManager, FingerprintAuthenticatedCallback fingerprintCallback) {
this.activity = activity;
this.cipher = cipher;
this.mFingerprintManager = mFingerprintManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yf.verify.fingerprint.factory;
package com.yf.verify.fingerprint;

import android.annotation.TargetApi;
import android.content.DialogInterface;
Expand All @@ -7,21 +7,23 @@
import android.support.v4.app.FragmentActivity;
import android.os.CancellationSignal;

import com.yf.verify.base.BaseBiometricPrompt;
import com.yf.verify.callback.FingerprintAuthenticatedCallback;

@TargetApi(Build.VERSION_CODES.P)
public class BaseBiometricPrompt29 extends BiometricPrompt.AuthenticationCallback implements BaseBiometricPrompt, DialogInterface.OnClickListener {
public class BiometricPrompt29 extends BiometricPrompt.AuthenticationCallback implements BaseBiometricPrompt, DialogInterface.OnClickListener {
private CancellationSignal mCancellationSignal;
private BiometricPrompt mBiometricPrompt;
private FragmentActivity activity;
private FingerprintAuthenticatedCallback callback;

public BaseBiometricPrompt29(FragmentActivity activity, final FingerprintAuthenticatedCallback callback) {
public BiometricPrompt29(FragmentActivity activity, final FingerprintAuthenticatedCallback callback) {
this.activity = activity;
this.callback = callback;
mCancellationSignal = new CancellationSignal();
mBiometricPrompt = new BiometricPrompt.Builder(activity)
.setNegativeButton("取消", activity.getMainExecutor(), this).setTitle("指纹验证")
.setNegativeButton("取消", activity.getMainExecutor(), this)
.setTitle("指纹验证")
.build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.yf.verify.fingerprint.factory;
package com.yf.verify.fingerprint;

import android.os.Build;
import android.support.v4.app.FragmentActivity;
import android.support.v4.hardware.fingerprint.FingerprintManagerCompat;

import com.yf.verify.base.BaseBiometricPrompt;
import com.yf.verify.callback.FingerprintAuthenticatedCallback;

import javax.crypto.Cipher;
Expand All @@ -25,9 +26,9 @@ public BiometricPromptFactory(FragmentActivity activity, Cipher cipher, Fingerpr

public void execute(int version) {
if (version >= Build.VERSION_CODES.P) {
prompt = new BaseBiometricPrompt29(activity, fingerprintCallback);
prompt = new BiometricPrompt29(activity, fingerprintCallback);
} else if (version >= Build.VERSION_CODES.M) {
prompt = new BaseBiometricPrompt28(activity, cipher, mFingerprintManager, fingerprintCallback);
prompt = new BiometricPrompt28(activity, cipher, mFingerprintManager, fingerprintCallback);
} else {
if (null != fingerprintCallback) {
fingerprintCallback.onNonsupportFingerprint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import com.yf.verify.callback.FingerprintAuthenticatedCallback;
import com.yf.verify.callback.FingerprintBaseCharacter;
import com.yf.verify.fingerprint.factory.BiometricPromptFactory;

import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
Expand Down
6 changes: 3 additions & 3 deletions fingerprint/src/main/res/anim/bottom_dialog_in.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="300"
android:duration="280"
android:fillAfter="true"
android:fromXDelta="0"
android:fromYDelta="100%"
Expand All @@ -10,7 +10,7 @@

</translate>
<alpha
android:duration="300"
android:duration="280"
android:fromAlpha="0.0"
android:toAlpha="1.0"/>
android:toAlpha="1.0" />
</set>
4 changes: 2 additions & 2 deletions fingerprint/src/main/res/anim/bottom_dialog_out.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="300"
android:duration="280"
android:fillAfter="true"
android:fromXDelta="0"
android:fromYDelta="0"
Expand All @@ -10,7 +10,7 @@

</translate>
<alpha
android:duration="300"
android:duration="280"
android:fromAlpha="1.0"
android:toAlpha="0.0" />
</set>

0 comments on commit e81541c

Please sign in to comment.