2025-10-20 10:16:44 +08:00
|
|
|
package com.xscm.moduleutil.dialog;
|
|
|
|
|
|
2025-10-24 17:52:11 +08:00
|
|
|
import static com.blankj.utilcode.util.ActivityUtils.startActivity;
|
2025-10-25 18:07:21 +08:00
|
|
|
import static com.tencent.qcloud.network.sonar.utils.Utils.isNetworkAvailable;
|
2025-10-24 17:52:11 +08:00
|
|
|
|
2025-10-20 10:16:44 +08:00
|
|
|
import android.app.Dialog;
|
|
|
|
|
import android.content.Context;
|
2025-10-24 17:52:11 +08:00
|
|
|
import android.content.Intent;
|
2025-10-20 10:16:44 +08:00
|
|
|
import android.graphics.Color;
|
|
|
|
|
import android.graphics.drawable.ColorDrawable;
|
|
|
|
|
import android.text.TextPaint;
|
|
|
|
|
import android.text.method.LinkMovementMethod;
|
|
|
|
|
import android.text.style.ClickableSpan;
|
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.databinding.DataBindingUtil;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.android.arouter.launcher.ARouter;
|
|
|
|
|
import com.blankj.utilcode.util.SpanUtils;
|
|
|
|
|
import com.xscm.moduleutil.R;
|
2025-10-24 17:52:11 +08:00
|
|
|
import com.xscm.moduleutil.activity.WebViewActivity;
|
2025-10-20 10:16:44 +08:00
|
|
|
import com.xscm.moduleutil.base.CommonAppContext;
|
|
|
|
|
import com.xscm.moduleutil.databinding.DialogPolicBinding;
|
|
|
|
|
import com.xscm.moduleutil.utils.ARouteConstants;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 隐私协议
|
|
|
|
|
*/
|
|
|
|
|
public class PolicyDialog extends Dialog {
|
|
|
|
|
private final DialogPolicBinding policBinding;
|
|
|
|
|
private PolicyClickListener mPolicyClickListener;
|
|
|
|
|
|
|
|
|
|
public PolicyDialog(@NonNull Context context) {
|
|
|
|
|
super(context);
|
|
|
|
|
policBinding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.dialog_polic, null, false);
|
|
|
|
|
policBinding.setClick(new PolicyClickProxy());
|
|
|
|
|
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
|
|
|
|
setContentView(policBinding.getRoot());
|
|
|
|
|
setCanceledOnTouchOutside(false);
|
|
|
|
|
initView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initView() {
|
|
|
|
|
SpanUtils spanUtils = new SpanUtils();
|
|
|
|
|
ClickableSpan clickSpan = new ClickableSpan() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(@NonNull View widget) {
|
2025-10-25 18:07:21 +08:00
|
|
|
// Intent intent = new Intent(getContext(), WebViewActivity.class);
|
|
|
|
|
// intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6");
|
|
|
|
|
// intent.putExtra("title", "用户协议");
|
|
|
|
|
// startActivity(intent);
|
|
|
|
|
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", "file:///android_asset/page_yongh.html").withString("title", "用户协议").navigation();
|
|
|
|
|
|
|
|
|
|
// 检查网络连接状态
|
|
|
|
|
if (isNetworkAvailable(getContext())) {
|
|
|
|
|
// 有网络时加载网络资源
|
|
|
|
|
Intent intent = new Intent(getContext(), WebViewActivity.class);
|
|
|
|
|
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6");
|
|
|
|
|
intent.putExtra("title", "用户协议");
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
} else {
|
|
|
|
|
// 无网络时加载本地资源
|
|
|
|
|
ARouter.getInstance().build(ARouteConstants.H5)
|
|
|
|
|
.withString("url", "file:///android_asset/page_yongh.html")
|
|
|
|
|
.withString("title", "用户协议")
|
|
|
|
|
.navigation();
|
|
|
|
|
}
|
2025-10-24 17:52:11 +08:00
|
|
|
|
|
|
|
|
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6" ).withString("title", "用户协议").navigation();
|
2025-10-20 10:16:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updateDrawState(@NonNull TextPaint ds) {
|
|
|
|
|
ds.setColor(Color.parseColor("#FFFFD6A2"));
|
|
|
|
|
ds.setUnderlineText(true);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
ClickableSpan ysClickSpan = new ClickableSpan() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(@NonNull View widget) {
|
2025-10-25 18:07:21 +08:00
|
|
|
// Intent intent = new Intent(getContext(), WebViewActivity.class);
|
|
|
|
|
// intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4");
|
|
|
|
|
// intent.putExtra("title", "隐私协议");
|
|
|
|
|
// startActivity(intent);
|
|
|
|
|
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", "file:///android_asset/page_show.html").withString("title", "隐私协议").navigation();
|
|
|
|
|
if (isNetworkAvailable(getContext())) {
|
|
|
|
|
Intent intent = new Intent(getContext(), WebViewActivity.class);
|
|
|
|
|
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4");
|
|
|
|
|
intent.putExtra("title", "隐私协议");
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
}else {
|
|
|
|
|
ARouter.getInstance().build(ARouteConstants.H5).withString("url", "file:///android_asset/page_show.html").withString("title", "隐私协议").navigation();
|
2025-10-24 17:52:11 +08:00
|
|
|
|
2025-10-25 18:07:21 +08:00
|
|
|
}
|
2025-10-24 17:52:11 +08:00
|
|
|
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4").withString("title", "隐私协议").navigation();
|
2025-10-20 10:16:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updateDrawState(@NonNull TextPaint ds) {
|
|
|
|
|
ds.setColor(Color.parseColor("#FFFFD6A2"));
|
|
|
|
|
ds.setUnderlineText(true);
|
|
|
|
|
}
|
|
|
|
|
};
|
2025-10-24 17:52:11 +08:00
|
|
|
spanUtils.append("欢迎使用羽声语音!\n").append("在使用我们的产品和服务之前,请您先阅读并了解").append("《用户协议》").setClickSpan(clickSpan).append("和").append("《隐私协议》").setClickSpan(ysClickSpan).append("。我们将严格按照上述协议为" +
|
2025-10-20 10:16:44 +08:00
|
|
|
"您提供服务,保护您的信息安全,点" +
|
|
|
|
|
"击“同意”即表示您已阅读并同意全部" +
|
|
|
|
|
"条款,可以继续使用我们的产品和服" +
|
|
|
|
|
"务。");
|
|
|
|
|
policBinding.tvText.setText(spanUtils.create());
|
|
|
|
|
policBinding.tvText.setMovementMethod(LinkMovementMethod.getInstance());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setPolicyClickListener(PolicyClickListener policyClickListener) {
|
|
|
|
|
this.mPolicyClickListener = policyClickListener;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class PolicyClickProxy {
|
|
|
|
|
public void onAgreeClick() {
|
|
|
|
|
if (mPolicyClickListener != null) {
|
|
|
|
|
mPolicyClickListener.policyAgree();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onExit() {
|
|
|
|
|
if (mPolicyClickListener != null) {
|
|
|
|
|
mPolicyClickListener.policyExit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface PolicyClickListener {
|
|
|
|
|
void policyAgree();
|
|
|
|
|
|
|
|
|
|
void policyExit();
|
|
|
|
|
}
|
|
|
|
|
}
|