From 5d3efa4c93dde0cde474951e5310bb72ebbf4184 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期三, 07 五月 2025 15:18:26 +0800
Subject: [PATCH] 2025年05月07日15:18:20 1.2.0

---
 app/src/main/java/com/hdl/photovoltaic/ui/account/ChangePassword.java |  342 ++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 230 insertions(+), 112 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/account/ChangePassword.java b/app/src/main/java/com/hdl/photovoltaic/ui/account/ChangePassword.java
index 84e6434..91c829d 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/account/ChangePassword.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/account/ChangePassword.java
@@ -22,11 +22,17 @@
 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;
+import com.sahooz.library.countrypicker.CountryPickerFragment;
+import com.sahooz.library.countrypicker.PickCountryCallback;
 
 /**
  * 蹇樿瀵嗙爜鐣岄潰
@@ -54,6 +60,8 @@
 
     @Override
     public void onBindView(Bundle savedInstanceState) {
+        setStatusBarTranslucent();
+        getWindow().setNavigationBarColor(getColor(R.color.text_00000000));
         //鍒濆鍖�
         initView();
         //鍒濆鍖栫晫闈㈢洃鍚櫒
@@ -64,8 +72,35 @@
      * 鍒濆鍖栫晫闈�
      */
     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();
+        }
+        HdlCommonLogic.getInstance().setSpan(viewBinding.changePhoneVerificationTv, viewBinding.changePhoneVerificationTv.getText().toString(), true, null);
+        HdlCommonLogic.getInstance().setSpan(viewBinding.changeMailVerificationTv, viewBinding.changeMailVerificationTv.getText().toString(), true, null);
     }
+
 
     /**
      * 璁剧疆鐩戝惉浜嬩欢
@@ -97,23 +132,16 @@
 
             }
         });
-        //杈撳叆鎵嬫満鍙锋垨鑰呴偖绠�
-        viewBinding.changeAccountEt.addTextChangedListener(new TextWatcher() {
+        //閫夋嫨鎵嬫満鍖哄彿鐨�
+        viewBinding.regionAccountRl.setOnClickListener(new View.OnClickListener() {
             @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) {
-
+            public void onClick(View v) {
+                selectArea();
             }
         });
+
+        //杈撳叆鎵嬫満鍙锋垨鑰呴偖绠�
+        viewBinding.changeAccountEt.addTextChangedListener(accountTextWatcher);
         //鎵嬫満鍙疯幏鍙栭獙璇佺爜
         viewBinding.changePhoneVerificationTv.setOnClickListener(new View.OnClickListener() {
             @Override
@@ -123,22 +151,7 @@
             }
         });
         //杈撳叆鎵嬫満楠岃瘉鐮�
-        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
@@ -148,39 +161,9 @@
             }
         });
         //杈撳叆閭楠岃瘉鐮�
-        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
@@ -202,22 +185,7 @@
             }
         });
         //杈撳叆纭瀵嗙爜
-        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
@@ -253,7 +221,7 @@
                     verification_code = viewBinding.changeMailVerificationEt.getText().toString();
                 }
                 if (UserConfigManage.getInstance().isBAccount()) {
-                    HdlAccountLogic.getInstance().changeBPassword(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() {
@@ -274,11 +242,11 @@
 
                         @Override
                         public void onFailure(HDLException e) {
-
+                            HdlThreadLogic.toast(_mActivity, e);
                         }
                     });
                 } else {
-                    HdlAccountLogic.getInstance().changeCPassword(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() {
@@ -299,13 +267,28 @@
 
                         @Override
                         public void onFailure(HDLException e) {
-
+                            HdlThreadLogic.toast(_mActivity, e);
                         }
                     });
                 }
             }
         });
 
+    }
+
+    /**
+     * 鍥藉鎵嬫満鍙峰尯鍙峰脊绐�
+     */
+    private void selectArea() {
+        CountryPickerFragment dialog = new CountryPickerFragment(this, new PickCountryCallback() {
+            @Override
+            public void onPick(Country country) {
+                if (country.flag != 0) viewBinding.regionAccountTv.setText(country.translate);
+                viewBinding.regionAccountNumberTv.setText("+" + country.code);
+            }
+        });
+        dialog.show();
+        dialog.setDialogSize();
     }
 
     /**
@@ -330,26 +313,48 @@
                 //璁剧疆璐﹀彿鎵�鍦ㄥ尯鍩熷崗璁強鍦板潃
                 AppConfigManage.setUserRegionUrl(obj.getRegionUrl());
                 HDLLinkPMUser.getInstance().setUserRegionUrl(AppConfigManage.getUserRegionUrl());
-                HdlAccountLogic.getInstance().sendVerifyCode(isPhoneType, account, "86", 2, new CloudCallBeak<Boolean>() {
-                    @Override
-                    public void onSuccess(Boolean obj) {
-                        if (isPhoneType) {
-                            phoneCountDownTimer.start();
-                        } else {
-                            mailCountDownTimer.start();
+
+
+                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) {
+                        @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
             public void onFailure(HDLException e) {
-
+                HdlThreadLogic.toast(_mActivity, e);
 //                hideLoading();
             }
         });
@@ -364,7 +369,7 @@
             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_FFACACAC));
             viewBinding.changePhoneVerificationTv.setEnabled(false);
 
         }
@@ -372,7 +377,7 @@
         @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_FFACACAC));
             viewBinding.changePhoneVerificationTv.setEnabled(true);
 
 
@@ -388,7 +393,7 @@
             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_FFACACAC));
             viewBinding.changeMailVerificationTv.setEnabled(false);
 
         }
@@ -396,7 +401,7 @@
         @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_FFACACAC));
             viewBinding.changeMailVerificationTv.setEnabled(true);
 
         }
@@ -408,19 +413,21 @@
     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.accountTitleTv.setText(R.string.home_login_phone);
+            viewBinding.changePhoneIc.accountTitleTv.setTextSize(18);
+            viewBinding.changePhoneIc.accountTitleTv.setTextColor(getResources().getColor(R.color.text_FFACACAC));
             viewBinding.changePhoneIc.lineV.setVisibility(View.VISIBLE);
 
-            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_FF5B5B5B));
             viewBinding.changeMailRl.lineV.setVisibility(View.GONE);
 
+
+            viewBinding.regionAccountRl.setVisibility(View.VISIBLE);
             //杈撳叆鎵嬫満鍙�
             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);
@@ -438,15 +445,17 @@
 
         } 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_FF5B5B5B));
             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.accountTitleTv.setText(R.string.home_login_email);
+            viewBinding.changeMailRl.accountTitleTv.setTextSize(18);
+            viewBinding.changeMailRl.accountTitleTv.setTextColor(getResources().getColor(R.color.text_FFACACAC));
             viewBinding.changeMailRl.lineV.setVisibility(View.VISIBLE);
+
+            viewBinding.regionAccountRl.setVisibility(View.GONE);
             //杈撳叆閭
             viewBinding.changeAccountEt.setInputType(InputType.TYPE_CLASS_TEXT);
             viewBinding.changeAccountEt.setHint(R.string.home_login_input_mail);
@@ -485,6 +494,11 @@
             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_FFACACAC));
+        } else {
+            viewBinding.confirmTv.setTextColor(getColor(R.color.text_FF5B5B5B));
+        }
         viewBinding.confirmTv.setEnabled(isEnabled);
     }
 
@@ -522,5 +536,109 @@
             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) {
+
+        }
+    };
 }
\ No newline at end of file

--
Gitblit v1.8.0