|
@@ -1,294 +0,0 @@
|
|
-package com.yyrh.ui;
|
|
|
|
-
|
|
|
|
-import android.app.Activity;
|
|
|
|
-import android.content.Context;
|
|
|
|
-import android.graphics.Paint;
|
|
|
|
-import android.os.CountDownTimer;
|
|
|
|
-import android.text.method.HideReturnsTransformationMethod;
|
|
|
|
-import android.text.method.PasswordTransformationMethod;
|
|
|
|
-import android.view.View;
|
|
|
|
-import android.widget.Button;
|
|
|
|
-import android.widget.CheckBox;
|
|
|
|
-import android.widget.EditText;
|
|
|
|
-import android.widget.ImageView;
|
|
|
|
-import android.widget.TextView;
|
|
|
|
-
|
|
|
|
-import com.yyrh.constant.SDKSettings;
|
|
|
|
-import com.yyrh.constant.URLConstants;
|
|
|
|
-import com.yyrh.networking.NetRequestApi;
|
|
|
|
-import com.yyrh.sdk.SDKEntry;
|
|
|
|
-import com.yyrh.sdk.YyrhSdkManager;
|
|
|
|
-import com.yyrh.ui.floatmenu.WvPageListDialog;
|
|
|
|
-import com.yyrh.ui.fragment.UserPhoneLoginFragment;
|
|
|
|
-import com.yyrh.ui.userlist.User;
|
|
|
|
-import com.yyrh.utils.ResourceUtil;
|
|
|
|
-import com.yyrh.utils.SignUtils;
|
|
|
|
-import com.yyrh.utils.TosUtil;
|
|
|
|
-import com.yyrh.utils.Utils;
|
|
|
|
-
|
|
|
|
-import static com.yyrh.constant.URLConstants.RSAKEY;
|
|
|
|
-
|
|
|
|
-public class PhoneRegisterLayout implements View.OnClickListener {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- private Context context;
|
|
|
|
- private ConstantDialog constantDialog;
|
|
|
|
- private EditText et_user_phone,et_user_code,et_user_pwd;
|
|
|
|
- private Button btn_get_code,et_reg_compete_btn;
|
|
|
|
- private ImageView down_eye_btn,close_btn;
|
|
|
|
- private boolean isShowPwd = false;
|
|
|
|
- private CheckBox cb_register;
|
|
|
|
- private TextView tv_tip,tv_private_policy;
|
|
|
|
- public PhoneRegisterLayout(Context context, ConstantDialog constantDialog){
|
|
|
|
-
|
|
|
|
- this.context = context;
|
|
|
|
- this.constantDialog = constantDialog;
|
|
|
|
- if (SDKSettings.isLandscape){
|
|
|
|
- constantDialog.setContentView(ResourceUtil.getLayoutId(context, "yyrh_phone_register_dialog"));
|
|
|
|
- }else{
|
|
|
|
- constantDialog.setContentView(ResourceUtil.getLayoutId(context, "yyrh_phone_register_dialog_protrait"));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- et_user_phone = constantDialog.findViewById(ResourceUtil.getId(context, "et_user_phone"));
|
|
|
|
- et_user_code = constantDialog.findViewById(ResourceUtil.getId(context, "et_user_code"));
|
|
|
|
- et_user_pwd = constantDialog.findViewById(ResourceUtil.getId(context, "et_user_pwd"));
|
|
|
|
- btn_get_code = constantDialog.findViewById(ResourceUtil.getId(context, "btn_get_code"));
|
|
|
|
- et_reg_compete_btn = constantDialog.findViewById(ResourceUtil.getId(context, "et_reg_compete_btn"));
|
|
|
|
- down_eye_btn = constantDialog.findViewById(ResourceUtil.getId(context, "down_eye_btn"));
|
|
|
|
-
|
|
|
|
- cb_register = constantDialog.findViewById(ResourceUtil.getId(context, "cb_register"));
|
|
|
|
-
|
|
|
|
- close_btn = constantDialog.findViewById(ResourceUtil.getId(context, "close_btn"));
|
|
|
|
-
|
|
|
|
- tv_tip = constantDialog.findViewById(ResourceUtil.getId(context, "tv_tip"));
|
|
|
|
- tv_tip.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG );
|
|
|
|
- tv_tip.getPaint().setAntiAlias(true);
|
|
|
|
-
|
|
|
|
- tv_private_policy = constantDialog.findViewById(ResourceUtil.getId(context, "tv_private_policy"));
|
|
|
|
- tv_private_policy.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG );
|
|
|
|
- tv_private_policy.getPaint().setAntiAlias(true);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- tv_private_policy.setOnClickListener(this);
|
|
|
|
- down_eye_btn.setOnClickListener(this);
|
|
|
|
- btn_get_code.setOnClickListener(this);
|
|
|
|
- close_btn.setOnClickListener(this);
|
|
|
|
- tv_tip.setOnClickListener(this);
|
|
|
|
- et_reg_compete_btn.setOnClickListener(this);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void onClick(View v) {
|
|
|
|
- int id = v.getId();
|
|
|
|
- if (id == ResourceUtil.getId(context, "btn_get_code")) {
|
|
|
|
- String phone = et_user_phone.getText().toString();
|
|
|
|
-
|
|
|
|
- if (phone.length() < 10) {
|
|
|
|
- new TosUtil(context,"blue", context.getString(ResourceUtil.getStringId(context, "yyrh_pls_input_right_phone"))).show();
|
|
|
|
- // ToastUtil.show(context, context.getString(ResourceUtil.getStringId(context, "yyrh_pls_input_right_phone")));
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- getPhoneCaptcha((Activity) context,phone,"register");
|
|
|
|
-
|
|
|
|
- }else if (id == ResourceUtil.getId(context, "et_reg_compete_btn")) {
|
|
|
|
-
|
|
|
|
- registerWithPhone((Activity) context);
|
|
|
|
- }else if (id == ResourceUtil.getId(context, "close_btn")) {
|
|
|
|
- new RegisterLayout(context,constantDialog);
|
|
|
|
- }else if (id == ResourceUtil.getId(context, "tv_tip")) {
|
|
|
|
-
|
|
|
|
- String url = SDKSettings.UserCentUrl + URLConstants.USERPROTOCOLWEB + "gcp_code=" + SDKSettings.gcp_code
|
|
|
|
- + "&game_code=" + SDKSettings.game_code;
|
|
|
|
-
|
|
|
|
- new WvPageListDialog(context,ResourceUtil.getStyleId(context,"yyrh_base_dialog"),url).show();
|
|
|
|
-
|
|
|
|
- }else if (id == ResourceUtil.getId(context, "tv_private_policy")) {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- String url = SDKSettings.UserCentUrl + URLConstants.USERPOLICYWEB + "gcp_code=" + SDKSettings.gcp_code
|
|
|
|
- + "&game_code=" + SDKSettings.game_code;
|
|
|
|
-
|
|
|
|
- new WvPageListDialog(context,ResourceUtil.getStyleId(context,"yyrh_base_dialog"),url).show();
|
|
|
|
-
|
|
|
|
- } else if (id == ResourceUtil.getId(context, "down_eye_btn")) {
|
|
|
|
- if (!isShowPwd) {
|
|
|
|
- isShowPwd = true;
|
|
|
|
- et_user_pwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
|
|
|
|
- down_eye_btn.setImageResource(ResourceUtil.getMipmapId(context, "yyrh_eye_icon_select"));
|
|
|
|
- } else {
|
|
|
|
- isShowPwd = false;
|
|
|
|
- et_user_pwd.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
|
|
|
- down_eye_btn.setImageResource(ResourceUtil.getMipmapId(context, "yyrh_eye_icon_normal"));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void getPhoneCaptcha(Activity activity, String phone, String action){
|
|
|
|
- NetRequestApi.getPhoneCaptcha(activity, phone, action, new UserPhoneLoginFragment.CaptchaCallback() {
|
|
|
|
- @Override
|
|
|
|
- public void onGetSuccess(String msg) {
|
|
|
|
- getCodeSuccess();
|
|
|
|
-
|
|
|
|
- new TosUtil(context,"green",context.getString(ResourceUtil.getStringId(context, "yyrh_send_code_success"))).show();
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // ToastUtil.show(context,context.getString(ResourceUtil.getStringId(context, "yyrh_send_code_success")));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void onGetFailed(String msg) {
|
|
|
|
-
|
|
|
|
- new TosUtil(context,"blue",msg).show();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- private void registerWithPhone(final Activity activity){
|
|
|
|
- String code = et_user_code.getText().toString();
|
|
|
|
- final String account = et_user_phone.getText().toString();
|
|
|
|
- final String pwd = et_user_pwd.getText().toString();
|
|
|
|
- String userInfo ="";
|
|
|
|
-
|
|
|
|
- if(account.length() < 10 || Utils.judgeStrNull(account))
|
|
|
|
- {
|
|
|
|
- new TosUtil(context,"blue", context.getString(ResourceUtil.getStringId(context, "yyrh_pls_input_right_phone"))).show();
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if(pwd.length() < 6 || Utils.judgeStrNull(pwd))
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- new TosUtil(context,"blue", context.getString(ResourceUtil.getStringId(context, "yyrh_pwd_limit_6"))).show();
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if(code.length() < 4 || Utils.judgeStrNull(code))
|
|
|
|
- {
|
|
|
|
- new TosUtil(context,"blue", context.getString(ResourceUtil.getStringId(context, "yyrh_pls_input_right_code"))).show();
|
|
|
|
-
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!cb_register.isChecked()){
|
|
|
|
-
|
|
|
|
- new TosUtil(context, "blue",context.getString(ResourceUtil.getStringId(context, "yyrh_pls_checked_reg_tip"))).show();
|
|
|
|
-
|
|
|
|
- return;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- userInfo = SignUtils.encryptRsaByPublicKey(RSAKEY,account+"|"+ pwd);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- // TODO Auto-generated catch block
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- registerInterval();
|
|
|
|
- NetRequestApi.registerWithPhone(activity,code,userInfo, new UserPhoneLoginFragment.PhoneRegisterCallback() {
|
|
|
|
- @Override
|
|
|
|
- public void onRegisterSuccess(String msg) {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- constantDialog.dismiss();
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- YyrhSdkManager.defaultManager(context).saveUserLoginInfo(context,account,pwd,msg);
|
|
|
|
-
|
|
|
|
- SDKEntry.getSdkInstance().adSdkCallback.onRegisterSuccess(account);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void onRegisterFailed(String msg) {
|
|
|
|
- new TosUtil(context,"blue", msg).show();
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- private void getCodeSuccess() {
|
|
|
|
- btn_get_code.setEnabled(false);
|
|
|
|
- btn_get_code.setText("60s");
|
|
|
|
- btn_get_code.setBackgroundResource(ResourceUtil.getDrawableId(context,"yyrh_radius_main_color_1dp"));
|
|
|
|
- TimeCount time = new TimeCount(60000, 1000);
|
|
|
|
- time.start();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- class TimeCount extends CountDownTimer {
|
|
|
|
-
|
|
|
|
- public TimeCount(long millisInFuture, long countDownInterval) {
|
|
|
|
- super(millisInFuture, countDownInterval);
|
|
|
|
- // TODO Auto-generated constructor stub
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void onTick(long millisUntilFinished) {
|
|
|
|
- // TODO Auto-generated method stub
|
|
|
|
- btn_get_code.setText(millisUntilFinished / 1000 + "s");
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void onFinish() {
|
|
|
|
- // TODO Auto-generated method stub
|
|
|
|
- btn_get_code.setEnabled(true);
|
|
|
|
- btn_get_code.setBackgroundResource(ResourceUtil.getDrawableId(context,"yyrh_radius_green_3dp"));
|
|
|
|
- btn_get_code.setText(ResourceUtil.getStringId(context, "yyrh_get_phone_code"));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public interface CaptchaCallback {
|
|
|
|
-
|
|
|
|
- void onGetSuccess(String msg);
|
|
|
|
- void onGetFailed(String msg);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public interface PhoneRegisterCallback {
|
|
|
|
-
|
|
|
|
- void onRegisterSuccess(String msg);
|
|
|
|
- void onRegisterFailed(String msg);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void registerInterval() {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- et_reg_compete_btn.setEnabled(false);
|
|
|
|
- et_reg_compete_btn.setText("3s");
|
|
|
|
- et_reg_compete_btn.setBackgroundResource(ResourceUtil.getColorId(context,"yyrh_black_color_40"));
|
|
|
|
- RegTimeCount time = new RegTimeCount(3000, 1000);
|
|
|
|
- time.start();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- class RegTimeCount extends CountDownTimer {
|
|
|
|
-
|
|
|
|
- public RegTimeCount(long millisInFuture, long countDownInterval) {
|
|
|
|
- super(millisInFuture, countDownInterval);
|
|
|
|
- // TODO Auto-generated constructor stub
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void onTick(long millisUntilFinished) {
|
|
|
|
- // TODO Auto-generated method stub
|
|
|
|
- et_reg_compete_btn.setText(millisUntilFinished / 1000 + "s");
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void onFinish() {
|
|
|
|
- // TODO Auto-generated method stub
|
|
|
|
- et_reg_compete_btn.setEnabled(true);
|
|
|
|
- et_reg_compete_btn.setBackgroundResource(ResourceUtil.getColorId(context,"yyrh_btn1_color"));
|
|
|
|
- et_reg_compete_btn.setText(ResourceUtil.getStringId(context, "yyrh_register_success"));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-}
|
|
|