1
0

3 Revīzijas 8d0a4dd191 ... 05892c9652

Autors SHA1 Ziņojums Datums
  ifengouy 05892c9652 Merge remote-tracking branch 'origin/master' 2 gadi atpakaļ
  ifengouy c28002f363 设置服务器地址不生效问题 2 gadi atpakaļ
  ifengouy d90881a50c 系统设置、黑名单用户提示框、身份证录入人脸采集提示框 2 gadi atpakaļ

+ 17 - 0
app/src/main/java/com/sunwin/visitorapp/BaseActivity.java

@@ -1,10 +1,12 @@
 package com.sunwin.visitorapp;
 
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.os.Bundle;
 
+import androidx.appcompat.app.AlertDialog;
 import androidx.appcompat.app.AppCompatActivity;
 
 import com.sunwin.visitorapp.activity.HomeAc;
@@ -82,4 +84,19 @@ public class BaseActivity extends AppCompatActivity {
         startActivity(intent);
         finish();
     }
+
+
+    public void showBlackUserDialog() {
+        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
+        builder.setTitle("提示");
+        builder.setCancelable(false);
+        builder.setMessage("信息异常,请联系管理员!");
+        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int which) {
+                finish();
+            }
+        });
+        builder.show();
+    }
 }

+ 2 - 2
app/src/main/java/com/sunwin/visitorapp/BaseFragment.java

@@ -11,13 +11,13 @@ import com.sunwin.visitorapp.view.LoadingDialog;
 
 public class BaseFragment extends Fragment {
     protected static String TAG = "";
-    protected Activity mContext;
+    protected BaseActivity mContext;
     private LoadingDialog loadingDialog;
 
 
     public void onAttach(Context context) {
         super.onAttach(context);
-        mContext = (Activity) context;
+        mContext = (BaseActivity) context;
     }
 
     public void onCreate(@Nullable Bundle savedInstanceState) {

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

@@ -197,7 +197,6 @@ public class HomeAc extends BaseActivity implements View.OnClickListener, RegTyp
      */
     @Override
     public void showIdCardReg() {
-        SharePrefenceUtils.putBoolean(Constant.ISharePrefence.LOGINTAG, false);
         Intent intent = new Intent(this, VisitorRegActivity.class);
         intent.putExtra(Constant.IIntentValue.VISIT_REG_TYPE, 1);
         intent.putExtra(Constant.IIntentValue.ISLOGINUSER, isLogin);

+ 9 - 5
app/src/main/java/com/sunwin/visitorapp/activity/VisitInputActivity.java

@@ -1,5 +1,6 @@
 package com.sunwin.visitorapp.activity;
 
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.os.Bundle;
 import android.text.TextUtils;
@@ -7,8 +8,9 @@ import android.view.View;
 import android.widget.Button;
 import android.widget.EditText;
 
+import androidx.appcompat.app.AlertDialog;
+
 import com.sunwin.visitorapp.BaseActivity;
-import com.sunwin.visitorapp.BaseApplication;
 import com.sunwin.visitorapp.R;
 import com.sunwin.visitorapp.db.BlackUserModel;
 import com.sunwin.visitorapp.db.DatabaseManager;
@@ -60,21 +62,23 @@ public class VisitInputActivity extends BaseActivity implements View.OnClickList
             ToastUtils.showToast("请输入身份证");
             return;
         }
-        if (idNum.length()!= 18) {
+        if (idNum.length() != 18) {
             ToastUtils.showToast("身份证号长度错误");
             return;
         }
         List<BlackUserModel> model = DatabaseManager.getInstance().query(BlackUserModel.class, "id_card_code", idNum);
         if (model.size() > 0) {
-            BaseApplication.getSystemTTS().playText("黑名单用户");
+            showBlackUserDialog();
+            return;
         }
 
         OpenDoorByFaceNetResultInfo info = new OpenDoorByFaceNetResultInfo();
         info.setIdNum(idNum);
         info.setPerson_name(name);
         Intent intent = new Intent(mContext, NoCardRegActivity.class);
-        intent.putExtra(Constant.IIntentValue.CURRENTFACEPATH,currentFacePath);
-        intent.putExtra(Constant.IIntentValue.RECOGNIZE_INFO,info);
+        intent.putExtra(Constant.IIntentValue.CURRENTFACEPATH, currentFacePath);
+        intent.putExtra(Constant.IIntentValue.RECOGNIZE_INFO, info);
         startActivity(intent);
     }
+
 }

+ 7 - 2
app/src/main/java/com/sunwin/visitorapp/activity/VisitSignActivity.java

@@ -16,6 +16,7 @@ import com.sunwin.visitorapp.db.BlackUserModel;
 import com.sunwin.visitorapp.db.DatabaseManager;
 import com.sunwin.visitorapp.db.UserInfoModel;
 import com.sunwin.visitorapp.face.CameraPreviewData;
+import com.sunwin.visitorapp.face.FRImpl;
 import com.sunwin.visitorapp.face.IDCardReaderUtil;
 import com.sunwin.visitorapp.face.IdCardReadCallback;
 import com.sunwin.visitorapp.fragment.TimeFragment;
@@ -115,6 +116,7 @@ public class VisitSignActivity extends BaseActivity implements IdCardReadCallbac
     @Override
     public void onIdNumRead(String idNum, String idCardPath) {
         LogUtil.e(TAG, "idNum = " + idNum);
+        FRImpl.getInstance().idCardInfo = null;
         this.idCardPath = idCardPath;
         updataUserInfoByIdNum(idNum, 5);
     }
@@ -122,7 +124,8 @@ public class VisitSignActivity extends BaseActivity implements IdCardReadCallbac
     private void updataUserInfoByIdNum(String idNum, int type) {
         List<BlackUserModel> model = DatabaseManager.getInstance().query(BlackUserModel.class, "id_card_code", idNum);
         if (model.size() > 0) {
-            BaseApplication.getSystemTTS().playText("黑名单用户");
+            showBlackUserDialog();
+            return;
         }
 
         List<UserInfoModel> userInfoModels = DatabaseManager.getInstance().query(UserInfoModel.class, "idNum", idNum);
@@ -191,7 +194,6 @@ public class VisitSignActivity extends BaseActivity implements IdCardReadCallbac
                 } catch (Exception e) {
 
                 }
-
                 requsetModel.setPhone(infoModel.getPhone());
                 long insert = DatabaseManager.getInstance().insert(requsetModel);
                 LogUtil.e(TAG, "insert sign record =" + insert);
@@ -255,6 +257,8 @@ public class VisitSignActivity extends BaseActivity implements IdCardReadCallbac
                 @Override
                 public void run() {
                     ToastUtils.showToast(visitType == 1 ? "签到成功!" : "签离成功!");
+
+                    BaseApplication.getSystemTTS().playText(visitType == 1 ? "签到成功" : "签离成功");
                     finish();
                 }
             });
