| | |
| | | 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.annotation.NonNull; |
| | | import androidx.appcompat.content.res.AppCompatResources; |
| | | |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | |
| | | import com.hdl.photovoltaic.config.AppConfigManage; |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.databinding.ActivityChangePasswordBinding; |
| | | import com.hdl.photovoltaic.enums.VerifyType; |
| | | 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.utils.GPSManagerUtils; |
| | | import com.hdl.photovoltaic.widget.ConfirmationCancelDialog; |
| | | import com.hdl.photovoltaic.widget.ConfirmationTipDialog; |
| | | import com.sahooz.library.countrypicker.Country; |
| | |
| | | * 初始化界面 |
| | | */ |
| | | private void initView() { |
| | | if (UserConfigManage.getInstance().isZh()) { |
| | | viewBinding.regionAccountTv.setText(getText(R.string.home_chinese_mainland)); |
| | | viewBinding.regionAccountNumberTv.setText("+86"); |
| | | } else { |
| | | viewBinding.regionAccountTv.setText(getText(R.string.iraq)); |
| | | viewBinding.regionAccountNumberTv.setText("+964"); |
| | | } |
| | | switchPhoneOrMailView(); |
| | | try { |
| | | Country.load(this); |
| | | Country country = null; |
| | | if (TextUtils.isEmpty(GPSManagerUtils.getInstance().getCountryCode(this))) { |
| | | //再根据系统语言 |
| | | country = Country.getCountryInfo(); |
| | | } else { |
| | | //先根据定位 |
| | | country = Country.getLocationCountryInfo(GPSManagerUtils.getInstance().getCountryCode(this)); |
| | | } |
| | | if (country != null) { |
| | | viewBinding.regionAccountTv.setText(country.translate); |
| | | viewBinding.regionAccountNumberTv.setText("+" + country.code); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | verification_code = viewBinding.changeMailVerificationEt.getText().toString(); |
| | | } |
| | | if (UserConfigManage.getInstance().isBAccount()) { |
| | | HdlAccountLogic.getInstance().changePassword_B(isPhoneType, account, psw, verification_code, new CloudCallBeak<Boolean>() { |
| | | HdlAccountLogic.getInstance().changePassword_B(isPhoneType, account, psw, verification_code, viewBinding.regionAccountNumberTv.getText().toString(), new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | |
| | | } |
| | | }); |
| | | } else { |
| | | HdlAccountLogic.getInstance().changePassword_C(isPhoneType, account, psw, verification_code, new CloudCallBeak<Boolean>() { |
| | | HdlAccountLogic.getInstance().changePassword_C(isPhoneType, account, psw, verification_code, viewBinding.regionAccountNumberTv.getText().toString(), new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | |
| | | CountryPickerFragment dialog = new CountryPickerFragment(this, new PickCountryCallback() { |
| | | @Override |
| | | public void onPick(Country country) { |
| | | if (country.flag != 0) viewBinding.regionAccountTv.setText(country.name); |
| | | if (country.flag != 0) viewBinding.regionAccountTv.setText(country.translate); |
| | | viewBinding.regionAccountNumberTv.setText("+" + country.code); |
| | | } |
| | | }); |
| | |
| | | //设置账号所在区域协议及地址 |
| | | AppConfigManage.setUserRegionUrl(obj.getRegionUrl()); |
| | | HDLLinkPMUser.getInstance().setUserRegionUrl(AppConfigManage.getUserRegionUrl()); |
| | | HdlAccountLogic.getInstance().sendVerifyCode(isPhoneType, account, viewBinding.regionAccountNumberTv.getText().toString(), 2, new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | if (isPhoneType) { |
| | | phoneCountDownTimer.start(); |
| | | } else { |
| | | mailCountDownTimer.start(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlThreadLogic.toast(_mActivity, e); |
| | | } |
| | | }); |
| | | |
| | | if (UserConfigManage.getInstance().isBAccount()) { |
| | | //B端发送获取验证码 |
| | | HdlAccountLogic.getInstance().sendVerifyCode_B(isPhoneType, account, viewBinding.regionAccountNumberTv.getText().toString(), VerifyType.VerifyType_FIND_PASSWORD, new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | if (isPhoneType) { |
| | | phoneCountDownTimer.start(); |
| | | } else { |
| | | mailCountDownTimer.start(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlThreadLogic.toast(_mActivity, e); |
| | | } |
| | | }); |
| | | } else { |
| | | //C端发送获取验证码 |
| | | HdlAccountLogic.getInstance().sendVerifyCode_C(isPhoneType, account, viewBinding.regionAccountNumberTv.getText().toString(), VerifyType.VerifyType_2, new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | if (isPhoneType) { |
| | | phoneCountDownTimer.start(); |
| | | } else { |
| | | mailCountDownTimer.start(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlThreadLogic.toast(_mActivity, e); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | 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_E6FFFFFF)); |
| | | // viewBinding.changePhoneVerificationTv.setTextColor(getResources().getColor(R.color.text_FFACACAC)); |
| | | 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_E6FFFFFF)); |
| | | // viewBinding.changePhoneVerificationTv.setTextColor(getResources().getColor(R.color.text_FFACACAC)); |
| | | 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_E6FFFFFF)); |
| | | // viewBinding.changeMailVerificationTv.setTextColor(getResources().getColor(R.color.text_FFACACAC)); |
| | | 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_E6FFFFFF)); |
| | | // viewBinding.changeMailVerificationTv.setTextColor(getResources().getColor(R.color.text_FFACACAC)); |
| | | viewBinding.changeMailVerificationTv.setEnabled(true); |
| | | |
| | | } |
| | |
| | | //手机号 |
| | | 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.accountTitleTv.setTextColor(getResources().getColor(R.color.text_FFACACAC)); |
| | | viewBinding.changePhoneIc.lineV.setVisibility(View.VISIBLE); |
| | | |
| | | 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.accountTitleTv.setTextColor(getResources().getColor(R.color.text_FF5B5B5B)); |
| | | viewBinding.changeMailRl.lineV.setVisibility(View.GONE); |
| | | |
| | | |
| | |
| | | //邮箱 |
| | | 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.accountTitleTv.setTextColor(getResources().getColor(R.color.text_FF5B5B5B)); |
| | | viewBinding.changePhoneIc.lineV.setVisibility(View.GONE); |
| | | |
| | | 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.accountTitleTv.setTextColor(getResources().getColor(R.color.text_FFACACAC)); |
| | | viewBinding.changeMailRl.lineV.setVisibility(View.VISIBLE); |
| | | |
| | | viewBinding.regionAccountRl.setVisibility(View.GONE); |
| | |
| | | } |
| | | 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)); |
| | | viewBinding.confirmTv.setTextColor(getColor(R.color.text_FFACACAC)); |
| | | } else { |
| | | viewBinding.confirmTv.setTextColor(getColor(R.color.text_66FFFFFF)); |
| | | viewBinding.confirmTv.setTextColor(getColor(R.color.text_FF5B5B5B)); |
| | | } |
| | | viewBinding.confirmTv.setEnabled(isEnabled); |
| | | } |