| | |
| | | package com.hdl.photovoltaic.ui.account; |
| | | |
| | | import android.app.AppComponentFactory; |
| | | |
| | | import android.os.Bundle; |
| | | import android.os.CountDownTimer; |
| | | import android.text.Editable; |
| | | import android.text.InputType; |
| | | import android.text.SpannableStringBuilder; |
| | | import android.text.TextPaint; |
| | | import android.text.TextUtils; |
| | | import android.text.TextWatcher; |
| | | import android.text.method.HideReturnsTransformationMethod; |
| | | import android.text.method.PasswordTransformationMethod; |
| | | import android.text.style.ClickableSpan; |
| | | import android.view.View; |
| | | import android.widget.TextView; |
| | | |
| | | import androidx.appcompat.app.AppCompatActivity; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.appcompat.content.res.AppCompatResources; |
| | | |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.base.CustomBaseActivity; |
| | | import com.hdl.photovoltaic.config.AppConfigManage; |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.databinding.ActivityChangePasswordBinding; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.other.HdlAccountLogic; |
| | | import com.hdl.photovoltaic.other.HdlCommonLogic; |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | import com.hdl.photovoltaic.widget.ConfirmationCancelDialog; |
| | | import com.hdl.photovoltaic.widget.ConfirmationTipDialog; |
| | | |
| | | /** |
| | | * 修改账号界面 |
| | | * 忘记密码界面 |
| | | */ |
| | | public class ChangePassword extends CustomBaseActivity { |
| | | ActivityChangePasswordBinding viewBinding; |
| | |
| | | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | setStatusBarTranslucent(); |
| | | getWindow().setNavigationBarColor(getColor(R.color.text_00000000)); |
| | | //初始化 |
| | | initView(); |
| | | //初始化界面监听器 |
| | |
| | | */ |
| | | private void initView() { |
| | | switchPhoneOrMailView(); |
| | | HdlCommonLogic.getInstance().setSpan(viewBinding.changePhoneVerificationTv, viewBinding.changePhoneVerificationTv.getText().toString(), true,null); |
| | | HdlCommonLogic.getInstance().setSpan(viewBinding.changeMailVerificationTv, viewBinding.changeMailVerificationTv.getText().toString(), true,null); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置监听事件 |
| | |
| | | } |
| | | }); |
| | | //输入手机号或者邮箱 |
| | | viewBinding.changeAccountEt.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) { |
| | | isCompleteEnabled(); |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable s) { |
| | | |
| | | } |
| | | }); |
| | | viewBinding.changeAccountEt.addTextChangedListener(accountTextWatcher); |
| | | //手机号获取验证码 |
| | | viewBinding.changePhoneVerificationTv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | |
| | | } |
| | | }); |
| | | //输入手机验证码 |
| | | viewBinding.changePhoneVerificationEt.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) { |
| | | isCompleteEnabled(); |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable s) { |
| | | |
| | | } |
| | | }); |
| | | viewBinding.changePhoneVerificationEt.addTextChangedListener(phoneVerificationTextWatcher); |
| | | //邮箱获取验证码 |
| | | viewBinding.changeMailVerificationTv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | |
| | | } |
| | | }); |
| | | //输入邮箱验证码 |
| | | viewBinding.changeMailVerificationEt.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) { |
| | | isCompleteEnabled(); |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable s) { |
| | | |
| | | } |
| | | }); |
| | | viewBinding.changeMailVerificationEt.addTextChangedListener(MailVerificationTextWatcher); |
| | | //输入密码 |
| | | viewBinding.changePswEt.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) { |
| | | isCompleteEnabled(); |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable s) { |
| | | |
| | | } |
| | | }); |
| | | viewBinding.changePswEt.addTextChangedListener(changePswTextWatcher); |
| | | //密码显示或者隐藏 |
| | | viewBinding.changePswHideIv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | |
| | | } |
| | | }); |
| | | //输入确认密码 |
| | | viewBinding.changeConfirmPswEt.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) { |
| | | isCompleteEnabled(); |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable s) { |
| | | |
| | | } |
| | | }); |
| | | viewBinding.changeConfirmPswEt.addTextChangedListener(changeConfirmPswTextWatcher); |
| | | //确认密码显示或者隐藏 |
| | | viewBinding.changeConfirmPswHideIv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | |
| | | } else { |
| | | verification_code = viewBinding.changeMailVerificationEt.getText().toString(); |
| | | } |
| | | HdlAccountLogic.getInstance().changePassword(isPhoneType, account, psw, verification_code, new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | ConfirmationTipDialog dialog = new ConfirmationTipDialog(_mActivity); |
| | | dialog.show(); |
| | | dialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() { |
| | | @Override |
| | | public void Confirm() { |
| | | finish(); |
| | | } |
| | | }); |
| | | } |
| | | }, null, null); |
| | | if (UserConfigManage.getInstance().isBAccount()) { |
| | | HdlAccountLogic.getInstance().changePassword_B(isPhoneType, account, psw, verification_code, new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | ConfirmationTipDialog dialog = new ConfirmationTipDialog(_mActivity); |
| | | dialog.show(); |
| | | dialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() { |
| | | @Override |
| | | public void Confirm() { |
| | | finish(); |
| | | } |
| | | }); |
| | | } |
| | | }, null, null); |
| | | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlThreadLogic.toast(_mActivity, e); |
| | | } |
| | | }); |
| | | } else { |
| | | HdlAccountLogic.getInstance().changePassword_C(isPhoneType, account, psw, verification_code, new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | ConfirmationTipDialog dialog = new ConfirmationTipDialog(_mActivity); |
| | | dialog.show(); |
| | | dialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() { |
| | | @Override |
| | | public void Confirm() { |
| | | finish(); |
| | | } |
| | | }); |
| | | } |
| | | }, null, null); |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlThreadLogic.toast(_mActivity, e); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | |
| | |
| | | } |
| | | return; |
| | | } |
| | | //获取账号区域信息 |
| | | HdlAccountLogic.getInstance().regionByAccount(account, new CloudCallBeak<HDLUserRegionBean>() { |
| | | //发送消息验证码 |
| | | @Override |
| | | public void onSuccess(HDLUserRegionBean obj) { |
| | | //设置账号所在区域协议及地址 |
| | | AppConfigManage.setUserRegionUrl(obj.getRegionUrl()); |
| | | HDLLinkPMUser.getInstance().setUserRegionUrl(AppConfigManage.getUserRegionUrl()); |
| | | HdlAccountLogic.getInstance().sendVerifyCode(isPhoneType, account, "86", 2, new CloudCallBeak<Boolean>() { |
| | |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | |
| | | HdlThreadLogic.toast(_mActivity, e); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | hideLoading(); |
| | | HdlThreadLogic.toast(_mActivity, e); |
| | | // hideLoading(); |
| | | } |
| | | }); |
| | | } |
| | |
| | | long time = (millisUntilFinished / 1000); |
| | | String str = time + "s" + getString(R.string.home_login_psw_verification_repeater); |
| | | viewBinding.changePhoneVerificationTv.setText(str); |
| | | viewBinding.changePhoneVerificationTv.setTextColor(getResources().getColor(R.color.text_25000000)); |
| | | // viewBinding.changePhoneVerificationTv.setTextColor(getResources().getColor(R.color.text_E6FFFFFF)); |
| | | viewBinding.changePhoneVerificationTv.setEnabled(false); |
| | | |
| | | } |
| | |
| | | @Override |
| | | public void onFinish() { |
| | | viewBinding.changePhoneVerificationTv.setText(getString(R.string.home_login_verification_regain)); |
| | | viewBinding.changePhoneVerificationTv.setTextColor(getResources().getColor(R.color.text_245EC3)); |
| | | // viewBinding.changePhoneVerificationTv.setTextColor(getResources().getColor(R.color.text_E6FFFFFF)); |
| | | viewBinding.changePhoneVerificationTv.setEnabled(true); |
| | | |
| | | |
| | |
| | | String str = time + "s" + getString(R.string.home_login_psw_verification_repeater); |
| | | |
| | | viewBinding.changeMailVerificationTv.setText(str); |
| | | viewBinding.changeMailVerificationTv.setTextColor(getResources().getColor(R.color.text_25000000)); |
| | | // viewBinding.changeMailVerificationTv.setTextColor(getResources().getColor(R.color.text_E6FFFFFF)); |
| | | viewBinding.changeMailVerificationTv.setEnabled(false); |
| | | |
| | | } |
| | |
| | | @Override |
| | | public void onFinish() { |
| | | viewBinding.changeMailVerificationTv.setText(getString(R.string.home_login_verification_regain)); |
| | | viewBinding.changeMailVerificationTv.setTextColor(getResources().getColor(R.color.text_245EC3)); |
| | | // viewBinding.changeMailVerificationTv.setTextColor(getResources().getColor(R.color.text_E6FFFFFF)); |
| | | viewBinding.changeMailVerificationTv.setEnabled(true); |
| | | |
| | | } |
| | |
| | | private void switchPhoneOrMailView() { |
| | | if (isPhoneType) { |
| | | //手机号 |
| | | viewBinding.changePhoneIc.accountTitleTv.setText(R.string.home_login_手机号); |
| | | viewBinding.changePhoneIc.accountTitleTv.setTextSize(20); |
| | | viewBinding.changePhoneIc.accountTitleTv.setTextColor(getResources().getColor(R.color.text_90000000)); |
| | | viewBinding.changePhoneIc.lineV.setVisibility(View.VISIBLE); |
| | | viewBinding.changePhoneIc.accountTitleTv.setText(R.string.home_login_phone); |
| | | viewBinding.changePhoneIc.accountTitleTv.setTextSize(18); |
| | | viewBinding.changePhoneIc.accountTitleTv.setTextColor(getResources().getColor(R.color.text_E6FFFFFF)); |
| | | viewBinding.changePhoneIc.lineV.setVisibility(View.GONE); |
| | | |
| | | viewBinding.changeMailRl.accountTitleTv.setText(R.string.home_login_邮箱); |
| | | viewBinding.changeMailRl.accountTitleTv.setTextSize(16); |
| | | viewBinding.changeMailRl.accountTitleTv.setTextColor(getResources().getColor(R.color.text_40000000)); |
| | | viewBinding.changeMailRl.accountTitleTv.setText(R.string.home_login_email); |
| | | viewBinding.changeMailRl.accountTitleTv.setTextSize(14); |
| | | viewBinding.changeMailRl.accountTitleTv.setTextColor(getResources().getColor(R.color.text_66FFFFFF)); |
| | | viewBinding.changeMailRl.lineV.setVisibility(View.GONE); |
| | | |
| | | //输入手机号 |
| | | viewBinding.changeAccountEt.setInputType(InputType.TYPE_CLASS_NUMBER); |
| | | viewBinding.changeAccountEt.setHint(R.string.home_login_请输入手机号); |
| | | viewBinding.changeAccountEt.setHint(R.string.home_login_input_phone); |
| | | //显示手机号验证码,隐藏邮箱验证码, |
| | | viewBinding.changePhoneVerificationCodeRl.setVisibility(View.VISIBLE); |
| | | viewBinding.changeMailVerificationCodeRl.setVisibility(View.GONE); |
| | |
| | | |
| | | } else { |
| | | //邮箱 |
| | | viewBinding.changePhoneIc.accountTitleTv.setText(R.string.home_login_手机号); |
| | | viewBinding.changePhoneIc.accountTitleTv.setTextSize(16); |
| | | viewBinding.changePhoneIc.accountTitleTv.setTextColor(getResources().getColor(R.color.text_40000000)); |
| | | viewBinding.changePhoneIc.accountTitleTv.setText(R.string.home_login_phone); |
| | | viewBinding.changePhoneIc.accountTitleTv.setTextSize(14); |
| | | viewBinding.changePhoneIc.accountTitleTv.setTextColor(getResources().getColor(R.color.text_66FFFFFF)); |
| | | viewBinding.changePhoneIc.lineV.setVisibility(View.GONE); |
| | | |
| | | viewBinding.changeMailRl.accountTitleTv.setText(R.string.home_login_邮箱); |
| | | viewBinding.changeMailRl.accountTitleTv.setTextSize(20); |
| | | viewBinding.changeMailRl.accountTitleTv.setTextColor(getResources().getColor(R.color.text_90000000)); |
| | | viewBinding.changeMailRl.lineV.setVisibility(View.VISIBLE); |
| | | viewBinding.changeMailRl.accountTitleTv.setText(R.string.home_login_email); |
| | | viewBinding.changeMailRl.accountTitleTv.setTextSize(18); |
| | | viewBinding.changeMailRl.accountTitleTv.setTextColor(getResources().getColor(R.color.text_E6FFFFFF)); |
| | | viewBinding.changeMailRl.lineV.setVisibility(View.GONE); |
| | | //输入邮箱 |
| | | viewBinding.changeAccountEt.setInputType(InputType.TYPE_CLASS_TEXT); |
| | | viewBinding.changeAccountEt.setHint(R.string.home_login_input_mail); |
| | |
| | | verification_code = viewBinding.changeMailVerificationEt.getText().toString(); |
| | | } |
| | | boolean isEnabled = account.length() > 0 && psw1.length() > 0 && psw2.length() > 0 && verification_code.length() > 0; |
| | | if (isEnabled) { |
| | | viewBinding.confirmTv.setTextColor(getColor(R.color.text_E6FFFFFF)); |
| | | } else { |
| | | viewBinding.confirmTv.setTextColor(getColor(R.color.text_66FFFFFF)); |
| | | } |
| | | viewBinding.confirmTv.setEnabled(isEnabled); |
| | | } |
| | | |
| | |
| | | mailCountDownTimer.cancel(); |
| | | mailCountDownTimer = null; |
| | | } |
| | | viewBinding.changeAccountEt.removeTextChangedListener(accountTextWatcher); |
| | | viewBinding.changePhoneVerificationEt.removeTextChangedListener(phoneVerificationTextWatcher); |
| | | viewBinding.changeMailVerificationEt.removeTextChangedListener(MailVerificationTextWatcher); |
| | | viewBinding.changePswEt.removeTextChangedListener(changePswTextWatcher); |
| | | viewBinding.changeConfirmPswEt.removeTextChangedListener(changeConfirmPswTextWatcher); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 输入手机号或者邮箱 |
| | | */ |
| | | private final TextWatcher accountTextWatcher = 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) { |
| | | isCompleteEnabled(); |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable s) { |
| | | |
| | | } |
| | | }; |
| | | /** |
| | | * 输入手机验证码 |
| | | */ |
| | | private final TextWatcher phoneVerificationTextWatcher = 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) { |
| | | isCompleteEnabled(); |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable s) { |
| | | |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * 邮箱获取验证码 |
| | | */ |
| | | private final TextWatcher MailVerificationTextWatcher = 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) { |
| | | isCompleteEnabled(); |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable s) { |
| | | |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * 输入密码 |
| | | */ |
| | | private final TextWatcher changePswTextWatcher = 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) { |
| | | isCompleteEnabled(); |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable s) { |
| | | |
| | | } |
| | | }; |
| | | /** |
| | | * 输入确认密码 |
| | | */ |
| | | private final TextWatcher changeConfirmPswTextWatcher = 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) { |
| | | isCompleteEnabled(); |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable s) { |
| | | |
| | | } |
| | | }; |
| | | } |