Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
android
/
dayu
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f7851b64
authored
Nov 22, 2024
by
han xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
身份验证增加更新功能
parent
d221c9d5
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
1202 additions
and
15 deletions
baseSDK/src/main/java/com/dayu/utils/SelectPicUtils.java
orderCenter/src/main/res/drawable/icon_camera_black.png → baseSDK/src/main/res/drawable-hdpi/icon_camera_black.png
baseSDK/src/main/res/values/strings.xml
provider/src/main/java/com/dayu/provider/router/RouterPath.java
userCenter/src/main/debug/AndroidManifest.xml
userCenter/src/main/java/com/dayu/usercenter/api/UserService2.java
userCenter/src/main/java/com/dayu/usercenter/model/bean/ServiceSaveBean1.java
userCenter/src/main/java/com/dayu/usercenter/presenter/userinfo/UserInfoContract.java
userCenter/src/main/java/com/dayu/usercenter/presenter/userinfo/UserInfoPresenter.java
userCenter/src/main/java/com/dayu/usercenter/ui/activity2/CertificationUpdateActivity.java
userCenter/src/main/java/com/dayu/usercenter/ui/activity2/IDCardCameraActivity.java
userCenter/src/main/java/com/dayu/usercenter/ui/activity2/RegisterActivity.java
userCenter/src/main/java/com/dayu/usercenter/ui/activity2/UserInfoActivity.java
userCenter/src/main/java/com/dayu/usercenter/ui/fragment/view/AutoFitTextureView.java
userCenter/src/main/release/AndroidManifest.xml
userCenter/src/main/res/layout/activity_certification_update.xml
userCenter/src/main/res/layout/activity_idcard_camera.xml
userCenter/src/main/res/layout/activity_person_info.xml
userCenter/src/main/res/layout/activity_user_info.xml
baseSDK/src/main/java/com/dayu/utils/SelectPicUtils.java
View file @
f7851b64
...
...
@@ -49,6 +49,21 @@ public class SelectPicUtils {
});
}
public
static
void
selectPicOnly
(
Activity
activity
,
int
maxImgCout
,
boolean
needCrop
,
int
requestCode
,
boolean
isFree
)
{
String
[]
mPerArr
=
new
String
[]{
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
};
MPermissionUtils
.
requestPermissionsResult
(
activity
,
1
,
mPerArr
,
new
MPermissionUtils
.
OnPermissionListener
()
{
@SuppressLint
(
"CheckResult"
)
@Override
public
void
onPermissionGranted
()
{
showPicDialogsWithoutCamera
(
activity
,
maxImgCout
,
needCrop
,
requestCode
,
isFree
);
}
@Override
public
void
onPermissionDenied
()
{
}
});
}
public
static
void
showPicDialogs
(
Activity
activity
,
int
size
,
boolean
needCrop
,
int
requestCode
)
{
ImageFileCropEngine
imageFileCropEngine
=
new
ImageFileCropEngine
(
false
);
...
...
@@ -100,6 +115,45 @@ public class SelectPicUtils {
selector
.
forResult
(
requestCode
);
}
public
static
void
showPicDialogsWithoutCamera
(
Activity
activity
,
int
size
,
boolean
needCrop
,
int
requestCode
,
boolean
isFree
)
{
ImageFileCropEngine
imageFileCropEngine
=
new
ImageFileCropEngine
(
isFree
);
PictureSelectionModel
selector
=
PictureSelector
.
create
(
activity
)
.
openGallery
(
SelectMimeType
.
ofImage
())
//全部.PictureMimeType.ofAll()、图片.ofImage()、视频.ofVideo()
// .setFilterMaxFileSize(size)
.
setImageEngine
(
GlideEngine
.
createGlideEngine
())
.
setImageSpanCount
(
4
)
.
isDisplayCamera
(
false
)
.
setSelectionMode
(
SelectModeConfig
.
MULTIPLE
);
if
(!
isFree
){
selector
.
setCropEngine
(
imageFileCropEngine
);
}
// .isPreviewImage(true)
// .isDisplayCamera(true)
// .isSelectZoomAnim(true)
// .setOutputCameraDir("/CustomPath");
// PictureSelectionModel selector = PictureSelector.create(activity)
// .openGallery(PictureMimeType.ofImage())//全部.PictureMimeType.ofAll()、图片.ofImage()、视频.ofVideo()
// .maxSelectNum(size)// 最大图片选择数量 int
// .imageSpanCount(4)// 每行显示个数 int
// .selectionMode(PictureConfig.MULTIPLE)// 多选 or 单选 PictureConfig.MULTIPLE or PictureConfig.SINGLE
// .previewImage(true)// 是否可预览图片 true or false
// .isCamera(true)// 是否显示拍照按钮 true or false
// .isZoomAnim(true)// 图片列表点击 缩放效果 默认true
// .sizeMultiplier(0.1f)// glide 加载图片大小 0~1之间 如设置 .glideOverride()无效
// .setOutputCameraPath("/CustomPath")// 自定义拍、照保存路径,可不填
// .compress(true)// 是否压缩 true or false
// .glideOverride(300, 500)// int glide 加载宽高,越小图片列表越流畅,但会影响列表图片浏览的清晰度
// .hideBottomControls(true)// 是否显示uCrop工具栏,默认不显示 true or false
// .compressSavePath(getPath())//压缩图片保存地址
// .previewEggs(true)// 预览图片时 是否增强左右滑动图片体验(图片滑动一半即可看到上一张是否选中) true or false
//// .minimumCompressSize(100)// 小于100kb的图片不压缩
// .synOrAsy(true)//同步true或异步false 压缩 默认同步、
// .enableCrop(needCrop)//是否裁剪
// .freeStyleCropEnabled(needCrop);
selector
.
forResult
(
requestCode
);
}
private
static
String
getPath
()
{
String
path
=
Environment
.
getExternalStorageDirectory
()
+
"/dayu/image/"
;
File
file
=
new
File
(
path
);
...
...
orderCenter/src/main/res/drawable
/icon_camera_black.png
→
baseSDK/src/main/res/drawable-hdpi
/icon_camera_black.png
View file @
f7851b64
File moved
baseSDK/src/main/res/values/strings.xml
View file @
f7851b64
...
...
@@ -563,8 +563,12 @@
<string
name=
"real_name"
>
真实姓名
</string>
<string
name=
"person_identity"
>
身份证号
</string>
<string
name=
"person_identity_audite"
>
身份认证
</string>
<string
name=
"identity_unaudite"
>
未通过
</string>
<string
name=
"identity_audited"
>
已认证
</string>
<string
name=
"identity_unaudite"
>
未认证
</string>
<string
name=
"identity_unpass"
>
未通过
</string>
<string
name=
"identity_wait"
>
待审核
</string>
<string
name=
"identity_update"
>
更新
</string>
<string
name=
"person_identity_pic"
>
身份证照片
</string>
<string
name=
"commite_identity_pic"
>
上传身份证照片
</string>
<string
name=
"commite_pic_zero"
>
已上传0/1张
</string>
...
...
provider/src/main/java/com/dayu/provider/router/RouterPath.java
View file @
f7851b64
...
...
@@ -31,6 +31,7 @@ public class RouterPath {
public
final
static
String
PATH_WEBVIEW
=
"/user/webView"
;
public
final
static
String
PATH_REDEPLOY
=
"/user/redeploy"
;
public
final
static
String
PATH_REGISTER
=
"/user/register"
;
public
final
static
String
PATH_CERTIFICAITON_UPDATE
=
"/user/certification_update"
;
public
final
static
String
PATH_SERVER_REGISTER
=
"/user/server_register"
;
public
final
static
String
PATH_BUSINESS_TYPE
=
"/user/businessType"
;
/**
...
...
userCenter/src/main/debug/AndroidManifest.xml
View file @
f7851b64
...
...
@@ -60,6 +60,9 @@
<activity
android:name=
".ui.activity.RegisterActivity"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.activity2.IDCardCameraActivity"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.activity.CommeWebViewActivity"
...
...
userCenter/src/main/java/com/dayu/usercenter/api/UserService2.java
View file @
f7851b64
...
...
@@ -401,6 +401,13 @@ public interface UserService2 {
*/
@POST
(
Constants
.
API_7100
+
"/engineerRelationCategory/registerInfo/batch/accountId/{accountId}"
)
Observable
<
BaseResponse
<
Boolean
>>
commitData1
(
@Body
ServiceSaveBean1
saveBean
,
@Path
(
"accountId"
)
int
accountId
);
/**
* 身份验证更新照片
*/
@PUT
(
Constants
.
API_7100
+
"/engineerRelationCategory/identity"
)
Observable
<
BaseResponse
<
Boolean
>>
commitCertificationUpdate
(
@Body
ServiceSaveBean1
.
AccountIdCardExt
saveBean
);
/**
* 提交注册信息.
*/
...
...
userCenter/src/main/java/com/dayu/usercenter/model/bean/ServiceSaveBean1.java
View file @
f7851b64
...
...
@@ -24,11 +24,25 @@ public class ServiceSaveBean1 {
this
.
identityBackUrl
=
identityBackUrl
;
}
public
AccountExt
(
String
realName
)
{
this
.
realName
=
realName
;
}
}
public
static
class
AccountIdCardExt
{
private
int
accountId
;
private
String
identityUrl
;
private
String
identityBackUrl
;
public
AccountIdCardExt
(
int
accountId
,
String
identityUrl
,
String
identityBackUrl
)
{
this
.
accountId
=
accountId
;
this
.
identityUrl
=
identityUrl
;
this
.
identityBackUrl
=
identityBackUrl
;
}
}
public
ServiceSaveBean1
(
String
lowestPriceDay
,
int
provinceId
,
String
provinceName
,
int
cityId
,
String
cityName
,
int
districtId
,
String
districtName
,
List
<
Long
>
labelIds
)
{
this
.
lowestPriceDay
=
lowestPriceDay
;
...
...
userCenter/src/main/java/com/dayu/usercenter/presenter/userinfo/UserInfoContract.java
View file @
f7851b64
...
...
@@ -17,6 +17,9 @@ public interface UserInfoContract {
void
setStarRatioData
(
List
<
StarRatioBean
>
starRatios
);
void
setGlobelRate
(
GlobelRateBean
rate
);
void
setRuler
(
String
str
);
void
setcertificationStatus
(
int
status
);
}
abstract
class
Presenter
extends
BasePresenter
<
View
>
{
...
...
userCenter/src/main/java/com/dayu/usercenter/presenter/userinfo/UserInfoPresenter.java
View file @
f7851b64
...
...
@@ -29,7 +29,7 @@ public class UserInfoPresenter extends UserInfoContract.Presenter {
public
ObservableField
<
AddressInfoBean
>
addressInfo
=
new
ObservableField
<>();
// public ObservableField<Boolean> status = new ObservableField<>();
private
int
mAccountId
;
p
rivate
int
mDetectStatus
;
p
ublic
int
mDetectStatus
;
@Override
public
void
onAttached
()
{
...
...
@@ -37,6 +37,7 @@ public class UserInfoPresenter extends UserInfoContract.Presenter {
mAccountId
=
Integer
.
parseInt
(
info
.
getAccountId
());
mDetectStatus
=
info
.
getDetectStatus
();
queryInfo
(
mAccountId
);
mView
.
setcertificationStatus
(
mDetectStatus
);
}
...
...
userCenter/src/main/java/com/dayu/usercenter/ui/activity2/CertificationUpdateActivity.java
0 → 100644
View file @
f7851b64
package
com
.
dayu
.
usercenter
.
ui
.
activity2
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.text.TextUtils
;
import
com.alibaba.android.arouter.facade.annotation.Route
;
import
com.dayu.base.api.Api
;
import
com.dayu.base.api.BaseApiFactory
;
import
com.dayu.base.ui.activity.BaseActivity
;
import
com.dayu.base.ui.presenter.SImplePresenter
;
import
com.dayu.common.Constants
;
import
com.dayu.provider.event.CertificationEvent
;
import
com.dayu.provider.event.RefreshEvent
;
import
com.dayu.provider.router.RouterPath
;
import
com.dayu.usercenter.R
;
import
com.dayu.usercenter.api.UserService2
;
import
com.dayu.usercenter.databinding.ActivityCertificationUpdateBinding
;
import
com.dayu.usercenter.databinding.ActivityRegisterVerifyBinding
;
import
com.dayu.usercenter.model.bean.ServiceBean
;
import
com.dayu.usercenter.model.bean.ServiceSaveBean1
;
import
com.dayu.usercenter.model.bean.ServiceTypeBean
;
import
com.dayu.utils.CommonUtils
;
import
com.dayu.utils.GlideImageLoader
;
import
com.dayu.utils.SelectPicUtils
;
import
com.dayu.utils.ToastUtils
;
import
com.dayu.utils.UserManager
;
import
com.luck.picture.lib.basic.PictureSelector
;
import
com.luck.picture.lib.entity.LocalMedia
;
import
org.greenrobot.eventbus.EventBus
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
@Route
(
path
=
RouterPath
.
PATH_CERTIFICAITON_UPDATE
)
public
class
CertificationUpdateActivity
extends
BaseActivity
<
SImplePresenter
,
ActivityCertificationUpdateBinding
>
{
private
String
identityUrl
;
private
String
identityBackUrl
;
private
String
identityPath
;
private
String
identityBackPath
;
private
int
identityRequest
=
124
;
private
int
identityBackRequest
=
124
;
private
volatile
int
uploadImageCount
=
0
;
@Override
public
void
setPresenter
()
{
}
@Override
public
int
getLayoutId
()
{
return
R
.
layout
.
activity_certification_update
;
}
@Override
public
void
initView
()
{
initUser
();
mBind
.
receivingBack
.
setOnClickListener
(
v
->
onBackPressed
());
mBind
.
tvSubmit
.
setOnClickListener
(
v
->
saveData
());
initData
();
initRefresh
();
setListener
();
}
private
void
setListener
()
{
mBind
.
addIdentity
.
setOnClickListener
(
v
->
{
// final String[] items={"拍照","从相册选择"};
// AlertDialog dialog=new AlertDialog.Builder(mActivity).setItems(items, new DialogInterface.OnClickListener() {
//
// @Override
// public void onClick(DialogInterface dialog, int which) {
//
// switch (which){
// case 0 :{
// ToastUtils.showLongToast("相机权限使用说明: 用于拍照、录制视频等场景");
// Intent intent = new Intent(RegisterActivity.this, IDCardCameraActivity.class);
//// intent.putExtra("isBack", false);
// startActivityForResult(intent, identityRequest);
//
// break;
// }
// case 1 :{
ToastUtils
.
showLongToast
(
"相机权限使用说明: 用于拍照、录制视频等场景"
);
CommonUtils
.
hideSoftInput
(
mActivity
);
SelectPicUtils
.
selectPic
(
mActivity
,
1
,
true
,
identityRequest
,
true
);
// break;
// SelectPicUtils.selectPicOnly(mActivity, 1, true, identityRequest,true); break;
// }
// default:
//
// }
// }
// }).create();
// dialog.show();
}
);
mBind
.
addIdentityBack
.
setOnClickListener
(
v
->
{
// final String[] items={"拍照","从相册选择"};
// AlertDialog dialog=new AlertDialog.Builder(mActivity).setItems(items, new DialogInterface.OnClickListener() {
//
// @Override
// public void onClick(DialogInterface dialog, int which) {
// switch (which){
// case 0 :{
// ToastUtils.showLongToast("相机权限使用说明: 用于拍照、录制视频等场景");
// Intent intent = new Intent();
// intent.putExtra("isBack", true);
// startActivityForReult(IDCardCameraActivity.class, identityBackRequest);
//
// break;
// }
// case 1 :{
ToastUtils
.
showLongToast
(
"相机权限使用说明: 用于拍照、录制视频等场景"
);
CommonUtils
.
hideSoftInput
(
mActivity
);
SelectPicUtils
.
selectPic
(
mActivity
,
1
,
true
,
identityBackRequest
,
true
);
// SelectPicUtils.selectPicOnly(mActivity, 1, true, identityBackRequest,true);
// break;
// }
// default:
//
// }
// }
// }).create();
// dialog.show();
}
);
}
private
void
initRefresh
()
{
mBind
.
refreshLayout
.
setEnableLoadMore
(
false
);
mBind
.
refreshLayout
.
setOnRefreshListener
(
refreshLayout
->
initData
());
}
private
void
initData
()
{
showDialog
();
//已保存服务类型数据
Api
.
getService
(
UserService2
.
class
).
getEngineerInfo
(
mUserId
).
compose
(
Api
.
applySchedulers
())
.
subscribe
(
mPresenter
.
baseObserver
(
data
->
{
ServiceBean
.
AccountExt
account
=
data
.
getAccountExt
();
identityUrl
=
account
.
getIdentityUrl
();
identityBackUrl
=
account
.
getIdentityBackUrl
();
if
(!
TextUtils
.
isEmpty
(
identityUrl
))
{
GlideImageLoader
.
load
(
mActivity
,
identityUrl
,
mBind
.
idetntity
);
}
if
(!
TextUtils
.
isEmpty
(
identityBackUrl
))
{
GlideImageLoader
.
load
(
mActivity
,
identityBackUrl
,
mBind
.
idetntityBack
);
}
}));
}
//保存服务类型数据
private
void
saveData
()
{
if
(
TextUtils
.
isEmpty
(
identityUrl
)
&&
TextUtils
.
isEmpty
(
identityPath
))
{
ToastUtils
.
showShortToast
(
"请先上传身份证人像面照片"
);
return
;
}
if
(
TextUtils
.
isEmpty
(
identityBackUrl
)
&&
TextUtils
.
isEmpty
(
identityPath
))
{
ToastUtils
.
showShortToast
(
"请先上传身份证国徽面照片"
);
return
;
}
showDialog
();
if
(
TextUtils
.
isEmpty
(
identityUrl
))
{
uploadImageCount
++;
BaseApiFactory
.
uploadPhotoNew
(
BaseApiFactory
.
packPhoto
(
identityPath
),
Constants
.
PHOTO
+
"/privacy/idcard"
,
"yyMM"
)
.
subscribe
(
mPresenter
.
baseObserver
(
data
->
{
identityUrl
=
data
.
get
(
0
);
uploadImageCount
--;
save
();
}));
}
if
(
TextUtils
.
isEmpty
(
identityBackUrl
))
{
uploadImageCount
++;
BaseApiFactory
.
uploadPhotoNew
(
BaseApiFactory
.
packPhoto
(
identityBackPath
),
Constants
.
PHOTO
+
"/privacy/idcard"
,
"yyMM"
)
.
subscribe
(
mPresenter
.
baseObserver
(
data
->
{
identityBackUrl
=
data
.
get
(
0
);
uploadImageCount
--;
save
();
}));
}
}
private
void
save
()
{
if
(
uploadImageCount
!=
0
){
return
;
}
ServiceSaveBean1
.
AccountIdCardExt
accountExt
=
new
ServiceSaveBean1
.
AccountIdCardExt
(
mUserId
,
identityUrl
,
identityBackUrl
);
Api
.
getService
(
UserService2
.
class
).
commitCertificationUpdate
(
accountExt
).
compose
(
Api
.
applySchedulers
())
.
subscribe
(
mPresenter
.
baseObserver
(
bool
->
{
ToastUtils
.
showShortToast
(
bool
?
R
.
string
.
save_success
:
R
.
string
.
save_fail
);
CommonUtils
.
hideSoftInput
(
mActivity
);
EventBus
.
getDefault
().
post
(
new
CertificationEvent
(
1
));
EventBus
.
getDefault
().
post
(
new
RefreshEvent
());
finish
();
}));
}
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
if
(
resultCode
==
RESULT_OK
)
{
mBind
.
rootView
.
requestFocus
();
CommonUtils
.
hideSoftInput
(
mActivity
);
List
<
LocalMedia
>
mSelectList
=
PictureSelector
.
obtainSelectorList
(
data
);
if
(
requestCode
==
identityRequest
)
{
identityUrl
=
""
;
// identityPath = data.getStringExtra("photoPath");
if
(!
TextUtils
.
isEmpty
(
mSelectList
.
get
(
0
).
getCompressPath
()))
{
identityPath
=
mSelectList
.
get
(
0
).
getCompressPath
();
}
else
{
identityPath
=
mSelectList
.
get
(
0
).
getPath
();
if
(
identityPath
.
contains
(
"content"
)){
identityPath
=
mSelectList
.
get
(
0
).
getRealPath
();
}
}
mBind
.
idetntity
.
setImageURI
(
Uri
.
parse
(
identityPath
));
GlideImageLoader
.
load_1
(
mActivity
,
identityPath
,
mBind
.
idetntity
);
}
else
if
(
requestCode
==
identityBackRequest
)
{
identityBackUrl
=
""
;
// identityBackPath = data.getStringExtra("photoPath");
if
(!
TextUtils
.
isEmpty
(
mSelectList
.
get
(
0
).
getCompressPath
()))
{
identityBackPath
=
mSelectList
.
get
(
0
).
getCompressPath
();
}
else
{
identityBackPath
=
mSelectList
.
get
(
0
).
getPath
();
if
(
identityBackPath
.
contains
(
"content"
)){
identityBackPath
=
mSelectList
.
get
(
0
).
getRealPath
();
}
}
mBind
.
idetntityBack
.
setImageURI
(
Uri
.
parse
(
identityBackPath
));
GlideImageLoader
.
load_1
(
mActivity
,
identityBackPath
,
mBind
.
idetntityBack
);
}
}
}
}
userCenter/src/main/java/com/dayu/usercenter/ui/activity2/IDCardCameraActivity.java
0 → 100644
View file @
f7851b64
package
com
.
dayu
.
usercenter
.
ui
.
activity2
;
import
static
android
.
hardware
.
SensorManager
.
getOrientation
;
import
android.Manifest
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.graphics.ImageFormat
;
import
android.graphics.SurfaceTexture
;
import
android.hardware.camera2.CameraAccessException
;
import
android.hardware.camera2.CameraCaptureSession
;
import
android.hardware.camera2.CameraCharacteristics
;
import
android.hardware.camera2.CameraDevice
;
import
android.hardware.camera2.CameraManager
;
import
android.hardware.camera2.CaptureRequest
;
import
android.hardware.camera2.TotalCaptureResult
;
import
android.hardware.camera2.params.StreamConfigurationMap
;
import
android.media.Image
;
import
android.media.ImageReader
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Environment
;
import
android.provider.MediaStore
;
import
android.text.TextUtils
;
import
android.util.Size
;
import
android.util.SparseIntArray
;
import
android.view.Surface
;
import
android.view.TextureView
;
import
android.view.View
;
import
android.widget.Toast
;
import
androidx.annotation.NonNull
;
import
androidx.core.app.ActivityCompat
;
import
androidx.core.content.ContextCompat
;
import
androidx.core.content.FileProvider
;
import
com.dayu.base.ui.activity.BaseActivity
;
import
com.dayu.base.ui.presenter.SImplePresenter
;
import
com.dayu.usercenter.R
;
import
com.dayu.usercenter.databinding.ActivityIdcardCameraBinding
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.nio.ByteBuffer
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
public
class
IDCardCameraActivity
extends
BaseActivity
<
SImplePresenter
,
ActivityIdcardCameraBinding
>
{
///是否国徽面
public
boolean
isBack
;
private
Uri
imageUri
;
private
static
final
int
REQUEST_CAMERA_PERMISSION
=
200
;
private
CameraDevice
cameraDevice
;
private
CameraCaptureSession
cameraCaptureSession
;
private
CaptureRequest
.
Builder
captureRequestBuilder
;
private
Size
imageDimension
;
private
ImageReader
imageReader
;
private
static
final
SparseIntArray
ORIENTATIONS
=
new
SparseIntArray
();
///为了使照片竖直显示
static
{
ORIENTATIONS
.
append
(
Surface
.
ROTATION_0
,
90
);
ORIENTATIONS
.
append
(
Surface
.
ROTATION_90
,
0
);
ORIENTATIONS
.
append
(
Surface
.
ROTATION_180
,
270
);
ORIENTATIONS
.
append
(
Surface
.
ROTATION_270
,
180
);
}
@Override
public
void
setPresenter
()
{
}
@Override
public
int
getLayoutId
()
{
return
R
.
layout
.
activity_idcard_camera
;
}
@Override
public
void
initView
()
{
mBind
.
titleBack
.
setOnClickListener
(
v
->
onBackPressed
());
if
(
isBack
){
mBind
.
title
.
setText
(
"请拍摄身份证国徽面"
);
mBind
.
imageCardRect
.
setImageResource
(
R
.
drawable
.
btn_blue_whitecontent
);
}
else
{
mBind
.
title
.
setText
(
"请拍摄身份证人像面"
);
mBind
.
imageCardRect
.
setImageResource
(
R
.
drawable
.
btn_red_rect_bord
);
}
mBind
.
cameraButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
takePicture
();
}
});
openCamera
();
}
private
TextureView
.
SurfaceTextureListener
textureListener
=
new
TextureView
.
SurfaceTextureListener
()
{
@Override
public
void
onSurfaceTextureAvailable
(
SurfaceTexture
surfaceTexture
,
int
width
,
int
height
)
{
openCamera
();
}
@Override
public
void
onSurfaceTextureSizeChanged
(
SurfaceTexture
surfaceTexture
,
int
width
,
int
height
)
{
}
@Override
public
boolean
onSurfaceTextureDestroyed
(
SurfaceTexture
surfaceTexture
)
{
return
false
;
}
@Override
public
void
onSurfaceTextureUpdated
(
SurfaceTexture
surfaceTexture
)
{
}
};
private
final
CameraDevice
.
StateCallback
stateCallback
=
new
CameraDevice
.
StateCallback
()
{
@Override
public
void
onOpened
(
@NonNull
CameraDevice
camera
)
{
cameraDevice
=
camera
;
createCameraPreview
();
}
@Override
public
void
onDisconnected
(
@NonNull
CameraDevice
camera
)
{
cameraDevice
.
close
();
}
@Override
public
void
onError
(
@NonNull
CameraDevice
camera
,
int
error
)
{
cameraDevice
.
close
();
cameraDevice
=
null
;
}
};
private
void
openCamera
()
{
CameraManager
manager
=
(
CameraManager
)
getSystemService
(
Context
.
CAMERA_SERVICE
);
try
{
String
cameraId
=
manager
.
getCameraIdList
()[
0
];
CameraCharacteristics
characteristics
=
manager
.
getCameraCharacteristics
(
cameraId
);
StreamConfigurationMap
map
=
characteristics
.
get
(
CameraCharacteristics
.
SCALER_STREAM_CONFIGURATION_MAP
);
imageDimension
=
map
.
getOutputSizes
(
SurfaceTexture
.
class
)[
0
];
//默认是横向输出 所以设置预览图需要宽高对调
mBind
.
textureView
.
setAspectRatio
(
imageDimension
.
getHeight
(),
imageDimension
.
getWidth
());
if
(
ContextCompat
.
checkSelfPermission
(
this
,
Manifest
.
permission
.
CAMERA
)
!=
PackageManager
.
PERMISSION_GRANTED
)
{
ActivityCompat
.
requestPermissions
(
this
,
new
String
[]{
Manifest
.
permission
.
CAMERA
},
REQUEST_CAMERA_PERMISSION
);
return
;
}
manager
.
openCamera
(
cameraId
,
stateCallback
,
null
);
}
catch
(
CameraAccessException
e
)
{
e
.
printStackTrace
();
}
}
private
void
createCameraPreview
()
{
try
{
SurfaceTexture
texture
=
mBind
.
textureView
.
getSurfaceTexture
();
assert
texture
!=
null
;
texture
.
setDefaultBufferSize
(
imageDimension
.
getWidth
(),
imageDimension
.
getHeight
());
Surface
surface
=
new
Surface
(
texture
);
captureRequestBuilder
=
cameraDevice
.
createCaptureRequest
(
CameraDevice
.
TEMPLATE_PREVIEW
);
captureRequestBuilder
.
addTarget
(
surface
);
cameraDevice
.
createCaptureSession
(
Arrays
.
asList
(
surface
),
new
CameraCaptureSession
.
StateCallback
()
{
@Override
public
void
onConfigured
(
@NonNull
CameraCaptureSession
cameraCaptureSession
)
{
if
(
cameraDevice
==
null
)
return
;
IDCardCameraActivity
.
this
.
cameraCaptureSession
=
cameraCaptureSession
;
updatePreview
();
}
@Override
public
void
onConfigureFailed
(
@NonNull
CameraCaptureSession
cameraCaptureSession
)
{
}
},
null
);
}
catch
(
CameraAccessException
e
)
{
e
.
printStackTrace
();
}
}
private
void
updatePreview
()
{
if
(
cameraDevice
==
null
)
return
;
captureRequestBuilder
.
set
(
CaptureRequest
.
CONTROL_MODE
,
CaptureRequest
.
CONTROL_MODE_AUTO
);
try
{
cameraCaptureSession
.
setRepeatingRequest
(
captureRequestBuilder
.
build
(),
null
,
null
);
}
catch
(
CameraAccessException
e
)
{
e
.
printStackTrace
();
}
}
private
void
takePicture
()
{
if
(
cameraDevice
==
null
)
return
;
CameraManager
manager
=
(
CameraManager
)
getSystemService
(
Context
.
CAMERA_SERVICE
);
try
{
CameraCharacteristics
characteristics
=
manager
.
getCameraCharacteristics
(
cameraDevice
.
getId
());
Size
[]
jpegSizes
=
null
;
if
(
characteristics
!=
null
)
{
jpegSizes
=
characteristics
.
get
(
CameraCharacteristics
.
SCALER_STREAM_CONFIGURATION_MAP
).
getOutputSizes
(
ImageFormat
.
JPEG
);
}
int
width
=
640
;
int
height
=
480
;
if
(
jpegSizes
!=
null
&&
jpegSizes
.
length
>
0
)
{
width
=
jpegSizes
[
0
].
getWidth
();
height
=
jpegSizes
[
0
].
getHeight
();
}
ImageReader
reader
=
ImageReader
.
newInstance
(
width
,
height
,
ImageFormat
.
JPEG
,
1
);
List
<
Surface
>
outputSurfaces
=
new
ArrayList
<>(
2
);
outputSurfaces
.
add
(
reader
.
getSurface
());
outputSurfaces
.
add
(
new
Surface
(
mBind
.
textureView
.
getSurfaceTexture
()));
final
CaptureRequest
.
Builder
captureBuilder
=
cameraDevice
.
createCaptureRequest
(
CameraDevice
.
TEMPLATE_STILL_CAPTURE
);
captureBuilder
.
addTarget
(
reader
.
getSurface
());
captureBuilder
.
set
(
CaptureRequest
.
CONTROL_MODE
,
CaptureRequest
.
CONTROL_MODE_AUTO
);
// Orientation
int
rotation
=
getWindowManager
().
getDefaultDisplay
().
getRotation
();
captureBuilder
.
set
(
CaptureRequest
.
JPEG_ORIENTATION
,
ORIENTATIONS
.
get
(
rotation
));
File
storageDir
=
getExternalFilesDir
(
Environment
.
DIRECTORY_PICTURES
);
// File file = new File(Environment.getExternalStorageDirectory() + "/pic.jpg");
File
image
=
null
;
try
{
image
=
File
.
createTempFile
(
"idcard"
,
/* prefix */
".jpg"
,
/* suffix */
storageDir
/* directory */
);
}
catch
(
IOException
e
)
{
// Error occurred while creating the File
e
.
printStackTrace
();
}
File
file
=
image
;
ImageReader
.
OnImageAvailableListener
readerListener
=
new
ImageReader
.
OnImageAvailableListener
()
{
@Override
public
void
onImageAvailable
(
ImageReader
reader
)
{
Image
image
=
null
;
try
{
image
=
reader
.
acquireLatestImage
();
ByteBuffer
buffer
=
image
.
getPlanes
()[
0
].
getBuffer
();
byte
[]
bytes
=
new
byte
[
buffer
.
capacity
()];
buffer
.
get
(
bytes
);
save
(
bytes
);
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
image
!=
null
)
{
image
.
close
();
}
}
}
private
void
save
(
byte
[]
bytes
)
throws
IOException
{
OutputStream
output
=
null
;
try
{
output
=
new
FileOutputStream
(
file
);
output
.
write
(
bytes
);
}
catch
(
IOException
e
){
e
.
printStackTrace
();
}
finally
{
if
(
output
!=
null
)
{
output
.
close
();
}
}
}
};
reader
.
setOnImageAvailableListener
(
readerListener
,
null
);
final
CameraCaptureSession
.
CaptureCallback
captureListener
=
new
CameraCaptureSession
.
CaptureCallback
()
{
@Override
public
void
onCaptureCompleted
(
CameraCaptureSession
session
,
CaptureRequest
request
,
TotalCaptureResult
result
)
{
super
.
onCaptureCompleted
(
session
,
request
,
result
);
String
photoPath
=
file
.
getPath
();
if
(!
TextUtils
.
isEmpty
(
photoPath
)){
Intent
intent
=
new
Intent
();
intent
.
putExtra
(
"photoPath"
,
photoPath
);
setResult
(
RESULT_OK
,
intent
);
finish
();
}
// Toast.makeText(IDCardCameraActivity.this, "Saved: " + file, Toast.LENGTH_SHORT).show();
// createCameraPreview();
}
};
cameraDevice
.
createCaptureSession
(
outputSurfaces
,
new
CameraCaptureSession
.
StateCallback
()
{
@Override
public
void
onConfigured
(
@NonNull
CameraCaptureSession
session
)
{
try
{
session
.
capture
(
captureBuilder
.
build
(),
captureListener
,
null
);
}
catch
(
CameraAccessException
e
)
{
e
.
printStackTrace
();
}
}
@Override
public
void
onConfigureFailed
(
@NonNull
CameraCaptureSession
session
)
{
}
},
null
);
}
catch
(
CameraAccessException
e
)
{
e
.
printStackTrace
();
}
}
@Override
public
void
onRequestPermissionsResult
(
int
requestCode
,
@NonNull
String
[]
permissions
,
@NonNull
int
[]
grantResults
)
{
super
.
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
if
(
requestCode
==
REQUEST_CAMERA_PERMISSION
)
{
if
(
grantResults
[
0
]
==
PackageManager
.
PERMISSION_DENIED
)
{
Toast
.
makeText
(
this
,
"Sorry!!!, you can't use this app without granting permission"
,
Toast
.
LENGTH_LONG
).
show
();
finish
();
}
}
}
@Override
public
void
onPause
()
{
super
.
onPause
();
if
(
cameraDevice
!=
null
)
{
cameraDevice
.
close
();
cameraDevice
=
null
;
}
}
}
userCenter/src/main/java/com/dayu/usercenter/ui/activity2/RegisterActivity.java
View file @
f7851b64
package
com
.
dayu
.
usercenter
.
ui
.
activity2
;
import
android.app.AlertDialog
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.text.TextUtils
;
...
...
@@ -84,16 +86,70 @@ public class RegisterActivity extends BaseActivity<SImplePresenter, ActivityRegi
SelectPicUtils
.
selectPic
(
mActivity
,
1
,
true
,
headerRequest
,
false
);
});
mBind
.
addIdentity
.
setOnClickListener
(
v
->
{
// final String[] items={"拍照","从相册选择"};
// AlertDialog dialog=new AlertDialog.Builder(mActivity).setItems(items, new DialogInterface.OnClickListener() {
//
// @Override
// public void onClick(DialogInterface dialog, int which) {
//
// switch (which){
// case 0 :{
// ToastUtils.showLongToast("相机权限使用说明: 用于拍照、录制视频等场景");
// Intent intent = new Intent(RegisterActivity.this, IDCardCameraActivity.class);
//// intent.putExtra("isBack", false);
// startActivityForResult(intent, identityRequest);
//
// break;
// }
// case 1 :{
ToastUtils
.
showLongToast
(
"相机权限使用说明: 用于拍照、录制视频等场景"
);
CommonUtils
.
hideSoftInput
(
mActivity
);
SelectPicUtils
.
selectPic
(
mActivity
,
1
,
true
,
identityRequest
,
true
);
CommonUtils
.
hideSoftInput
(
mActivity
);
SelectPicUtils
.
selectPic
(
mActivity
,
1
,
true
,
identityRequest
,
true
);
// break;
// SelectPicUtils.selectPicOnly(mActivity, 1, true, identityRequest,true); break;
// }
// default:
//
// }
// }
// }).create();
// dialog.show();
}
);
mBind
.
addIdentityBack
.
setOnClickListener
(
v
->
{
ToastUtils
.
showLongToast
(
"相机权限使用说明: 用于拍照、录制视频等场景"
);
CommonUtils
.
hideSoftInput
(
mActivity
);
SelectPicUtils
.
selectPic
(
mActivity
,
1
,
true
,
identityBackRequest
,
true
);
}
// final String[] items={"拍照","从相册选择"};
// AlertDialog dialog=new AlertDialog.Builder(mActivity).setItems(items, new DialogInterface.OnClickListener() {
//
// @Override
// public void onClick(DialogInterface dialog, int which) {
// switch (which){
// case 0 :{
// ToastUtils.showLongToast("相机权限使用说明: 用于拍照、录制视频等场景");
// Intent intent = new Intent();
// intent.putExtra("isBack", true);
// startActivityForReult(IDCardCameraActivity.class, identityBackRequest);
//
// break;
// }
// case 1 :{
ToastUtils
.
showLongToast
(
"相机权限使用说明: 用于拍照、录制视频等场景"
);
CommonUtils
.
hideSoftInput
(
mActivity
);
SelectPicUtils
.
selectPic
(
mActivity
,
1
,
true
,
identityBackRequest
,
true
);
// SelectPicUtils.selectPicOnly(mActivity, 1, true, identityBackRequest,true);
// break;
// }
// default:
//
// }
// }
// }).create();
// dialog.show();
}
);
}
...
...
@@ -172,25 +228,32 @@ public class RegisterActivity extends BaseActivity<SImplePresenter, ActivityRegi
showDialog
();
if
(
TextUtils
.
isEmpty
(
identityUrl
))
{
uploadImageCount
++;
BaseApiFactory
.
uploadPhotoNew
(
BaseApiFactory
.
packPhoto
(
identityPath
),
Constants
.
PHOTO
+
"/privacy/idcard"
,
"yyMM"
)
.
subscribe
(
mPresenter
.
baseObserver
(
data
->
{
identityUrl
=
data
.
get
(
0
);
uploadImageCount
--;
save
();
}));
}
if
(
TextUtils
.
isEmpty
(
identityBackUrl
))
{
uploadImageCount
++;
BaseApiFactory
.
uploadPhotoNew
(
BaseApiFactory
.
packPhoto
(
identityBackPath
),
Constants
.
PHOTO
+
"/privacy/idcard"
,
"yyMM"
)
.
subscribe
(
mPresenter
.
baseObserver
(
data
->
{
identityBackUrl
=
data
.
get
(
0
);
uploadImageCount
--;
save
();
}));
}
if
(
TextUtils
.
isEmpty
(
accountUrl
))
{
uploadImageCount
++;
BaseApiFactory
.
uploadPhotoNew
(
BaseApiFactory
.
packPhoto
(
accountPath
),
Constants
.
PHOTO
+
"/privacy/head"
,
"yyMM"
)
.
subscribe
(
mPresenter
.
baseObserver
(
imgs
->
{
accountUrl
=
imgs
.
get
(
0
);
uploadImageCount
--;
save
();
}));
}
...
...
@@ -221,8 +284,9 @@ public class RegisterActivity extends BaseActivity<SImplePresenter, ActivityRegi
mBind
.
rootView
.
requestFocus
();
CommonUtils
.
hideSoftInput
(
mActivity
);
List
<
LocalMedia
>
mSelectList
=
PictureSelector
.
obtainSelectorList
(
data
);
if
(
mSelectList
!=
null
&&
mSelectList
.
size
()
>
0
)
{
if
(
requestCode
==
headerRequest
)
{
if
(
requestCode
==
headerRequest
)
{
if
(
mSelectList
!=
null
&&
mSelectList
.
size
()
>
0
){
accountUrl
=
""
;
if
(!
TextUtils
.
isEmpty
(
mSelectList
.
get
(
0
).
getCompressPath
()))
{
accountPath
=
mSelectList
.
get
(
0
).
getCompressPath
();
...
...
@@ -231,8 +295,12 @@ public class RegisterActivity extends BaseActivity<SImplePresenter, ActivityRegi
}
mBind
.
header
.
setImageURI
(
Uri
.
parse
(
accountPath
));
GlideImageLoader
.
load
(
mActivity
,
accountPath
,
mBind
.
header
);
}
else
if
(
requestCode
==
identityRequest
)
{
}
}
else
{
if
(
requestCode
==
identityRequest
)
{
identityUrl
=
""
;
// identityPath = data.getStringExtra("photoPath");
if
(!
TextUtils
.
isEmpty
(
mSelectList
.
get
(
0
).
getCompressPath
()))
{
identityPath
=
mSelectList
.
get
(
0
).
getCompressPath
();
}
else
{
...
...
@@ -241,10 +309,11 @@ public class RegisterActivity extends BaseActivity<SImplePresenter, ActivityRegi
identityPath
=
mSelectList
.
get
(
0
).
getRealPath
();
}
}
mBind
.
idetntity
.
setImageURI
(
Uri
.
parse
(
identityPath
));
GlideImageLoader
.
load_1
(
mActivity
,
identityPath
,
mBind
.
idetntity
);
}
}
else
if
(
requestCode
==
identityBackRequest
)
{
identityBackUrl
=
""
;
}
else
if
(
requestCode
==
identityBackRequest
)
{
identityBackUrl
=
""
;
// identityBackPath = data.getStringExtra("photoPath")
;
if
(!
TextUtils
.
isEmpty
(
mSelectList
.
get
(
0
).
getCompressPath
()))
{
identityBackPath
=
mSelectList
.
get
(
0
).
getCompressPath
();
}
else
{
...
...
@@ -253,7 +322,9 @@ public class RegisterActivity extends BaseActivity<SImplePresenter, ActivityRegi
identityBackPath
=
mSelectList
.
get
(
0
).
getRealPath
();
}
}
GlideImageLoader
.
load_1
(
mActivity
,
identityBackPath
,
mBind
.
idetntityBack
);
mBind
.
idetntityBack
.
setImageURI
(
Uri
.
parse
(
identityBackPath
));
GlideImageLoader
.
load_1
(
mActivity
,
identityBackPath
,
mBind
.
idetntityBack
);
}
}
}
}
...
...
userCenter/src/main/java/com/dayu/usercenter/ui/activity2/UserInfoActivity.java
View file @
f7851b64
...
...
@@ -2,7 +2,10 @@ package com.dayu.usercenter.ui.activity2;
import
android.graphics.Color
;
import
android.view.View
;
import
android.widget.LinearLayout
;
import
android.widget.RelativeLayout
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.alibaba.android.arouter.launcher.ARouter
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
...
...
@@ -22,6 +25,7 @@ import com.dayu.usercenter.presenter.userinfo.UserInfoContract;
import
com.dayu.usercenter.presenter.userinfo.UserInfoPresenter
;
import
com.dayu.usercenter.ui.activity.PersonInfoActivity
;
import
com.dayu.utils.CommonUtils
;
import
com.dayu.utils.ToastUtils
;
import
com.dayu.utils.UserManager
;
import
com.dayu.widgets.CustomDialog
;
import
com.dayu.widgets.RegisterDialog
;
...
...
@@ -54,6 +58,7 @@ public class UserInfoActivity extends BaseActivity<UserInfoPresenter, ActivityUs
public
void
initView
()
{
mBind
.
rlUser
.
setOnClickListener
(
view
->
startActivity
(
PersonInfoActivity
.
class
));
mBind
.
rlBank
.
setOnClickListener
(
view
->
toEditBank
());
mBind
.
certification
.
setOnClickListener
(
view
->
updateCertification
());
mBind
.
rlAddress
.
setOnClickListener
(
view
->
startActivity
(
EditAddressActivity
.
class
));
mBind
.
tvHotLine
.
setOnClickListener
(
view
->
CommonUtils
.
dialPhone
(
this
,
getString
(
R
.
string
.
customer_hot_line2
)));
mPresenter
.
getRuler
();
...
...
@@ -64,6 +69,57 @@ public class UserInfoActivity extends BaseActivity<UserInfoPresenter, ActivityUs
showInfoDialog
();
}
///身份认证
private
void
updateCertification
(){
switch
(
mPresenter
.
mDetectStatus
){
case
1
:
//跳转更新页面
ARouter
.
getInstance
().
build
(
RouterPath
.
PATH_CERTIFICAITON_UPDATE
).
navigation
();
break
;
case
2
:
case
3
:
//跳转注册页面
ARouter
.
getInstance
().
build
(
RouterPath
.
PATH_REGISTER
).
navigation
();
break
;
case
4
:
ToastUtils
.
showLongToast
(
"请等待审核"
);
break
;
default
:
break
;
}
}
@Override
public
void
setcertificationStatus
(
int
status
){
RelativeLayout
.
LayoutParams
params
=
new
RelativeLayout
.
LayoutParams
(
RelativeLayout
.
LayoutParams
.
WRAP_CONTENT
,
RelativeLayout
.
LayoutParams
.
WRAP_CONTENT
);
params
.
addRule
(
RelativeLayout
.
ALIGN_PARENT_RIGHT
,
RelativeLayout
.
TRUE
);
switch
(
status
){
case
1
:
//已认证
mBind
.
identityAudited
.
setText
(
R
.
string
.
identity_audited
);
params
.
setMarginEnd
(
0
);
break
;
case
2
:
//未认证
mBind
.
identityAudited
.
setText
(
R
.
string
.
identity_unaudite
);
params
.
setMarginEnd
(
60
);
break
;
case
3
:
//未通过
mBind
.
identityAudited
.
setText
(
R
.
string
.
identity_unpass
);
params
.
setMarginEnd
(
60
);
break
;
case
4
:
//待审核
params
.
setMarginEnd
(
0
);
mBind
.
identityAudited
.
setText
(
R
.
string
.
identity_wait
);
break
;
default
:
break
;
}
mBind
.
identityAudited
.
setLayoutParams
(
params
);
}
@Override
public
void
onResume
()
{
super
.
onResume
();
...
...
userCenter/src/main/java/com/dayu/usercenter/ui/fragment/view/AutoFitTextureView.java
0 → 100644
View file @
f7851b64
package
com
.
dayu
.
usercenter
.
ui
.
fragment
.
view
;
import
android.content.Context
;
import
android.util.AttributeSet
;
import
android.view.TextureView
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
public
class
AutoFitTextureView
extends
TextureView
{
private
static
final
String
TAG
=
"AutoFitTextureView"
;
private
int
mRatioWidth
=
0
;
private
int
mRatioHeight
=
0
;
public
AutoFitTextureView
(
@NonNull
Context
context
)
{
super
(
context
);
}
public
AutoFitTextureView
(
@NonNull
Context
context
,
@Nullable
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
}
public
AutoFitTextureView
(
@NonNull
Context
context
,
@Nullable
AttributeSet
attrs
,
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
);
}
public
AutoFitTextureView
(
@NonNull
Context
context
,
@Nullable
AttributeSet
attrs
,
int
defStyleAttr
,
int
defStyleRes
)
{
super
(
context
,
attrs
,
defStyleAttr
,
defStyleRes
);
}
public
void
setAspectRatio
(
int
width
,
int
height
)
{
if
(
width
<
0
||
height
<
0
)
{
throw
new
IllegalArgumentException
(
"Size cannot be negative."
);
}
mRatioWidth
=
width
;
mRatioHeight
=
height
;
requestLayout
();
}
@Override
protected
void
onMeasure
(
int
widthMeasureSpec
,
int
heightMeasureSpec
)
{
super
.
onMeasure
(
widthMeasureSpec
,
heightMeasureSpec
);
int
width
=
MeasureSpec
.
getSize
(
widthMeasureSpec
);
int
height
=
MeasureSpec
.
getSize
(
heightMeasureSpec
);
if
(
mRatioWidth
==
0
||
mRatioHeight
==
0
){
setMeasuredDimension
(
width
,
height
);
}
else
{
//横屏
if
(
width
<
height
*
mRatioWidth
/
mRatioHeight
)
{
setMeasuredDimension
(
width
,
width
*
mRatioHeight
/
mRatioWidth
);
}
//竖屏
else
{
setMeasuredDimension
(
height
*
mRatioWidth
/
mRatioHeight
,
height
);
}
}
}
}
userCenter/src/main/release/AndroidManifest.xml
View file @
f7851b64
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
package=
"com.dayu.usercenter"
>
<uses-permission
android:name=
"android.permission.CAMERA"
/>
<application
android:allowBackup=
"true"
android:label=
"@string/app_name"
...
...
@@ -128,6 +130,13 @@
android:name=
".ui.activity2.RegisterActivity"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.activity2.IDCardCameraActivity"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.activity2.CertificationUpdateActivity"
android:screenOrientation=
"portrait"
tools:ignore=
"Instantiatable"
/>
<activity
android:name=
".ui.activity2.ServerRegisterActivity"
android:screenOrientation=
"portrait"
/>
</application>
...
...
userCenter/src/main/res/layout/activity_certification_update.xml
0 → 100644
View file @
f7851b64
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
>
<RelativeLayout
android:id=
"@+id/rootView"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:focusable=
"true"
android:focusableInTouchMode=
"true"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<RelativeLayout
android:id=
"@+id/title_back"
style=
"@style/title"
>
<TextView
android:id=
"@+id/tv_title"
style=
"@style/text_title"
android:text=
"@string/person_identity_audite"
/>
<ImageView
android:id=
"@+id/receiving_back"
style=
"@style/title_image_back"
/>
</RelativeLayout>
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id=
"@+id/refresh_layout"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_marginBottom=
"65dp"
>
<androidx.core.widget.NestedScrollView
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:gravity=
"center"
android:orientation=
"vertical"
android:paddingTop=
"10dp"
>
<TextView
style=
"@style/sale_item_text"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:background=
"@color/color_ee"
android:gravity=
"center"
android:paddingEnd=
"10dp"
android:paddingTop=
"5dp"
android:paddingBottom=
"5dp"
android:text=
"请确认您的身份证照片:"
android:textColor=
"@color/default_text_color"
android:textSize=
"16dp"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:gravity=
"center"
android:orientation=
"horizontal"
android:paddingTop=
"20dp"
>
<LinearLayout
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"2"
android:gravity=
"center"
>
<ImageView
android:id=
"@+id/idetntity"
android:layout_width=
"172dp"
android:layout_height=
"108dp"
android:src=
"@drawable/iicon_register_identity"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/addIdentity"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"center"
android:orientation=
"vertical"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"+"
android:textColor=
"@color/common_text_color"
android:textSize=
"30dp"
/>
<TextView
style=
"@style/sale_item_text"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center"
android:paddingEnd=
"10dp"
android:text=
"上传/拍照"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:gravity=
"center"
android:orientation=
"horizontal"
android:paddingTop=
"20dp"
>
<LinearLayout
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"2"
android:gravity=
"center"
>
<ImageView
android:id=
"@+id/idetntityBack"
android:layout_width=
"172dp"
android:layout_height=
"108dp"
android:src=
"@drawable/iicon_register_identity_back"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/addIdentityBack"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"center"
android:orientation=
"vertical"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"+"
android:textColor=
"@color/common_text_color"
android:textSize=
"30dp"
/>
<TextView
style=
"@style/sale_item_text"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center"
android:paddingEnd=
"10dp"
android:text=
"上传/拍照"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</LinearLayout>
<TextView
android:id=
"@+id/tv_submit"
style=
"@style/btn_bottom_common"
android:layout_alignParentBottom=
"true"
android:layout_marginStart=
"20dp"
android:layout_marginTop=
"20dp"
android:layout_marginEnd=
"20dp"
android:layout_marginBottom=
"20dp"
android:text=
"提交"
/>
</RelativeLayout>
</layout>
\ No newline at end of file
userCenter/src/main/res/layout/activity_idcard_camera.xml
0 → 100644
View file @
f7851b64
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ImageView
android:id=
"@+id/title_back"
style=
"@style/title_image_back"
android:layout_centerVertical=
"false"
android:layout_marginTop=
"@dimen/dp_20"
/>
<com.dayu.usercenter.ui.fragment.view.AutoFitTextureView
android:id=
"@+id/texture_view"
android:layout_centerVertical=
"true"
android:layout_centerHorizontal=
"true"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
tools:ignore=
"MissingConstraints"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_centerVertical=
"true"
android:id=
"@+id/card_rect"
android:layout_centerHorizontal=
"true"
android:layout_height=
"wrap_content"
android:layout_width=
"match_parent"
>
<ImageView
android:id=
"@+id/image_card_rect"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_marginRight=
"@dimen/dp_60"
android:layout_marginLeft=
"@dimen/dp_60"
android:layout_centerVertical=
"false"
android:src=
"@drawable/btn_red_rect_bord"
tools:ignore=
"MissingConstraints"
app:layout_constraintDimensionRatio=
"H,4:3"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id=
"@+id/title"
style=
"@style/text_title"
android:text=
"请拍摄身份证国徽面"
android:layout_above=
"@+id/card_rect"
android:layout_marginBottom=
"@dimen/dp_20"
/>
<Button
android:id=
"@+id/camera_button"
android:layout_width=
"100dp"
android:layout_height=
"100dp"
android:layout_centerHorizontal=
"true"
android:layout_marginBottom=
"@dimen/dp_30"
android:layout_alignParentBottom=
"true"
android:background=
"@drawable/icon_camera_black"
/>
</RelativeLayout>
</layout>
\ No newline at end of file
userCenter/src/main/res/layout/activity_person_info.xml
View file @
f7851b64
...
...
@@ -150,6 +150,7 @@
android:layout_height=
"50dp"
android:background=
"@color/white"
android:gravity=
"center_vertical"
android:visibility=
"gone"
android:orientation=
"horizontal"
>
<TextView
...
...
userCenter/src/main/res/layout/activity_user_info.xml
View file @
f7851b64
...
...
@@ -295,6 +295,51 @@
android:visibility=
"gone"
/>
</RelativeLayout>
<RelativeLayout
android:id=
"@+id/certification"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"5dp"
android:padding=
"@dimen/dp_15"
android:background=
"@color/cl_white"
>
<TextView
style=
"@style/user_info_text"
android:text=
"@string/person_identity_audite"
android:textStyle=
"bold"
/>
<ImageView
android:id=
"@+id/img_cert_arrow"
android:layout_width=
"15dp"
android:layout_height=
"15dp"
android:layout_alignParentEnd=
"true"
android:layout_centerVertical=
"true"
android:src=
"@drawable/icon_arrow_right"
android:visibility=
"@{(presenter.mDetectStatus==2 || presenter.mDetectStatus==3)?View.VISIBLE:View.GONE}"
/>
<TextView
android:id=
"@+id/identity_audited"
style=
"@style/user_info_text"
android:text=
"@string/identity_audited"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentEnd=
"true"
/>
<TextView
android:id=
"@+id/btn_update"
style=
"@style/user_info_text"
android:layout_toStartOf=
"@id/identity_audited"
android:text=
"@string/identity_update"
android:visibility=
"@{presenter.mDetectStatus==1?View.VISIBLE:View.GONE}"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"@dimen/dp_30"
android:textColor=
"@color/text_common_blue"
/>
</RelativeLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment