1.私聊新增风险提示类型 2.房间文本消息设置易盾业务ID

(cherry picked from commit 67142b1618a6668b82e016c670dfc543f0566839)
This commit is contained in:
huangjian
2021-04-22 16:04:42 +08:00
parent 27b228bbdf
commit 217f08a622
10 changed files with 140 additions and 0 deletions

View File

@@ -81,6 +81,7 @@ import com.yizhuan.erban.share.viewholder.InAppSharingMsgViewHolder;
import com.yizhuan.erban.ui.im.actions.GiftAction;
import com.yizhuan.erban.ui.im.avtivity.NimP2PMessageActivity;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderAudioParty;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderChatHint;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderContent;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderGift;
import com.yizhuan.erban.ui.im.chat.MsgViewHolderHello;
@@ -125,6 +126,7 @@ import com.yizhuan.xchat_android_core.home.model.HomeModel;
import com.yizhuan.xchat_android_core.im.custom.bean.AssistantAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.CarAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.CarveUpGoldThirdLevelAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.ChatHintAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.GiftAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.InAppSharingFamilyAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.InAppSharingMiniWorldAttachment;
@@ -400,6 +402,9 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
NimUIKit.registerMsgItemViewHolder(DynamicSysAttachment.class, DynamicSysHolder.class); // 动态审核, 违规删除
//世界动态分享
NimUIKit.registerMsgItemViewHolder(WorldDynamicAttachment.class, WorldDynamicShareViewHolder.class);
NimUIKit.registerMsgItemViewHolder(ChatHintAttachment.class, MsgViewHolderChatHint.class);
NimUIKit.registerMsgItemViewHolder(MatchAttachment.class, MsgViewHolderMatch.class);
NimUIKit.setSessionListener(listener);
NimUIKit.setContactEventListener(listener1);

View File

@@ -0,0 +1,61 @@
package com.yizhuan.erban.ui.im.chat;
import android.widget.TextView;
import com.netease.nim.uikit.business.session.viewholder.MsgViewHolderBase;
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
import com.yizhuan.erban.R;
import com.yizhuan.xchat_android_core.im.custom.bean.ChatHintAttachment;
public class MsgViewHolderChatHint extends MsgViewHolderBase {
private TextView tvContent;
public MsgViewHolderChatHint(BaseMultiItemFetchLoadAdapter adapter) {
super(adapter);
}
@Override
protected int getContentResId() {
return R.layout.layout_msg_view_holder_chat_hint;
}
@Override
protected boolean isMiddleItem() {
return true;
}
@Override
protected void inflateContentView() {
tvContent = findViewById(R.id.tv_content);
}
@Override
protected int leftBackground() {
return R.drawable.shape_f2f2f2_r_10;
}
@Override
protected int rightBackground() {
return R.drawable.shape_f2f2f2_r_10;
}
@Override
protected boolean isShowHeadImage() {
return false;
}
@Override
protected boolean shouldDisplayReceipt() {
return false;
}
@Override
protected void bindContentView() {
ChatHintAttachment attachment = (ChatHintAttachment) message.getAttachment();
if (attachment != null) {
tvContent.setText(attachment.getContent());
}
}
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="10dp" />
<solid android:color="@color/color_f2f2f2" />
</shape>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="48dp"
android:layout_marginEnd="48dp"
tools:background="@drawable/shape_f2f2f2_r_10">
<TextView
android:id="@+id/tv_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="15dp"
android:textColor="@color/color_999999"
android:textSize="13sp"
tools:text="您发送的消息中可能包含了您发送的消息中可能包含了您发送的消息中可能包含了您发送的消息中可能包含了" />
</FrameLayout>

View File

@@ -370,6 +370,7 @@
<color name="color_female_FE3F77">@color/color_female</color>
<color name="color_80ffffff">#80ffffff</color>
<color name="color_80fffffe">#80fffffe</color>
<color name="color_f2f2f2">#f2f2f2</color>
<color name="color_f5f5f5">#f5f5f5</color>
<color name="pink_ff4362">#ff4362</color>
<color name="color_FF5B69">#FF5B69</color>

View File

@@ -296,4 +296,10 @@ public class XChatConstants {
(byte)0x33,(byte)0x3f,(byte)0x33,(byte)0x90,(byte)0x07,(byte)0x53,(byte)0xeb,(byte)0xd2,(byte)0xd2,
(byte)0x4e,(byte)0xc5,(byte)0xed,(byte)0xfd,(byte)0x43
};
/**
* 聊天室文本消息易盾反垃圾业务id
*/
public static final String CHAT_ROOM_ANTI_SPAM_CONFIG_ID = "7ed4c5f72673dfc2d813a27bd5854874";
}

View File

@@ -42,6 +42,7 @@ import com.netease.nimlib.sdk.msg.attachment.NotificationAttachment;
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
import com.netease.nimlib.sdk.msg.constant.NotificationType;
import com.netease.nimlib.sdk.msg.model.IMMessage;
import com.netease.nimlib.sdk.msg.model.NIMAntiSpamOption;
import com.netease.nimlib.sdk.util.Entry;
import com.netease.nimlib.sdk.util.api.RequestResult;
import com.orhanobut.logger.Logger;
@@ -1891,6 +1892,9 @@ public final class IMNetEaseManager {
return Single.error(new ErrorThrowable("message == null !!!"));
ChatRoomMessage chatRoomMessage = ChatRoomMessageBuilder.createChatRoomTextMessage(
String.valueOf(roomId), message);
NIMAntiSpamOption antiSpamOption = new NIMAntiSpamOption();
antiSpamOption.antiSpamConfigId = XChatConstants.CHAT_ROOM_ANTI_SPAM_CONFIG_ID;
chatRoomMessage.setNIMAntiSpamOption(antiSpamOption);
if (AntiSpamUtil.checkLocalAntiSpam(chatRoomMessage)) {
EventBus.getDefault().post(new AntiSpamEvent());
return Single.error(new AntiSpamHitException("检测到敏感词,需要过滤,不能发送"));

View File

@@ -0,0 +1,30 @@
package com.yizhuan.xchat_android_core.im.custom.bean;
import com.alibaba.fastjson.JSONObject;
public class ChatHintAttachment extends CustomAttachment {
private String content;
public ChatHintAttachment( int second) {
super(CUSTOM_MSG_CHAT_HINT, second);
}
@Override
protected void parseData(JSONObject data) {
super.parseData(data);
content = data.getString("content");
}
@Override
protected JSONObject packData() {
JSONObject object = new JSONObject();
object.put("content", content);
return object;
}
public String getContent() {
return content;
}
}

View File

@@ -548,6 +548,9 @@ public class CustomAttachParser implements MsgAttachmentParser {
case CustomAttachment.CUSTOM_MESS_TAROT:
attachment = new TarotAttachment(CustomAttachment.CUSTOM_MESS_TAROT, CustomAttachment.CUSTOM_MESS_TAROT_SUCCESS);
break;
case CustomAttachment.CUSTOM_MSG_CHAT_HINT:
attachment = new ChatHintAttachment(CustomAttachment.CUSTOM_MSG_SUB_CHAT_HINT);
break;
case CustomAttachment.CUSTOM_MSG_MATCH:
attachment = new MatchAttachment(second);
break;

View File

@@ -389,6 +389,10 @@ public class CustomAttachment implements MsgAttachment {
public static final int CUSTOM_MSG_QUICK_DISMISS = 745;
public static final int CUSTOM_MSG_QUICK_ENOUGH_QUOTA = 746;
//私聊提示
public static final int CUSTOM_MSG_CHAT_HINT = 75;
public static final int CUSTOM_MSG_SUB_CHAT_HINT = 751;
public CustomAttachment() {
}