Explorar o código

增加昵称设置最大长度为12,绑定密码的时候强制设置昵称和性别

Pq %!s(int64=2) %!d(string=hai) anos
pai
achega
bedfef7aab

+ 1 - 1
student/src/main/res/layout/activity_modify_nickname.xml

@@ -23,7 +23,7 @@
             android:background="@null"
             android:gravity="left|center_vertical"
             android:hint="请输入昵称"
-            android:maxLength="7"
+            android:maxLength="12"
             android:paddingLeft="14dp"
             android:paddingRight="30dp"
             android:textColor="@color/color_1a1a1a"

+ 1 - 1
teacher/src/main/res/layout/activity_modify_nickname.xml

@@ -25,7 +25,7 @@
             android:hint="请输入昵称"
             android:paddingLeft="14dp"
             android:paddingRight="30dp"
-            android:maxLength="7"
+            android:maxLength="12"
             android:textColor="@color/color_1a1a1a"
             android:textColorHint="@color/color_999999"
             android:textSize="@dimen/sp_16" />

+ 3 - 0
usercenter/src/main/java/com/cooleshow/usercenter/constants/UserConstants.java

@@ -18,4 +18,7 @@ public class UserConstants {
     public static final String EMPTY_ICON_RESID="empty_icon_resid";
     public static final String EMPTY_BTN_TEXT="empty_btn_text";
 
+
+    public static final String GENDER_TYPE_MALE = "1";//男
+    public static final String GENDER_TYPE_FEMALE = "0";//女
 }

+ 14 - 1
usercenter/src/main/java/com/cooleshow/usercenter/data/api/UserApi.kt

@@ -84,7 +84,11 @@ interface UserApi {
    */
     @FormUrlEncoded
     @POST(BaseConstant.AUTH_GROUP + "user/setUsernameAndPassword")
-    fun bindPassword(@Field("password") password: String,@Field("username") username: String): Observable<BaseResponse<Object>>
+    fun bindPassword(
+        @Field("password") password: String,
+        @Field("username") username: String,
+        @Field("gender") gander: String
+    ): Observable<BaseResponse<Object>>
 
     /*
       发送验证码
@@ -119,4 +123,13 @@ interface UserApi {
     @GET(BaseConstant.TEACHER_GROUP + "sysConfig/queryByParamName")
     fun queryModifyNickConfigForTeacher(@Query("paramName") last_username_month: String?): Observable<BaseResponse<QueryParamsConfigBean?>?>?
 
+
+    /**
+     * 获取修改名称限制时间
+     *
+     * @param
+     * @return
+     */
+    @GET(BaseConstant.STUDENT_GROUP + "sysConfig/queryByParamName")
+    fun queryModifyNickConfig(@Query("paramName") last_username_month: String?): Observable<BaseResponse<QueryParamsConfigBean?>?>?
 }

+ 16 - 2
usercenter/src/main/java/com/cooleshow/usercenter/presenter/BindPasswordPresenter.java

@@ -20,7 +20,7 @@ import com.cooleshow.usercenter.presenter.contract.BindPasswordContract;
 public class BindPasswordPresenter extends BasePresenter<BindPasswordContract.BindPwdView> implements BindPasswordContract.Presenter {
 
     @Override
-    public void onBindPwd(String pwd, String nickName) {
+    public void onBindPwd(String pwd, String nickName,String gender) {
         if (getView() != null) {
             getView().showLoading();
         }
@@ -39,7 +39,7 @@ public class BindPasswordPresenter extends BasePresenter<BindPasswordContract.Bi
                 }
             });
         } else {
-            addSubscribe(create(UserApi.class).bindPassword(pwd, nickName), new BaseObserver<Object>(getView()) {
+            addSubscribe(create(UserApi.class).bindPassword(pwd, nickName,gender), new BaseObserver<Object>(getView()) {
                 @Override
                 protected void onSuccess(Object data) {
                     if (getView() != null) {
@@ -74,6 +74,20 @@ public class BindPasswordPresenter extends BasePresenter<BindPasswordContract.Bi
 
                 }
             });
+        }else{
+            addSubscribe(create(UserApi.class).queryModifyNickConfig(params), new BaseObserver<QueryParamsConfigBean>(getView()) {
+                @Override
+                protected void onSuccess(QueryParamsConfigBean data) {
+                    if (getView() != null) {
+                        getView().queryModifyConfigSuccess(data);
+                    }
+                }
+
+                @Override
+                public void onError(Throwable e) {
+                    super.onError(e);
+                }
+            });
         }
     }
 }

+ 1 - 1
usercenter/src/main/java/com/cooleshow/usercenter/presenter/contract/BindPasswordContract.java

@@ -14,6 +14,6 @@ public interface BindPasswordContract {
     }
 
     interface Presenter {
-        void onBindPwd(String pwd,String nickName);
+        void onBindPwd(String pwd,String nickName,String gander);
     }
 }

+ 58 - 13
usercenter/src/main/java/com/cooleshow/usercenter/ui/activity/BindPasswordActivity.java

@@ -4,9 +4,12 @@ import android.content.Intent;
 import android.os.Bundle;
 import android.text.TextUtils;
 import android.view.View;
+import android.widget.TextView;
 
 import com.alibaba.android.arouter.facade.annotation.Route;
 import com.alibaba.android.arouter.launcher.ARouter;
+import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
+import com.bigkoo.pickerview.view.OptionsPickerView;
 import com.cooleshow.base.bean.QueryParamsConfigBean;
 import com.cooleshow.base.common.BaseApplication;
 import com.cooleshow.base.router.RouterPath;
@@ -21,6 +24,8 @@ import com.cooleshow.usercenter.helper.PhoneCheckHelper;
 import com.cooleshow.usercenter.presenter.BindPasswordPresenter;
 import com.cooleshow.usercenter.presenter.contract.BindPasswordContract;
 
+import java.util.ArrayList;
+
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 
@@ -30,6 +35,10 @@ import androidx.annotation.Nullable;
 @Route(path = RouterPath.UserCenter.PATH_BIND_PASSWORD)
 public class BindPasswordActivity extends BaseMVPActivity<ActivityBindPwdLayoutBinding, BindPasswordPresenter> implements BindPasswordContract.BindPwdView, View.OnClickListener {
     private String tempToken;
+    private OptionsPickerView pvOptions;
+    private ArrayList<String> sexList = new ArrayList<>();
+    private String currentGander = "";
+
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -47,17 +56,16 @@ public class BindPasswordActivity extends BaseMVPActivity<ActivityBindPwdLayoutB
     protected void initView() {
         viewBinding.tvConfirm.setOnClickListener(this);
         tempToken = getIntent().getStringExtra(UserConstants.TEMP_TOKEN);
+        sexList.add("男");
+        sexList.add("女");
     }
 
     @Override
     public void initData() {
         super.initData();
-        if(BaseApplication.Companion.isTeacherClient()){
-            presenter.queryModifyConfig();
-            viewBinding.groupNickname.setVisibility(View.VISIBLE);
-        }else{
-            viewBinding.groupNickname.setVisibility(View.GONE);
-        }
+        presenter.queryModifyConfig();
+        viewBinding.groupNickname.setVisibility(View.VISIBLE);
+        viewBinding.tvSetSex.setOnClickListener(this);
     }
 
     @Override
@@ -79,21 +87,28 @@ public class BindPasswordActivity extends BaseMVPActivity<ActivityBindPwdLayoutB
 
     @Override
     public void onClick(View v) {
-        if (v.getId() == R.id.tv_confirm) {
+        int id = v.getId();
+        if (id == R.id.tv_confirm) {
             String pwd = viewBinding.etPwd.getText().toString();
             String pwdAgain = viewBinding.etPwdAgain.getText().toString();
             String nickName = viewBinding.etNickname.getText().toString().trim();
-            if(BaseApplication.Companion.isTeacherClient()){
-                if (TextUtils.isEmpty(nickName)) {
-                    ToastUtil.getInstance().showShort("请输入昵称!");
-                    return;
-                }
+            if (TextUtils.isEmpty(nickName)) {
+                ToastUtil.getInstance().showShort("请输入昵称!");
+                return;
+            }
+            if (TextUtils.isEmpty(currentGander)) {
+                ToastUtil.getInstance().showShort("请设置性别!");
+                return;
             }
             if (PhoneCheckHelper.checkPwdValidity(pwd, pwdAgain)) {
-                presenter.onBindPwd(pwdAgain,nickName);
+                presenter.onBindPwd(pwdAgain, nickName,currentGander);
             }
             return;
         }
+        if (id == R.id.tv_set_sex) {
+            selectSex();
+            return;
+        }
     }
 
     private void reBackLogin() {
@@ -104,8 +119,38 @@ public class BindPasswordActivity extends BaseMVPActivity<ActivityBindPwdLayoutB
 
     }
 
+    private void selectSex() {
+        pvOptions = new OptionsPickerBuilder(this, (options1, options2, options3, v) -> {
+            if (options1 < sexList.size()) {
+                String s = sexList.get(options1);
+                viewBinding.tvSetSex.setTextColor(getResources().getColor(com.cooleshow.base.R.color.color_333333));
+                viewBinding.tvSetSex.setText(s);
+                setGanderValue(s);
+            }
+        }).setLayoutRes(R.layout.pickerview_sex_select_layout, v -> {
+            //自定义布局中的控件初始化及事件处理
+            final TextView tvSubmit = (TextView) v.findViewById(com.cooleshow.base.R.id.tv_finish);
+            TextView ivCancel = (TextView) v.findViewById(com.cooleshow.base.R.id.tv_cancel);
+            tvSubmit.setOnClickListener(v12 -> {
+                pvOptions.returnData();
+                pvOptions.dismiss();
+            });
+            ivCancel.setOnClickListener(v1 -> pvOptions.dismiss());
+
+        }).isDialog(false).build();
+        pvOptions.setPicker(sexList);
+        pvOptions.show();
+
+    }
+
     @Override
     protected BindPasswordPresenter createPresenter() {
         return new BindPasswordPresenter();
     }
+
+    private void setGanderValue(String result) {
+        if (!TextUtils.isEmpty(result)) {
+            currentGander = TextUtils.equals(result, "男") ? UserConstants.GENDER_TYPE_MALE : UserConstants.GENDER_TYPE_FEMALE;
+        }
+    }
 }

BIN=BIN
usercenter/src/main/res/drawable-xhdpi/icon_check_select_20dp.png


BIN=BIN
usercenter/src/main/res/drawable-xhdpi/icon_check_unselect.png


BIN=BIN
usercenter/src/main/res/drawable-xxhdpi/icon_check_select_20dp.png


BIN=BIN
usercenter/src/main/res/drawable-xxhdpi/icon_check_unselect.png


+ 42 - 3
usercenter/src/main/res/layout/activity_bind_pwd_layout.xml

@@ -51,7 +51,7 @@
         android:background="@null"
         android:hint="请设置您的昵称"
         android:inputType="text"
-        android:maxLength="7"
+        android:maxLength="12"
         android:textColorHint="@color/color_ffc1c1c1"
         android:textSize="@dimen/sp_16"
         app:layout_constraintLeft_toLeftOf="parent"
@@ -82,14 +82,53 @@
 
     <androidx.constraintlayout.widget.Group
         android:visibility="gone"
+        tools:visibility="visible"
         android:id="@+id/group_nickname"
         app:constraint_referenced_ids="tv_modify_config,view_nickname_divide,et_nickname,tv_set_nickname"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"/>
 
     <TextView
+        android:layout_marginTop="16dp"
+        android:id="@+id/tv_sex_title"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="35dp"
+        android:includeFontPadding="false"
+        android:text="请设置性别"
+        android:textColor="@color/black"
+        android:textSize="@dimen/sp_18"
+        android:textStyle="bold"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/tv_modify_config" />
+
+    <TextView
+        android:id="@+id/tv_set_sex"
+        android:layout_width="match_parent"
+        android:layout_height="50dp"
+        android:layout_marginStart="35dp"
+        android:layout_marginEnd="35dp"
+        android:background="@null"
+        android:gravity="center_vertical"
+        android:hint="请设置您的性别"
+        android:inputType="text"
+        android:textColor="@color/color_ffc1c1c1"
+        android:textSize="@dimen/sp_16"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/tv_sex_title" />
+
+    <View
+        android:background="@color/color_f0f0f0"
+        app:layout_constraintBottom_toBottomOf="@+id/tv_set_sex"
+        android:layout_marginEnd="35dp"
+        android:layout_marginStart="35dp"
+        android:layout_width="match_parent"
+        android:layout_height="1px"/>
+
+    <TextView
         app:layout_goneMarginTop="71dp"
-        android:layout_marginTop="10dp"
+        android:layout_marginTop="16dp"
         android:id="@+id/tv_phone_num"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
@@ -100,7 +139,7 @@
         android:textSize="@dimen/sp_18"
         android:textStyle="bold"
         app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintTop_toBottomOf="@+id/tv_modify_config" />
+        app:layout_constraintTop_toBottomOf="@+id/tv_set_sex" />
 
 
     <EditText

+ 76 - 0
usercenter/src/main/res/layout/pickerview_sex_select_layout.xml

@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:background="@drawable/bg_white_top_10dp"
+    android:orientation="vertical">
+
+    <RelativeLayout
+        android:layout_width="match_parent"
+        android:layout_height="50dp">
+
+
+        <TextView
+            android:id="@+id/tv_cancel"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerVertical="true"
+            android:layout_marginLeft="17dp"
+            android:text="取消"
+            android:textColor="@color/color_999999"
+            android:textSize="@dimen/dp_16" />
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerInParent="true"
+            android:text=""
+            android:textColor="@color/color_1a1a1a"
+            android:textSize="18dp" />
+
+        <TextView
+            android:id="@+id/tv_finish"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentRight="true"
+            android:layout_centerVertical="true"
+            android:layout_marginRight="17dp"
+            android:padding="8dp"
+            android:text="确定"
+            android:textColor="@color/colorPrimary"
+            android:textSize="@dimen/dp_16" />
+
+    </RelativeLayout>
+
+    <View style="@style/line_style" />
+    <!--此部分需要完整复制过去,删减或者更改ID会导致初始化找不到内容而报空-->
+    <LinearLayout
+        android:id="@+id/optionspicker"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/dp_200"
+        android:background="#ffffff"
+        android:gravity="center"
+        android:minHeight="150dp"
+        android:orientation="horizontal">
+
+        <com.contrarywind.view.WheelView
+            android:id="@+id/options1"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="1" />
+
+        <com.contrarywind.view.WheelView
+            android:id="@+id/options2"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="1" />
+
+        <com.contrarywind.view.WheelView
+            android:id="@+id/options3"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="1" />
+    </LinearLayout>
+
+
+</LinearLayout>