群聊修改
This commit is contained in:
@@ -16,7 +16,11 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.netease.nim.highavailable.LogUtils;
|
||||
import com.netease.nimlib.sdk.NIMClient;
|
||||
import com.netease.nimlib.sdk.RequestCallback;
|
||||
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
|
||||
import com.netease.nimlib.sdk.team.TeamService;
|
||||
import com.netease.nimlib.sdk.team.model.Team;
|
||||
import com.netease.yunxin.kit.chatkit.ui.R;
|
||||
import com.netease.yunxin.kit.chatkit.ui.common.GsonUtils;
|
||||
import com.netease.yunxin.kit.chatkit.ui.common.MessageHelper;
|
||||
@@ -26,6 +30,7 @@ import com.netease.yunxin.kit.chatkit.ui.fun.view.message.viewholder.FunChatBase
|
||||
import com.netease.yunxin.kit.chatkit.ui.model.BusinessCardBean;
|
||||
import com.netease.yunxin.kit.chatkit.ui.model.BusinessShareBean;
|
||||
import com.netease.yunxin.kit.chatkit.ui.model.ChatMessageBean;
|
||||
import com.netease.yunxin.kit.chatkit.ui.model.TeamExtensionBean;
|
||||
import com.netease.yunxin.kit.chatkit.ui.view.message.viewholder.ChatBaseMessageViewHolder;
|
||||
import com.netease.yunxin.kit.common.ui.utils.ToastX;
|
||||
import com.netease.yunxin.kit.corekit.im.IMKitClient;
|
||||
@@ -48,6 +53,11 @@ public class ChatBusinessViewHolder extends FunChatBaseMessageViewHolder {
|
||||
LayoutInflater.from(parent.getContext()), getMessageContainer());
|
||||
}
|
||||
|
||||
private String teamId = "";
|
||||
private int isAllowAdd = 0;
|
||||
private String teamOwnerId; //群主id;
|
||||
private TeamExtensionBean extensionBean;
|
||||
|
||||
@SuppressLint("ResourceAsColor")
|
||||
@Override
|
||||
public void bindData(ChatMessageBean message, ChatMessageBean lastMessage) {
|
||||
@@ -57,7 +67,36 @@ public class ChatBusinessViewHolder extends FunChatBaseMessageViewHolder {
|
||||
BusinessShareBean circleShareBean = GsonUtils.getObjFromJSON(name, BusinessShareBean.class);
|
||||
Log.i("名片", "名片获取到的数据0:" + GsonUtils.beanToJSONString(circleShareBean));
|
||||
// Log.i("名片","名片获取到的数据2:"+message.getMessageData().getMessage().getSessionId());
|
||||
|
||||
// if (currentMessage.getMessageData().getMessage().getSessionType() == SessionTypeEnum.Team) {
|
||||
// teamId = currentMessage.getMessageData().getMessage().getSessionId();
|
||||
// NIMClient.getService(TeamService.class).searchTeam(teamId).setCallback(new RequestCallback<Team>() {
|
||||
// @Override
|
||||
// public void onSuccess(Team result) {
|
||||
// teamOwnerId = teamInfo.getCreator();
|
||||
// if (!TextUtils.isEmpty(teamInfo.getExtension())) {
|
||||
// extensionBean = GsonUtils.getObjFromJSON(teamInfo.getExtension(), TeamExtensionBean.class);
|
||||
// if (extensionBean == null) {
|
||||
// extensionBean = new TeamExtensionBean(Integer.parseInt(teamInfo.getExtension()), 1);
|
||||
// }
|
||||
// } else {
|
||||
// extensionBean = new TeamExtensionBean(1, 1);
|
||||
// }
|
||||
// isAllowAdd = extensionBean.getAllowAddFriends();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFailed(int code) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onException(Throwable exception) {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// teamId = "";
|
||||
// }
|
||||
if (message.getMessageData().getMessage().getFromAccount().equals(IMKitClient.account())) {
|
||||
binding.bigLy.setBackgroundResource(R.drawable.fun_message_send_bg);
|
||||
binding.userNameTv.setTextColor(binding.bigLy.getResources().getColor(R.color.color_white));
|
||||
@@ -77,12 +116,23 @@ public class ChatBusinessViewHolder extends FunChatBaseMessageViewHolder {
|
||||
binding.cavIcon.setData(circleShareBean.data.getAvatar(), circleShareBean.data.getName());
|
||||
}
|
||||
binding.userNameTv.setText(circleShareBean.data.getName());
|
||||
binding.bigLy.setOnClickListener(v -> XKitRouter.withKey(RouterConstant.PATH_USER_INFO_PAGE)
|
||||
.withContext(binding.bigLy.getContext())
|
||||
.withParam(RouterConstant.KEY_ACCOUNT_ID_KEY, circleShareBean.data.getAccout())
|
||||
.withParam("isGroup", currentMessage.getMessageData().getMessage().getSessionType().getValue() != SessionTypeEnum.P2P.getValue())
|
||||
.withParam("userId", circleShareBean.data.getAccout())
|
||||
.navigate());
|
||||
// binding.bigLy.setOnClickListener(v -> {
|
||||
// //如果是群,且群不允许群内添加好友 当前登录用户不是群主,以及userid 也不是群主 直接跳过
|
||||
// if (!TextUtils.isEmpty(teamId) && isAllowAdd == 0 &&
|
||||
// !IMKitClient.getUserInfo().getAccount().equals(teamOwnerId) &&
|
||||
// !circleShareBean.data.getAccout().equals(teamOwnerId)) {
|
||||
// return;
|
||||
// }
|
||||
// XKitRouter.withKey(RouterConstant.PATH_USER_INFO_PAGE)
|
||||
// .withContext(binding.bigLy.getContext())
|
||||
// .withParam(RouterConstant.KEY_ACCOUNT_ID_KEY, circleShareBean.data.getAccout())
|
||||
// .withParam("isGroup", currentMessage.getMessageData().getMessage().getSessionType().getValue() != SessionTypeEnum.P2P.getValue())
|
||||
// .withParam("userId", circleShareBean.data.getAccout())
|
||||
// .withParam("teamId", teamId)
|
||||
// .navigate();
|
||||
// });
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -7,9 +7,16 @@ package com.netease.yunxin.kit.chatkit.ui.factory;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.netease.nim.highavailable.LogUtils;
|
||||
import com.netease.nimlib.sdk.NIMClient;
|
||||
import com.netease.nimlib.sdk.RequestCallback;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgDirectionEnum;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgStatusEnum;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
|
||||
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
|
||||
import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||||
import com.netease.nimlib.sdk.team.TeamService;
|
||||
import com.netease.nimlib.sdk.team.constant.TeamMemberType;
|
||||
import com.netease.nimlib.sdk.team.model.TeamMember;
|
||||
import com.netease.yunxin.kit.chatkit.ui.ChatMessageType;
|
||||
import com.netease.yunxin.kit.chatkit.ui.R;
|
||||
import com.netease.yunxin.kit.chatkit.ui.common.GsonUtils;
|
||||
@@ -20,6 +27,7 @@ import com.netease.yunxin.kit.chatkit.ui.view.popmenu.IChatPopMenu;
|
||||
import com.netease.yunxin.kit.chatkit.ui.view.popmenu.IChatPopMenuClickListener;
|
||||
import com.netease.yunxin.kit.common.ui.utils.ToastX;
|
||||
import com.netease.yunxin.kit.common.utils.NetworkUtils;
|
||||
import com.netease.yunxin.kit.corekit.im.IMKitClient;
|
||||
import com.netease.yunxin.kit.corekit.im.custom.CustomAttachment;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
@@ -56,11 +64,21 @@ public class ChatPopActionFactory {
|
||||
this.customPopMenu = new WeakReference<>(popMenu);
|
||||
}
|
||||
|
||||
boolean isManager = false;
|
||||
|
||||
public List<ChatPopMenuAction> getNormalActions(ChatMessageBean message) {
|
||||
List<ChatPopMenuAction> actions = new ArrayList<>();
|
||||
if (message.getMessageData() == null) {
|
||||
return actions;
|
||||
}
|
||||
isManager = false;
|
||||
IMMessage imMessage = message.getMessageData().getMessage();
|
||||
if ((imMessage.getSessionType() == SessionTypeEnum.Team || imMessage.getSessionType() == SessionTypeEnum.SUPER_TEAM)) {
|
||||
TeamMember teamMember = NIMClient.getService(TeamService.class).queryTeamMemberBlock(imMessage.getSessionId(), IMKitClient.account());
|
||||
if (teamMember != null && (teamMember.getType() == TeamMemberType.Manager || teamMember.getType() == TeamMemberType.Owner)) {
|
||||
isManager = true;
|
||||
}
|
||||
}
|
||||
if (customPopMenu == null
|
||||
|| customPopMenu.get() == null
|
||||
|| customPopMenu.get().showDefaultPopMenu()) {
|
||||
@@ -93,11 +111,13 @@ public class ChatPopActionFactory {
|
||||
actions.add(getMultiSelectAction(message));
|
||||
// actions.add(getCollectionAction(message));
|
||||
// actions.add(getDeleteAction(message));
|
||||
if (message.getMessageData().getMessage().getDirect() == MsgDirectionEnum.Out) {
|
||||
|
||||
|
||||
if (imMessage.getDirect() == MsgDirectionEnum.Out || isManager) {
|
||||
boolean isShowChehui = true;
|
||||
if (message.getViewType() == MsgTypeEnum.custom.getValue()) {
|
||||
CustomAttachment attachment =
|
||||
(CustomAttachment) message.getMessageData().getMessage().getAttachment();
|
||||
(CustomAttachment) imMessage.getAttachment();
|
||||
LogUtils.i("自定义消息的类型", "自定义消息的类型:" + GsonUtils.beanToJSONString(attachment));
|
||||
|
||||
if (attachment != null) {
|
||||
|
||||
@@ -44,12 +44,14 @@ import com.netease.yunxin.kit.chatkit.ui.ChatKitUIConstant;
|
||||
import com.netease.yunxin.kit.chatkit.ui.R;
|
||||
import com.netease.yunxin.kit.chatkit.ui.common.ChatDataUtils;
|
||||
import com.netease.yunxin.kit.chatkit.ui.common.ChatUtils;
|
||||
import com.netease.yunxin.kit.chatkit.ui.common.GsonUtils;
|
||||
import com.netease.yunxin.kit.chatkit.ui.data.entity.ChatDraftData;
|
||||
import com.netease.yunxin.kit.chatkit.ui.databinding.FunChatSearchViewHolderBinding;
|
||||
import com.netease.yunxin.kit.chatkit.ui.fun.view.MessageBottomLayout;
|
||||
import com.netease.yunxin.kit.chatkit.ui.fun.viewholder.FunSearchMessageViewHolder;
|
||||
import com.netease.yunxin.kit.chatkit.ui.model.ChatMessageBean;
|
||||
import com.netease.yunxin.kit.chatkit.ui.model.CleanHistoryEvent;
|
||||
import com.netease.yunxin.kit.chatkit.ui.model.TeamExtensionBean;
|
||||
import com.netease.yunxin.kit.chatkit.ui.model.UpdateTeamEvent;
|
||||
import com.netease.yunxin.kit.chatkit.ui.model.ait.AitBlock;
|
||||
import com.netease.yunxin.kit.chatkit.ui.page.adapter.SearchMessageAdapter;
|
||||
@@ -82,7 +84,6 @@ import java.util.Map;
|
||||
|
||||
public class FunChatTeamFragment extends FunChatFragment {
|
||||
private static final String TAG = "ChatTeamFragment";
|
||||
Team teamInfo;
|
||||
IMMessage anchorMessage;
|
||||
private boolean showDeleteDialog = false;
|
||||
Observer<FetchResult<List<IMTeamMessageReceiptInfo>>> teamReceiptObserver;
|
||||
@@ -169,7 +170,7 @@ public class FunChatTeamFragment extends FunChatFragment {
|
||||
super.initData(bundle);
|
||||
}
|
||||
|
||||
|
||||
public TeamExtensionBean extensionBean;
|
||||
private void refreshView() {
|
||||
if (teamInfo != null) {
|
||||
// chatView.getTitleBar().setTitle(teamInfo.getName());
|
||||
@@ -212,6 +213,17 @@ public class FunChatTeamFragment extends FunChatFragment {
|
||||
|
||||
|
||||
}
|
||||
|
||||
//获取是否允许加好友状态
|
||||
if (!TextUtils.isEmpty(teamInfo.getExtension())) {
|
||||
extensionBean = GsonUtils.getObjFromJSON(teamInfo.getExtension(), TeamExtensionBean.class);
|
||||
if (extensionBean == null) {
|
||||
extensionBean = new TeamExtensionBean(Integer.parseInt(teamInfo.getExtension()), 1);
|
||||
}
|
||||
} else {
|
||||
extensionBean = new TeamExtensionBean(1, 1);
|
||||
}
|
||||
isAllowAd = extensionBean.getAllowAddFriends();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.netease.yunxin.kit.chatkit.ui.model;
|
||||
|
||||
/**
|
||||
* 群聊扩展字段对象
|
||||
*/
|
||||
public class TeamExtensionBean {
|
||||
|
||||
|
||||
public TeamExtensionBean(int showQrCode, int allowAddFriends) {
|
||||
this.showQrCode = showQrCode;
|
||||
this.allowAddFriends = allowAddFriends;
|
||||
}
|
||||
|
||||
private int showQrCode = 1;
|
||||
private int allowAddFriends = 1;
|
||||
|
||||
public int getShowQrCode() {
|
||||
return showQrCode;
|
||||
}
|
||||
|
||||
public void setShowQrCode(int showQrCode) {
|
||||
this.showQrCode = showQrCode;
|
||||
}
|
||||
|
||||
public int getAllowAddFriends() {
|
||||
return allowAddFriends;
|
||||
}
|
||||
|
||||
public void setAllowAddFriends(int allowAddFriends) {
|
||||
this.allowAddFriends = allowAddFriends;
|
||||
}
|
||||
}
|
||||
@@ -49,12 +49,13 @@ public interface ApiService {
|
||||
/**
|
||||
* 正式环境
|
||||
*/
|
||||
String URL = "https://api.letschat2023.com/";
|
||||
String URL = "https://api.letschat2023.com/";
|
||||
|
||||
/**
|
||||
* 测试环境
|
||||
*/
|
||||
//String URL = "https://api-test.letschat2023.com/";
|
||||
// String URL = "https://8.217.244.135:8001/";
|
||||
|
||||
|
||||
String SUBSTATIONID = "1703655363476242434";
|
||||
|
||||
@@ -79,6 +79,7 @@ import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||||
import com.netease.nimlib.sdk.msg.model.MsgPinOption;
|
||||
import com.netease.nimlib.sdk.msg.model.QueryDirectionEnum;
|
||||
import com.netease.nimlib.sdk.msg.model.RecentContact;
|
||||
import com.netease.nimlib.sdk.team.model.Team;
|
||||
import com.netease.nimlib.sdk.uinfo.UserService;
|
||||
import com.netease.nimlib.sdk.uinfo.model.NimUserInfo;
|
||||
import com.netease.yunxin.kit.alog.ALog;
|
||||
@@ -278,6 +279,9 @@ public abstract class ChatBaseFragment extends BaseFragment {
|
||||
|
||||
public String forwardAction;
|
||||
|
||||
public Team teamInfo;
|
||||
public int isAllowAd = 0;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(
|
||||
@@ -1633,6 +1637,13 @@ public abstract class ChatBaseFragment extends BaseFragment {
|
||||
|| !delegateListener.onUserIconClick(view, position, messageBean)) {
|
||||
// Log.i("点击了去用户详情页", "点击了去用户详情页:" + messageBean.getMessageData().getMessage().getFromAccount());
|
||||
if (!isServices) {
|
||||
//如果是群,且群不允许群内添加好友 当前登录用户不是群主,以及userid 也不是群主 直接跳过
|
||||
if ((sessionType == SessionTypeEnum.SUPER_TEAM || sessionType == SessionTypeEnum.Team)
|
||||
&& isAllowAd == 0
|
||||
&& teamInfo != null && !teamInfo.getCreator().equals(IMKitClient.account())
|
||||
&& !teamInfo.getCreator().equals(messageBean.getMessageData().getMessage().getFromAccount())) {
|
||||
return false;
|
||||
}
|
||||
XKitRouter.withKey(getUserInfoRoutePath())
|
||||
.withContext(view.getContext())
|
||||
.withParam(
|
||||
@@ -1640,6 +1651,7 @@ public abstract class ChatBaseFragment extends BaseFragment {
|
||||
messageBean.getMessageData().getMessage().getFromAccount())
|
||||
.withParam("userId", messageBean.getMessageData().getMessage().getFromAccount())
|
||||
.withParam("isGroup", (sessionType == SessionTypeEnum.Team || sessionType == SessionTypeEnum.SUPER_TEAM))
|
||||
.withParam("teamId", (sessionType == SessionTypeEnum.Team || sessionType == SessionTypeEnum.SUPER_TEAM) ? messageBean.getMessageData().getMessage().getSessionId() : "")
|
||||
.navigate();
|
||||
}
|
||||
}
|
||||
@@ -1944,11 +1956,24 @@ public abstract class ChatBaseFragment extends BaseFragment {
|
||||
case ChatMessageType.CUSTOM_STICKER_BUSINESS_CARD:
|
||||
BusinessShareBean businessShareBean = GsonUtils.getObjFromJSON(name, BusinessShareBean.class);
|
||||
if (businessShareBean != null) {
|
||||
//如果是群,且群不允许群内添加好友 当前登录用户不是群主,以及userid 也不是群主 直接跳过
|
||||
if ((sessionType == SessionTypeEnum.SUPER_TEAM || sessionType == SessionTypeEnum.Team)
|
||||
&& isAllowAd == 0
|
||||
&& teamInfo != null && !teamInfo.getCreator().equals(IMKitClient.account())
|
||||
&& !teamInfo.getCreator().equals(businessShareBean.data.getAccout())) {
|
||||
return;
|
||||
}
|
||||
XKitRouter.withKey(RouterConstant.PATH_USER_INFO_PAGE)
|
||||
.withContext(getActivity())
|
||||
.withParam(RouterConstant.KEY_ACCOUNT_ID_KEY, businessShareBean.data.getAccout())
|
||||
.withParam("isGroup", sessionType != SessionTypeEnum.P2P)
|
||||
.withParam("userId", businessShareBean.data.getAccout())
|
||||
.navigate();
|
||||
// XKitRouter.withKey(RouterConstant.PATH_USER_INFO_PAGE)
|
||||
// .withContext(getActivity())
|
||||
// .withParam(RouterConstant.KEY_ACCOUNT_ID_KEY, businessShareBean.data.getAccout())
|
||||
// .withParam("userId", businessShareBean.data.getAccout())
|
||||
// .navigate();
|
||||
}
|
||||
break;
|
||||
case ChatMessageType.CUSTOM_STICKER_TRANSFER_ACCOUNTS:
|
||||
|
||||
Reference in New Issue
Block a user