| | |
| | | package com.hdl.photovoltaic.ui.account; |
| | | |
| | | |
| | | import android.Manifest; |
| | | import android.content.Context; |
| | | import android.content.pm.PackageManager; |
| | | import android.os.Bundle; |
| | | import android.os.CountDownTimer; |
| | | import android.telephony.TelephonyManager; |
| | | import android.text.Editable; |
| | | import android.text.InputType; |
| | | import android.text.TextUtils; |
| | |
| | | |
| | | import androidx.appcompat.content.res.AppCompatResources; |
| | | import androidx.constraintlayout.widget.ConstraintSet; |
| | | import androidx.core.content.ContextCompat; |
| | | |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | | import com.hdl.linkpm.sdk.user.HDLLinkPMUser; |
| | |
| | | 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.ActivityRegisterAccountBinding; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.other.HdlAccountLogic; |
| | |
| | | import com.sahooz.library.countrypicker.CountryPickerFragment; |
| | | import com.sahooz.library.countrypicker.PickCountryCallback; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Locale; |
| | | |
| | | /** |
| | | * 注册账号界面 |
| | |
| | | |
| | | |
| | | private void initView() { |
| | | //根据app语言默认服务器地址 |
| | | if (UserConfigManage.getInstance().isZh()) { |
| | | mUrl = "https://china-gateway.hdlcontrol.com"; |
| | | viewBinding.regionTv.setText("HDL China"); |
| | | } else { |
| | | viewBinding.regionTv.setText("HDL Bahrain"); |
| | | mUrl = "https://bahrain-gateway.hdlcontrol.com"; |
| | | } |
| | | switchPhoneOrEmailStyleView(); |
| | | try { |
| | | Country.load(this); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | private void initEvent() { |
| | |
| | | if (!isLocalCheckAccountAndPassword()) { |
| | | return; |
| | | } |
| | | // |
| | | viewBinding.textErrorTv.setText(""); |
| | | |
| | | String account = viewBinding.registerAccountEt.getText().toString(); |
| | | String psw = viewBinding.registerConfirmPswEt.getText().toString(); |
| | | String verification_code; |
| | |
| | | } else { |
| | | verification_code = viewBinding.registerMailVerificationEt.getText().toString(); |
| | | } |
| | | showLoading(); |
| | | HdlAccountLogic.getInstance().registerAccount_C(isPhoneType, account, psw, verification_code, new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | hideLoading(); |
| | | ConfirmationTipDialog dialog = new ConfirmationTipDialog(_mActivity); |
| | | dialog.show(); |
| | | dialog.setTitle(getString(R.string.home_account_registered_successfully)); |
| | | dialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() { |
| | | @Override |
| | | public void Confirm() { |
| | |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | |
| | | hideLoading(); |
| | | HdlThreadLogic.tipFlashingBox(_mActivity, false, e.getMsg(), e.getCode()); |
| | | } |
| | | }); |
| | | } |
| | |
| | | @Override |
| | | public void onSuccess(HDLUserRegionBean obj) { |
| | | HdlThreadLogic.toast(RegisterAccountActivity.this, getString(R.string.home_login_already_exists)); |
| | | HdlLogLogic.print("获取账号区域信息===" + obj, false); |
| | | HdlLogLogic.print("获取账号区域信息--->" + obj, false); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | |
| | | HdlThreadLogic.toast(_mActivity, e); |
| | | } |
| | | }); |
| | | } else { |
| | | HdlThreadLogic.toast(_mActivity, e); |
| | | } |
| | | |
| | | |
| | | } |
| | | }); |
| | |
| | | * 切换手机号或者邮箱的样式 |
| | | */ |
| | | private void switchPhoneOrEmailStyleView() { |
| | | |
| | | |
| | | if (isPhoneType) { |
| | | //手机号 |
| | | viewBinding.registerPhoneTitleIc.accountTitleTv.setText(R.string.home_login_phone); |
| | |
| | | viewBinding.registerMailTitleIc.accountTitleTv.setTextSize(16); |
| | | viewBinding.registerMailTitleIc.accountTitleTv.setTextColor(getResources().getColor(R.color.text_40000000, null)); |
| | | viewBinding.registerMailTitleIc.lineV.setVisibility(View.GONE); |
| | | |
| | | //显示区号 |
| | | viewBinding.registerRegionAccountRl.setVisibility(View.VISIBLE); |
| | | //输入手机号 |
| | | viewBinding.registerAccountEt.setInputType(InputType.TYPE_CLASS_NUMBER); |
| | | viewBinding.registerAccountEt.setHint(R.string.home_login_input_phone); |
| | |
| | | viewBinding.registerMailTitleIc.accountTitleTv.setTextSize(20); |
| | | viewBinding.registerMailTitleIc.accountTitleTv.setTextColor(getResources().getColor(R.color.text_90000000, null)); |
| | | viewBinding.registerMailTitleIc.lineV.setVisibility(View.VISIBLE); |
| | | |
| | | //隐藏区号 |
| | | viewBinding.registerRegionAccountRl.setVisibility(View.GONE); |
| | | //输入邮箱 |
| | | viewBinding.registerAccountEt.setInputType(InputType.TYPE_CLASS_TEXT); |
| | | viewBinding.registerAccountEt.setHint(R.string.home_login_input_mail); |
| | |
| | | viewBinding.registerConfirmPswEt.setText(mMailConfirmPsw); |
| | | |
| | | } |
| | | isCompleteEnabled(); |
| | | try { |
| | | Country.load(this); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |