From d830fef6a2bc2ab061e6ac2b423c4a49dda3cf21 Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期三, 06 十二月 2023 18:08:26 +0800 Subject: [PATCH] 2023年12月06日18:08:20 --- app/src/main/java/com/hdl/photovoltaic/ui/account/RegisterAccountActivity.java | 288 ++++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 182 insertions(+), 106 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/account/RegisterAccountActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/account/RegisterAccountActivity.java index 0a099e0..6e30683 100644 --- a/app/src/main/java/com/hdl/photovoltaic/ui/account/RegisterAccountActivity.java +++ b/app/src/main/java/com/hdl/photovoltaic/ui/account/RegisterAccountActivity.java @@ -1,8 +1,12 @@ 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; @@ -13,6 +17,7 @@ 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; @@ -26,10 +31,17 @@ import com.hdl.photovoltaic.other.HdlLogLogic; import com.hdl.photovoltaic.other.HdlThreadLogic; import com.hdl.photovoltaic.utils.KeyboardStateObserverUtils; +import com.hdl.photovoltaic.utils.LocalManageUtil; import com.hdl.photovoltaic.widget.ConfirmationCancelDialog; import com.hdl.photovoltaic.widget.ConfirmationTipDialog; -import com.hdl.photovoltaic.widget.ListDialog; -import com.hdl.sdk.link.common.utils.ThreadToolUtils; +import com.hdl.photovoltaic.widget.ListStaticDialog; +import com.sahooz.library.countrypicker.Country; +import com.sahooz.library.countrypicker.CountryPickerFragment; +import com.sahooz.library.countrypicker.PickCountryCallback; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; /** * 娉ㄥ唽璐﹀彿鐣岄潰 @@ -91,7 +103,7 @@ private void initView() { - switchPhoneOrMailView(); + switchPhoneOrEmailStyleView(); } private void initEvent() { @@ -102,35 +114,46 @@ finish(); } }); + //鏈嶅姟鍣ㄩ�夋嫨 viewBinding.registerRegionServerRl.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - ListDialog listDialog = new ListDialog(_mActivity); + ListStaticDialog listDialog = new ListStaticDialog(_mActivity); listDialog.show(); - listDialog.setOnHDLChinaOnListener(new ListDialog.onHDLChinaListener() { + listDialog.setOnHDLChinaOnListener(new ListStaticDialog.onHDLChinaListener() { @Override public void HDLChina() { mUrl = "https://china-gateway.hdlcontrol.com"; viewBinding.regionTv.setText(listDialog.geHDLChinaText()); + listDialog.dismiss(); } }); - listDialog.setOnHDLBahrainListener(new ListDialog.onHDLBahrainListener() { + listDialog.setOnHDLBahrainListener(new ListStaticDialog.onHDLBahrainListener() { @Override public void HDLBahrain() { mUrl = "https://bahrain-gateway.hdlcontrol.com"; viewBinding.regionTv.setText(listDialog.getHDLBahrainText()); + listDialog.dismiss(); } }); } }); + //鎵嬫満鍖哄彿閫夋嫨 + viewBinding.registerRegionAccountRl.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + selectArea(); + } + }); + //鍒囨崲鎵嬫満鍙� viewBinding.registerPhoneTitleIc.underlineCl.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { isPhoneType = true; - switchPhoneOrMailView(); + switchPhoneOrEmailStyleView(); } }); //鍒囨崲閭 @@ -138,27 +161,12 @@ @Override public void onClick(View v) { isPhoneType = false; - switchPhoneOrMailView(); + switchPhoneOrEmailStyleView(); } }); //杈撳叆瀵嗙爜 - viewBinding.registerPswEt.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.registerPswEt.addTextChangedListener(changePswTextWatcher); //瀵嗙爜鏄剧ず鎴栬�呴殣钘� viewBinding.registerPswHideIv.setOnClickListener(new View.OnClickListener() { @Override @@ -180,22 +188,7 @@ } }); //杈撳叆纭瀵嗙爜 - viewBinding.registerConfirmPswEt.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.registerConfirmPswEt.addTextChangedListener(changeConfirmPswTextWatcher); //纭瀵嗙爜鏄剧ず鎴栬�呴殣钘� viewBinding.registerConfirmPswHideIv.setOnClickListener(new View.OnClickListener() { @Override @@ -216,22 +209,7 @@ } }); //杈撳叆鎵嬫満鍙锋垨鑰呴偖绠� - viewBinding.registerAccountEt.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.registerAccountEt.addTextChangedListener(accountTextWatcher); //鎵嬫満鍙疯幏鍙栭獙璇佺爜 viewBinding.registerPhoneVerificationTv.setOnClickListener(new View.OnClickListener() { @Override @@ -241,22 +219,7 @@ } }); //杈撳叆鎵嬫満楠岃瘉鐮� - viewBinding.registerPhoneVerificationEt.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.registerPhoneVerificationEt.addTextChangedListener(phoneVerificationTextWatcher); //閭鑾峰彇楠岃瘉鐮� viewBinding.registerMailVerificationTv.setOnClickListener(new View.OnClickListener() { @Override @@ -266,22 +229,7 @@ } }); //杈撳叆閭楠岃瘉鐮� - viewBinding.registerMailVerificationEt.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.registerMailVerificationEt.addTextChangedListener(mailVerificationTextWatcher); //娉ㄥ唽璐﹀彿 viewBinding.registerCompleteTv.setOnClickListener(new View.OnClickListener() { @Override @@ -297,7 +245,7 @@ } else { verification_code = viewBinding.registerMailVerificationEt.getText().toString(); } - HdlAccountLogic.getInstance().registerAccount(isPhoneType, account, psw, verification_code, new CloudCallBeak<Boolean>() { + HdlAccountLogic.getInstance().registerAccount_C(isPhoneType, account, psw, verification_code, new CloudCallBeak<Boolean>() { @Override public void onSuccess(Boolean obj) { HdlThreadLogic.runMainThread(new Runnable() { @@ -326,6 +274,7 @@ } + /** * 鍙戦�侀獙璇佺爜鎸囦护 */ @@ -346,9 +295,8 @@ HdlAccountLogic.getInstance().regionByAccount(account, new CloudCallBeak<HDLUserRegionBean>() { @Override public void onSuccess(HDLUserRegionBean obj) { - //鍙戦�佹秷鎭獙璇佺爜 HdlThreadLogic.toast(RegisterAccountActivity.this, getString(R.string.home_login_already_exists)); - HdlLogLogic.print("regionByAccount onSuccess==" + obj); + HdlLogLogic.print("鑾峰彇璐﹀彿鍖哄煙淇℃伅===" + obj, false); } @Override @@ -362,7 +310,7 @@ mUrl = "https://test-gz.hdlcontrol.com"; } HDLLinkPMUser.getInstance().setUserRegionUrl(mUrl); - HdlAccountLogic.getInstance().sendVerifyCode(isPhoneType, account, "86", 1, new CloudCallBeak<Boolean>() { + HdlAccountLogic.getInstance().sendVerifyCode(isPhoneType, account, viewBinding.regionAccountNumberTv.getText().toString(), 1, new CloudCallBeak<Boolean>() { @Override public void onSuccess(Boolean obj) { if (isPhoneType) { @@ -384,6 +332,7 @@ } + /** * 鍒濆鍖栨墜鏈哄彿璁℃椂鍣� */ @@ -393,7 +342,7 @@ long time = (millisUntilFinished / 1000); String str = time + "s" + getString(R.string.home_login_psw_verification_repeater); viewBinding.registerPhoneVerificationTv.setText(str); - viewBinding.registerPhoneVerificationTv.setTextColor(getResources().getColor(R.color.text_25000000)); + viewBinding.registerPhoneVerificationTv.setTextColor(getResources().getColor(R.color.text_25000000, null)); viewBinding.registerPhoneVerificationTv.setEnabled(false); } @@ -401,7 +350,7 @@ @Override public void onFinish() { viewBinding.registerPhoneVerificationTv.setText(getString(R.string.home_login_verification_regain)); - viewBinding.registerPhoneVerificationTv.setTextColor(getResources().getColor(R.color.text_245EC3)); + viewBinding.registerPhoneVerificationTv.setTextColor(getResources().getColor(R.color.text_245EC3, null)); viewBinding.registerPhoneVerificationTv.setEnabled(true); @@ -417,7 +366,7 @@ String str = time + "s" + getString(R.string.home_login_psw_verification_repeater); viewBinding.registerMailVerificationTv.setText(str); - viewBinding.registerMailVerificationTv.setTextColor(getResources().getColor(R.color.text_25000000)); + viewBinding.registerMailVerificationTv.setTextColor(getResources().getColor(R.color.text_25000000, null)); viewBinding.registerMailVerificationTv.setEnabled(false); } @@ -425,31 +374,47 @@ @Override public void onFinish() { viewBinding.registerMailVerificationTv.setText(getString(R.string.home_login_verification_regain)); - viewBinding.registerMailVerificationTv.setTextColor(getResources().getColor(R.color.text_245EC3)); + viewBinding.registerMailVerificationTv.setTextColor(getResources().getColor(R.color.text_245EC3, null)); viewBinding.registerMailVerificationTv.setEnabled(true); } }; /** + * 鍥藉鎵嬫満鍙峰尯鍙峰脊绐� + */ + private void selectArea() { + CountryPickerFragment dialog = new CountryPickerFragment(this, new PickCountryCallback() { + @Override + public void onPick(Country country) { + if (country.flag != 0) + viewBinding.regionAccountTv.setText(country.name); + viewBinding.regionAccountNumberTv.setText("+" + country.code); + } + }); + dialog.show(); + dialog.setDialogSize(); + } + + /** * 鍒囨崲鎵嬫満鍙锋垨鑰呴偖绠辩殑鏍峰紡 */ - private void switchPhoneOrMailView() { + private void switchPhoneOrEmailStyleView() { if (isPhoneType) { //鎵嬫満鍙� - viewBinding.registerPhoneTitleIc.accountTitleTv.setText(R.string.home_login_鎵嬫満鍙�); + viewBinding.registerPhoneTitleIc.accountTitleTv.setText(R.string.home_login_phone); viewBinding.registerPhoneTitleIc.accountTitleTv.setTextSize(20); - viewBinding.registerPhoneTitleIc.accountTitleTv.setTextColor(getResources().getColor(R.color.text_90000000)); + viewBinding.registerPhoneTitleIc.accountTitleTv.setTextColor(getResources().getColor(R.color.text_90000000, null)); viewBinding.registerPhoneTitleIc.lineV.setVisibility(View.VISIBLE); - viewBinding.registerMailTitleIc.accountTitleTv.setText(R.string.home_login_閭); + viewBinding.registerMailTitleIc.accountTitleTv.setText(R.string.home_login_email); viewBinding.registerMailTitleIc.accountTitleTv.setTextSize(16); - viewBinding.registerMailTitleIc.accountTitleTv.setTextColor(getResources().getColor(R.color.text_40000000)); + viewBinding.registerMailTitleIc.accountTitleTv.setTextColor(getResources().getColor(R.color.text_40000000, null)); viewBinding.registerMailTitleIc.lineV.setVisibility(View.GONE); //杈撳叆鎵嬫満鍙� viewBinding.registerAccountEt.setInputType(InputType.TYPE_CLASS_NUMBER); - viewBinding.registerAccountEt.setHint(R.string.home_login_璇疯緭鍏ユ墜鏈哄彿); + viewBinding.registerAccountEt.setHint(R.string.home_login_input_phone); //鏄剧ず鎵嬫満鍙烽獙璇佺爜锛岄殣钘忛偖绠遍獙璇佺爜, viewBinding.registerPhoneVerificationCodeRl.setVisibility(View.VISIBLE); viewBinding.registerMailVerificationCodeRl.setVisibility(View.GONE); @@ -467,14 +432,14 @@ } else { //閭 - viewBinding.registerPhoneTitleIc.accountTitleTv.setText(R.string.home_login_鎵嬫満鍙�); + viewBinding.registerPhoneTitleIc.accountTitleTv.setText(R.string.home_login_phone); viewBinding.registerPhoneTitleIc.accountTitleTv.setTextSize(16); - viewBinding.registerPhoneTitleIc.accountTitleTv.setTextColor(getResources().getColor(R.color.text_40000000)); + viewBinding.registerPhoneTitleIc.accountTitleTv.setTextColor(getResources().getColor(R.color.text_40000000, null)); viewBinding.registerPhoneTitleIc.lineV.setVisibility(View.GONE); - viewBinding.registerMailTitleIc.accountTitleTv.setText(R.string.home_login_閭); + viewBinding.registerMailTitleIc.accountTitleTv.setText(R.string.home_login_email); viewBinding.registerMailTitleIc.accountTitleTv.setTextSize(20); - viewBinding.registerMailTitleIc.accountTitleTv.setTextColor(getResources().getColor(R.color.text_90000000)); + viewBinding.registerMailTitleIc.accountTitleTv.setTextColor(getResources().getColor(R.color.text_90000000, null)); viewBinding.registerMailTitleIc.lineV.setVisibility(View.VISIBLE); //杈撳叆閭 viewBinding.registerAccountEt.setInputType(InputType.TYPE_CLASS_TEXT); @@ -497,6 +462,11 @@ } isCompleteEnabled(); + try { + Country.load(this); + } catch (Exception e) { + e.printStackTrace(); + } } @@ -543,6 +513,7 @@ @Override protected void onDestroy() { super.onDestroy(); + Country.destroy(); if (phoneCountDownTimer != null) { phoneCountDownTimer.cancel(); phoneCountDownTimer = null; @@ -551,5 +522,110 @@ mailCountDownTimer.cancel(); mailCountDownTimer = null; } + viewBinding.registerAccountEt.removeTextChangedListener(accountTextWatcher); + viewBinding.registerPhoneVerificationEt.removeTextChangedListener(phoneVerificationTextWatcher); + viewBinding.registerMailVerificationEt.removeTextChangedListener(mailVerificationTextWatcher); + viewBinding.registerPswEt.removeTextChangedListener(changePswTextWatcher); + viewBinding.registerConfirmPswEt.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) { + + } + }; + + } \ No newline at end of file -- Gitblit v1.8.0