mirror of
https://gitee.com/willfree/min-vpn-client_v2.git
synced 2026-06-06 10:19:32 +08:00
加入打开APP时进行指纹识别的步骤
This commit is contained in:
@@ -9,7 +9,9 @@ package com.pkusz.min_vpn_client.activity.welcome;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.pkusz.min_vpn_client.R;
|
||||
@@ -23,6 +25,7 @@ import cn.qjm253.quick_android_base.GlideApp;
|
||||
import cn.qjm253.quick_android_base.QuickAndroid;
|
||||
import cn.qjm253.quick_android_base.extensions.ContextExtensionKt;
|
||||
import cn.qjm253.quick_android_base.util.FileUtils;
|
||||
import co.infinum.goldfinger.Goldfinger;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.plugins.RxJavaPlugins;
|
||||
@@ -54,10 +57,48 @@ public class WelcomeActivity extends MINVpnBaseActivity<WelcomeActivityPresenter
|
||||
}
|
||||
|
||||
public void fingerprintAuthenticate(){
|
||||
System.out.println("指纹验证 ing...");
|
||||
// todo: 指纹验证
|
||||
System.out.println("指纹验证 success");
|
||||
initView();
|
||||
Goldfinger goldfinger = new Goldfinger.Builder(getApplicationContext()).build();
|
||||
if(!goldfinger.hasFingerprintHardware()){
|
||||
// 不支持指纹的手机直接进入到登录界面
|
||||
initView();
|
||||
return;
|
||||
}
|
||||
if(!goldfinger.hasEnrolledFingerprint()){
|
||||
// 支持指纹但并未录入指纹信息的手机,提示用户录入指纹
|
||||
Toast.makeText(getApplicationContext(),
|
||||
"请至少在手机设置中注册一个指纹",Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
// 设置参数
|
||||
Goldfinger.PromptParams params = new Goldfinger.PromptParams.Builder(this)
|
||||
.title("请验证指纹").negativeButtonText("取消")
|
||||
.description("把手指放在指纹识别区").build();
|
||||
// 设置指纹验证成功及失败时分别要执行的动作
|
||||
goldfinger.authenticate(params, new Goldfinger.Callback() {
|
||||
@Override
|
||||
public void onResult(@NonNull @NotNull Goldfinger.Result result) {
|
||||
if(result.type().equals(Goldfinger.Type.SUCCESS)){
|
||||
System.out.println("指纹验证成功");
|
||||
initView();
|
||||
}else if(result.type().equals(Goldfinger.Type.ERROR)){
|
||||
Toast.makeText(getApplicationContext(),
|
||||
"指纹验证失败",Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
System.out.println("指纹验证失败,原因: "+result.reason().toString());
|
||||
}else if(result.type().equals(Goldfinger.Type.INFO)){
|
||||
System.out.println("指纹验证传回类型为INFO,原因: "+result.reason().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull @NotNull Exception e) {
|
||||
Toast.makeText(getApplicationContext(),
|
||||
"指纹验证失败",Toast.LENGTH_SHORT).show();
|
||||
System.out.println("指纹验证失败-onError,原因: "+e.getMessage());
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initView(){
|
||||
|
||||
Reference in New Issue
Block a user