Просмотр исходного кода

手机号,姓名,身份证隐藏显示
删除身份真照片,访客登记人脸照片
身份真和手机号输入长度判断

ifengouy 2 лет назад
Родитель
Сommit
64692c7995

+ 1 - 1
app/src/main/java/com/sunwin/visitorapp/activity/IdcardRegActivity.java

@@ -118,7 +118,7 @@ public class IdcardRegActivity extends BaseActivity implements View.OnClickListe
     }
 
     @Override
-    public void onIdNumRead(String idNum) {
+    public void onIdNumRead(String idNum, String mAuthentticaImagePath) {
         LogUtil.e(TAG, "idNum = " + idNum);
         //读取身份证后显示人脸扫描框
         runOnUiThread(new Runnable() {

+ 4 - 0
app/src/main/java/com/sunwin/visitorapp/activity/VisitInputActivity.java

@@ -55,6 +55,10 @@ public class VisitInputActivity extends BaseActivity implements View.OnClickList
             ToastUtils.showToast("请输入身份证");
             return;
         }
+        if (idNum.length()!= 18) {
+            ToastUtils.showToast("身份证号长度错误");
+            return;
+        }
         OpenDoorByFaceNetResultInfo info = new OpenDoorByFaceNetResultInfo();
         info.setIdNum(idNum);
         info.setPerson_name(name);

+ 13 - 8
app/src/main/java/com/sunwin/visitorapp/activity/VisitSignActivity.java

@@ -1,6 +1,5 @@
 package com.sunwin.visitorapp.activity;
 
-import android.content.DialogInterface;
 import android.content.Intent;
 import android.os.Bundle;
 import android.text.TextUtils;
@@ -8,11 +7,8 @@ import android.view.View;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
-import androidx.appcompat.app.AlertDialog;
-
 import com.sunwin.visitorapp.BaseActivity;
 import com.sunwin.visitorapp.BaseApplication;
-import com.sunwin.visitorapp.LoginActivity;
 import com.sunwin.visitorapp.R;
 import com.sunwin.visitorapp.db.DatabaseManager;
 import com.sunwin.visitorapp.db.UserInfoModel;
@@ -30,7 +26,6 @@ import com.sunwin.visitorapp.utils.BitmapUtils;
 import com.sunwin.visitorapp.utils.Constant;
 import com.sunwin.visitorapp.utils.FileUtil;
 import com.sunwin.visitorapp.utils.LogUtil;
-import com.sunwin.visitorapp.utils.SharePrefenceUtils;
 import com.sunwin.visitorapp.utils.TimeUtils;
 import com.sunwin.visitorapp.utils.ToastUtils;
 import com.sunwin.visitorapp.view.FaceDetecterView;
@@ -98,8 +93,9 @@ public class VisitSignActivity extends BaseActivity implements IdCardReadCallbac
      * 读取身份证回调
      */
     @Override
-    public void onIdNumRead(String idNum) {
+    public void onIdNumRead(String idNum, String idCardPath) {
         LogUtil.e(TAG, "idNum = " + idNum);
+        this.idCardPath = idCardPath;
         updataUserInfoByIdNum(idNum, 5);
     }
 
@@ -129,6 +125,10 @@ public class VisitSignActivity extends BaseActivity implements IdCardReadCallbac
             requsetModel.setImgCode(BitmapUtils.scaleBitmap(currentFace));
             requsetModel.setImgUrl(currentFace);
             requsetModel.setThreshold(similarity + "");
+        } else {
+            requsetModel.setImgCode(BitmapUtils.scaleBitmap(idCardPath));
+            requsetModel.setImgUrl(idCardPath);
+            requsetModel.setThreshold(similarity + "");
         }
 
 
@@ -150,7 +150,11 @@ public class VisitSignActivity extends BaseActivity implements IdCardReadCallbac
                         //删除图片
                         if (!TextUtils.isEmpty(currentFace)) {
                             boolean b = FileUtil.deleteFile(currentFace);
-                            LogUtil.e(TAG, "delete File=" + b);
+                            LogUtil.e(TAG, "delete currentFace=" + b);
+                        }
+                        if (!TextUtils.isEmpty(idCardPath)) {
+                            boolean b = FileUtil.deleteFile(idCardPath);
+                            LogUtil.e(TAG, "delete idCardPath=" + b);
                         }
                         ToastUtils.showToast("保存成功");
                     } else {
@@ -188,6 +192,7 @@ public class VisitSignActivity extends BaseActivity implements IdCardReadCallbac
     }
 
     private String currentFace;
+    private String idCardPath;
     private double similarity;
 
     @Override
@@ -197,7 +202,7 @@ public class VisitSignActivity extends BaseActivity implements IdCardReadCallbac
         String idNum = openDoorByFaceNetResultInfo.getIdNum();
         currentFace = openDoorByFaceNetResultInfo.getCurrentFace();
         similarity = openDoorByFaceNetResultInfo.getSimilarity();
-        similarity =  AppUtil.retains3decimal(similarity);
+        similarity = AppUtil.retains3decimal(similarity);
         updataUserInfoByIdNum(idNum, 1);
     }
 

+ 6 - 2
app/src/main/java/com/sunwin/visitorapp/activity/VisitorRegisterAc.java

@@ -34,6 +34,7 @@ import com.sunwin.visitorapp.utils.AppManager;
 import com.sunwin.visitorapp.utils.AppUtil;
 import com.sunwin.visitorapp.utils.BitmapUtils;
 import com.sunwin.visitorapp.utils.Constant;
+import com.sunwin.visitorapp.utils.FileUtil;
 import com.sunwin.visitorapp.utils.LogUtil;
 import com.sunwin.visitorapp.utils.TimeUtils;
 import com.sunwin.visitorapp.utils.ToastUtils;
@@ -212,7 +213,10 @@ public class VisitorRegisterAc extends BaseActivity implements View.OnClickListe
             ToastUtils.showToast("请输入手机号码");
             return;
         }