@@ -263,6 +267,7 @@ public class VisitSignActivity extends BaseActivity implements IdCardReadCallbac
                 @Override
                 public void run() {
                     ToastUtils.showToast("用户不存在!");
+                    BaseApplication.getSystemTTS().playText("用户不存在");
                 }
             });
         }

+ 3 - 2
app/src/main/java/com/sunwin/visitorapp/face/FRImpl.java

@@ -53,7 +53,7 @@ import mcv.facepass.types.FacePassTrackOptions;
 public class FRImpl extends FRAbs {
     private static final String DEBUG_TAG = "SwFaceLoop";
     private static FRImpl mSwFaceLoop;
-    private FacePassHandler mFacePassHandler;
+    public FacePassHandler mFacePassHandler;
     private boolean isLocalGroupExist;
     private NV21ToBitmap nV21ToBitmap;
     private FeedFrameThread feedFrameThread;
@@ -140,7 +140,7 @@ public class FRImpl extends FRAbs {
                             //config.ageGenderModel = null;
 
                             config.searchThreshold = Constant.COMPARSION_VALUE;
-                            config.livenessThreshold = 50f;// TODO: 2021/12/22   60f
+                            config.livenessThreshold = Constant.LIVENESS_VALUE;// TODO: 2021/12/22   60f
                             config.livenessEnabled = true;
 //                            config.rgbIrLivenessEnabled = false;
                             config.faceMinThreshold = 100;
@@ -495,6 +495,7 @@ public class FRImpl extends FRAbs {
                     openDoorByFaceNetResultInfo.setFaces(arrayList);
                     EventBus.getDefault().post(new DescEvent().setDesc(DescEvent.DESC_FR_SUCC).setOpenDoorByFaceNetResultInfo(openDoorByFaceNetResultInfo));
                     recognizeTime = 0;
+                    idCardInfo = null;
                     LogUtil.e("step", "6");
                 } else {
                     LogUtil.e(TAG, "人证识别时间:" + recognizeTime);

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

@@ -133,10 +133,10 @@ public class IDCardReaderUtil implements Runnable {
                             //保存一张照片
                             String fileName = idCardInfo.getId() + ".jpg";  //jpeg文件名定义
                             String dirPath = Constant.RecognitionDir;    //系统路径
-                            File mkDir = new File(dirPath);
-                            if (!mkDir.exists()) {
-                                mkDir.mkdirs();   //目录不存在,则创建
-                            }
+//                            File mkDir = new File(dirPath);
+//                            if (!mkDir.exists()) {
+//                                mkDir.mkdirs();   //目录不存在,则创建
+//                            }
                             mAuthentticaImagePath = dirPath + fileName;
                             Bitmap bitmap = IDPhotoHelper.Bgr2Bitmap(buf);
                             BitmapUtils.saveJPGE_After(mContext, bitmap, mAuthentticaImagePath, 100);

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

@@ -1,7 +1,9 @@
 package com.sunwin.visitorapp.fragment;
 
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.os.Bundle;
+import android.os.Handler;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -9,6 +11,7 @@ import android.widget.LinearLayout;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
+import androidx.appcompat.app.AlertDialog;
 
 import com.sunwin.visitorapp.BaseApplication;
 import com.sunwin.visitorapp.BaseFragment;
@@ -92,16 +95,44 @@ public class IdcardRegFragment extends BaseFragment implements IdCardReadCallbac
                 @Override
                 public void run() {
                     if (model.size() > 0) {
-                        BaseApplication.getSystemTTS().playText("黑名单用户");
+                        if (model.size() > 0) {
+                            mContext.showBlackUserDialog();
+                            return;
+                        }
                     }
                     mLlIdCardReg.setVisibility(View.GONE);
                     ToastUtils.showToast(getString(R.string.have_readed_id_card));
                     BaseApplication.getSystemTTS().playText(getString(R.string.have_readed_id_card));
-                    mFaceDetecterView.setVisibility(View.VISIBLE);
+                    showTipDialog();
                 }
             });
     }
+    private void showTipDialog() {        // 创建退出对话框
+        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
+        builder.setTitle("温馨提示");
+        builder.setCancelable(false);
+        builder.setMessage("将对您的面部拍摄一张照片,用于人员信息录入,使用完成后会进行删除,不做保存。如同意请点击”确定“按钮");
+        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int which) {
+                new Handler().post(new Runnable() {
+                    @Override
+                    public void run() {
+                        mFaceDetecterView.setVisibility(View.VISIBLE);
+                    }
+                });
+                BaseApplication.getSystemTTS().playText("请看摄像头");
+            }
+        });
+        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int which) {
+                mContext.finish();
+            }
+        });
+        builder.show();
 
