Pārlūkot izejas kodu

增加老师端修改群名称流程

Pq 1 gadu atpakaļ
vecāks
revīzija
f49b6bb3c8

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

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

+ 9 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/api/IMApi.java

@@ -161,4 +161,13 @@ public interface IMApi {
 
     @POST("{group_name}" + "/imGroup/addGroupMember")
     Observable<BaseResponse<Object>> addGroupMembers(@Body RequestBody body,@Path("group_name")String group_name);
+
+    /**
+     * 修改群信息
+     *
+     * @param body
+     * @return
+     */
+    @POST(TEACHER_GROUP + "imGroup/update")
+    Observable<BaseResponse<Object>> updateGroupInfo(@Body RequestBody body);
 }

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

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

+ 49 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/presenter/SetRemarksPresenter.java

@@ -0,0 +1,49 @@
+package com.cooleshow.chatmodule.presenter;
+
+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.SetRemarksContract;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ * 创建日期:2022/6/13 11:18
+ *
+ * @author Ryan
+ * 类说明:
+ */
+public class SetRemarksPresenter extends BasePresenter<SetRemarksContract.SetRemarksView> implements SetRemarksContract.Presenter {
+
+
+    public void updateGroupInfo(String groupId,String name){
+        if (getView() != null) {
+            getView().showLoading();
+        }
+        JSONObject jsonObject = new JSONObject();
+        try {
+            jsonObject.putOpt("name", name);
+            jsonObject.putOpt("id", groupId);
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+        addSubscribe(create(IMApi.class).updateGroupInfo(RequestBodyUtil.convertToRequestBodyJson(jsonObject.toString())), new BaseObserver<Object>(getView()) {
+            @Override
+            protected void onSuccess(Object data) {
+                if (getView() != null) {
+                    getView().updateGroupInfoSuccess(groupId, name);
+                }
+            }
+
+            @Override
+            public void onComplete() {
+                super.onComplete();
+                if (getView() != null) {
+                    getView().hideLoading();
+                }
+            }
+        });
+    }
+}

+ 8 - 4
chatModule/src/main/java/com/cooleshow/chatmodule/ui/ChatGroupSettingActivity.java

@@ -73,10 +73,10 @@ public class ChatGroupSettingActivity extends BaseMVPActivity<TcActivityChatGrou
             TUICore.startActivity("SearchMainActivity", null);
         } else if (view.getId() == R.id.tv_group_name_remarks) {
             //设置群名称
-//            ARouter.getInstance().build(RouterPath.ChatCenter.CHAT_GROUP_SET_REMARK)
-//                    .withString("targetId", targetId)
-//                    .withString("remarks", tv_group_name_remarks.getText().toString().trim())
-//                    .navigation(this, REQUEST_GROUP_REMARKS_CODE);
+            ARouter.getInstance().build(TCChatRouterPath.CHAT_GROUP_SET_REMARK)
+                    .withString("targetId", targetId)
+                    .withString("remarks", tv_group_name_remarks.getText().toString().trim())
+                    .navigation(this, REQUEST_GROUP_REMARKS_CODE);
         } else if (view.getId() == R.id.tv_group_member_list) {
             //查看联系人
             if (mAdapter != null) {
@@ -204,9 +204,13 @@ public class ChatGroupSettingActivity extends BaseMVPActivity<TcActivityChatGrou
 
         if (BaseApplication.Companion.isTeacherClient()) {
             btnConfirm.setText("解散群组");
+            viewBinding.tvGroupNameRemarks.setClickable(true);
+            viewBinding.tvGroupNameRemarks.setCompoundDrawablesWithIntrinsicBounds(0, 0, com.cooleshow.base.R.drawable.icon_arrow_right, 0);
         } else {
             btnConfirm.setText("发消息");
             viewBinding.llChatJoinApply.setVisibility(View.GONE);
+            viewBinding.tvGroupNameRemarks.setClickable(false);
+            viewBinding.tvGroupNameRemarks.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
         }
 
         GridLayoutManager gridLayoutManager = new GridLayoutManager(this, MAX_SHOW_GROUP_MEMBER_COUNT);

+ 115 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/ui/SetRemarksActivity.java

@@ -0,0 +1,115 @@
+package com.cooleshow.chatmodule.ui;
+
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.text.Editable;
+import android.text.TextUtils;
+import android.text.TextWatcher;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.ImageView;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.cooleshow.base.router.RouterPath;
+import com.cooleshow.base.ui.activity.BaseMVPActivity;
+import com.cooleshow.base.utils.LogUtils;
+import com.cooleshow.base.utils.ToastUtil;
+import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
+import com.cooleshow.chatmodule.R;
+import com.cooleshow.chatmodule.constants.TCChatRouterPath;
+import com.cooleshow.chatmodule.contract.SetRemarksContract;
+import com.cooleshow.chatmodule.databinding.ActivitySetRemarkBinding;
+import com.cooleshow.chatmodule.presenter.SetRemarksPresenter;
+
+import androidx.annotation.Nullable;
+
+/**
+ * 创建日期:2022/6/13 11:15
+ *
+ * @author Ryan
+ * 类说明:
+ */
+@Route(path = TCChatRouterPath.CHAT_GROUP_SET_REMARK)
+public class SetRemarksActivity extends BaseMVPActivity<ActivitySetRemarkBinding, SetRemarksPresenter> implements SetRemarksContract.SetRemarksView, View.OnClickListener {
+    @Override
+    public void onClick(View v) {
+        int id = v.getId();
+        if (id == com.cooleshow.base.R.id.tv_right_text) {
+            remarks = et_remarks.getText().toString().trim();
+            if (TextUtils.isEmpty(remarks)) {
+                ToastUtil.getInstance().showShort("请输入备注名");
+                return;
+            }
+            presenter.updateGroupInfo(targetId, remarks);
+        } else if (id == R.id.iv_close) {
+            et_remarks.setText("");
+        }
+    }
+
+    private EditText et_remarks;
+    private String targetId;
+    private String remarks;
+    private ImageView iv_close;
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        QMUIStatusBarHelper.setStatusBarLightMode(this);
+    }
+
+    @Override
+    protected void initView() {
+        initMidTitleToolBar(viewBinding.toolbarInclude.toolbar, "设置备注名");
+        viewBinding.toolbarInclude.tvRightText.setText("完成");
+        viewBinding.toolbarInclude.tvRightText.setTextColor(getResources().getColor(com.cooleshow.base.R.color.color_2dc7aa));
+        viewBinding.toolbarInclude.tvRightText.setVisibility(View.VISIBLE);
+        viewBinding.toolbarInclude.tvRightText.setOnClickListener(this);
+        et_remarks = viewBinding.etRemarks;
+        iv_close = viewBinding.ivClose;
+        iv_close.setOnClickListener(this);
+        Intent intent = getIntent();
+        targetId = intent.getStringExtra("targetId");
+        remarks = intent.getStringExtra("remarks");
+        et_remarks.setText(remarks);
+        et_remarks.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) {
+                if (et_remarks.getText().toString().length() > 0) {
+                    iv_close.setVisibility(View.VISIBLE);
+                } else {
+                    iv_close.setVisibility(View.GONE);
+                }
+            }
+
+            @Override
+            public void afterTextChanged(Editable s) {
+
+            }
+        });
+    }
+
+    @Override
+    protected ActivitySetRemarkBinding getLayoutView() {
+        return ActivitySetRemarkBinding.inflate(getLayoutInflater());
+    }
+
+    @Override
+    protected SetRemarksPresenter createPresenter() {
+        return new SetRemarksPresenter();
+    }
+
+    @Override
+    public void updateGroupInfoSuccess(String targetId, String title) {
+        ToastUtil.getInstance().showShort("设置成功");
+        Intent intent = new Intent();
+        intent.putExtra("remarks", remarks);
+        setResult(RESULT_OK, intent);
+        finish();
+    }
+}

