This commit is contained in:
@ -16,6 +16,8 @@ import com.gh.common.util.DialogUtils.checkDialogContext
|
||||
import com.gh.gamecenter.AboutActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.DialogAlertDefaultBinding
|
||||
import com.gh.gamecenter.databinding.DialogProgressBinding
|
||||
import splitties.systemservices.layoutInflater
|
||||
|
||||
object DialogHelper {
|
||||
|
||||
@ -162,6 +164,23 @@ object DialogHelper {
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getProgressDialog(
|
||||
context: Context,
|
||||
content: String,
|
||||
uiModificationCallback: ((binding: DialogProgressBinding) -> Unit)? = null
|
||||
): Dialog {
|
||||
val dialog = Dialog(context)
|
||||
val binding = DialogProgressBinding.inflate(context.layoutInflater)
|
||||
binding.contentTv.text = content
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
dialog.setContentView(binding.root)
|
||||
dialog.setCanceledOnTouchOutside(false)
|
||||
uiModificationCallback?.invoke(binding)
|
||||
dialog.show()
|
||||
return dialog
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun showSignatureConflictDialog(context: Context,
|
||||
confirmClickCallback: (() -> Unit)? = null) {
|
||||
|
||||
@ -88,7 +88,7 @@ object NewLogUtils {
|
||||
|
||||
/**
|
||||
* 记录实名认证结果
|
||||
* @param result 0 失败, 1 成功但未成年 2 成功且成年
|
||||
* @param result 0 失败, 1 成功但未成年 2 成功且成年 3 认证中
|
||||
*/
|
||||
fun logCertificationResult(isForced: Boolean, result: Int) {
|
||||
val json = json {
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
package com.halo.assistant.fragment.user
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Dialog
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.text.InputType
|
||||
import android.text.TextUtils
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintSet
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
@ -24,6 +26,7 @@ class RealNameInfoFragment : NormalFragment() {
|
||||
private var mHasBackdoor: Boolean = false // 是否留有不实名完成也自动开始下载的后门
|
||||
private var mIsForcedToCertificate: Boolean = false
|
||||
private val mViewModel: RealNameInfoViewModel by viewModels()
|
||||
private var mProgressDialog: Dialog? = null
|
||||
|
||||
private val mBinding: FragmentRealNameBinding by lazy {
|
||||
FragmentRealNameBinding.inflate(
|
||||
@ -48,12 +51,39 @@ class RealNameInfoFragment : NormalFragment() {
|
||||
|
||||
if (mIsForcedToCertificate || !isRealNameInfoExist()) {
|
||||
initEditingView()
|
||||
mViewModel.certificateResultLiveData.observeNonNull(viewLifecycleOwner) {
|
||||
requireActivity().setResult(
|
||||
Activity.RESULT_OK,
|
||||
Intent().putExtra(UserInfoEditFragment.AUTH_SUCCESS, true)
|
||||
)
|
||||
requireActivity().finish()
|
||||
mViewModel.certificateResultLiveData.observeNonNull(viewLifecycleOwner) { status ->
|
||||
if (status == RealNameInfoViewModel.RESULT_SUCCESS) {
|
||||
requireActivity().setResult(
|
||||
Activity.RESULT_OK,
|
||||
Intent().putExtra(UserInfoEditFragment.AUTH_SUCCESS, true)
|
||||
)
|
||||
requireActivity().finish()
|
||||
} else if (status == RealNameInfoViewModel.RESULT_PROGRESSING) {
|
||||
DialogHelper.showDialog(requireContext(),
|
||||
title = "提示",
|
||||
content = "系统繁忙,请稍后再试",
|
||||
confirmText = "前往人工审核",
|
||||
cancelText = "确定",
|
||||
confirmClickCallback = {
|
||||
startActivity(
|
||||
ShellActivity.getIntent(
|
||||
requireContext(),
|
||||
ShellActivity.Type.MANUALLY_REAL_NAME,
|
||||
Bundle().apply {
|
||||
putString(EntranceUtils.KEY_NAME, nameEt.text.toString())
|
||||
putString(EntranceUtils.KEY_ID, idCardEt.text.toString())
|
||||
}
|
||||
)
|
||||
)
|
||||
requireActivity().finish()
|
||||
},
|
||||
uiModificationCallback = {
|
||||
it.titleTv.gravity = Gravity.CENTER
|
||||
it.contentTv.gravity = Gravity.CENTER
|
||||
}
|
||||
)
|
||||
}
|
||||
mProgressDialog?.dismiss()
|
||||
}
|
||||
} else {
|
||||
initDisplayOnlyView()
|
||||
@ -210,6 +240,10 @@ class RealNameInfoFragment : NormalFragment() {
|
||||
o.put("id", mBinding.idCardEt.text.toString())
|
||||
o.put("name", mBinding.nameEt.text.toString())
|
||||
mViewModel.postCertification(o.toString(), mIsForcedToCertificate)
|
||||
mProgressDialog = DialogHelper.getProgressDialog(requireContext(), "提交中")
|
||||
.apply {
|
||||
show()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mBinding.submitBtn.alpha = 0.4F
|
||||
@ -227,12 +261,6 @@ class RealNameInfoFragment : NormalFragment() {
|
||||
if (idCard.length < 18) {
|
||||
return Pair(false, "必须使用18位的身份证号码")
|
||||
}
|
||||
val idCardRegex =
|
||||
Regex("^[1-9]\\d{5}([1-9]\\d{3})(0\\d|1[0-2])([0-2]\\d|3[0-1])\\d{3}[\\dXx]$")
|
||||
if (!idCard.matches(idCardRegex)) {
|
||||
return Pair(false, "身份证无效,请重新输入")
|
||||
}
|
||||
|
||||
return Pair(true, "")
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ import retrofit2.HttpException
|
||||
|
||||
class RealNameInfoViewModel(application: Application) : AndroidViewModel(application) {
|
||||
|
||||
val certificateResultLiveData = MutableLiveData<Boolean>()
|
||||
val certificateResultLiveData = MutableLiveData<Int>()
|
||||
|
||||
fun getUserInfo(): UserInfoEntity? {
|
||||
var userInfoEntity = UserManager.getInstance().userInfoEntity
|
||||
@ -59,11 +59,20 @@ class RealNameInfoViewModel(application: Application) : AndroidViewModel(applica
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody?>() {
|
||||
override fun onFailure(exception: Exception) {
|
||||
ErrorHelper.handleError(
|
||||
ErrorHelper.handleErrorWithCustomizedHandler(
|
||||
HaloApp.getInstance(),
|
||||
(exception as? HttpException)?.response()?.errorBody()?.string()
|
||||
)
|
||||
NewLogUtils.logCertificationResult(isForced, 0)
|
||||
) {
|
||||
if (it == 400012) {
|
||||
NewLogUtils.logCertificationResult(isForced, 3)
|
||||
certificateResultLiveData.postValue(RESULT_PROGRESSING)
|
||||
return@handleErrorWithCustomizedHandler true
|
||||
} else {
|
||||
NewLogUtils.logCertificationResult(isForced, 0)
|
||||
certificateResultLiveData.postValue(RESULT_UNQUALIFIED)
|
||||
return@handleErrorWithCustomizedHandler false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSuccess(data: ResponseBody?) {
|
||||
@ -89,7 +98,7 @@ class RealNameInfoViewModel(application: Application) : AndroidViewModel(applica
|
||||
|
||||
DataUtils.getDeviceCertification(HaloApp.getInstance().gid)
|
||||
|
||||
certificateResultLiveData.postValue(true)
|
||||
certificateResultLiveData.postValue(RESULT_SUCCESS)
|
||||
|
||||
// 安装因为实名延迟的游戏
|
||||
resumeInstallationIfNeeded()
|
||||
@ -116,4 +125,10 @@ class RealNameInfoViewModel(application: Application) : AndroidViewModel(applica
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val RESULT_SUCCESS = 1 // 认证成功,通过
|
||||
const val RESULT_UNQUALIFIED = 2 // 内容不合规,或其它
|
||||
const val RESULT_PROGRESSING = 3 // 实名认证中
|
||||
}
|
||||
|
||||
}
|
||||
BIN
app/src/main/res/drawable-xxxhdpi/spinner_progress.webp
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/spinner_progress.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
11
app/src/main/res/drawable/progressbar_gray.xml
Normal file
11
app/src/main/res/drawable/progressbar_gray.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<rotate
|
||||
android:drawable="@drawable/spinner_progress"
|
||||
android:pivotX="50%"
|
||||
android:pivotY="50%"
|
||||
android:fromDegrees="0"
|
||||
android:toDegrees="1080" />
|
||||
</item>
|
||||
</layer-list>
|
||||
28
app/src/main/res/layout/dialog_progress.xml
Normal file
28
app/src/main/res/layout/dialog_progress.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/background_shape_white_radius_6"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.core.widget.ContentLoadingProgressBar
|
||||
style="@style/Widget.Holo.ProgressBar.GH"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginStart="69dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginEnd="69dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/contentTv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:textColor="@color/text_subtitle"
|
||||
android:textSize="14sp"
|
||||
tools:text="提交中..." />
|
||||
|
||||
</LinearLayout>
|
||||
@ -244,6 +244,10 @@
|
||||
<item name="android:maxHeight">36dp</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.Holo.ProgressBar.GH" parent="android:Widget.ProgressBar.Large">
|
||||
<item name="android:indeterminateDrawable">@drawable/progressbar_gray</item>
|
||||
</style>
|
||||
|
||||
<style name="discoverItem">
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">48dp</item>
|
||||
|
||||
Reference in New Issue
Block a user