-
+        if (phone.length()!= 11) {
+            ToastUtils.showToast("手机号号长度错误");
+            return;
+        }
 
         loadingDialog.showLoadingDialog("");
         UserInfoModel infoModel = new UserInfoModel();
@@ -317,7 +321,7 @@ public class VisitorRegisterAc extends BaseActivity implements View.OnClickListe
                     int code = response.body().getCode();
                     LogUtil.e(TAG, "--code--" + code);
                     if (code == 0) {
-
+                        FileUtil.deleteFile(filePath);
                     } else {
 
                     }

+ 4 - 3
app/src/main/java/com/sunwin/visitorapp/adapter/VisitLogAdapter.java

@@ -9,6 +9,7 @@ import android.widget.TextView;
 
 import com.sunwin.visitorapp.R;
 import com.sunwin.visitorapp.model.UploadRecordRequsetModel;
+import com.sunwin.visitorapp.utils.DigitUtil;
 
 import java.util.List;
 
@@ -50,12 +51,12 @@ public class VisitLogAdapter extends BaseAdapter {
             holder = (ViewHolder) convertView.getTag();
         }
         UploadRecordRequsetModel model = mList.get(i);
-        holder.mTvIdNum.setText(model.getIdNum());
+        holder.mTvIdNum.setText(DigitUtil.idCardHide(model.getIdNum()));
         holder.mTvVisitTime.setText(model.getPostDate()+"\n"+model.getLostDate());
-        holder.mTvName.setText(model.getPersonName());
+        holder.mTvName.setText(DigitUtil.nameHide(model.getPersonName()));
         holder.mTvInOut.setText(model.getInout_flag() == 0 ? "进" : model.getInout_flag() == 1 ? "出" : "无");
         holder.mTvDept.setText(model.getCategoryName());
-        holder.mTvTel.setText(model.getPhone());
+        holder.mTvTel.setText(DigitUtil.phoneHide(model.getPhone()));
 //        holder.mTvShenhe.setText(model.getStatus2());
 
         return convertView;

+ 1 - 1
app/src/main/java/com/sunwin/visitorapp/face/IDCardReaderUtil.java

@@ -145,7 +145,7 @@ public class IDCardReaderUtil implements Runnable {
                             if (mContext != null) {
                                 LogUtil.e("detecterView", idCardInfo.getName());
                                 if (mIdCardReadCallback != null) {
-                                    mIdCardReadCallback.onIdNumRead(idCardInfo.getId());
+                                    mIdCardReadCallback.onIdNumRead(idCardInfo.getId(),mAuthentticaImagePath);
                                 }
 
                             }

+ 1 - 3
app/src/main/java/com/sunwin/visitorapp/face/IdCardReadCallback.java

@@ -1,8 +1,6 @@
 package com.sunwin.visitorapp.face;
 
-import android.graphics.Bitmap;
-
 public interface IdCardReadCallback {
     /**运行在子线程*/
-    void onIdNumRead(String idNum);
+    void onIdNumRead(String idNum, String mAuthentticaImagePath);
 }

+ 1 - 1
app/src/main/java/com/sunwin/visitorapp/face/SwFaceLoop.java

@@ -530,7 +530,7 @@ public class SwFaceLoop extends FRAbsLoop {
             if (result != null) {
                 if (result.result == 0) {
                     boolean b = mFacePassHandler.bindGroup(group_name, result.faceToken);
-                    LogUtil.e(TAG, "bindGroup: " + currentFacePath + ":" + b);
+                    LogUtil.e(TAG, "bindGroup: " + currentFacePath + ":" + b+",token="+ new String(result.faceToken));
                     return new String(result.faceToken);
                 }
             }

+ 5 - 2
app/src/main/java/com/sunwin/visitorapp/fragment/IdcardRegFragment.java

@@ -19,6 +19,7 @@ import com.sunwin.visitorapp.face.IDCardReaderUtil;
 import com.sunwin.visitorapp.face.IdCardReadCallback;
 import com.sunwin.visitorapp.model.OpenDoorByFaceNetResultInfo;
 import com.sunwin.visitorapp.utils.Constant;
+import com.sunwin.visitorapp.utils.FileUtil;
 import com.sunwin.visitorapp.utils.LogUtil;
 import com.sunwin.visitorapp.utils.ToastUtils;
 import com.sunwin.visitorapp.view.FaceDetecterView;
@@ -72,10 +73,11 @@ public class IdcardRegFragment extends BaseFragment implements IdCardReadCallbac
         mLlIdCardReg = view.findViewById(R.id.ll_id_card_reg);
         mFaceDetecterView = view.findViewById(R.id.faceDetecterView);
     }
-
+    private String mCardPath;
     @Override
-    public void onIdNumRead(String idNum) {
+    public void onIdNumRead(String idNum, String mAuthentticaImagePath) {
         LogUtil.e(TAG, "idNum = " + idNum);
+        mCardPath = mAuthentticaImagePath;
         //读取身份证后显示人脸扫描框
         if (isAdded())
             mContext.runOnUiThread(new Runnable() {
@@ -99,6 +101,7 @@ public class IdcardRegFragment extends BaseFragment implements IdCardReadCallbac
 
     @Override
     public void detectedUser(OpenDoorByFaceNetResultInfo info) {
+        FileUtil.deleteFile(mCardPath);
         BaseApplication.getSystemTTS().playText("识别成功");
         Intent intent = new Intent(mContext, VisitorRegisterAc.class);
         intent.putExtra(Constant.IIntentValue.CURRENTFACEPATH, info.getCurrentFace());

+ 1 - 1
app/src/main/java/com/sunwin/visitorapp/fragment/NoCardRegFragment.java

@@ -86,7 +86,7 @@ public class NoCardRegFragment extends BaseFragment implements FaceDetecterView.
         AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
         builder.setTitle("温馨提示");
         builder.setCancelable(false);
-        builder.setMessage("将对您的面部拍摄一张照片,用于人员信息录入,如同意请点击确定");
+        builder.setMessage("将对您的面部拍摄一张照片,用于人员信息录入,使用完成后会进行删除,不做保存。如同意请点击确定“按钮");
         builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int which) {

+ 61 - 0
app/src/main/java/com/sunwin/visitorapp/utils/DigitUtil.java

@@ -0,0 +1,61 @@
+package com.sunwin.visitorapp.utils;
+
+import android.text.TextUtils;
+
+public class DigitUtil {
+    /**
+     * 手机号中间四位隐藏
+     *
+     * @param phone 手机号
+     */
+    public static String phoneHide(String phone) {
+        if (phone.length() <= 4) {
+            return phone;
+        }
+        if (phone.length() == 11) {
+            return phone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
+
+        }else{
+            return phone.replaceAll("(\\d{3})\\d[4]", "$1****");
+        }
+
+    }
+
+    /**
+     * 身份证中间8位隐藏
+     * 隐藏出生年月
+     *
+     * @param idCard 身份证号
+     */
+    public static String idCardHide(String idCard) {
+        if (idCard.length() <= 8) {
+            return idCard;
+        }
+        String idCardHide = idCard.replaceAll("(\\d{6})\\d{8}(\\w{4})", "$1********$2");
+        return idCardHide;
+    }
+
+
+    /**
+     * 隐藏名
+     * 隐藏姓名
+     *
+     * @param showName
+     * @return
+     */
+    public static String nameHide(String showName) {
+        StringBuilder sb = new StringBuilder();
+        if (!TextUtils.isEmpty(showName) && showName.length() > 0) {
+            for (int i = 0; i < showName.length(); i++) {
+                char c = showName.charAt(i);
+                if (i >= 1) {
+                    sb.append('*');
+                } else {
+                    sb.append(c);
+                }
+            }
+
+        }
+        return sb.toString();//方法2:输出“舒**”
+    }
+}

+ 4 - 0
app/src/main/java/com/sunwin/visitorapp/utils/FileUtil.java

@@ -8,6 +8,7 @@ import android.graphics.Matrix;
 import android.graphics.Rect;
 import android.graphics.YuvImage;
 import android.net.Uri;
+import android.text.TextUtils;
 
 import com.sunwin.visitorapp.face.CameraPreviewData;
 
@@ -139,6 +140,9 @@ public class FileUtil {
     }
 
     public static boolean deleteFile(String path) {
+        if (TextUtils.isEmpty(path)){
+            return false;
+        }
         File file = new File(path);
         if (file.exists()) {
             boolean delete = file.delete();

+ 5 - 2
app/src/main/java/com/sunwin/visitorapp/view/FaceDetecterView.java

@@ -115,7 +115,7 @@ public class FaceDetecterView extends RelativeLayout {
     }
 
     public void onDestroy() {
-        if (mFRAbsLoop!= null){
+        if (mFRAbsLoop != null) {
             mFRAbsLoop.shutdown();
         }
         BaseApplication.getSystemTTS().stopSpeak();
@@ -224,7 +224,10 @@ public class FaceDetecterView extends RelativeLayout {
         } else if (event.getDesc().equalsIgnoreCase(DescEvent.DESC_FR_NO_BODY)) {
             isCanFlush = true;
             BaseApplication.getSystemTTS().playText(event.getDesc());
-            mListener.detecterFail(event.getDesc());
+            if (mListener != null) {
+                mListener.detecterFail(event.getDesc());
+
+            }
         } else if (event.getDesc().equalsIgnoreCase(DescEvent.DESC_FR_FROCUSE_EYE)) {
             BaseApplication.getSystemTTS().playText(event.getDesc());
         } else if (event.getDesc().equalsIgnoreCase(DescEvent.DESC_TAKE_PIC)) {