+    }
     /**
      * ------------------FaceDetecterView.Listener 开始------------------------------
      */

+ 131 - 6
app/src/main/java/com/sunwin/visitorapp/fragment/SystemOptionFr.java

@@ -1,25 +1,150 @@
 package com.sunwin.visitorapp.fragment;
 
 import android.os.Bundle;
+import android.text.TextUtils;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.EditText;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
-import androidx.fragment.app.Fragment;
 
+import com.sunwin.visitorapp.BaseFragment;
 import com.sunwin.visitorapp.R;
+import com.sunwin.visitorapp.face.FRImpl;
+import com.sunwin.visitorapp.net.RetrofitUtil;
+import com.sunwin.visitorapp.utils.Constant;
+import com.sunwin.visitorapp.utils.SharePrefenceUtils;
+import com.sunwin.visitorapp.utils.ToastUtils;
 
-public class SystemOptionFr extends Fragment {
+import org.jetbrains.annotations.NotNull;
+
+import mcv.facepass.FacePassException;
+import mcv.facepass.FacePassHandler;
+import mcv.facepass.types.FacePassConfig;
+import okhttp3.HttpUrl;
+
+public class SystemOptionFr extends BaseFragment implements View.OnClickListener {
+
+    private EditText mEditTimeZone;
+    private EditText mEditIPAddress;
+    private EditText mEtCompareValue;
+    private EditText mEtIpServer;
+    private EditText mEtLivenessValue;
+    private EditText mEtIpPort;
+    private EditText mEtCompareNum;
+    private Button mTextButtonSure;
 
-    private View root;
     @Nullable
     @Override
-    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+    public View onCreateView(@NonNull @NotNull LayoutInflater inflater, @Nullable @org.jetbrains.annotations.Nullable ViewGroup container, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
+        View view = inflater.inflate(R.layout.fr_system_option, container, false);
+
+        return view;
+    }
+
+    @Override
+    public void onViewCreated(@NonNull @NotNull View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
+        super.onViewCreated(view, savedInstanceState);
+        initView(view);
+        initData();
+    }
+
+    private void initData() {
+        String serverUrl = SharePrefenceUtils.getString(Constant.ISharePrefence.BASEURL, Constant.BASE_HOST);
+
+        int lastIndex = serverUrl.lastIndexOf(":");
+        mEtIpServer.setText(serverUrl.substring(0, lastIndex));
+        mEtIpPort.setText(serverUrl.substring(lastIndex + 1, serverUrl.length() - 1));
+
+        mEtCompareValue.setText(Constant.COMPARSION_VALUE + "");
+        mEtLivenessValue.setText(Constant.LIVENESS_VALUE + "");
+        mEtCompareNum.setText(Constant.COMPARSION_FREQUENCY + "");
+
+
+    }
+
+    private void initView(View view) {
+        mEditTimeZone = view.findViewById(R.id.EditTimeZone);
+        mEditIPAddress = view.findViewById(R.id.EditIPAddress);
+        mEtCompareValue = view.findViewById(R.id.et_compareValue);
+        mEtIpServer = view.findViewById(R.id.et_ipServer);
+        mEtLivenessValue = view.findViewById(R.id.et_livenessValue);
+        mEtIpPort = view.findViewById(R.id.et_ipPort);
+        mEtCompareNum = view.findViewById(R.id.et_compareNum);
+        mTextButtonSure = view.findViewById(R.id.TextButtonSure);
+        mTextButtonSure.setOnClickListener(this);
+    }
+
+    @Override
+    public void onClick(View view) {
+        submit();
+    }
+
+    private void submit() {
+        String ipServer = mEtIpServer.getText().toString().trim();
+        String ipPort = mEtIpPort.getText().toString().trim();
+        String campareValue = mEtCompareValue.getText().toString().trim();
+        String livenessValue = mEtLivenessValue.getText().toString().trim();
+        String compareNum = mEtCompareNum.getText().toString().trim();
+        if (TextUtils.isEmpty(ipServer)) {
+            ToastUtils.showToast("服务器地址不能为空!");
+            return;
+        }
+        if (TextUtils.isEmpty(ipPort)) {
+            ToastUtils.showToast("服务器端口不能为空!");
+            return;
+        }
+        if (TextUtils.isEmpty(campareValue)) {
+            ToastUtils.showToast("比对阈值不能为空!");
+            return;
+        }
+        if (TextUtils.isEmpty(livenessValue)) {
+            ToastUtils.showToast("活体阈值不能为空!");
+            return;
+        }
+        if (TextUtils.isEmpty(compareNum)) {
+            ToastUtils.showToast("比对次数不能为空!");
+            return;
+        }
+        String address = ipServer + ":" + ipPort + "/";
+        boolean illegalUrl = isIllegalUrl(address);
+        if (!illegalUrl) {
+            ToastUtils.showToast("非法服务器路径,请重新输入!");
+            return;
+        }
+        SharePrefenceUtils.putString(Constant.ISharePrefence.BASEURL, address);
+        RetrofitUtil.initRetrofit();
+
+        //人脸比对参数
+        try {
+            FacePassHandler mFacePassHandler = FRImpl.getInstance().mFacePassHandler;
+
+            FacePassConfig config = mFacePassHandler.getConfig();
+            config.searchThreshold = Integer.parseInt(campareValue);
+            config.livenessThreshold = Integer.parseInt(livenessValue);
+            mFacePassHandler.setConfig(config);
+        } catch (FacePassException e) {
+            e.printStackTrace();
+        }
+        SharePrefenceUtils.putInt("comparsion_value", Integer.parseInt(campareValue));
+        SharePrefenceUtils.putInt("liveness_value", Integer.parseInt(campareValue));
+        SharePrefenceUtils.putInt("comparsion_frequency_value", Integer.parseInt(compareNum));
+
+        ToastUtils.showToast("保存成功!");
+    }
 
-        if(root==null)root = inflater.inflate(R.layout.fr_system_option,container,false);
 
-        return root;
+    /**
+     * 判断服务器地址是否合法
+     */
+    boolean isIllegalUrl(String url) {
+        HttpUrl httpUrl = HttpUrl.parse(url);
+        if (httpUrl == null) {
+            return false;
+        }
+        return true;
     }
 }

+ 2 - 0
app/src/main/java/com/sunwin/visitorapp/utils/Constant.java

@@ -10,6 +10,7 @@ public class Constant {
     final public static boolean isSufaRotate = SharePrefenceUtils.getBoolean("sufaRotate", false);
 
     public static int COMPARSION_VALUE = SharePrefenceUtils.getInt("comparsion_value", Constant.NumerValue.defaultComparsionValue);
+    public static int LIVENESS_VALUE = SharePrefenceUtils.getInt("liveness_value", NumerValue.defaultLivenessValue);
     public static int COMPARSION_FREQUENCY = SharePrefenceUtils.getInt("comparsion_frequency_value", Constant.NumerValue.defaultComparsionFrequency);
     public int AVOID_SAME_PEOPLE_VALUE = SharePrefenceUtils.getInt("avoid_same_people_value", Constant.NumerValue.defaultAvoidSamePeopleValue);
     public int MOUDLE_UPDATE_VALUE = SharePrefenceUtils.getInt("mould_update_value", Constant.NumerValue.defaultMoudleUpdateValue);
@@ -71,6 +72,7 @@ public class Constant {
          * 比对设置参数
          */
         int defaultComparsionValue = 55;
+        int defaultLivenessValue = 50;
         int defaultMoudleUpdateValue = 100;
         int defaultAvoidSamePeopleValue = 80;
         int defaultComparsionFrequency = 3;

+ 1 - 0
app/src/main/java/com/sunwin/visitorapp/view/FaceDetecterView.java

@@ -213,6 +213,7 @@ public class FaceDetecterView extends RelativeLayout {
             isCanFlush = true;
             BaseApplication.getSystemTTS().stopSpeak();
             LogUtil.e(TAG, "接收成功信息");
+            LogUtil.e(TAG,"----mListener---"+mListener);
             if (mListener != null) {
 
                 mListener.detectedUser(event.getOpenDoorByFaceNetResultInfo());

+ 11 - 2
app/src/main/res/layout/fr_system_option.xml

@@ -61,10 +61,13 @@
                 android:layout_width="wrap_content"
                 android:text="比对阈值"
                 />
+
             <EditText
-                android:layout_width="match_parent"
+                android:inputType="number"
+                android:id="@+id/et_compareValue"
                 style="@style/StyleInputContent"
-                android:layout_height="wrap_content"/>
+                android:layout_width="match_parent"
+                android:layout_height="37dp" />
         </LinearLayout>
     </LinearLayout>
     <LinearLayout
@@ -85,6 +88,7 @@
                 android:text="服务器地址"
                 />
             <EditText
+                android:id="@+id/et_ipServer"
                 android:layout_width="match_parent"
                 style="@style/StyleInputContent"
                 android:layout_height="wrap_content"/>
@@ -119,6 +123,8 @@
                 android:text="活体阈值"
                 />
             <EditText
+                android:inputType="number"
+                android:id="@+id/et_livenessValue"
                 android:layout_width="match_parent"
                 style="@style/StyleInputContent"
                 android:layout_height="wrap_content"/>
@@ -142,6 +148,7 @@
                 android:text="服务器端口"
                 />
             <EditText
+                android:id="@+id/et_ipPort"
                 android:layout_width="match_parent"
                 style="@style/StyleInputContent"
                 android:layout_height="wrap_content"/>
@@ -234,6 +241,8 @@
                 android:text="比对次数"
                 />
             <EditText
+                android:inputType="number"
+                android:id="@+id/et_compareNum"
                 android:layout_width="match_parent"
                 style="@style/StyleInputContent"
                 android:layout_height="wrap_content"/>