1:修改页面的图标
This commit is contained in:
103
app/src/main/java/com/jdf/myyuliao/AppContext.java
Normal file
103
app/src/main/java/com/jdf/myyuliao/AppContext.java
Normal file
@@ -0,0 +1,103 @@
|
||||
package com.jdf.myyuliao;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
|
||||
|
||||
/**
|
||||
* Created by cxf on 2017/8/3.
|
||||
*/
|
||||
|
||||
public class AppContext extends CommonAppContext {
|
||||
|
||||
private boolean mBeautyInited;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
ToastUtils.init(this);
|
||||
ARouter.init(this);
|
||||
|
||||
/* mqttClient = MyMQTTClient.getInstance(this);
|
||||
mqttClient.initialize("tcp://81.70.45.221:1883");
|
||||
new Thread(() -> {
|
||||
boolean connected = mqttClient.connect();
|
||||
runOnUiThread(() -> {
|
||||
if (connected) {
|
||||
} else {
|
||||
com.blankj.utilcode.util.ToastUtils.showShort("MQTT连接失败");
|
||||
}
|
||||
});
|
||||
}).start();*/
|
||||
|
||||
// ToastUtils.setInterceptor(new IToastInterceptor() {
|
||||
// @Override
|
||||
// public boolean intercept(CharSequence charSequence) {
|
||||
// return !CommonAppContext.getInstance().isFront();
|
||||
// }
|
||||
// });
|
||||
// L.setDeBug(BuildConfig.DEBUG);
|
||||
}
|
||||
public static void initSdk() {
|
||||
// CommonAppContext context = CommonAppContext.getInstance();
|
||||
|
||||
// if (BuildConfig.DEBUG) {
|
||||
// L.e("应用签名:" + context.getAppSignature());
|
||||
// //L.e("facebook散列秘钥------>" + context.getFacebookHashKey());
|
||||
// }
|
||||
// //腾讯云直播鉴权url
|
||||
// String liveLicenceUrl = "https://license.vod2.myqcloud.com/license/v2/1346816652_1/v_cube.license";
|
||||
// //腾讯云直播鉴权key
|
||||
// String liveKey = "c30f209835056ba00f738a014ca4448a";
|
||||
// //腾讯云视频鉴权url
|
||||
// String ugcLicenceUrl = "https://license.vod2.myqcloud.com/license/v2/1346816652_1/v_cube.license";
|
||||
// //腾讯云视频鉴权key
|
||||
// String ugcKey = "c30f209835056ba00f738a014ca4448a";
|
||||
// TXLiveBase.getInstance().setDebug(BuildConfig.DEBUG);
|
||||
// TXLiveBase.getInstance().setLicence(context, liveLicenceUrl, liveKey, ugcLicenceUrl, ugcKey);
|
||||
// //初始化腾讯bugly
|
||||
// CrashReport.initCrashReport(context);
|
||||
// CrashReport.setAppVersion(context, CommonAppConfig.getInstance().getVersion());
|
||||
// //初始化ShareSdk
|
||||
// MobSDK.init(context);
|
||||
// MobSDK.submitPolicyGrantResult(true);
|
||||
// //初始化IM
|
||||
// ImMessageUtil.getInstance().init();
|
||||
// //初始化腾讯TPNS 移动推送
|
||||
// TpnsUtil.register(BuildConfig.DEBUG);
|
||||
// //初始化友盟统计
|
||||
// UmengUtil.init(context, BuildConfig.DEBUG);
|
||||
// //OpenInstall
|
||||
// OpenInstall.init(context);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化美狐
|
||||
*/
|
||||
public void initBeautySdk(String beautyAppId, String beautyKey) {
|
||||
// if (!TextUtils.isEmpty(beautyAppId) && !TextUtils.isEmpty(beautyKey)) {
|
||||
// if (!mBeautyInited) {
|
||||
// mBeautyInited = true;
|
||||
// if (CommonAppConfig.isYunBaoApp()) {
|
||||
// beautyAppId = DecryptUtil.decrypt(beautyAppId);
|
||||
// beautyKey = DecryptUtil.decrypt(beautyKey);
|
||||
// }
|
||||
// MHSDK.init(this, beautyAppId, beautyKey);
|
||||
// CommonAppConfig.getInstance().setMhBeautyEnable(true);
|
||||
// L.e("美狐初始化----AppId--->" + beautyAppId + "---AppKey--->" + beautyKey);
|
||||
// }
|
||||
// } else {
|
||||
// CommonAppConfig.getInstance().setMhBeautyEnable(false);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startInitSdk() {
|
||||
initSdk();
|
||||
}
|
||||
|
||||
}
|
||||
20
app/src/main/java/com/jdf/myyuliao/LaunchContacter.java
Normal file
20
app/src/main/java/com/jdf/myyuliao/LaunchContacter.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.jdf.myyuliao;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
|
||||
public final class LaunchContacter {
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
|
||||
}
|
||||
|
||||
public interface ILoginPre extends IPresenter {
|
||||
|
||||
void oauthLogin(String login_token);
|
||||
|
||||
void address_ip(String address_ip);
|
||||
}
|
||||
}
|
||||
153
app/src/main/java/com/jdf/myyuliao/LaunchPageActivity.java
Normal file
153
app/src/main/java/com/jdf/myyuliao/LaunchPageActivity.java
Normal file
@@ -0,0 +1,153 @@
|
||||
package com.jdf.myyuliao;
|
||||
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.PersistableBundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.jdf.myyuliao.databinding.ActivityLaunchPageBinding;
|
||||
import com.xscm.modulelogin.activity.ImproveInfoActivity;
|
||||
import com.xscm.moduleutil.activity.BaseAppCompatActivity;
|
||||
import com.xscm.moduleutil.base.AppStateListener;
|
||||
import com.xscm.moduleutil.base.AppStateManager;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.dialog.PolicyDialog;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
public class LaunchPageActivity extends BaseAppCompatActivity<ActivityLaunchPageBinding> {
|
||||
private Handler handler;
|
||||
private PolicyDialog policyDialog;
|
||||
private AppStateListener appStateListener;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
|
||||
super.onCreate(savedInstanceState, persistentState);
|
||||
|
||||
// 获取Application实例并设置监听器
|
||||
CommonAppContext app = (CommonAppContext) getApplication();
|
||||
appStateListener = AppStateManager.getInstance();
|
||||
app.setAppStateListener(appStateListener);
|
||||
|
||||
if (!isTaskRoot()) {
|
||||
|
||||
if (SpUtil.getUnderagePassword() != null && !SpUtil.getUnderagePassword().isEmpty()) {
|
||||
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/feedback/teenage?id=" + SpUtil.getToken())
|
||||
.withString("type", "1").navigation();//type==1:青少年模式
|
||||
} else {
|
||||
// 如果没有设置青少年模式,应该导航到首页
|
||||
try {
|
||||
ARouter.getInstance().build(ARouteConstants.ME).navigation();
|
||||
} catch (Exception e) {
|
||||
Log.e("LaunchPageActivity", "导航到首页失败", e);
|
||||
}
|
||||
}
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
// if (shouldRestoreRoom()) {
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页").withString("roomId", CommonAppContext.getInstance().playId).navigation();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
private boolean shouldRestoreRoom() {
|
||||
// 检查是否应该恢复房间:
|
||||
// 1. 应用有正在播放的房间
|
||||
// 2. 应用应该显示房间
|
||||
// 3. 应用是从后台恢复的(通过检查 CommonAppContext 状态)
|
||||
return CommonAppContext.getInstance().isPlaying
|
||||
&& CommonAppContext.getInstance().isShow;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
handler = new Handler();
|
||||
// 定义一个Runnable
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
initLogin();
|
||||
}
|
||||
};
|
||||
if (SpUtil.isAgreePolicy()) {
|
||||
initLogin();
|
||||
// //延迟1.5秒执行
|
||||
// handler.postDelayed(runnable, 2500);
|
||||
} else {
|
||||
policyDialog = new PolicyDialog(this);
|
||||
policyDialog.setCancelable(false);
|
||||
policyDialog.setCanceledOnTouchOutside(false);
|
||||
policyDialog.setPolicyClickListener(new PolicyDialog.PolicyClickListener() {
|
||||
@Override
|
||||
public void policyAgree() {
|
||||
SpUtil.completeAgreePolicy();
|
||||
// CommonAppContext.getInstance().initialization();
|
||||
initLogin();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void policyExit() {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
policyDialog.show();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
// 如果 PolicyDialog 仍在显示,则 dismiss 它
|
||||
if (policyDialog != null && policyDialog.isShowing()) {
|
||||
policyDialog.dismiss();
|
||||
policyDialog = null;
|
||||
}
|
||||
|
||||
// 移除所有待处理的回调以防止内存泄漏
|
||||
if (handler != null) {
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
|
||||
}
|
||||
|
||||
private void initLogin() {
|
||||
// 在启动新 Activity 前先关闭对话框
|
||||
if (policyDialog != null && policyDialog.isShowing()) {
|
||||
policyDialog.dismiss();
|
||||
policyDialog = null;
|
||||
}
|
||||
startActivity(new Intent(this, PasswordLoginActivity.class));
|
||||
finish();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_launch_page;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (!isTaskRoot()) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
99
app/src/main/java/com/jdf/myyuliao/LaunchPresenter.java
Normal file
99
app/src/main/java/com/jdf/myyuliao/LaunchPresenter.java
Normal file
@@ -0,0 +1,99 @@
|
||||
package com.jdf.myyuliao;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.xscm.modulelogin.activity.ImproveInfoActivity;
|
||||
import com.xscm.modulelogin.activity.SwitchAccountsActivity;
|
||||
import com.xscm.modulemain.activity.MainActivity;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.UserBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class LaunchPresenter extends BasePresenter<LaunchContacter.View> implements LaunchContacter.ILoginPre {
|
||||
|
||||
public LaunchPresenter(LaunchContacter.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void oauthLogin(String login_token) {
|
||||
api.oauthLogin(login_token, new BaseObserver<List<UserBean>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<UserBean> userBeans) {
|
||||
loginSuccess(userBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void address_ip(String address_ip) {
|
||||
api.address_ip(address_ip, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void loginSuccess(List<UserBean> userBean) {
|
||||
if (userBean==null) {
|
||||
ToastUtils.showShort("登录失败请重试");
|
||||
return;
|
||||
}
|
||||
if (userBean.size()==1) {
|
||||
|
||||
CommonAppContext.getInstance().setUser(userBean.get(0));
|
||||
|
||||
// PreferencesUtils.putString( CommonAppContext.getInstance(), "mobile", userBean.get());
|
||||
|
||||
if (isViewAttach()) {
|
||||
// MvpRef.get().disLoadings();
|
||||
}
|
||||
if (userBean.get(0).getSex() == 0) {
|
||||
try {
|
||||
Intent intent = new Intent(com.blankj.utilcode.util.ActivityUtils.getTopActivity(), ImproveInfoActivity.class);
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable("userBean", userBean.get(0));
|
||||
intent.putExtras(bundle);
|
||||
com.blankj.utilcode.util.ActivityUtils.startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
com.blankj.utilcode.util.ActivityUtils.startActivity(MainActivity.class);
|
||||
}
|
||||
}else {
|
||||
Intent intent=new Intent(com.blankj.utilcode.util.ActivityUtils.getTopActivity(), SwitchAccountsActivity.class);
|
||||
Bundle bundle=new Bundle();
|
||||
bundle.putSerializable("userBean", userBean.get(0));
|
||||
intent.putExtras(bundle);
|
||||
com.blankj.utilcode.util.ActivityUtils.startActivity(intent);
|
||||
|
||||
}
|
||||
EventBus.getDefault().post(userBean);
|
||||
// EventBus.getDefault().post(new SplashFinishEvent());
|
||||
// AppLog.setUserUniqueID(userBean.getUser_id()); // 设置您自己的账号体系ID, 并保证其唯一性 !
|
||||
}
|
||||
}
|
||||
627
app/src/main/java/com/jdf/myyuliao/PasswordLoginActivity.java
Normal file
627
app/src/main/java/com/jdf/myyuliao/PasswordLoginActivity.java
Normal file
@@ -0,0 +1,627 @@
|
||||
package com.jdf.myyuliao;
|
||||
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.PasswordTransformationMethod;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alipay.sdk.app.AuthTask;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.ThreadUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.jdf.myyuliao.databinding.ActivityPasswordLoginBinding;
|
||||
import com.mobile.auth.gatewayauth.AuthUIConfig;
|
||||
import com.mobile.auth.gatewayauth.PhoneNumberAuthHelper;
|
||||
import com.mobile.auth.gatewayauth.PreLoginResultListener;
|
||||
import com.mobile.auth.gatewayauth.TokenResultListener;
|
||||
import com.mobile.auth.gatewayauth.model.TokenRet;
|
||||
import com.xscm.modulelogin.activity.ImproveInfoActivity;
|
||||
import com.xscm.modulelogin.even.LoginFinishEvent;
|
||||
import com.xscm.modulelogin.present.LoginContacter;
|
||||
import com.xscm.modulelogin.present.LoginPresenter;
|
||||
import com.xscm.modulemain.activity.MainActivity;
|
||||
import com.xscm.moduleutil.activity.BaseMvpActivity;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.ThemeBean;
|
||||
import com.xscm.moduleutil.bean.UserBean;
|
||||
import com.xscm.moduleutil.utils.BarUtils;
|
||||
import com.xscm.moduleutil.utils.PreferencesUtils;
|
||||
import com.xscm.moduleutil.utils.logger.Logger;
|
||||
import com.tencent.mm.opensdk.modelbase.BaseResp;
|
||||
import com.tencent.mm.opensdk.modelmsg.SendAuth;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class PasswordLoginActivity extends BaseMvpActivity<LoginPresenter, ActivityPasswordLoginBinding> implements LoginContacter.View, View.OnClickListener {
|
||||
|
||||
private CountDownTimer mTimer;
|
||||
public String mobile;
|
||||
private int type;//1:验证码登录2:密码登录
|
||||
boolean isPasswordVisible = false;
|
||||
public PhoneNumberAuthHelper phoneNumberAuthHelper;
|
||||
private TokenResultListener tokenResultListener;
|
||||
private boolean canOnePass;
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_password_login;
|
||||
}
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
// 检查是否已经创建过该Activity
|
||||
if (!isTaskRoot()) {
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
String action = intent.getAction();
|
||||
// 如果是从Launcher启动的,并且Activity已经存在,则finish当前实例
|
||||
if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(action)) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
// EventBus.getDefault().register(this);
|
||||
// AppLogUtil.reportAppLog(AppLogEvent.A0101);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
EventBus.getDefault().unregister(this);
|
||||
if (phoneNumberAuthHelper!=null) {
|
||||
phoneNumberAuthHelper.hideLoginLoading();
|
||||
//获取成功 dimiss就去登录、登录成功
|
||||
phoneNumberAuthHelper.quitLoginPage();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void finishEvent(LoginFinishEvent event) {
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
super.initView();
|
||||
MvpPre.getThemeData();
|
||||
initQuickLogin();
|
||||
checkOnePass();
|
||||
|
||||
BarUtils.setStatusBarAlpha(this, 0);
|
||||
mBinding.edPhone.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
setUpLoginBtn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
mBinding.edPhone.setOnFocusChangeListener(new View.
|
||||
OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (mBinding.edPhone == null) {
|
||||
return;
|
||||
}
|
||||
if (hasFocus) {
|
||||
mBinding.relPhone.setSelected(true);
|
||||
} else {
|
||||
// 此处为失去焦点时的处理内容
|
||||
mBinding.relPhone.setSelected(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
mBinding.edPhone.setText(PreferencesUtils.getString(CommonAppContext.getInstance(), "mobile"));
|
||||
if (!TextUtils.isEmpty(mobile)) {
|
||||
mBinding.edPhone.setText(mobile);
|
||||
}
|
||||
mBinding.tvCodeText.setOnClickListener(this::onClick);
|
||||
mBinding.flLogin.setOnClickListener(this::onClick);
|
||||
mBinding.tvYhxy.setOnClickListener(this::onClick);
|
||||
mBinding.tvYsxy.setOnClickListener(this::onClick);
|
||||
mBinding.ivZfb.setOnClickListener(this::onClick);
|
||||
mBinding.ivWeixin.setOnClickListener(this::onClick);
|
||||
mBinding.tvSendCode.setOnClickListener(this::onClick);
|
||||
mBinding.ivEye.setOnClickListener(this::onClick);
|
||||
|
||||
if (mBinding.tvCodeText.getText().equals("切换密码登录")){
|
||||
type=1;
|
||||
}else {
|
||||
type=2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initQuickLogin() {
|
||||
tokenResultListener = new TokenResultListener() {
|
||||
@Override
|
||||
public void onTokenSuccess(String s) {
|
||||
Logger.e("onTokenSuccess", s);
|
||||
ThreadUtils.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TokenRet tokenRet = null;
|
||||
try {
|
||||
tokenRet = JSON.parseObject(s, TokenRet.class);
|
||||
if (tokenRet != null && ("600000").equals(tokenRet.getCode())) {
|
||||
|
||||
LogUtils.e("@@@",tokenRet.getToken());
|
||||
MvpPre.oauthLoginLogin(tokenRet.getToken());
|
||||
// phoneNumberAuthHelper.hideLoginLoading();
|
||||
// //获取成功 dimiss就去登录、登录成功
|
||||
// phoneNumberAuthHelper.quitLoginPage();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTokenFailed(String s) {
|
||||
Logger.e("onTokenFailed", s);
|
||||
ThreadUtils.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
phoneNumberAuthHelper.hideLoginLoading();
|
||||
phoneNumberAuthHelper.quitLoginPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
phoneNumberAuthHelper = PhoneNumberAuthHelper.getInstance(getApplicationContext(), null);
|
||||
phoneNumberAuthHelper.getReporter().setLoggerEnable(true);
|
||||
// phoneNumberAuthHelper.setAuthSDKInfo("6rdWuz058oq5OahdbFiGEybUcdahd12J83L34Uc7MrPIrxtFG+rXiwDvRcqNvjwbClbbmvMrmxKVkIysFByBsl0Qe9kqd2w8T/nhK5G6eXXlk2V9AjYCieIU+jRnjZBB+Cfechr6rCGJ2aeBARIsXcRPW7wm9WFK9euh5T+v6Pyte68yNaNdcYCll3+U4/uCEog7HygCnMIbAU+kqoPdmn2H+51YOHW+VsnsHd4w1+I3f8Tt0xLIXGM4GWnQueZ5GR46GTWiSYMy8dCIh9SPIMRyC91GosVcfGPMJSdcXqc=");
|
||||
phoneNumberAuthHelper.setAuthSDKInfo(((CommonAppContext) getApplication()).getCurrentEnvironment().getALI_AUTH_KEY());
|
||||
phoneNumberAuthHelper.checkEnvAvailable(2);
|
||||
|
||||
} catch (Throwable ignored) {
|
||||
Logger.e("initAuthSDK", ignored);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void checkOnePass() {
|
||||
if (!TextUtils.isEmpty(CommonAppContext.getInstance().getToken()) && !TextUtils.isEmpty(CommonAppContext.getInstance().getUser().getTencent_im())) {
|
||||
isRoot();
|
||||
return;
|
||||
}
|
||||
showLoadings();
|
||||
if (phoneNumberAuthHelper != null) {
|
||||
phoneNumberAuthHelper.accelerateLoginPage(3 * 1000, new PreLoginResultListener() {
|
||||
@Override
|
||||
public void onTokenSuccess(String s) {
|
||||
Logger.e("onTokenSuccess", s);
|
||||
canOnePass = true;
|
||||
isRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTokenFailed(String s, String s1) {
|
||||
Logger.e("onTokenFailed", "错误信息" + s, s1);
|
||||
isRoot();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
canOnePass = false;
|
||||
isRoot();
|
||||
}
|
||||
}
|
||||
|
||||
private void isRoot() {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
disLoadings();
|
||||
if (!PasswordLoginActivity.this.isTaskRoot()) {
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
String action = intent.getAction();
|
||||
if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(action)) {
|
||||
finish();
|
||||
} else {
|
||||
goNextActivity();
|
||||
}
|
||||
} else {
|
||||
goNextActivity();
|
||||
}
|
||||
} else {
|
||||
goNextActivity();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void goNextActivity() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
if (isFinishing() || isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (TextUtils.isEmpty(CommonAppContext.getInstance().getToken()) || TextUtils.isEmpty(CommonAppContext.getInstance().getUser().getTencent_im())) {
|
||||
Logger.e("SplashEnd", "ARouters.CODE_LOGIN");
|
||||
if (canOnePass) {
|
||||
phoneNumberAuthHelper.setAuthListener(tokenResultListener);
|
||||
doOnePass();
|
||||
} else {
|
||||
|
||||
}
|
||||
} else {
|
||||
Logger.e("SplashEnd", "ARouters.MAIN");
|
||||
|
||||
UserBean userBean = CommonAppContext.getInstance().getUser();
|
||||
|
||||
// TUILogin.login(getBaseContext(), CommonAppContext.getInstance().getCurrentEnvironment().getSdkAppId(), "u"+userBean.getUser_id(), userBean.getTencent_im(), new TUICallback() {
|
||||
// @Override
|
||||
// public void onError(final int code, final String desc) {
|
||||
// LogUtils.e("@@@",code,"描述:",desc);
|
||||
// }
|
||||
// @Override
|
||||
// public void onSuccess() {
|
||||
// LogUtils.e("@@@","成功");
|
||||
//
|
||||
// }
|
||||
// });
|
||||
if (userBean.getSex() == 0) {
|
||||
Intent intent = new Intent(this, ImproveInfoActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable("userBean", userBean);
|
||||
intent.putExtras(bundle);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
} else {
|
||||
EventBus.getDefault().post(userBean);
|
||||
startActivity(new Intent(this, MainActivity.class));
|
||||
finish();
|
||||
}
|
||||
// finish();
|
||||
}
|
||||
}
|
||||
|
||||
private void doOnePass() {
|
||||
AuthUIConfig authUIConfig = new AuthUIConfig.Builder()
|
||||
//导航栏
|
||||
.setNavColor(Color.TRANSPARENT)
|
||||
.setNavReturnHidden(true)
|
||||
.setNavHidden(true)
|
||||
.setNavText("")
|
||||
.setNavTextColor(Color.BLACK)
|
||||
.setWebNavColor(Color.TRANSPARENT)
|
||||
.setWebNavTextColor(Color.BLACK)
|
||||
.setWebNavReturnImgPath("ic_topbar_back_dark")
|
||||
//状态栏区
|
||||
.setStatusBarColor(Color.TRANSPARENT)
|
||||
.setLightColor(false)
|
||||
.setWebViewStatusBarColor(Color.TRANSPARENT)
|
||||
.setStatusBarUIFlag(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
|
||||
//logo区
|
||||
.setLogoImgPath("login_log")
|
||||
.setLogoWidth(142)
|
||||
.setLogoHeight(142)
|
||||
.setLogoOffsetY(54)
|
||||
.setLogoHidden(false)
|
||||
.setLogoScaleType(ImageView.ScaleType.FIT_XY)
|
||||
//Slogan
|
||||
.setSloganText("本机号码")
|
||||
.setSloganTextColor(Color.parseColor("#A8A8A8"))
|
||||
.setSloganTextSize(12)
|
||||
.setSloganOffsetY(236)
|
||||
//掩码栏
|
||||
.setNumberColor(Color.BLACK)
|
||||
.setNumberSize(30)
|
||||
.setNumFieldOffsetY(263)
|
||||
.setNumberLayoutGravity(Gravity.CENTER_HORIZONTAL)
|
||||
//登录按钮
|
||||
.setLogBtnText("一键登录")
|
||||
.setLogBtnWidth(300)
|
||||
.setLogBtnHeight(42)
|
||||
.setLogBtnOffsetY(325)
|
||||
.setLogBtnTextSize(14)
|
||||
.setLogBtnTextColor(getResources().getColor(R.color.white))
|
||||
.setLogBtnBackgroundPath("theme_bg")
|
||||
//切换到其他方式
|
||||
.setSwitchAccText("其他登录方式")
|
||||
.setSwitchAccTextColor(Color.parseColor("#333333"))
|
||||
.setSwitchAccTextSize(12)
|
||||
.setSwitchOffsetY(390)
|
||||
//协议栏
|
||||
.setAppPrivacyOne("《用户协议》", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6")
|
||||
.setAppPrivacyTwo("《隐私协议》", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4")
|
||||
.setAppPrivacyColor(Color.parseColor("#A8A8A8"), Color.parseColor("#FFBC00"))
|
||||
.setPrivacyBefore("登录即代表同意")
|
||||
.setPrivacyEnd("并授权获得号码")
|
||||
.setPrivacyTextSize(11)
|
||||
.setPrivacyAlertContentVerticalMargin(20)
|
||||
.setPrivacyMargin(39)
|
||||
.setPrivacyState(true)
|
||||
.setCheckboxHidden(false)
|
||||
.setCheckedImgPath("ic_agreement_selected")
|
||||
.setUncheckedImgPath("ic_agreement_unselect")
|
||||
.setPrivacyOffsetX(2)
|
||||
.setVendorPrivacyPrefix("《")
|
||||
.setVendorPrivacySuffix("》")
|
||||
.setProtocolAction("com.xscm.qxlive.PROTOCOL_WEBVIEW")//跳转到自定义的页面展示隐私协议
|
||||
.setPackageName("com.xscm.qxlive")
|
||||
//全页面属性
|
||||
.setAuthPageActIn("in_activity", "out_activity")
|
||||
.setAuthPageActOut("in_activity", "out_activity")
|
||||
.setPageBackgroundPath("log_bj")
|
||||
.create();
|
||||
phoneNumberAuthHelper.setAuthUIConfig(authUIConfig);
|
||||
phoneNumberAuthHelper.getLoginToken(getApplicationContext(), 5000);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LoginPresenter bindPresenter() {
|
||||
return new LoginPresenter(this, this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void showLoadings() {
|
||||
showLoading();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disLoadings() {
|
||||
disLoading();
|
||||
}
|
||||
|
||||
private void setUpLoginBtn() {
|
||||
String text = mBinding.edPhone.getText().toString();
|
||||
if (text.length() == 11) {
|
||||
mBinding.flLogin.setEnabled(true);
|
||||
mBinding.ivLoginBg.setAlpha(1f);
|
||||
} else {
|
||||
mBinding.ivLoginBg.setAlpha(0.3f);
|
||||
mBinding.flLogin.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
if (id == R.id.tv_code_text) {
|
||||
// Intent intent = new Intent(this, LoginActivity.class);
|
||||
// intent.putExtra("mobile", mBinding.edPhone.getText().toString());
|
||||
// startActivity(intent);
|
||||
// finish();
|
||||
|
||||
if (mBinding.tvCodeText.getText().equals("切换密码登录")){
|
||||
mBinding.rlPassCode.setVisibility(VISIBLE);
|
||||
mBinding.rlCode.setVisibility(View.GONE);
|
||||
mBinding.tvCodeText.setText("切换验证码登录");
|
||||
mBinding.tvLoginText.setText("密码登录");
|
||||
type=2;
|
||||
}else {
|
||||
mBinding.rlPassCode.setVisibility(View.GONE);
|
||||
mBinding.rlCode.setVisibility(VISIBLE);
|
||||
mBinding.tvCodeText.setText("切换密码登录");
|
||||
mBinding.tvLoginText.setText("验证码登录");
|
||||
type=1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (id == R.id.fl_login) {
|
||||
if (!mBinding.cbPrivacy.isChecked()) {
|
||||
ToastUtils.show("请先勾选服务条款");
|
||||
return;
|
||||
}
|
||||
String phone = mBinding.edPhone.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phone)) {
|
||||
com.blankj.utilcode.util.ToastUtils.showShort("请输入手机号");
|
||||
return;
|
||||
}
|
||||
if (type==1) {
|
||||
String code = mBinding.edPassword.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(code)) {
|
||||
com.blankj.utilcode.util.ToastUtils.showShort("请输入验证码");
|
||||
return;
|
||||
}
|
||||
MvpPre.login(phone, "", code, 1);
|
||||
}else if (type==2) {
|
||||
String password = mBinding.edPasswordCode.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(password)) {
|
||||
com.blankj.utilcode.util.ToastUtils.showShort("请输入密码");
|
||||
return;
|
||||
}
|
||||
MvpPre.login(phone, password, "", 2);
|
||||
}
|
||||
|
||||
} else if (id == R.id.tv_yhxy) {
|
||||
MvpPre.ysxl();
|
||||
} else if (id == R.id.tv_ysxy) {
|
||||
MvpPre.yhxy();
|
||||
} else if (id == R.id.iv_zfb) {
|
||||
if (!mBinding.cbPrivacy.isChecked()) {
|
||||
ToastUtils.show("请先勾选服务条款");
|
||||
return;
|
||||
}
|
||||
MvpPre.authorization("zfb");
|
||||
// MvpPre.authorization(SHARE_MEDIA.QQ);
|
||||
} else if (id == R.id.iv_weixin) {
|
||||
if (!mBinding.cbPrivacy.isChecked()) {
|
||||
ToastUtils.show("请先勾选服务条款");
|
||||
return;
|
||||
}
|
||||
// MvpPre.authorization("wx");
|
||||
wcLogin();
|
||||
} else if (id == R.id.tv_send_code) {
|
||||
String phone = mBinding.edPhone.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phone)) {
|
||||
com.blankj.utilcode.util.ToastUtils.showShort("请输入手机号");
|
||||
return;
|
||||
}
|
||||
sendCodeSuccess(phone);
|
||||
MvpPre.sendCode(phone, 1);
|
||||
}else if (id == R.id.iv_eye) {
|
||||
|
||||
if (!isPasswordVisible) {
|
||||
mBinding.edPassword.setInputType(android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
|
||||
mBinding.ivEye.setImageResource(com.xscm.moduleutil.R.mipmap.eye_visible); // 设置按钮文本为隐藏密码
|
||||
} else {
|
||||
mBinding.edPassword.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
mBinding.edPassword.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||
mBinding.ivEye.setImageResource(com.xscm.moduleutil.R.mipmap.eye_close); // 设置按钮文本为显示密码
|
||||
}
|
||||
mBinding.edPassword.setSelection(mBinding.edPassword.getText().length()); // 将光标移动到文字末尾
|
||||
isPasswordVisible = !isPasswordVisible; // 切换状态
|
||||
}
|
||||
}
|
||||
private void wcLogin() {
|
||||
//发起登陆请求前先注册微信api
|
||||
IWXAPI api = WXAPIFactory.createWXAPI(this,CommonAppContext.getInstance().getCurrentEnvironment().getWxAppId(),true);
|
||||
api.registerApp(CommonAppContext.getInstance().getCurrentEnvironment().getWxAppId());
|
||||
if (!api.isWXAppInstalled()){
|
||||
//todo 提醒未安装微信
|
||||
com.blankj.utilcode.util.ToastUtils.showShort("请安装微信客户端");
|
||||
return;
|
||||
}
|
||||
//开始发起登陆请求
|
||||
final SendAuth.Req req = new SendAuth.Req();
|
||||
req.scope = "snsapi_userinfo";
|
||||
req.state = "wechat_sdk_demo_test";
|
||||
api.sendReq(req);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void loginEvent(BaseResp event) {
|
||||
if (event.errCode ==BaseResp.ErrCode.ERR_OK){
|
||||
SendAuth.Resp authResp = (SendAuth.Resp)event;
|
||||
LogUtils.e("@@@",authResp.code);
|
||||
MvpPre.oauthLogin(authResp.code,1);
|
||||
}
|
||||
}
|
||||
private void releaseTimer() {
|
||||
if (mTimer != null) {
|
||||
mTimer.cancel();
|
||||
mTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void sendCodeSuccess(String phoneNumber) {
|
||||
com.blankj.utilcode.util.ToastUtils.showShort("短信验证码发送成功请注意查收");
|
||||
mBinding.tvSendCode.setEnabled(false);
|
||||
mBinding.tvSendCode.setAlpha(0.5f);
|
||||
releaseTimer();
|
||||
if (mTimer != null) {
|
||||
mTimer.cancel();
|
||||
}
|
||||
mTimer = new CountDownTimer(60000L, 1000L) {
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
if (mBinding.tvSendCode != null) {
|
||||
mBinding.tvSendCode.setText(String.format("重新发送(%s)", millisUntilFinished / 1000));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
mBinding.tvSendCode.setAlpha(1f);
|
||||
mBinding.tvSendCode.setEnabled(true);
|
||||
mBinding.tvSendCode.setText("重新发送");
|
||||
}
|
||||
};
|
||||
mTimer.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCodeSuccess1(String s) {
|
||||
LogUtils.e(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loginSuccess(UserBean userBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void authorizationSuccess(String s) {
|
||||
zfbLogin(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ysxlSuccess(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getThemeData(ThemeBean themeBean) {
|
||||
|
||||
}
|
||||
|
||||
private void zfbLogin(String s) {
|
||||
LogUtils.e("@@@",s);
|
||||
CommonAppContext.getInstance();
|
||||
if (!CommonAppContext.isAlipayInstalled(this)){
|
||||
com.blankj.utilcode.util.ToastUtils.showShort("请安装支付宝客户端");
|
||||
return;
|
||||
}
|
||||
String authInfo = s;
|
||||
// String authInfo = "apiname=com.alipay.account.auth&app_id=2021005152631691&app_name=yusheng&auth_type=AUTHACCOUNT&biz_type=openservice&method=alipay.open.auth.sdk.code.get&pid=2088170624624316&product_id=APP_FAST_LOGIN&scope=kuaijie&sign_type=RSA2&target_id=20141225xxxx&sign=fMcp4GtiM6rxSIeFnJCVePJKV43eXrUP86CQgiLhDHH2u%2FdN75eEvmywc2ulkm7qKRetkU9fbVZtJIqFdMJcJ9Yp%2BJI%2FF%2FpESafFR6rB2fRjiQQLGXvxmDGVMjPSxHxVtIqpZy5FDoKUSjQ2%2FILDKpu3%2F%2BtAtm2jRw1rUoMhgt0%3D";
|
||||
Runnable authRunnable = new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// 构造AuthTask 对象
|
||||
AuthTask authTask = new AuthTask(PasswordLoginActivity.this);
|
||||
// 调用授权接口,获取授权结果
|
||||
Map<String, String> result = authTask.authV2(authInfo, true);
|
||||
LogUtils.e(result);
|
||||
if (result.get("resultStatus").equals("9000")){
|
||||
Pattern pattern = Pattern.compile("auth_code=([^&]*)");
|
||||
Matcher matcher = pattern.matcher(result.get("result"));
|
||||
|
||||
if (matcher.find()) {
|
||||
String authCode = matcher.group(1);
|
||||
LogUtils.e("AuthCode", authCode);
|
||||
MvpPre.oauthLogin(authCode,2);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Thread authThread = new Thread(authRunnable);
|
||||
authThread.start();
|
||||
}
|
||||
}
|
||||
201
app/src/main/java/com/jdf/myyuliao/RealNameActivity.java
Normal file
201
app/src/main/java/com/jdf/myyuliao/RealNameActivity.java
Normal file
@@ -0,0 +1,201 @@
|
||||
package com.jdf.myyuliao;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.AbsoluteSizeSpan;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.blankj.utilcode.util.RegexUtils;
|
||||
import com.example.modulevocal.conacts.RealNameConacts;
|
||||
import com.example.modulevocal.presenter.RealNamePresenter;
|
||||
import com.jdf.myyuliao.databinding.ActivityRealNameBinding;
|
||||
import com.xscm.moduleutil.activity.BaseMvpActivity;
|
||||
import com.xscm.moduleutil.bean.RealNameBean;
|
||||
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||
import com.xscm.moduleutil.dialog.ConfirmDialog;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ColorManager;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.tencent.cloud.huiyansdkface.facelight.api.WbCloudFaceContant;
|
||||
import com.tencent.cloud.huiyansdkface.facelight.api.WbCloudFaceVerifySdk;
|
||||
import com.tencent.cloud.huiyansdkface.facelight.api.listeners.WbCloudFaceVerifyLoginListener;
|
||||
import com.tencent.cloud.huiyansdkface.facelight.api.listeners.WbCloudFaceVerifyResultListener;
|
||||
import com.tencent.cloud.huiyansdkface.facelight.api.result.WbFaceError;
|
||||
import com.tencent.cloud.huiyansdkface.facelight.api.result.WbFaceVerifyResult;
|
||||
import com.tencent.cloud.huiyansdkface.facelight.process.FaceVerifyStatus;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/7/15
|
||||
*@description: 实名认证
|
||||
*/
|
||||
@Route(path = ARouteConstants.REAL_NAME_ACTIVITY2)
|
||||
public class RealNameActivity extends BaseMvpActivity<RealNamePresenter, ActivityRealNameBinding> implements RealNameConacts.View{
|
||||
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
mBinding.topBar.setTitle("实名认证");
|
||||
String fullText = "您知悉并同意应用提供者\n· 收集、使用您本人的身份信息和人脸图像\n· 向合法数据持有者核实您的身份信息\n· 本操作数据仅用于身份核实,安全可靠";
|
||||
SpannableString spannable = new SpannableString(fullText);
|
||||
|
||||
int firstLineEnd = fullText.indexOf('\n');
|
||||
if (firstLineEnd > 0) {
|
||||
// 设置第一行字体大小和颜色
|
||||
spannable.setSpan(
|
||||
new AbsoluteSizeSpan(16, true), // 18sp,基于 TextView 的 sp 值调整
|
||||
0,
|
||||
firstLineEnd,
|
||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
);
|
||||
|
||||
spannable.setSpan(
|
||||
new ForegroundColorSpan(Color.BLACK),
|
||||
0,
|
||||
firstLineEnd,
|
||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
);
|
||||
}
|
||||
|
||||
mBinding.tvAgreeTerms.setText(spannable);
|
||||
mBinding.btnSubmit.setOnClickListener(this::onClick);
|
||||
|
||||
ThemeableDrawableUtils.setThemeableRoundedBackground(mBinding.btnSubmit, ColorManager.getInstance().getPrimaryColorInt(), 53);
|
||||
mBinding.btnSubmit.setTextColor(ColorManager.getInstance().getButtonColorInt());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_real_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RealNamePresenter bindPresenter() {
|
||||
return new RealNamePresenter(this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void realNameSuccess(RealNameBean msg) {
|
||||
Bundle data = new Bundle();
|
||||
WbCloudFaceVerifySdk.InputData inputData = new WbCloudFaceVerifySdk.InputData(
|
||||
msg.getFaceId(),
|
||||
msg.getOrderNo(),
|
||||
msg.getAppid(),
|
||||
msg.getApiVersion(),
|
||||
msg.getNonce(),
|
||||
msg.getUserid(),
|
||||
msg.getSign(),
|
||||
FaceVerifyStatus.Mode.GRADE,
|
||||
msg.getLicence());
|
||||
data.putSerializable(WbCloudFaceContant.INPUT_DATA, inputData);
|
||||
//设置是否打开语音提示,默认关闭,此处设置为关闭
|
||||
data.putBoolean(WbCloudFaceContant. PLAY_VOICE, true);
|
||||
|
||||
//避免用户快速点击导致二次登录,二次拉起刷脸等操作引起问题
|
||||
WbCloudFaceVerifySdk.getInstance().
|
||||
initAdvSdk(RealNameActivity.this, data, new WbCloudFaceVerifyLoginListener() {
|
||||
@Override
|
||||
public void onLoginSuccess () {
|
||||
//登录成功,拉起 sdk 页面,由 FaceVerifyResultListener 返回刷脸结果
|
||||
WbCloudFaceVerifySdk.getInstance().startWbFaceVerifySdk(RealNameActivity.this, new WbCloudFaceVerifyResultListener() {
|
||||
@Override
|
||||
public void onFinish(WbFaceVerifyResult result) {
|
||||
if (result != null) {
|
||||
if (result.isSuccess()) {
|
||||
Log.d("@@@", "刷脸成功!");
|
||||
SpUtil.setRealName(true);
|
||||
MvpPre.realNameResult(result.getOrderNo());
|
||||
|
||||
} else {
|
||||
Log.d("@@@", "刷脸失败!");
|
||||
queren1();
|
||||
}
|
||||
}
|
||||
//刷脸结束后,及时释放资源
|
||||
WbCloudFaceVerifySdk.getInstance().release();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void onLoginFailed (WbFaceError error){
|
||||
Log.d("@@@", "刷脸失败!");
|
||||
//刷脸结束后,及时释放资源
|
||||
WbCloudFaceVerifySdk.getInstance().release();
|
||||
queren1();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCodeSuccess() {
|
||||
queren();
|
||||
}
|
||||
private void queren() {
|
||||
// 创建并显示确认对话框
|
||||
new ConfirmDialog(this,
|
||||
"温馨提示",
|
||||
"恭喜您获得内测资格,将获得10万金币",
|
||||
"确认",
|
||||
"",
|
||||
v -> {
|
||||
// 点击“确认”按钮时执行
|
||||
finish();
|
||||
},
|
||||
v -> {
|
||||
// 点击“取消”按钮时什么都不做
|
||||
|
||||
}, true, 0).show();
|
||||
}
|
||||
|
||||
private void queren1() {
|
||||
// 创建并显示确认对话框
|
||||
new ConfirmDialog(this,
|
||||
"温馨提示",
|
||||
"实名未通过,重新实名",
|
||||
"确认",
|
||||
"",
|
||||
v -> {
|
||||
// 点击“确认”按钮时执行
|
||||
finish();
|
||||
},
|
||||
v -> {
|
||||
// 点击“取消”按钮时什么都不做
|
||||
|
||||
}, true, 0).show();
|
||||
}
|
||||
private void onClick(View view) {
|
||||
if (view.getId()== R.id.btnSubmit){
|
||||
if (mBinding.edName.getText().toString().isEmpty()){
|
||||
com.blankj.utilcode.util.ToastUtils.showShort("请输入姓名");
|
||||
return;
|
||||
}
|
||||
if (mBinding.edPassword.getText().toString().isEmpty()){
|
||||
com.blankj.utilcode.util.ToastUtils.showShort("请输入身份证号");
|
||||
return;
|
||||
}
|
||||
if (RegexUtils.isIDCard18Exact(mBinding.edPassword.getText().toString())) {
|
||||
if (mBinding.btnSubmit.getText().toString().equals("下一步")) {
|
||||
mBinding.stepNum1.setBackground(getResources().getDrawable(com.xscm.moduleutil.R.mipmap.num_11));
|
||||
mBinding.stepNum2.setBackground(getResources().getDrawable(com.xscm.moduleutil.R.mipmap.num_2));
|
||||
// mBinding.l1.setVisibility(View.GONE);
|
||||
// mBinding.l2.setVisibility(View.VISIBLE);
|
||||
// mBinding.btnSubmit.setText("立即认证");
|
||||
MvpPre.realName(mBinding.edName.getText().toString(),mBinding.edPassword.getText().toString());
|
||||
} else {
|
||||
SpUtil.setRealName(true);
|
||||
finish();
|
||||
}
|
||||
}else {
|
||||
com.blankj.utilcode.util.ToastUtils.showShort("请输入正确的身份证号");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
110
app/src/main/java/com/jdf/myyuliao/presenter/BasePresenter.java
Normal file
110
app/src/main/java/com/jdf/myyuliao/presenter/BasePresenter.java
Normal file
@@ -0,0 +1,110 @@
|
||||
package com.jdf.myyuliao.presenter;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public abstract class BasePresenter<V extends IView> implements IPresenter {
|
||||
protected CompositeDisposable mDisposables = new CompositeDisposable();
|
||||
// private RemoteDataSource api;
|
||||
protected Reference<V> MvpRef;
|
||||
protected Context mContext;
|
||||
|
||||
@Deprecated
|
||||
public BasePresenter(V view) {
|
||||
attachView(view);
|
||||
}
|
||||
|
||||
public BasePresenter(V view, Context context) {
|
||||
attachView(view);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
private void attachView(V view) {
|
||||
MvpRef = new WeakReference<V>(view);
|
||||
}
|
||||
|
||||
protected V getView() {
|
||||
if (MvpRef != null) {
|
||||
return MvpRef.get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// protected RemoteDataSource getApi() {
|
||||
// if (api == null) {
|
||||
// api = RemoteDataSource.getInstance();
|
||||
// }
|
||||
// return api;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 主要用于判断IView的生命周期是否结束,防止出现内存泄露状况
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isViewAttach() {
|
||||
return MvpRef != null && MvpRef.get() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachView() {
|
||||
cancelRequest();
|
||||
if (MvpRef != null) {
|
||||
MvpRef.clear();
|
||||
MvpRef = null;
|
||||
}
|
||||
// if (api != null) {
|
||||
// api = null;
|
||||
// }
|
||||
unBindView();
|
||||
}
|
||||
|
||||
|
||||
public void unBindView() {
|
||||
if (MvpRef != null) {
|
||||
MvpRef.clear();
|
||||
}
|
||||
mContext=null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加入订阅对象
|
||||
*
|
||||
* @param disposable
|
||||
*/
|
||||
public void addDisposable(Disposable disposable) {
|
||||
mDisposables.add(disposable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除订阅对象
|
||||
*
|
||||
* @param disposable
|
||||
*/
|
||||
public void removeDisposable(Disposable disposable) {
|
||||
mDisposables.remove(disposable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消所有请求
|
||||
*/
|
||||
public void cancelRequest() {
|
||||
if (mDisposables != null) {
|
||||
mDisposables.clear(); // clear时网络请求会随即cancel
|
||||
mDisposables = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
233
app/src/main/java/com/jdf/myyuliao/wxapi/WXEntryActivity.java
Normal file
233
app/src/main/java/com/jdf/myyuliao/wxapi/WXEntryActivity.java
Normal file
@@ -0,0 +1,233 @@
|
||||
package com.jdf.myyuliao.wxapi;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.tencent.mm.opensdk.modelbase.BaseReq;
|
||||
import com.tencent.mm.opensdk.modelbase.BaseResp;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
public class WXEntryActivity extends Activity implements IWXAPIEventHandler{
|
||||
// private static String TAG = "MicroMsg.WXEntryActivity";
|
||||
//
|
||||
// private IWXAPI api;
|
||||
// private MyHandler handler;
|
||||
//
|
||||
// private static class MyHandler extends Handler {
|
||||
// private final WeakReference<WXEntryActivity> wxEntryActivityWeakReference;
|
||||
//
|
||||
// public MyHandler(WXEntryActivity wxEntryActivity){
|
||||
// wxEntryActivityWeakReference = new WeakReference<WXEntryActivity>(wxEntryActivity);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void handleMessage(Message msg) {
|
||||
// int tag = msg.what;
|
||||
// switch (tag) {
|
||||
// case 0: {
|
||||
// Bundle data = msg.getData();
|
||||
// JSONObject json = null;
|
||||
// try {
|
||||
// json = new JSONObject(data.getString("result"));
|
||||
// String openId, accessToken, refreshToken, scope;
|
||||
// openId = json.getString("openid");
|
||||
// accessToken = json.getString("access_token");
|
||||
// refreshToken = json.getString("refresh_token");
|
||||
// scope = json.getString("scope");
|
||||
//// Intent intent = new Intent(wxEntryActivityWeakReference.get(), SendToWXActivity.class);
|
||||
//// intent.putExtra("openId", openId);
|
||||
//// intent.putExtra("accessToken", accessToken);
|
||||
//// intent.putExtra("refreshToken", refreshToken);
|
||||
//// intent.putExtra("scope", scope);
|
||||
//// wxEntryActivityWeakReference.get().startActivity(intent);
|
||||
// } catch (JSONException e) {
|
||||
// Log.e(TAG, e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onCreate(Bundle savedInstanceState) {
|
||||
// super.onCreate(savedInstanceState);
|
||||
//
|
||||
// api = WXAPIFactory.createWXAPI(this, CommonAppContext.getInstance().getCurrentEnvironment().getWxAppId(), false);
|
||||
// handler = new MyHandler(this);
|
||||
//
|
||||
// try {
|
||||
// Intent intent = getIntent();
|
||||
// api.handleIntent(intent, this);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void onNewIntent(Intent intent) {
|
||||
// super.onNewIntent(intent);
|
||||
//
|
||||
// setIntent(intent);
|
||||
// api.handleIntent(intent, this);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onReq(BaseReq req) {
|
||||
// switch (req.getType()) {
|
||||
// case ConstantsAPI.COMMAND_GETMESSAGE_FROM_WX:
|
||||
//// goToGetMsg();
|
||||
// break;
|
||||
// case ConstantsAPI.COMMAND_SHOWMESSAGE_FROM_WX:
|
||||
//// goToShowMsg((ShowMessageFromWX.Req) req);
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// finish();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onResp(BaseResp resp) {
|
||||
// int result = 0;
|
||||
//
|
||||
// switch (resp.errCode) {
|
||||
// case BaseResp.ErrCode.ERR_OK:
|
||||
//// result = com.qxcm.moduleutil.R.string.errcode_success;
|
||||
// break;
|
||||
// case BaseResp.ErrCode.ERR_USER_CANCEL:
|
||||
//// result = R.string.errcode_cancel;
|
||||
// break;
|
||||
// case BaseResp.ErrCode.ERR_AUTH_DENIED:
|
||||
//// result = R.string.errcode_deny;
|
||||
// break;
|
||||
// case BaseResp.ErrCode.ERR_UNSUPPORT:
|
||||
//// result = R.string.errcode_unsupported;
|
||||
// break;
|
||||
// default:
|
||||
//// result = R.string.errcode_unknown;
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// Toast.makeText(this, getString(result) + ", type=" + resp.getType(), Toast.LENGTH_SHORT).show();
|
||||
//
|
||||
//
|
||||
// if (resp.getType() == ConstantsAPI.COMMAND_SUBSCRIBE_MESSAGE) {
|
||||
// SubscribeMessage.Resp subscribeMsgResp = (SubscribeMessage.Resp) resp;
|
||||
// String text = String.format("openid=%s\ntemplate_id=%s\nscene=%d\naction=%s\nreserved=%s",
|
||||
// subscribeMsgResp.openId, subscribeMsgResp.templateID, subscribeMsgResp.scene, subscribeMsgResp.action, subscribeMsgResp.reserved);
|
||||
//
|
||||
// Toast.makeText(this, text, Toast.LENGTH_LONG).show();
|
||||
// }
|
||||
//
|
||||
// if (resp.getType() == ConstantsAPI.COMMAND_LAUNCH_WX_MINIPROGRAM) {
|
||||
// WXLaunchMiniProgram.Resp launchMiniProgramResp = (WXLaunchMiniProgram.Resp) resp;
|
||||
// String text = String.format("openid=%s\nextMsg=%s\nerrStr=%s",
|
||||
// launchMiniProgramResp.openId, launchMiniProgramResp.extMsg,launchMiniProgramResp.errStr);
|
||||
//
|
||||
// Toast.makeText(this, text, Toast.LENGTH_LONG).show();
|
||||
// }
|
||||
//
|
||||
// if (resp.getType() == ConstantsAPI.COMMAND_OPEN_BUSINESS_VIEW) {
|
||||
// WXOpenBusinessView.Resp launchMiniProgramResp = (WXOpenBusinessView.Resp) resp;
|
||||
// String text = String.format("openid=%s\nextMsg=%s\nerrStr=%s\nbusinessType=%s",
|
||||
// launchMiniProgramResp.openId, launchMiniProgramResp.extMsg,launchMiniProgramResp.errStr,launchMiniProgramResp.businessType);
|
||||
//
|
||||
// Toast.makeText(this, text, Toast.LENGTH_LONG).show();
|
||||
// }
|
||||
//
|
||||
// if (resp.getType() == ConstantsAPI.COMMAND_OPEN_BUSINESS_WEBVIEW) {
|
||||
// WXOpenBusinessWebview.Resp response = (WXOpenBusinessWebview.Resp) resp;
|
||||
// String text = String.format("businessType=%d\nresultInfo=%s\nret=%d",response.businessType,response.resultInfo,response.errCode);
|
||||
//
|
||||
// Toast.makeText(this, text, Toast.LENGTH_LONG).show();
|
||||
// }
|
||||
//
|
||||
// if (resp.getType() == ConstantsAPI.COMMAND_SENDAUTH) {
|
||||
// SendAuth.Resp authResp = (SendAuth.Resp)resp;
|
||||
// final String code = authResp.code;
|
||||
//// NetworkUtil.sendWxAPI(handler, String.format("https://api.weixin.qq.com/sns/oauth2/access_token?" +
|
||||
//// "appid=%s&secret=%s&code=%s&grant_type=authorization_code", "wxd930ea5d5a258f4f",
|
||||
//// "1d6d1d57a3dd063b36d917bc0b44d964", code), NetworkUtil.GET_TOKEN);
|
||||
// }
|
||||
// finish();
|
||||
// }
|
||||
//
|
||||
//// private void goToGetMsg() {
|
||||
//// Intent intent = new Intent(this, GetFromWXActivity.class);
|
||||
//// intent.putExtras(getIntent());
|
||||
//// startActivity(intent);
|
||||
//// finish();
|
||||
//// }
|
||||
////
|
||||
//// private void goToShowMsg(ShowMessageFromWX.Req showReq) {
|
||||
//// WXMediaMessage wxMsg = showReq.message;
|
||||
//// WXAppExtendObject obj = (WXAppExtendObject) wxMsg.mediaObject;
|
||||
////
|
||||
//// StringBuffer msg = new StringBuffer();
|
||||
//// msg.append("description: ");
|
||||
//// msg.append(wxMsg.description);
|
||||
//// msg.append("\n");
|
||||
//// msg.append("extInfo: ");
|
||||
//// msg.append(obj.extInfo);
|
||||
//// msg.append("\n");
|
||||
//// msg.append("filePath: ");
|
||||
//// msg.append(obj.filePath);
|
||||
////
|
||||
//// Intent intent = new Intent(this, ShowFromWXActivity.class);
|
||||
//// intent.putExtra(Constants.ShowMsgActivity.STitle, wxMsg.title);
|
||||
//// intent.putExtra(Constants.ShowMsgActivity.SMessage, msg.toString());
|
||||
//// intent.putExtra(Constants.ShowMsgActivity.BAThumbData, wxMsg.thumbData);
|
||||
//// startActivity(intent);
|
||||
//// finish();
|
||||
//// }
|
||||
|
||||
|
||||
private final String TAG = this.getClass().getSimpleName();
|
||||
public static final String APP_ID = CommonAppContext.getInstance().getCurrentEnvironment().getWxAppId();
|
||||
public static final String APP_SECRET = "请自己填写";
|
||||
private IWXAPI mApi;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mApi = WXAPIFactory.createWXAPI(this, APP_ID, true);
|
||||
mApi.handleIntent(this.getIntent(), this);
|
||||
}
|
||||
|
||||
//微信发送的请求将回调到onReq方法
|
||||
@Override
|
||||
public void onReq(BaseReq baseReq) {
|
||||
}
|
||||
|
||||
//发送到微信请求的响应结果
|
||||
@Override
|
||||
public void onResp(BaseResp resp) {
|
||||
switch (resp.errCode) {
|
||||
case BaseResp.ErrCode.ERR_OK:
|
||||
//发送成功
|
||||
ToastUtils.showShort("发送成功",resp.transaction);
|
||||
EventBus.getDefault().post(resp);
|
||||
break;
|
||||
case BaseResp.ErrCode.ERR_USER_CANCEL:
|
||||
//发送取消
|
||||
ToastUtils.showShort("发送取消",resp);
|
||||
break;
|
||||
case BaseResp.ErrCode.ERR_AUTH_DENIED:
|
||||
ToastUtils.showShort("发送被拒绝",resp);
|
||||
//发送被拒绝
|
||||
break;
|
||||
default:
|
||||
//发送返回
|
||||
break;
|
||||
}
|
||||
finish();
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user