Commit 3a310146 authored by macbook's avatar macbook

人脸识别

parent 4d34c706
......@@ -116,7 +116,7 @@ kapt {
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(dir: '../libs', include: ['*.jar'])
// implementation 'com.android.support:support-v4:28.0.3'
implementation 'androidx.leanback:leanback:1.0.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
......@@ -136,7 +136,6 @@ dependencies {
implementation 'com.aliyun.sdk.android:AliyunPlayer:4.7.0-part'
//阿里云播放器的两个依赖
// implementation(name: 'AliyunPlayer-4.7.0-part', ext: 'aar')
// implementation 'com.alivc.conan:AlivcConan:0.9.5'
......@@ -173,7 +172,6 @@ dependencies {
implementation 'com.github.razerdp:BasePopup:2.2.10'
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.7'
......@@ -246,7 +244,8 @@ dependencies {
// 汉子转拼音 库
implementation 'com.github.promeg:tinypinyin:2.0.3' // TinyPinyin核心包,约80KB
implementation 'com.github.promeg:tinypinyin-lexicons-android-cncity:2.0.3' // 可选,适用于Android的中国地区词典
implementation 'com.github.promeg:tinypinyin-lexicons-android-cncity:2.0.3'
// 可选,适用于Android的中国地区词典
implementation 'io.objectbox:objectbox-android-objectbrowser:2.3.4'
implementation 'io.objectbox:objectbox-kotlin:2.3.4'
......@@ -291,14 +290,15 @@ dependencies {
implementation 'com.github.xiaohaibin:XBanner:androidx_v1.1.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.github.chrisbanes:PhotoView:2.1.3'
implementation 'com.aliyun.dpa:oss-android-sdk:+'
implementation files('libs\\fastjson-1.2.62.jar')
implementation (name:'rpsdk-4.8.3', ext:'aar')
implementation(name: 'rpsdk-4.8.3', ext: 'aar')
// implementation (name:'oss-android-sdk-2.9.2', ext:'aar')
implementation (name:'SecurityGuardSDK-external-release-5.5.28-preInstall', ext:'aar')
implementation (name:'SecurityBodySDK-external-release-5.5.28-preInstall', ext:'aar')
implementation (name:'MiddleTierSDK-external-release-5.5.13874142', ext:'aar')
implementation (name:'windvane', ext:'aar')
implementation(name: 'SecurityGuardSDK-external-release-5.5.28-preInstall', ext: 'aar')
implementation(name: 'SecurityBodySDK-external-release-5.5.28-preInstall', ext: 'aar')
implementation(name: 'MiddleTierSDK-external-release-5.5.13874142', ext: 'aar')
implementation(name: 'windvane', ext: 'aar')
//popupWindow
implementation 'com.github.zyyoona7:EasyPopup:1.1.2'
//tabLayout
......
......@@ -28,6 +28,7 @@ import com.alibaba.security.realidentity.RPResult;
import com.alibaba.security.realidentity.RPVerify;
import com.aliyun.svideo.common.utils.ToastUtils;
import com.beanpodtech.allinone.R;
import com.beanpodtech.allinone.bean.DescribeVerifyBean;
import com.beanpodtech.allinone.bean.User;
import com.beanpodtech.allinone.bean.VerifyTokenBean;
import com.beanpodtech.allinone.http.UrlConfig;
......@@ -51,6 +52,7 @@ import com.zyyoona7.popup.EasyPopup;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
......@@ -76,13 +78,42 @@ public class LoginActivity extends BaseActivity {
public final static String PHONE_PATTERN = "^(1)\\d{10}$";
private EasyPopup agreePopup; //协议弹窗
private EasyPopup agreePopup, mFacePopup; //协议弹窗
private RelativeLayout mainLayout;
private CheckBox checkBox;
private TextView agreeText;
private Boolean booAgree = false; //是否已经同意协议
private LoadingView loadingView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
BoxUtil.hideBottomUIMenu(this);
}
@Override
public int bindLayout() {
return R.layout.activity_login;
}
@Override
public void initView(View view) {
mainLayout = findViewById(R.id.rl_login_main); //根布局
btn_login = findViewById(R.id.LoginButton); //登录按钮
checkBox = findViewById(R.id.cb_login); //checkBox
agreeText = findViewById(R.id.tv_user_agree); //查看用户协议
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
booAgree = isChecked;
checkBox.setChecked(isChecked);
}
});
loadingView = new LoadingView(LoginActivity.this, R.style.CustomDialog);
loadingView.setTitle(getResources().getString(R.string.waitloading));
initPop(); //初始化协议弹窗
initFacePop();
}
/**
* 正则表达式
......@@ -127,14 +158,12 @@ public class LoginActivity extends BaseActivity {
Login();
break;
case R.id.tv_user_agree: //用户协议
//显示弹窗
agreePopup.dismiss();
agreePopup.showAtLocation(getWindow().getDecorView(), Gravity.CENTER, 0, 0);
break;
case R.id.rl_login_main:
SoftInputUtil.hideSoftInput(this);
break;
......@@ -177,7 +206,7 @@ public class LoginActivity extends BaseActivity {
startActivity(new Intent(LoginActivity.this, HomeActivity.class));
finish();
} else {
getVerifyToken();
mFacePopup.showAtLocation(getWindow().getDecorView(), Gravity.CENTER, 0, 0);
}
} else if (body.getcode() == -1) {
......@@ -205,7 +234,9 @@ public class LoginActivity extends BaseActivity {
*/
private void getVerifyToken() {
loadingView.show();
RetrofitClient.getInstance().getApi().getVerifyToken()
Map<String, Object> mMap = new HashMap<>();
mMap.put("type", "1");
RetrofitClient.getInstance().getApi().getVerifyToken(mMap)
.compose(RxScheduler.Obs_io_main())
.subscribe(new BaseObserver<VerifyTokenBean>() {
@Override
......@@ -222,54 +253,54 @@ public class LoginActivity extends BaseActivity {
});
}
/**
* 调用人脸识别进行录入
* @param token
*/
private void startFace(String token) {
RPVerify.startByNative(LoginActivity.this, token, new RPEventListener() {
@Override
public void onFinish(RPResult auditResult, String code, String msg) {
if (auditResult == RPResult.AUDIT_PASS) {
// 认证通过。建议接入方调用实人认证服务端接口DescribeVerifyResult来获取最终的认证状态,并以此为准进行业务上的判断和处理。
// do something
getDescribeVerifyResult();
} else if (auditResult == RPResult.AUDIT_FAIL) {
// 认证不通过。建议接入方调用实人认证服务端接口DescribeVerifyResult来获取最终的认证状态,并以此为准进行业务上的判断和处理。
// do something
showToast("认证不通过,请重新认证");
} else if (auditResult == RPResult.AUDIT_NOT) {
// 未认证,具体原因可通过code来区分(code取值参见错误码说明),通常是用户主动退出或者姓名身份证号实名校验不匹配等原因,导致未完成认证流程。
// do something
showToast("未认证");
}
}
});
}
/**
* 调用DescribeVerifyResult查询实人认证结果。
*/
private void getDescribeVerifyResult() {
loadingView.show();
Map<String, Object> mMap = new HashMap<>();
mMap.put("type", "1");
RetrofitClient.getInstance().getApi().getDescribeVerifyResult(mMap)
.compose(RxScheduler.Obs_io_main())
.subscribe(new BaseObserver<DescribeVerifyBean>() {
@Override
public int bindLayout() {
return R.layout.activity_login;
public void onSuccess(DescribeVerifyBean data) {
showToast("录入成功");
loadingView.dismiss();
startActivity(new Intent(LoginActivity.this, HomeActivity.class));
finish();
}
@Override
public void initView(View view) {
mainLayout = findViewById(R.id.rl_login_main); //根布局
btn_login = findViewById(R.id.LoginButton); //登录按钮
checkBox = findViewById(R.id.cb_login); //checkBox
agreeText = findViewById(R.id.tv_user_agree); //查看用户协议
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
booAgree = isChecked;
checkBox.setChecked(isChecked);
public void onFailure(Throwable e, String errorMsg) {
loadingView.dismiss();
showToast(errorMsg);
}
});
loadingView = new LoadingView(LoginActivity.this, R.style.CustomDialog);
loadingView.setTitle(getResources().getString(R.string.waitloading));
initPop(); //初始化协议弹窗
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
BoxUtil.hideBottomUIMenu(this);
}
private void initPop() { //初始化协议弹窗
agreePopup = EasyPopup.create()
......@@ -295,6 +326,26 @@ public class LoginActivity extends BaseActivity {
}
private void initFacePop() { //初始化协议弹窗
mFacePopup = EasyPopup.create()
.setContext(this)
.setContentView(R.layout.pop_face)
.setWidth(WindowManager.LayoutParams.WRAP_CONTENT)
.setHeight(WindowManager.LayoutParams.WRAP_CONTENT)
.setOutsideTouchable(true)
.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
.setBackgroundDimEnable(true)
.setDimValue(0.3f)
.setDimColor(Color.BLACK)
.apply();
TextView agreeBtn = mFacePopup.findViewById(R.id.tv_face_btn);
agreeBtn.setOnClickListener(v -> {
getVerifyToken();
});
}
@Override
public void initListener() {
btn_login.setOnClickListener(this);
......
......@@ -8,6 +8,7 @@ import android.util.Log;
import androidx.multidex.MultiDex;
import com.alibaba.security.realidentity.RPConfig;
import com.alibaba.security.realidentity.RPVerify;
import com.aliyun.private_service.PrivateService;
import com.beanpodtech.allinone.BuildConfig;
......@@ -85,6 +86,9 @@ public class EduApplication extends Application {
}, 10000);*/
//初始化阿里人脸识别
RPVerify.init(mContext);
RPConfig.Builder configBuilder = new RPConfig.Builder()
.setSkinInAssets(true);// 是否是内置皮肤。
configBuilder.setSkinPath("");//// 设置皮肤路径。
}
......
package com.beanpodtech.allinone.bean;
import com.google.gson.annotations.SerializedName;
/**
* @Description: java类作用描述
* @Author: 大魔王老杨
* @Date: 4/28/21 3:59 PM
*/
public class DescribeVerifyBean {
@SerializedName("VerifyStatus")
private String verifyStatus;
@SerializedName("Material")
private MaterialBean material;
@SerializedName("AuthorityComparisonScore")
private String authorityComparisonScore;
public String getVerifyStatus() {
return verifyStatus;
}
public void setVerifyStatus(String verifyStatus) {
this.verifyStatus = verifyStatus;
}
public MaterialBean getMaterial() {
return material;
}
public void setMaterial(MaterialBean material) {
this.material = material;
}
public String getAuthorityComparisonScore() {
return authorityComparisonScore;
}
public void setAuthorityComparisonScore(String authorityComparisonScore) {
this.authorityComparisonScore = authorityComparisonScore;
}
public static class MaterialBean {
@SerializedName("FaceImageUrl")
private String faceImageUrl;
@SerializedName("FaceMask")
private String faceMask;
@SerializedName("FaceQuality")
private String faceQuality;
@SerializedName("IdCardName")
private String idCardName;
@SerializedName("IdCardNumber")
private String idCardNumber;
@SerializedName("IdCardInfo")
private IdCardInfoBean idCardInfo;
public String getFaceImageUrl() {
return faceImageUrl;
}
public void setFaceImageUrl(String faceImageUrl) {
this.faceImageUrl = faceImageUrl;
}
public String getFaceMask() {
return faceMask;
}
public void setFaceMask(String faceMask) {
this.faceMask = faceMask;
}
public String getFaceQuality() {
return faceQuality;
}
public void setFaceQuality(String faceQuality) {
this.faceQuality = faceQuality;
}
public String getIdCardName() {
return idCardName;
}
public void setIdCardName(String idCardName) {
this.idCardName = idCardName;
}
public String getIdCardNumber() {
return idCardNumber;
}
public void setIdCardNumber(String idCardNumber) {
this.idCardNumber = idCardNumber;
}
public IdCardInfoBean getIdCardInfo() {
return idCardInfo;
}
public void setIdCardInfo(IdCardInfoBean idCardInfo) {
this.idCardInfo = idCardInfo;
}
public static class IdCardInfoBean {
@SerializedName("FrontImageUrl")
private String frontImageUrl;
@SerializedName("BackImageUrl")
private String backImageUrl;
@SerializedName("Name")
private String name;
@SerializedName("Number")
private String number;
@SerializedName("Birth")
private String birth;
@SerializedName("Address")
private String address;
@SerializedName("StartDate")
private String startDate;
@SerializedName("EndDate")
private String endDate;
@SerializedName("Authority")
private String authority;
public String getFrontImageUrl() {
return frontImageUrl;
}
public void setFrontImageUrl(String frontImageUrl) {
this.frontImageUrl = frontImageUrl;
}
public String getBackImageUrl() {
return backImageUrl;
}
public void setBackImageUrl(String backImageUrl) {
this.backImageUrl = backImageUrl;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getBirth() {
return birth;
}
public void setBirth(String birth) {
this.birth = birth;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getStartDate() {
return startDate;
}
public void setStartDate(String startDate) {
this.startDate = startDate;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
public String getAuthority() {
return authority;
}
public void setAuthority(String authority) {
this.authority = authority;
}
}
}
}
......@@ -2,6 +2,7 @@ package com.beanpodtech.allinone.retrofit;
import com.beanpodtech.allinone.bean.BaseResponse;
import com.beanpodtech.allinone.bean.DescribeVerifyBean;
import com.beanpodtech.allinone.bean.VerifyTokenBean;
......@@ -19,13 +20,13 @@ import retrofit2.http.Path;
* @Date: 4/12/21 5:35 PM
*/
public interface APIService {
//
// @POST("api/portal-management-service/newsInterface/getAppNotificationList")
// Observable<BaseResponse<MessageBean>> getMessage(@Body Map<String, Object> map);
//
@GET("faceReco/DescribeVerifyToken")
Observable<BaseResponse<VerifyTokenBean>> getVerifyToken();
@POST("faceReco/DescribeVerifyResult")
Observable<BaseResponse<DescribeVerifyBean>> getDescribeVerifyResult(@Body Map<String, Object> map);
@POST("faceReco/DescribeVerifyToken")
Observable<BaseResponse<VerifyTokenBean>> getVerifyToken(@Body Map<String, Object> map);
@POST("faceReco/updateFaceUrl")
Observable<BaseResponse<VerifyTokenBean>> getLogin(@Body Map<String, Object> map);
Observable<BaseResponse<VerifyTokenBean>> updateFaceUrl(@Body Map<String, Object> map);
}
No preview for this file type
No preview for this file type
File mode changed from 100644 to 100755
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="@drawable/bg_pop_agree"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_marginTop="20dp"
android:text="温馨提示"
android:textSize="18sp"
android:textColor="#333333"
android:textStyle="bold"
android:gravity="center"
android:includeFontPadding="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_gravity="center_horizontal"
android:orientation="vertical"
android:layout_marginTop="33px"
android:layout_marginLeft="30px"
android:layout_marginRight="23px"
android:layout_marginBottom="@dimen/x34"
android:layout_width="200dp"
android:layout_height="50dp">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_weight="1"
android:paddingTop="33px"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tv_agree_content"
android:textColor="#666666"
android:textSize="14sp"
android:gravity="center"
android:lineHeight="27px"
android:layout_marginLeft="@dimen/x30"
android:layout_marginRight="@dimen/x23"
android:text="请先进行人脸识别录入!"
android:includeFontPadding="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
<TextView
android:id="@+id/tv_face_btn"
android:background="@drawable/login_btn_bg"
android:layout_gravity="center_horizontal"
android:text="确定"
android:textColor="@color/white"
android:textSize="24px"
android:layout_marginBottom="@dimen/x30"
android:textStyle="bold"
android:gravity="center"
android:layout_marginTop="@dimen/x20"
android:layout_width="247px"
android:layout_height="67px"/>
</LinearLayout>
\ No newline at end of file
......@@ -19,6 +19,9 @@ buildscript {
maven {
url "http://maven.aliyun.com/nexus/content/groups/public/"
}
flatDir {
dirs '../libs'
}
}
apply from: 'thirdparty-lib/config.gradle'
dependencies {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment