Pq пре 3 месеци
родитељ
комит
3bd5dab01c

+ 1 - 0
BaseLibrary/src/main/res/values/colors.xml

@@ -234,4 +234,5 @@
     <color name="color_006eb0">#006EB0</color>
     <color name="color_cc005ba2">#cc005BA2</color>
     <color name="color_d9d9d9">#D9D9D9</color>
+    <color name="color_c1c1c1">#C1C1C1</color>
 </resources>

+ 6 - 0
chatModule/src/main/AndroidManifest.xml

@@ -92,6 +92,12 @@
             android:configChanges="orientation|screenSize|keyboardHidden|fontScale|smallestScreenSize|screenLayout|uiMode"
             android:screenOrientation="portrait" />
 
+        <activity
+            android:name=".ui.GroupIntroduceActivity"
+            android:windowSoftInputMode="adjustPan"
+            android:configChanges="orientation|screenSize|keyboardHidden|fontScale|smallestScreenSize|screenLayout|uiMode"
+            android:screenOrientation="portrait" />
+
         <provider
             android:name=".widget.CustomChatGroupTopRightIconExtension"
             android:authorities="${applicationId}.TUIGroup.ClassicUI.Init"

+ 11 - 2
chatModule/src/main/java/com/cooleshow/chatmodule/api/IMApi.java

@@ -186,8 +186,8 @@ public interface IMApi {
      * @param body
      * @return
      */
-    @POST(TEACHER_GROUP + "imGroup/update")
-    Observable<BaseResponse<Object>> updateGroupInfo(@Body RequestBody body);
+    @POST("{group_name}" + "imGroup/update")
+    Observable<BaseResponse<Object>> updateGroupInfo(@Body RequestBody body,@Path("group_name")String group_name);
 
     @POST("{group_name}" + "/imGroupMember/groupMute")
     Observable<BaseResponse<Object>> groupMemberMute(@Body RequestBody body,@Path("group_name")String group_name);
@@ -203,4 +203,13 @@ public interface IMApi {
      */
     @POST("{group_name}" + "/imUserFriend/getDetail/{imUserId}")
     Observable<BaseResponse<IMUserInfo>> queryFriendDetail(@Path("group_name")String group_name,@Path("imUserId") String imUserId);
+
+    /**
+     * 修改群信息
+     *
+     * @param body
+     * @return
+     */
+    @POST("{group_name}" + "imGroup/updateIntroduce")
+    Observable<BaseResponse<Object>> updateGroupIntroduce(@Body RequestBody body,@Path("group_name")String group_name);
 }

+ 1 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/constants/Constants.java

@@ -5,5 +5,6 @@ package com.cooleshow.chatmodule.constants;
  */
 public class Constants {
     public static final String TARGET_ID_KEY = "targetId";
+    public static final String COMMON_EXTRA_KEY = "common_extra";
     public static final long MAX_MUTE_TIME = -1;
 }

+ 1 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/constants/TCChatRouterPath.java

@@ -17,4 +17,5 @@ public class TCChatRouterPath {
     public final static String CHAT_GROUP_JOIN_APPLY = "/tc/activity/JoinGroupApplyActivity";
     public final static String CHAT_SELECT_CONTACT = "/tc/activity/SelectContactActivity";
     public final static String CHAT_GROUP_NOTICE_DETAIL = "/tc/activity/NoticeDetailActivity";
+    public final static String CHAT_GROUP_INTRODUCE = "/tc/activity/GroupIntroduceActivity";
 }

+ 18 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/contract/GroupIntroduceContract.java

@@ -0,0 +1,18 @@
+package com.cooleshow.chatmodule.contract;
+
+import com.cooleshow.base.presenter.view.BaseView;
+
+/**
+ * 创建日期:2022/6/11 19:39
+ *
+ * @author Ryan
+ * 类说明:
+ */
+public interface GroupIntroduceContract {
+    interface View extends BaseView {
+        void updateGroupIntroduceSuccess();
+    }
+
+    interface Presenter {
+    }
+}

+ 44 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/presenter/GroupIntroducePresenter.java

@@ -0,0 +1,44 @@
+package com.cooleshow.chatmodule.presenter;
+
+import com.cooleshow.base.common.BaseConstant;
+import com.cooleshow.base.presenter.BasePresenter;
+import com.cooleshow.base.rx.BaseObserver;
+import com.cooleshow.base.utils.RequestBodyUtil;
+import com.cooleshow.chatmodule.api.IMApi;
+import com.cooleshow.chatmodule.contract.GroupIntroduceContract;
+import com.cooleshow.chatmodule.contract.NoticeEditContract;
+import com.cooleshow.usercenter.helper.UserHelper;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ * 创建日期:2022/6/11 19:38
+ *
+ * @author Ryan
+ * 类说明:
+ */
+public class GroupIntroducePresenter extends BasePresenter<GroupIntroduceContract.View> implements GroupIntroduceContract.Presenter {
+    public void updateGroupIntroduce(String targetId, String content) {
+        if (getView() != null) {
+            getView().showLoading();
+        }
+        JSONObject jsonObject = new JSONObject();
+        try {
+            jsonObject.putOpt("groupId", targetId);
+            jsonObject.putOpt("introduce", content);
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+        addSubscribe(create(IMApi.class).updateGroupIntroduce(RequestBodyUtil.convertToRequestBodyJson(jsonObject.toString()), BaseConstant.CLIENT_API_GROUP_NAME), new BaseObserver<Object>(getView()) {
+            @Override
+            protected void onSuccess(Object data) {
+                if (getView() != null) {
+                    getView().updateGroupIntroduceSuccess();
+                }
+            }
+        });
+
+    }
+
+}

+ 2 - 1
chatModule/src/main/java/com/cooleshow/chatmodule/presenter/SetRemarksPresenter.java

@@ -1,5 +1,6 @@
 package com.cooleshow.chatmodule.presenter;
 
+import com.cooleshow.base.common.BaseConstant;
 import com.cooleshow.base.presenter.BasePresenter;
 import com.cooleshow.base.rx.BaseObserver;
 import com.cooleshow.base.utils.RequestBodyUtil;
@@ -29,7 +30,7 @@ public class SetRemarksPresenter extends BasePresenter<SetRemarksContract.SetRem
         } catch (JSONException e) {
             e.printStackTrace();
         }
-        addSubscribe(create(IMApi.class).updateGroupInfo(RequestBodyUtil.convertToRequestBodyJson(jsonObject.toString())), new BaseObserver<Object>(getView()) {
+        addSubscribe(create(IMApi.class).updateGroupInfo(RequestBodyUtil.convertToRequestBodyJson(jsonObject.toString()), BaseConstant.CLIENT_API_GROUP_NAME), new BaseObserver<Object>(getView()) {
             @Override
             protected void onSuccess(Object data) {
                 if (getView() != null) {

+ 11 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/ui/ChatGroupSettingActivity.java

@@ -91,6 +91,7 @@ public class ChatGroupSettingActivity extends BaseMVPActivity<TcActivityChatGrou
     GroupSettingMemberAdapter mAdapter;
     private GroupInfo mGroupInfo;
     private GroupRoleType currentUserGroupType = GroupRoleType.Member;
+    private String groupIntroduce;
 
     @Override
     public void onClick(View view) {
@@ -140,6 +141,12 @@ public class ChatGroupSettingActivity extends BaseMVPActivity<TcActivityChatGrou
                     .withString(Constants.TARGET_ID_KEY, targetId)
                     .navigation();
             return;
+        } else if (view.getId() == R.id.ll_group_introduce) {
+            //群简介
+            ARouter.getInstance().build(TCChatRouterPath.CHAT_GROUP_INTRODUCE)
+                    .withString(Constants.TARGET_ID_KEY, targetId)
+                    .withString(Constants.COMMON_EXTRA_KEY, groupIntroduce)
+                    .navigation();
         }
 
     }
@@ -225,6 +232,7 @@ public class ChatGroupSettingActivity extends BaseMVPActivity<TcActivityChatGrou
         viewBinding.tvFeedback.setOnClickListener(this);
         viewBinding.btnConfirm.setOnClickListener(this);
         viewBinding.tvMuteMemberManager.setOnClickListener(this);
+        viewBinding.llGroupIntroduce.setOnClickListener(this);
 
         IMThemManager.getInstance().setCheckButtonDrawable(viewBinding.cbMessage);
         IMThemManager.getInstance().setMainButtonStyles(viewBinding.btnConfirm);
@@ -406,6 +414,9 @@ public class ChatGroupSettingActivity extends BaseMVPActivity<TcActivityChatGrou
             }
             tv_group_name.setText(data.getName());
             tv_group_name_remarks.setText(data.getName());
+            //群简介
+            this.groupIntroduce = data.getIntroduce();
+            viewBinding.tvGroupIntroduce.setText(data.getIntroduce());
 
             //群禁言状态
             if (!TextUtils.isEmpty(data.getConfigJson())) {

+ 144 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/ui/GroupIntroduceActivity.java

@@ -0,0 +1,144 @@
+package com.cooleshow.chatmodule.ui;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.Editable;
+import android.text.TextUtils;
+import android.text.TextWatcher;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.cooleshow.base.common.BaseApplication;
+import com.cooleshow.base.ui.activity.BaseMVPActivity;
+import com.cooleshow.base.utils.ToastUtil;
+import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
+import com.cooleshow.chatmodule.constants.Constants;
+import com.cooleshow.chatmodule.constants.TCChatRouterPath;
+import com.cooleshow.chatmodule.contract.GroupIntroduceContract;
+import com.cooleshow.chatmodule.databinding.TcActivityGroupIntroduceBinding;
+import com.cooleshow.chatmodule.presenter.GroupIntroducePresenter;
+
+import java.util.Locale;
+
+import androidx.annotation.Nullable;
+
+/**
+ * 创建日期:2022/6/11 19:25
+ *
+ * @author Ryan
+ * 类说明:
+ */
+@Route(path = TCChatRouterPath.CHAT_GROUP_INTRODUCE)
+public class GroupIntroduceActivity extends BaseMVPActivity<TcActivityGroupIntroduceBinding, GroupIntroducePresenter> implements GroupIntroduceContract.View {
+
+    EditText etNotice;
+    Button btnCommit;
+    private String targetId;
+    private String contentText;
+
+    private TextWatcher mContentWatcher = 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) {
+
+        }
+
+        @Override
+        public void afterTextChanged(Editable s) {
+            formatTextNum2();
+        }
+    };
+
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        QMUIStatusBarHelper.setStatusBarLightMode(this);
+    }
+
+    @Override
+    protected void initView() {
+        etNotice = viewBinding.etNotice;
+        btnCommit = viewBinding.btnCommit;
+
+        Intent intent = getIntent();
+        targetId = intent.getStringExtra(Constants.TARGET_ID_KEY);
+        initMidTitleToolBar(viewBinding.toolbarInclude.toolbar, "群简介");
+        contentText = intent.getStringExtra(Constants.COMMON_EXTRA_KEY);
+        etNotice.setText(contentText);
+        initListener();
+        formatTextNum2();
+    }
+
+    @Override
+    public void initData() {
+        super.initData();
+        if(BaseApplication.Companion.isTeacherClient()){
+            viewBinding.tvContentTextNum.setVisibility(View.VISIBLE);
+            viewBinding.btnCommit.setVisibility(View.VISIBLE);
+            etNotice.setFocusable(true);
+            etNotice.setFocusableInTouchMode(true);
+        }else{
+            viewBinding.tvContentTextNum.setVisibility(View.GONE);
+            viewBinding.btnCommit.setVisibility(View.GONE);
+            etNotice.setFocusable(false);
+            etNotice.setFocusableInTouchMode(false);
+        }
+    }
+
+    private void initListener() {
+        viewBinding.etNotice.addTextChangedListener(mContentWatcher);
+        btnCommit.setOnClickListener(v -> {
+            String content = etNotice.getText().toString().trim();
+            if (TextUtils.isEmpty(content)) {
+                ToastUtil.getInstance().showShort("请输入群简介");
+                return;
+            }
+            presenter.updateGroupIntroduce(targetId, content);
+        });
+    }
+
+    @Override
+    protected TcActivityGroupIntroduceBinding getLayoutView() {
+        return TcActivityGroupIntroduceBinding.inflate(getLayoutInflater());
+    }
+
+    @Override
+    protected GroupIntroducePresenter createPresenter() {
+        return new GroupIntroducePresenter();
+    }
+
+
+    private void formatTextNum2() {
+        String text = viewBinding.etNotice.getText().toString().trim();
+        int cLength = text.length();
+        viewBinding.tvContentTextNum.setText(String.format(Locale.getDefault(), "%d/200", cLength));
+    }
+
+    @Override
+    public void onDestroy() {
+        removeTextWatcher();
+        super.onDestroy();
+    }
+
+    private void removeTextWatcher() {
+        if (viewBinding != null) {
+            viewBinding.etNotice.removeTextChangedListener(mContentWatcher);
+        }
+    }
+
+    @Override
+    public void updateGroupIntroduceSuccess() {
+        if (!checkActivityExist()) {
+            return;
+        }
+        ToastUtil.getInstance().showShort("保存成功");
+        finish();
+    }
+}

+ 35 - 0
chatModule/src/main/res/layout/tc_activity_chat_group_setting.xml

@@ -184,6 +184,41 @@
             </LinearLayout>
 
             <LinearLayout
+                android:id="@+id/ll_group_introduce"
+                android:layout_width="match_parent"
+                android:layout_height="50dp"
+                android:layout_marginTop="@dimen/dp_1"
+                android:background="@color/white"
+                android:orientation="horizontal">
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:gravity="center_vertical"
+                    android:paddingLeft="@dimen/dp_13"
+                    android:text="群简介"
+                    android:textColor="@color/color_333333"
+                    android:textSize="@dimen/sp_16" />
+
+                <TextView
+                    android:id="@+id/tv_group_introduce"
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:layout_weight="1"
+                    android:background="@color/transparent"
+                    android:drawableEnd="@drawable/icon_arrow_right"
+                    android:drawablePadding="@dimen/dp_12"
+                    android:gravity="center_vertical|right"
+                    android:paddingLeft="@dimen/dp_65"
+                    android:paddingRight="@dimen/dp_15"
+                    android:singleLine="true"
+                    android:text=""
+                    tools:text="哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈"
+                    android:textColor="@color/color_666666"
+                    android:textSize="@dimen/dp_16" />
+            </LinearLayout>
+
+            <LinearLayout
                 android:layout_width="match_parent"
                 android:layout_height="50dp"
                 android:layout_marginTop="@dimen/dp_1"

+ 85 - 0
chatModule/src/main/res/layout/tc_activity_group_introduce.xml

@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <include
+        android:id="@+id/toolbar_include"
+        layout="@layout/common_toolbar_layout"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:id="@+id/cs_content"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="12dp"
+        android:layout_marginTop="12dp"
+        android:layout_marginEnd="12dp"
+        android:background="@drawable/bg_white_10dp"
+        android:paddingStart="12dp"
+        android:paddingTop="15dp"
+        android:paddingEnd="12dp"
+        android:paddingBottom="15dp"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/toolbar_include">
+
+
+        <TextView
+            android:id="@+id/tv_content"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:drawableStart="@drawable/icon_group_des_tag"
+            android:drawablePadding="3dp"
+            android:text="群简介"
+            android:textColor="@color/color_333333"
+            android:textSize="@dimen/sp_16"
+            android:textStyle="bold"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <EditText
+            android:id="@+id/et_notice"
+            android:layout_width="match_parent"
+            android:layout_height="@dimen/dp_260"
+            android:layout_marginTop="9dp"
+            android:background="@color/white"
+            android:gravity="start|top"
+            android:hint="请输入群简介"
+            android:lineSpacingMultiplier="1.2"
+            android:maxLength="200"
+            android:textColorHint="@color/color_c1c1c1"
+            android:textColor="@color/color_333333"
+            android:textSize="@dimen/dp_16"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/tv_content" />
+
+        <TextView
+            android:id="@+id/tv_content_text_num"
+            android:layout_width="wrap_content"
+            android:layout_height="20dp"
+            android:gravity="center"
+            android:text="0/200"
+            android:textColor="@color/color_aaaaaa"
+            android:textSize="@dimen/sp_14"
+            app:layout_constraintRight_toRightOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+
+    <Button
+        app:layout_constraintBottom_toBottomOf="parent"
+        android:id="@+id/btn_commit"
+        style="?android:attr/borderlessButtonStyle"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/dp_44"
+        android:layout_marginStart="@dimen/dp_25"
+        android:layout_marginEnd="@dimen/dp_25"
+        android:layout_marginBottom="@dimen/dp_40"
+        android:background="@drawable/btn_primary_default_shape"
+        android:text="保存"
+        android:textColor="@color/white"
+        android:textSize="@dimen/dp_18" />
+</androidx.constraintlayout.widget.ConstraintLayout>