Commit 273f0cf51bef00ec7b3ba7e28d88e5f0fd6cf16d
Merge branch 'master' of http://bj.gitlab.cnlive.com/cnlive-team/newModuleStrike
Showing
7 changed files
with
214 additions
and
54 deletions
.idea/misc.xml
| @@ -39,7 +39,7 @@ | @@ -39,7 +39,7 @@ | ||
| 39 | </value> | 39 | </value> |
| 40 | </option> | 40 | </option> |
| 41 | </component> | 41 | </component> |
| 42 | - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK"> | 42 | + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK"> |
| 43 | <output url="file://$PROJECT_DIR$/build/classes" /> | 43 | <output url="file://$PROJECT_DIR$/build/classes" /> |
| 44 | </component> | 44 | </component> |
| 45 | <component name="ProjectType"> | 45 | <component name="ProjectType"> |
core/dentity_verfication/src/main/java/com/cnlive/core/people_verfication/activity/TakeIdentityPictureActivity.java
| @@ -8,6 +8,7 @@ import android.text.TextUtils; | @@ -8,6 +8,7 @@ import android.text.TextUtils; | ||
| 8 | 8 | ||
| 9 | import com.baidu.ocr.sdk.model.IDCardParams; | 9 | import com.baidu.ocr.sdk.model.IDCardParams; |
| 10 | import com.cnlive.core.libs.base.frame.activity.BaseActivity; | 10 | import com.cnlive.core.libs.base.frame.activity.BaseActivity; |
| 11 | +import com.cnlive.core.libs.base.util.AlertUtil; | ||
| 11 | import com.cnlive.core.libs.base.util.FileUtils; | 12 | import com.cnlive.core.libs.base.util.FileUtils; |
| 12 | import com.cnlive.core.ocr.ui.camera.CameraActivity; | 13 | import com.cnlive.core.ocr.ui.camera.CameraActivity; |
| 13 | import com.cnlive.core.people_verfication.R; | 14 | import com.cnlive.core.people_verfication.R; |
| @@ -15,8 +16,12 @@ import com.cnlive.core.people_verfication.databinding.ActivityTakePictureBinding | @@ -15,8 +16,12 @@ import com.cnlive.core.people_verfication.databinding.ActivityTakePictureBinding | ||
| 15 | import com.cnlive.core.people_verfication.presenter.TakeIdentityPicturePresenter; | 16 | import com.cnlive.core.people_verfication.presenter.TakeIdentityPicturePresenter; |
| 16 | import com.cnlive.core.people_verfication.view.ICertificatePhohosView; | 17 | import com.cnlive.core.people_verfication.view.ICertificatePhohosView; |
| 17 | import com.cnlive.core.people_verfication.view.TakeIdentityPictureView; | 18 | import com.cnlive.core.people_verfication.view.TakeIdentityPictureView; |
| 19 | +import com.cnlive.media.picker.PickerConfig; | ||
| 20 | +import com.cnlive.media.picker.entity.Media; | ||
| 18 | import com.cnlive.media.picker.utils.PermissionChecker; | 21 | import com.cnlive.media.picker.utils.PermissionChecker; |
| 19 | 22 | ||
| 23 | +import java.util.ArrayList; | ||
| 24 | + | ||
| 20 | import androidx.annotation.NonNull; | 25 | import androidx.annotation.NonNull; |
| 21 | import androidx.databinding.ViewDataBinding; | 26 | import androidx.databinding.ViewDataBinding; |
| 22 | 27 | ||
| @@ -32,6 +37,7 @@ public class TakeIdentityPictureActivity extends BaseActivity<TakeIdentityPictur | @@ -32,6 +37,7 @@ public class TakeIdentityPictureActivity extends BaseActivity<TakeIdentityPictur | ||
| 32 | private int preViewClickId = 0; | 37 | private int preViewClickId = 0; |
| 33 | private static int CAMERA_WRITE_FR_PERMISSION = 1001; | 38 | private static int CAMERA_WRITE_FR_PERMISSION = 1001; |
| 34 | private static int CAMERA_WRITE_BA_PERMISSION = 1002; | 39 | private static int CAMERA_WRITE_BA_PERMISSION = 1002; |
| 40 | + private static int CAMERA_WRITE_PI_PERMISSION = 1003; | ||
| 35 | 41 | ||
| 36 | @Override | 42 | @Override |
| 37 | protected int getBindLayoutId() { | 43 | protected int getBindLayoutId() { |
| @@ -63,21 +69,23 @@ public class TakeIdentityPictureActivity extends BaseActivity<TakeIdentityPictur | @@ -63,21 +69,23 @@ public class TakeIdentityPictureActivity extends BaseActivity<TakeIdentityPictur | ||
| 63 | preViewClickTime = curClickTime; | 69 | preViewClickTime = curClickTime; |
| 64 | preViewClickId = id; | 70 | preViewClickId = id; |
| 65 | if (id == R.id.certificate_front) { | 71 | if (id == R.id.certificate_front) { |
| 66 | - if(hasCampermission(CAMERA_WRITE_FR_PERMISSION)){//权限判断 | 72 | + if (hasCampermission(CAMERA_WRITE_FR_PERMISSION)) {//权限判断 |
| 67 | getMvpView().takeIdCardPictures(this, ICertificatePhohosView.ID_CARD_SIDE_FRONT); | 73 | getMvpView().takeIdCardPictures(this, ICertificatePhohosView.ID_CARD_SIDE_FRONT); |
| 68 | } | 74 | } |
| 69 | } else if (id == R.id.certificate_back) { | 75 | } else if (id == R.id.certificate_back) { |
| 70 | - if(hasCampermission(CAMERA_WRITE_BA_PERMISSION)){//权限判断 | 76 | + if (hasCampermission(CAMERA_WRITE_BA_PERMISSION)) {//权限判断 |
| 71 | getMvpView().takeIdCardPictures(this, ICertificatePhohosView.ID_CARD_SIDE_BACK); | 77 | getMvpView().takeIdCardPictures(this, ICertificatePhohosView.ID_CARD_SIDE_BACK); |
| 72 | } | 78 | } |
| 73 | } else if (id == R.id.take_picture) { | 79 | } else if (id == R.id.take_picture) { |
| 74 | - | 80 | + if (hasCampermission(CAMERA_WRITE_PI_PERMISSION)) { |
| 81 | + getMvpView().showDialog(); | ||
| 82 | + } | ||
| 75 | } | 83 | } |
| 76 | } | 84 | } |
| 77 | 85 | ||
| 78 | - private boolean hasCampermission(int typeNum){ | 86 | + private boolean hasCampermission(int typeNum) { |
| 79 | boolean hasPermission = PermissionChecker.checkPermissions(this | 87 | boolean hasPermission = PermissionChecker.checkPermissions(this |
| 80 | - , new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE} | 88 | + , new String[]{Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO, Manifest.permission.WRITE_EXTERNAL_STORAGE} |
| 81 | , typeNum, R.string.dialog_imagepicker_permission_camera_nerver_ask_message); | 89 | , typeNum, R.string.dialog_imagepicker_permission_camera_nerver_ask_message); |
| 82 | return hasPermission; | 90 | return hasPermission; |
| 83 | } | 91 | } |
| @@ -86,13 +94,17 @@ public class TakeIdentityPictureActivity extends BaseActivity<TakeIdentityPictur | @@ -86,13 +94,17 @@ public class TakeIdentityPictureActivity extends BaseActivity<TakeIdentityPictur | ||
| 86 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | 94 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { |
| 87 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); | 95 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
| 88 | if (requestCode == CAMERA_WRITE_FR_PERMISSION) { | 96 | if (requestCode == CAMERA_WRITE_FR_PERMISSION) { |
| 89 | - if (PermissionChecker.onRequestPermissionsResult(this,requestCode, permissions, grantResults, false, R.string.dialog_imagepicker_permission_sdcard_message)[0]) { | 97 | + if (PermissionChecker.onRequestPermissionsResult(this, requestCode, permissions, grantResults, false, R.string.dialog_imagepicker_permission_sdcard_message)[0]) { |
| 90 | getMvpView().takeIdCardPictures(this, ICertificatePhohosView.ID_CARD_SIDE_FRONT); | 98 | getMvpView().takeIdCardPictures(this, ICertificatePhohosView.ID_CARD_SIDE_FRONT); |
| 91 | } | 99 | } |
| 92 | - }else if(requestCode == CAMERA_WRITE_BA_PERMISSION){ | ||
| 93 | - if (PermissionChecker.onRequestPermissionsResult(this,requestCode, permissions, grantResults, false, R.string.dialog_imagepicker_permission_sdcard_message)[0]) { | 100 | + } else if (requestCode == CAMERA_WRITE_BA_PERMISSION) { |
| 101 | + if (PermissionChecker.onRequestPermissionsResult(this, requestCode, permissions, grantResults, false, R.string.dialog_imagepicker_permission_sdcard_message)[0]) { | ||
| 94 | getMvpView().takeIdCardPictures(this, ICertificatePhohosView.ID_CARD_SIDE_BACK); | 102 | getMvpView().takeIdCardPictures(this, ICertificatePhohosView.ID_CARD_SIDE_BACK); |
| 95 | } | 103 | } |
| 104 | + } else if (requestCode == CAMERA_WRITE_PI_PERMISSION) { | ||
| 105 | + if (PermissionChecker.onRequestPermissionsResult(this, requestCode, permissions, grantResults, false, R.string.dialog_imagepicker_permission_sdcard_message)[0]) { | ||
| 106 | + getMvpView().showDialog(); | ||
| 107 | + } | ||
| 96 | } | 108 | } |
| 97 | } | 109 | } |
| 98 | 110 | ||
| @@ -107,14 +119,25 @@ public class TakeIdentityPictureActivity extends BaseActivity<TakeIdentityPictur | @@ -107,14 +119,25 @@ public class TakeIdentityPictureActivity extends BaseActivity<TakeIdentityPictur | ||
| 107 | String frontFilePath = FileUtils.getSaveFile(getApplicationContext(), ICertificatePhohosView.PIC_FRONT).getAbsolutePath(); | 119 | String frontFilePath = FileUtils.getSaveFile(getApplicationContext(), ICertificatePhohosView.PIC_FRONT).getAbsolutePath(); |
| 108 | if (getMvpView() == null) return; | 120 | if (getMvpView() == null) return; |
| 109 | getMvpView().recIDCard(IDCardParams.ID_CARD_SIDE_FRONT, frontFilePath); | 121 | getMvpView().recIDCard(IDCardParams.ID_CARD_SIDE_FRONT, frontFilePath); |
| 110 | - | ||
| 111 | } else if (CameraActivity.CONTENT_TYPE_ID_CARD_BACK.equals(contentType)) { | 122 | } else if (CameraActivity.CONTENT_TYPE_ID_CARD_BACK.equals(contentType)) { |
| 112 | String backFilePath = FileUtils.getSaveFile(getApplicationContext(), ICertificatePhohosView.PIC_BACK).getAbsolutePath(); | 123 | String backFilePath = FileUtils.getSaveFile(getApplicationContext(), ICertificatePhohosView.PIC_BACK).getAbsolutePath(); |
| 113 | if (getMvpView() == null) return; | 124 | if (getMvpView() == null) return; |
| 114 | getMvpView().recIDCard(IDCardParams.ID_CARD_SIDE_BACK, backFilePath); | 125 | getMvpView().recIDCard(IDCardParams.ID_CARD_SIDE_BACK, backFilePath); |
| 126 | + }else if(CameraActivity.CONTENT_TYPE_GENERAL.endsWith(contentType)){ | ||
| 127 | + String filePath = FileUtils.getSaveFile(getApplicationContext(), ICertificatePhohosView.PIC_GENERAL).getAbsolutePath(); | ||
| 128 | + if (getMvpView() == null) return; | ||
| 129 | + if (!TextUtils.isEmpty(filePath))getMvpView().hasFace(filePath); | ||
| 115 | } | 130 | } |
| 116 | } | 131 | } |
| 117 | } | 132 | } |
| 133 | + }else if (requestCode == 200 && resultCode == PickerConfig.DEFAULT_RESULT_CODE) { | ||
| 134 | + ArrayList<Media> select = data.getParcelableArrayListExtra(PickerConfig.EXTRA_RESULT); | ||
| 135 | + if (select != null && select.size() > 0) { | ||
| 136 | + String path = select.get(0).path; | ||
| 137 | + if (!TextUtils.isEmpty(path))getMvpView().hasFace(path); | ||
| 138 | + } else { | ||
| 139 | + AlertUtil.showDeftToast(this, "请选择图片"); | ||
| 140 | + } | ||
| 118 | } | 141 | } |
| 119 | } | 142 | } |
| 120 | 143 |
core/dentity_verfication/src/main/java/com/cnlive/core/people_verfication/view/ICertificatePhohosView.java
| @@ -10,6 +10,8 @@ public interface ICertificatePhohosView extends MvpView { | @@ -10,6 +10,8 @@ public interface ICertificatePhohosView extends MvpView { | ||
| 10 | int REQUEST_CODE_CAMERA = 102; | 10 | int REQUEST_CODE_CAMERA = 102; |
| 11 | int ID_CARD_SIDE_FRONT = 1; | 11 | int ID_CARD_SIDE_FRONT = 1; |
| 12 | int ID_CARD_SIDE_BACK = 2; | 12 | int ID_CARD_SIDE_BACK = 2; |
| 13 | + int ID_CAMERA_GENETAL = 3; | ||
| 13 | String PIC_FRONT = "pic_front"; | 14 | String PIC_FRONT = "pic_front"; |
| 14 | String PIC_BACK = "pic_back"; | 15 | String PIC_BACK = "pic_back"; |
| 16 | + String PIC_GENERAL = "pic_general"; | ||
| 15 | } | 17 | } |
core/dentity_verfication/src/main/java/com/cnlive/core/people_verfication/view/TakeIdentityPictureView.java
| 1 | package com.cnlive.core.people_verfication.view; | 1 | package com.cnlive.core.people_verfication.view; |
| 2 | 2 | ||
| 3 | import android.app.Activity; | 3 | import android.app.Activity; |
| 4 | +import android.app.Dialog; | ||
| 4 | import android.content.Context; | 5 | import android.content.Context; |
| 5 | import android.content.Intent; | 6 | import android.content.Intent; |
| 6 | import android.graphics.Bitmap; | 7 | import android.graphics.Bitmap; |
| 7 | import android.graphics.BitmapFactory; | 8 | import android.graphics.BitmapFactory; |
| 8 | import android.hardware.Camera; | 9 | import android.hardware.Camera; |
| 10 | + | ||
| 11 | +import com.cnlive.media.picker.ImagePicker; | ||
| 12 | +import com.cnlive.media.picker.PickerConfig; | ||
| 13 | + | ||
| 14 | +import android.media.FaceDetector; | ||
| 9 | import android.os.Environment; | 15 | import android.os.Environment; |
| 10 | import android.os.Handler; | 16 | import android.os.Handler; |
| 11 | import android.os.Looper; | 17 | import android.os.Looper; |
| 12 | import android.text.TextUtils; | 18 | import android.text.TextUtils; |
| 19 | +import android.view.Gravity; | ||
| 20 | +import android.view.View; | ||
| 21 | +import android.view.ViewGroup; | ||
| 22 | +import android.view.Window; | ||
| 13 | import android.widget.ImageView; | 23 | import android.widget.ImageView; |
| 14 | 24 | ||
| 15 | import com.baidu.ocr.sdk.OCR; | 25 | import com.baidu.ocr.sdk.OCR; |
| @@ -30,17 +40,16 @@ import com.cnlive.core.ocr.ui.camera.CameraActivity; | @@ -30,17 +40,16 @@ import com.cnlive.core.ocr.ui.camera.CameraActivity; | ||
| 30 | import com.cnlive.core.ocr.ui.util.ImageUtil; | 40 | import com.cnlive.core.ocr.ui.util.ImageUtil; |
| 31 | import com.cnlive.core.people_verfication.R; | 41 | import com.cnlive.core.people_verfication.R; |
| 32 | import com.cnlive.core.people_verfication.activity.TakeIdentityPictureActivity; | 42 | import com.cnlive.core.people_verfication.activity.TakeIdentityPictureActivity; |
| 43 | +import com.cnlive.media.picker.utils.ImagePickerComUtils; | ||
| 33 | 44 | ||
| 34 | -import java.io.ByteArrayOutputStream; | ||
| 35 | import java.io.File; | 45 | import java.io.File; |
| 36 | -import java.io.FileNotFoundException; | ||
| 37 | -import java.io.FileOutputStream; | ||
| 38 | -import java.io.IOException; | ||
| 39 | import java.text.SimpleDateFormat; | 46 | import java.text.SimpleDateFormat; |
| 40 | import java.util.Date; | 47 | import java.util.Date; |
| 41 | 48 | ||
| 49 | + | ||
| 42 | import static com.cnlive.core.people_verfication.view.ICertificatePhohosView.PIC_BACK; | 50 | import static com.cnlive.core.people_verfication.view.ICertificatePhohosView.PIC_BACK; |
| 43 | import static com.cnlive.core.people_verfication.view.ICertificatePhohosView.PIC_FRONT; | 51 | import static com.cnlive.core.people_verfication.view.ICertificatePhohosView.PIC_FRONT; |
| 52 | +import static com.cnlive.core.people_verfication.view.ICertificatePhohosView.PIC_GENERAL; | ||
| 44 | 53 | ||
| 45 | public class TakeIdentityPictureView extends BaseView { | 54 | public class TakeIdentityPictureView extends BaseView { |
| 46 | 55 | ||
| @@ -51,6 +60,7 @@ public class TakeIdentityPictureView extends BaseView { | @@ -51,6 +60,7 @@ public class TakeIdentityPictureView extends BaseView { | ||
| 51 | private boolean isBackEffective = false; | 60 | private boolean isBackEffective = false; |
| 52 | private String idCardNo; | 61 | private String idCardNo; |
| 53 | private String realName; | 62 | private String realName; |
| 63 | + private Dialog dialog; | ||
| 54 | 64 | ||
| 55 | public TakeIdentityPictureView(TakeIdentityPictureActivity activity) { | 65 | public TakeIdentityPictureView(TakeIdentityPictureActivity activity) { |
| 56 | this.activity = activity; | 66 | this.activity = activity; |
| @@ -64,14 +74,9 @@ public class TakeIdentityPictureView extends BaseView { | @@ -64,14 +74,9 @@ public class TakeIdentityPictureView extends BaseView { | ||
| 64 | activity.finish(); | 74 | activity.finish(); |
| 65 | } | 75 | } |
| 66 | 76 | ||
| 67 | - /** | ||
| 68 | - * 拍摄 | ||
| 69 | - * | ||
| 70 | - * @param idCardSide | ||
| 71 | - */ | ||
| 72 | public void takeIdCardPictures(Context context, final int idCardSide) { | 77 | public void takeIdCardPictures(Context context, final int idCardSide) { |
| 73 | long curClickTime = System.currentTimeMillis(); | 78 | long curClickTime = System.currentTimeMillis(); |
| 74 | - if (preViewClickTime > 0 && curClickTime - preViewClickTime <= 2000 ) { | 79 | + if (preViewClickTime > 0 && curClickTime - preViewClickTime <= 2000) { |
| 75 | return; | 80 | return; |
| 76 | } | 81 | } |
| 77 | preViewClickTime = curClickTime; | 82 | preViewClickTime = curClickTime; |
| @@ -83,6 +88,8 @@ public class TakeIdentityPictureView extends BaseView { | @@ -83,6 +88,8 @@ public class TakeIdentityPictureView extends BaseView { | ||
| 83 | takePhoto(PIC_FRONT, CameraActivity.CONTENT_TYPE_ID_CARD_FRONT); | 88 | takePhoto(PIC_FRONT, CameraActivity.CONTENT_TYPE_ID_CARD_FRONT); |
| 84 | } else if (idCardSide == ICertificatePhohosView.ID_CARD_SIDE_BACK) { | 89 | } else if (idCardSide == ICertificatePhohosView.ID_CARD_SIDE_BACK) { |
| 85 | takePhoto(PIC_BACK, CameraActivity.CONTENT_TYPE_ID_CARD_BACK); | 90 | takePhoto(PIC_BACK, CameraActivity.CONTENT_TYPE_ID_CARD_BACK); |
| 91 | + } else if (idCardSide == ICertificatePhohosView.ID_CAMERA_GENETAL) { | ||
| 92 | + takePhoto(PIC_GENERAL, CameraActivity.CONTENT_TYPE_GENERAL); | ||
| 86 | } | 93 | } |
| 87 | } | 94 | } |
| 88 | 95 | ||
| @@ -130,7 +137,7 @@ public class TakeIdentityPictureView extends BaseView { | @@ -130,7 +137,7 @@ public class TakeIdentityPictureView extends BaseView { | ||
| 130 | camera.release(); | 137 | camera.release(); |
| 131 | } catch (Throwable e) { | 138 | } catch (Throwable e) { |
| 132 | e.printStackTrace(); | 139 | e.printStackTrace(); |
| 133 | - AlertUtil.showDeftToast(getContext(),"没有相机权限,相机开启失败"); | 140 | + AlertUtil.showDeftToast(getContext(), "没有相机权限,相机开启失败"); |
| 134 | return; | 141 | return; |
| 135 | } | 142 | } |
| 136 | } | 143 | } |
| @@ -198,7 +205,7 @@ public class TakeIdentityPictureView extends BaseView { | @@ -198,7 +205,7 @@ public class TakeIdentityPictureView extends BaseView { | ||
| 198 | frontBitmap = bitmap; | 205 | frontBitmap = bitmap; |
| 199 | showIdCard(idCardSide, frontBitmap, activity.binding.certificateFront); | 206 | showIdCard(idCardSide, frontBitmap, activity.binding.certificateFront); |
| 200 | activity.binding.certificateFront.setImageBitmap(bitmap); | 207 | activity.binding.certificateFront.setImageBitmap(bitmap); |
| 201 | - if(isBackEffective){ | 208 | + if (isBackEffective) { |
| 202 | // activity.binding.submit.setClickable(true); | 209 | // activity.binding.submit.setClickable(true); |
| 203 | // activity.binding.submit.setTextColor(activity.getResources().getColor(R.color.white)); | 210 | // activity.binding.submit.setTextColor(activity.getResources().getColor(R.color.white)); |
| 204 | // activity.binding.submit.setBackground(getContext().getResources().getDrawable(R.drawable.bg_apply_btn)); | 211 | // activity.binding.submit.setBackground(getContext().getResources().getDrawable(R.drawable.bg_apply_btn)); |
| @@ -208,20 +215,20 @@ public class TakeIdentityPictureView extends BaseView { | @@ -208,20 +215,20 @@ public class TakeIdentityPictureView extends BaseView { | ||
| 208 | if (idCardSide.equals(IDCardParams.ID_CARD_SIDE_BACK)) { | 215 | if (idCardSide.equals(IDCardParams.ID_CARD_SIDE_BACK)) { |
| 209 | backBitmap = bitmap; | 216 | backBitmap = bitmap; |
| 210 | isBackEffective = true; | 217 | isBackEffective = true; |
| 211 | - if(TextUtils.isEmpty(idCardResult.getIssueAuthority().toString().trim()) || | ||
| 212 | - TextUtils.isEmpty(idCardResult.getSignDate().toString().trim())){ | 218 | + if (TextUtils.isEmpty(idCardResult.getIssueAuthority().toString().trim()) || |
| 219 | + TextUtils.isEmpty(idCardResult.getSignDate().toString().trim())) { | ||
| 213 | // activity.binding.submit.setClickable(false); | 220 | // activity.binding.submit.setClickable(false); |
| 214 | AlertUtil.showDeftToast(getContext(), "身份证信息读取失败,请重新拍摄"); | 221 | AlertUtil.showDeftToast(getContext(), "身份证信息读取失败,请重新拍摄"); |
| 215 | return; | 222 | return; |
| 216 | } | 223 | } |
| 217 | - try{ | 224 | + try { |
| 218 | Integer.parseInt(idCardResult.getExpiryDate().toString().trim()); | 225 | Integer.parseInt(idCardResult.getExpiryDate().toString().trim()); |
| 219 | - if(idCardResult.getExpiryDate() != null && Integer.parseInt(idCardResult.getExpiryDate().toString().trim()) < getCurrentTime()){ | 226 | + if (idCardResult.getExpiryDate() != null && Integer.parseInt(idCardResult.getExpiryDate().toString().trim()) < getCurrentTime()) { |
| 220 | // activity.binding.submit.setClickable(false); | 227 | // activity.binding.submit.setClickable(false); |
| 221 | AlertUtil.showDeftToast(getContext(), "身份证有效期失效"); | 228 | AlertUtil.showDeftToast(getContext(), "身份证有效期失效"); |
| 222 | return; | 229 | return; |
| 223 | } | 230 | } |
| 224 | - }catch (Exception e){ | 231 | + } catch (Exception e) { |
| 225 | e.printStackTrace(); | 232 | e.printStackTrace(); |
| 226 | } | 233 | } |
| 227 | 234 | ||
| @@ -234,7 +241,7 @@ public class TakeIdentityPictureView extends BaseView { | @@ -234,7 +241,7 @@ public class TakeIdentityPictureView extends BaseView { | ||
| 234 | // activity.binding.submit.setBackground(getContext().getResources().getDrawable(R.drawable.bg_apply_btn)); | 241 | // activity.binding.submit.setBackground(getContext().getResources().getDrawable(R.drawable.bg_apply_btn)); |
| 235 | } | 242 | } |
| 236 | } | 243 | } |
| 237 | - }else { | 244 | + } else { |
| 238 | // activity.binding.submit.setClickable(false); | 245 | // activity.binding.submit.setClickable(false); |
| 239 | AlertUtil.showDeftToast(getContext(), "身份证信息读取失败,请重新拍摄"); | 246 | AlertUtil.showDeftToast(getContext(), "身份证信息读取失败,请重新拍摄"); |
| 240 | } | 247 | } |
| @@ -259,34 +266,71 @@ public class TakeIdentityPictureView extends BaseView { | @@ -259,34 +266,71 @@ public class TakeIdentityPictureView extends BaseView { | ||
| 259 | return Integer.parseInt(date); | 266 | return Integer.parseInt(date); |
| 260 | } | 267 | } |
| 261 | 268 | ||
| 262 | - public File compressImage(Bitmap bitmap, String filename) { | ||
| 263 | - ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
| 264 | - bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);//质量压缩方法,这里100表示不压缩,把压缩后的数据存放到baos中 | ||
| 265 | - int options = 100; | ||
| 266 | - while (baos.toByteArray().length / 1024 > 500) { //循环判断如果压缩后图片是否大于500kb,大于继续压缩 | ||
| 267 | - baos.reset();//重置baos即清空baos | ||
| 268 | - options -= 10;//每次都减少10 | ||
| 269 | - bitmap.compress(Bitmap.CompressFormat.JPEG, options, baos);//这里压缩options%,把压缩后的数据存放到baos中 | ||
| 270 | - long length = baos.toByteArray().length; | 269 | + public void showDialog() { |
| 270 | + if (dialog == null) { | ||
| 271 | + dialog = new Dialog(activity, R.style.DialogStyle); | ||
| 272 | + View view = View.inflate(activity, R.layout.dialog_takimg, null); | ||
| 273 | + dialog.setContentView(view); | ||
| 274 | + Window window = dialog.getWindow(); | ||
| 275 | + window.setGravity(Gravity.BOTTOM); | ||
| 276 | + window.setWindowAnimations(R.style.dialogStyle); | ||
| 277 | + window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); | ||
| 278 | + dialog.show(); | ||
| 279 | + } else { | ||
| 280 | + dialog.show(); | ||
| 271 | } | 281 | } |
| 272 | - File file = new File(Environment.getExternalStorageDirectory() + "/aegis/file"); | ||
| 273 | - if (!file.exists()) { | ||
| 274 | - file.mkdirs(); | 282 | + dialog.findViewById(R.id.take_photo).setOnClickListener(view -> { |
| 283 | + dialog.dismiss(); | ||
| 284 | + takeIdCardPictures(activity, ICertificatePhohosView.ID_CAMERA_GENETAL); | ||
| 285 | + }); | ||
| 286 | + dialog.findViewById(R.id.get_img).setOnClickListener(view -> { | ||
| 287 | + dialog.dismiss(); | ||
| 288 | + showAum(); | ||
| 289 | + }); | ||
| 290 | + dialog.findViewById(R.id.cancle).setOnClickListener(view -> dialog.dismiss()); | ||
| 291 | + } | ||
| 292 | + | ||
| 293 | + /** | ||
| 294 | + * 打开相册 | ||
| 295 | + */ | ||
| 296 | + public void showAum() { | ||
| 297 | + if (!ImagePickerComUtils.isSdExist()) { | ||
| 298 | + AlertUtil.showDeftToast(getContext(), "SD卡不存在"); | ||
| 299 | + return; | ||
| 275 | } | 300 | } |
| 276 | - file = new File(Environment.getExternalStorageDirectory() + "/aegis/file/", filename + ".png"); | ||
| 277 | - try { | ||
| 278 | - FileOutputStream fos = new FileOutputStream(file); | ||
| 279 | - try { | ||
| 280 | - fos.write(baos.toByteArray()); | ||
| 281 | - fos.flush(); | ||
| 282 | - fos.close(); | ||
| 283 | - } catch (IOException e) { | ||
| 284 | - e.printStackTrace(); | 301 | + new ImagePicker.Builder() |
| 302 | + .maxNum(1) | ||
| 303 | + .maxImageSize(20 * 1024 * 1024) | ||
| 304 | + .setSelectGif(false) | ||
| 305 | + //是否需要相机 | ||
| 306 | +// .needCamera(true) | ||
| 307 | + .selectMode(PickerConfig.PICKER_IMAGE) | ||
| 308 | + .cachePath(Environment.getExternalStorageDirectory() + "/strike/file/") | ||
| 309 | + .isSinglePick(true) | ||
| 310 | + .doCrop(1, 1, 300, 300) | ||
| 311 | + .builder() | ||
| 312 | + .start(activity, 200, PickerConfig.DEFAULT_RESULT_CODE); | ||
| 313 | + } | ||
| 314 | + | ||
| 315 | + /** | ||
| 316 | + * 检测是否有人脸 | ||
| 317 | + * @param path | ||
| 318 | + */ | ||
| 319 | + public void hasFace(String path){ | ||
| 320 | + int numberOfFace = 12; | ||
| 321 | + FaceDetector myFaceDetect; | ||
| 322 | + Bitmap bitmap = BitmapFactory.decodeFile(path); | ||
| 323 | + Bitmap bitmap565 = bitmap.copy(Bitmap.Config.RGB_565, true); | ||
| 324 | + int imageWidth = bitmap565.getWidth(); | ||
| 325 | + int imageHeight = bitmap565.getHeight(); | ||
| 326 | + FaceDetector.Face[] myFace = new FaceDetector.Face[numberOfFace]; | ||
| 327 | + myFaceDetect = new FaceDetector(imageWidth, imageHeight, numberOfFace); | ||
| 328 | + int numberOfFaceDetected = myFaceDetect.findFaces(bitmap565, myFace); | ||
| 329 | + AlertUtil.showDeftToast(getContext(), "检测到"+numberOfFaceDetected+"个人脸"); | ||
| 330 | + if(numberOfFaceDetected == 1) { | ||
| 331 | + GlideUtil.init(activity, path).error(R.drawable.take_photo).into(activity.binding.takePicture); | ||
| 332 | + }else if(new File(path).exists()){ | ||
| 333 | + new File(path).delete(); | ||
| 285 | } | 334 | } |
| 286 | - } catch (FileNotFoundException e) { | ||
| 287 | - e.printStackTrace(); | ||
| 288 | - } | ||
| 289 | -// recycleBitmap(bitmap); | ||
| 290 | - return file; | ||
| 291 | } | 335 | } |
| 292 | } | 336 | } |
core/dentity_verfication/src/main/res/layout/dialog_takimg.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:layout_width="match_parent" | ||
| 4 | + android:layout_height="match_parent" | ||
| 5 | + android:background="@color/white" | ||
| 6 | + android:orientation="vertical"> | ||
| 7 | + | ||
| 8 | + <LinearLayout | ||
| 9 | + android:id="@+id/take_photo" | ||
| 10 | + android:layout_width="match_parent" | ||
| 11 | + android:layout_height="wrap_content" | ||
| 12 | + android:orientation="vertical"> | ||
| 13 | + | ||
| 14 | + <TextView | ||
| 15 | + android:layout_width="match_parent" | ||
| 16 | + android:layout_height="wrap_content" | ||
| 17 | + android:gravity="center_horizontal" | ||
| 18 | + android:padding="15dp" | ||
| 19 | + android:text="@string/tak_picture" | ||
| 20 | + android:textColor="#333333" | ||
| 21 | + android:textSize="15sp" /> | ||
| 22 | + | ||
| 23 | + <View | ||
| 24 | + android:layout_width="match_parent" | ||
| 25 | + android:layout_height="1dp" | ||
| 26 | + android:background="#f2f3f4" /> | ||
| 27 | + </LinearLayout> | ||
| 28 | + | ||
| 29 | + <LinearLayout | ||
| 30 | + android:id="@+id/get_img" | ||
| 31 | + android:layout_width="match_parent" | ||
| 32 | + android:layout_height="wrap_content" | ||
| 33 | + android:orientation="vertical"> | ||
| 34 | + | ||
| 35 | + <TextView | ||
| 36 | + android:layout_width="match_parent" | ||
| 37 | + android:layout_height="wrap_content" | ||
| 38 | + android:gravity="center_horizontal" | ||
| 39 | + android:padding="15dp" | ||
| 40 | + android:text="@string/to_picture" | ||
| 41 | + android:textColor="#333333" | ||
| 42 | + android:textSize="15sp" /> | ||
| 43 | + | ||
| 44 | + <View | ||
| 45 | + android:layout_width="match_parent" | ||
| 46 | + android:layout_height="1dp" | ||
| 47 | + android:background="#f2f3f4" /> | ||
| 48 | + </LinearLayout> | ||
| 49 | + | ||
| 50 | + <LinearLayout | ||
| 51 | + android:id="@+id/cancle" | ||
| 52 | + android:layout_width="match_parent" | ||
| 53 | + android:layout_height="wrap_content" | ||
| 54 | + android:orientation="vertical"> | ||
| 55 | + | ||
| 56 | + <View | ||
| 57 | + android:layout_width="match_parent" | ||
| 58 | + android:layout_height="10dp" | ||
| 59 | + android:background="#f2f3f4" /> | ||
| 60 | + | ||
| 61 | + <TextView | ||
| 62 | + android:layout_width="match_parent" | ||
| 63 | + android:layout_height="wrap_content" | ||
| 64 | + android:gravity="center_horizontal" | ||
| 65 | + android:padding="15dp" | ||
| 66 | + android:text="@string/cancle" | ||
| 67 | + android:textColor="#333333" | ||
| 68 | + android:textSize="15sp" /> | ||
| 69 | + </LinearLayout> | ||
| 70 | +</LinearLayout> | ||
| 0 | \ No newline at end of file | 71 | \ No newline at end of file |
core/dentity_verfication/src/main/res/values/strings.xml
| @@ -13,4 +13,7 @@ | @@ -13,4 +13,7 @@ | ||
| 13 | 13 | ||
| 14 | <string name="init_baidu_faile">初始化失败</string> | 14 | <string name="init_baidu_faile">初始化失败</string> |
| 15 | <string name="only_for_verified">仅用于实名认证</string> | 15 | <string name="only_for_verified">仅用于实名认证</string> |
| 16 | + <string name="tak_picture">拍摄</string> | ||
| 17 | + <string name="to_picture">从手机相册选择</string> | ||
| 18 | + <string name="cancle">取消</string> | ||
| 16 | </resources> | 19 | </resources> |
core/dentity_verfication/src/main/res/values/styles.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<resources> | ||
| 3 | + <style name="DialogStyle" parent="@android:style/Theme.Dialog"> | ||
| 4 | + <item name="android:windowFrame">@null</item> | ||
| 5 | + <item name="android:windowIsFloating">true</item> | ||
| 6 | + <item name="android:windowIsTranslucent">true</item> | ||
| 7 | + <item name="android:windowNoTitle">true</item> | ||
| 8 | + <item name="android:windowBackground">@android:color/transparent</item> | ||
| 9 | + <item name="android:backgroundDimEnabled">true</item> | ||
| 10 | + <item name="android:backgroundDimAmount">0.6</item> | ||
| 11 | + <item name="android:windowCloseOnTouchOutside">true</item> | ||
| 12 | + </style> | ||
| 13 | + | ||
| 14 | + <style name="dialogStyle" parent="android:Animation"> | ||
| 15 | + <item name="android:windowEnterAnimation">@anim/anim_enter</item> | ||
| 16 | + <item name="android:windowExitAnimation">@anim/anim_exit</item> | ||
| 17 | + </style> | ||
| 18 | +</resources> | ||
| 0 | \ No newline at end of file | 19 | \ No newline at end of file |