+ 1 - 1
chatModule/src/main/java/com/cooleshow/chatmodule/widget/CustomChatGroupTopRightIconExtension.java

@@ -68,7 +68,7 @@ public class CustomChatGroupTopRightIconExtension extends ServiceInitializer imp
                 extensionInfo.setExtensionListener(new TUIExtensionEventListener() {
                     @Override
                     public void onClicked(Map<String, Object> param) {
-                        ARouter.getInstance().build(RouterPath.ChatCenter.CHAT_IM_APPEAL)
+                        ARouter.getInstance().build(TCChatRouterPath.CHAT_IM_APPEAL)
                                 .withString("targetId", userId)
                                 .withString("name", "")
                                 .withString("type", "PERSON")

+ 40 - 0
chatModule/src/main/res/layout/activity_set_remark.xml

@@ -0,0 +1,40 @@
+<?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="match_parent"
+    android:background="@color/color_f6f8f9"
+    android:orientation="vertical">
+
+    <include
+        android:id="@+id/toolbar_include"
+        layout="@layout/common_toolbar_layout" />
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="50dp"
+        android:layout_marginTop="@dimen/dp_15"
+        android:background="@color/white"
+        android:gravity="center_vertical"
+        android:orientation="horizontal">
+
+        <EditText
+            android:id="@+id/et_remarks"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:layout_weight="1"
+            android:background="@color/transparent"
+            android:gravity="center_vertical"
+            android:paddingLeft="@dimen/dp_15"
+            android:textColor="@color/color_666666"
+            android:textSize="@dimen/dp_16"/>
+
+        <ImageView
+            android:id="@+id/iv_close"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:padding="@dimen/dp_15"
+            android:src="@drawable/ic_input_del"/>
+
+    </LinearLayout>
+
+</LinearLayout>

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

@@ -170,6 +170,7 @@
                     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_15"