diff --git a/app/src/main/java/com/nnbc123/app/avroom/widget/MessageView.java b/app/src/main/java/com/nnbc123/app/avroom/widget/MessageView.java
index a3757074c..4b557ad7e 100644
--- a/app/src/main/java/com/nnbc123/app/avroom/widget/MessageView.java
+++ b/app/src/main/java/com/nnbc123/app/avroom/widget/MessageView.java
@@ -1,5 +1,6 @@
package com.nnbc123.app.avroom.widget;
+import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GIFT;
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GIFT_COMPOUND;
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_KITCHEN;
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_PRIVILEGE;
@@ -93,6 +94,7 @@ import com.nnbc123.core.im.custom.bean.CarveUpGoldAttachment;
import com.nnbc123.core.im.custom.bean.CleanScreenAttachment;
import com.nnbc123.core.im.custom.bean.CustomAttachment;
import com.nnbc123.core.im.custom.bean.DatingAttachment;
+import com.nnbc123.core.im.custom.bean.DressUpGiftAttachment;
import com.nnbc123.core.im.custom.bean.FaceAttachment;
import com.nnbc123.core.im.custom.bean.FansTeamMsgAttachment;
import com.nnbc123.core.im.custom.bean.GiftAttachment;
@@ -121,6 +123,7 @@ import com.nnbc123.core.im.custom.bean.RoomReceivedLuckyGiftAttachment;
import com.nnbc123.core.im.custom.bean.RoomTipAttachment;
import com.nnbc123.core.im.custom.bean.TarotAttachment;
import com.nnbc123.core.im.custom.bean.TarotMsgBean;
+import com.nnbc123.core.im.custom.bean.UnLockGiftAttachment;
import com.nnbc123.core.im.custom.bean.VipMessageAttachment;
import com.nnbc123.core.im.custom.bean.WelcomeAttachment;
import com.nnbc123.core.im.custom.bean.WishListAttachment;
@@ -215,6 +218,7 @@ public class MessageView extends FrameLayout {
private int whiteColor;
private int greyColor;
private int appColor;
+ private int giftColor;
private int badgeWidth;
private int badgeHeight;
private int sysIconHeight;
@@ -277,6 +281,7 @@ public class MessageView extends FrameLayout {
whiteColor = ContextCompat.getColor(context, R.color.white);
greyColor = ContextCompat.getColor(context, R.color.white_transparent_50);
appColor = ContextCompat.getColor(context, R.color.app_color);
+ giftColor = ContextCompat.getColor(context, R.color.color_5CEFFF);
paddingWidth = Utils.dip2px(context, 10);
paddingHeight = Utils.dip2px(context, 8);
badgeWidth = Utils.dip2px(context, 15);
@@ -1011,6 +1016,12 @@ public class MessageView extends FrameLayout {
if (second == CustomAttachment.CUSTOM_MSG_PRIVILEGE_SECOND || second == CustomAttachment.CUSTOM_MSG_PRIVILEGE_SECOND_VIDEO) {
setPrivilegeNoticeMessage(chatRoomMessage, tvContent);
}
+ } else if (first == CUSTOM_MSG_GIFT) {
+ if (second == CustomAttachment.CUSTOM_MSG_GIFT_UNLOCK) {
+ setUnLockGiftMsg(tvContent, (UnLockGiftAttachment) attachment, chatRoomMessage);
+ } else if (second == CustomAttachment.CUSTOM_MSG_GIFT_DRESS) {
+ setDressGiftMsg(tvContent, (DressUpGiftAttachment) attachment, chatRoomMessage);
+ }
} else {
tvContent.setTextColor(Color.WHITE);
tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip));
@@ -2928,6 +2939,53 @@ public class MessageView extends FrameLayout {
}
+ private void setUnLockGiftMsg(TextView tvContent, UnLockGiftAttachment attachment, ChatRoomMessage chatRoomMessage) {
+ if (attachment == null) return;
+ String nick = RegexUtil.getPrintableString(attachment.getNick());
+ String giftName = attachment.getGiftNameNotNull();
+ String giftImage = attachment.getGiftUrlNotNull();
+ SpannableBuilder text = new SpannableBuilder(tvContent)
+ .append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
+ .append(nick, new ForegroundColorSpan(appColor), new OriginalDrawStatusClickSpan() {
+
+ @Override
+ public void onClick(@NonNull View widget) {
+ if (clickConsumer != null) {
+ Single.just(chatRoomMessage.getFromAccount()).subscribe(clickConsumer);
+ }
+ }
+ })
+ .append(" 已解锁礼物 ", new ForegroundColorSpan(whiteColor))
+ .append(giftImage, giftLength, giftLength)
+ .append(giftName, new ForegroundColorSpan(giftColor));
+ tvContent.setText(text.build());
+ tvContent.setOnClickListener(null);
+ tvContent.setMovementMethod(new LinkMovementMethod());
+ }
+
+ private void setDressGiftMsg(TextView tvContent, DressUpGiftAttachment attachment, ChatRoomMessage chatRoomMessage) {
+ if (attachment == null) return;
+ String nick = RegexUtil.getPrintableString(attachment.getNick());
+ String dressName = attachment.getDressNameNotNull();
+ String dressImage = attachment.getDressUrlNotNull();
+ SpannableBuilder text = new SpannableBuilder(tvContent)
+ .append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
+ .append(nick, new ForegroundColorSpan(appColor), new OriginalDrawStatusClickSpan() {
+
+ @Override
+ public void onClick(@NonNull View widget) {
+ if (clickConsumer != null) {
+ Single.just(chatRoomMessage.getFromAccount()).subscribe(clickConsumer);
+ }
+ }
+ })
+ .append(" 获得 "+dressName+"装扮 ", new ForegroundColorSpan(whiteColor))
+ .append(dressImage, giftLength, giftLength);
+ tvContent.setText(text.build());
+ tvContent.setOnClickListener(null);
+ tvContent.setMovementMethod(new LinkMovementMethod());
+ }
+
@Nullable
private Drawable getNewUserDrawable(ChatRoomMessage chatRoomMessage) {
boolean newUser = NobleUtil.getIsNewUser(UserInfo.IS_NEW_USER, chatRoomMessage);
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index aca977342..866640aa7 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -629,5 +629,5 @@
#FFD46C
#695CEB
#FFFFF265
-
+ #FF5CEFFF
diff --git a/core/src/diff_src_erban/java/com/nnbc123/core/manager/IMNetEaseManager.java b/core/src/diff_src_erban/java/com/nnbc123/core/manager/IMNetEaseManager.java
index 4b28938b5..4705d35dd 100644
--- a/core/src/diff_src_erban/java/com/nnbc123/core/manager/IMNetEaseManager.java
+++ b/core/src/diff_src_erban/java/com/nnbc123/core/manager/IMNetEaseManager.java
@@ -1443,6 +1443,14 @@ public final class IMNetEaseManager {
.setEvent(RoomEvent.ROOM_HOUR_RANK));
}
}
+ break;
+ case CUSTOM_MSG_GIFT:
+ if (customAttachment.getSecond() == CUSTOM_MSG_GIFT_UNLOCK) {
+ addMessages(msg);
+ } else if (customAttachment.getSecond() == CUSTOM_MSG_GIFT_DRESS) {
+ addMessages(msg);
+ }
+ break;
default:
break;
}
diff --git a/core/src/main/java/com/nnbc123/core/im/custom/bean/CustomAttachParser.java b/core/src/main/java/com/nnbc123/core/im/custom/bean/CustomAttachParser.java
index dc1084bfd..385519c0e 100644
--- a/core/src/main/java/com/nnbc123/core/im/custom/bean/CustomAttachParser.java
+++ b/core/src/main/java/com/nnbc123/core/im/custom/bean/CustomAttachParser.java
@@ -19,6 +19,7 @@ import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_EXPER_
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_EXPER_LEVEL_UP_NOTICE;
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GAME_INVITE;
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GAME_INVITE_SECOND;
+import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GIFT;
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GROUP_CHAT_MEMBER_COUNT;
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GROUP_CHAT_ROOM_NOTIFY;
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GROUP_CHAT_TOPIC;
@@ -622,6 +623,13 @@ public class CustomAttachParser implements MsgAttachmentParser {
attachment = new GameInviteAttachment(first, second);
}
break;
+ case CUSTOM_MSG_GIFT:
+ if (second == CustomAttachment.CUSTOM_MSG_GIFT_UNLOCK) {
+ attachment = new UnLockGiftAttachment(first, second);
+ } else if (second == CustomAttachment.CUSTOM_MSG_GIFT_DRESS) {
+ attachment = new DressUpGiftAttachment(first, second);
+ }
+ break;
default:
LogUtils.e("未定义的first,请现在CustomAttachParser中解析first=" + first + " second=" + second);
break;
diff --git a/core/src/main/java/com/nnbc123/core/im/custom/bean/CustomAttachment.java b/core/src/main/java/com/nnbc123/core/im/custom/bean/CustomAttachment.java
index 6e1808491..1d3ad30b5 100644
--- a/core/src/main/java/com/nnbc123/core/im/custom/bean/CustomAttachment.java
+++ b/core/src/main/java/com/nnbc123/core/im/custom/bean/CustomAttachment.java
@@ -437,6 +437,10 @@ public class CustomAttachment implements MsgAttachment {
public static final int CUSTOM_MSG_HOUR_RANK = 97; // 小时榜
public static final int CUSTOM_MSG_HOUR_RANK_UPDATE = 971; // 小时榜更新
+ public static final int CUSTOM_MSG_GIFT = 98; // 礼物相关
+ public static final int CUSTOM_MSG_GIFT_UNLOCK = 981; // 解锁了礼物
+ public static final int CUSTOM_MSG_GIFT_DRESS = 982; // 获得装扮礼物
+
public static final int CUSTOM_MSG_PRIVILEGE = 102; //特权卡
public static final int CUSTOM_MSG_PRIVILEGE_SECOND = 1020;//特权卡(图片、gif)
public static final int CUSTOM_MSG_PRIVILEGE_SECOND_VIDEO = 1021;//特权卡(视频类型)
diff --git a/core/src/main/java/com/nnbc123/core/im/custom/bean/DressUpGiftAttachment.kt b/core/src/main/java/com/nnbc123/core/im/custom/bean/DressUpGiftAttachment.kt
new file mode 100644
index 000000000..fbfe8ad5b
--- /dev/null
+++ b/core/src/main/java/com/nnbc123/core/im/custom/bean/DressUpGiftAttachment.kt
@@ -0,0 +1,49 @@
+package com.nnbc123.core.im.custom.bean
+
+import com.alibaba.fastjson.JSONObject
+
+/**
+ * Created by Max on 2024/1/29 15:54
+ * Desc:
+ **/
+class DressUpGiftAttachment : CustomAttachment {
+
+ var uid: Long? = null
+ var nick: String? = null
+ var dressId: Long? = null
+ var dressName: String? = null
+ var dressUrl: String? = null
+
+ constructor() : super()
+ constructor(first: Int, second: Int) : super(first, second)
+
+ fun getDressNameNotNull(): String {
+ return dressName ?: ""
+ }
+
+ fun getDressUrlNotNull(): String {
+ return dressName ?: ""
+ }
+
+ override fun parseData(data: JSONObject?) {
+ super.parseData(data)
+ if (data == null) {
+ return
+ }
+ if (data.containsKey("uid")) {
+ this.uid = data.getLong("uid")
+ }
+ if (data.containsKey("nick")) {
+ this.nick = data.getString("nick")
+ }
+ if (data.containsKey("dressId")) {
+ this.dressId = data.getLong("dressId")
+ }
+ if (data.containsKey("dressName")) {
+ this.dressName = data.getString("dressName")
+ }
+ if (data.containsKey("dressUrl")) {
+ this.dressUrl = data.getString("dressUrl")
+ }
+ }
+}
\ No newline at end of file
diff --git a/core/src/main/java/com/nnbc123/core/im/custom/bean/UnLockGiftAttachment.kt b/core/src/main/java/com/nnbc123/core/im/custom/bean/UnLockGiftAttachment.kt
new file mode 100644
index 000000000..93f682e76
--- /dev/null
+++ b/core/src/main/java/com/nnbc123/core/im/custom/bean/UnLockGiftAttachment.kt
@@ -0,0 +1,50 @@
+package com.nnbc123.core.im.custom.bean
+
+import com.alibaba.fastjson.JSONObject
+
+/**
+ * Created by Max on 2024/1/29 15:54
+ * Desc:
+ **/
+class UnLockGiftAttachment : CustomAttachment{
+
+ var uid: Long? = null
+ var nick: String? = null
+ var giftId: Long? = null
+ var giftName: String? = null
+ var giftUrl: String? = null
+
+ constructor() : super()
+ constructor(first: Int, second: Int) : super(first, second)
+
+
+ fun getGiftNameNotNull(): String {
+ return giftName ?: ""
+ }
+
+ fun getGiftUrlNotNull(): String {
+ return giftUrl ?: ""
+ }
+
+ override fun parseData(data: JSONObject?) {
+ super.parseData(data)
+ if (data == null) {
+ return
+ }
+ if (data.containsKey("uid")) {
+ this.uid = data.getLong("uid")
+ }
+ if (data.containsKey("nick")) {
+ this.nick = data.getString("nick")
+ }
+ if (data.containsKey("giftId")) {
+ this.giftId = data.getLong("giftId")
+ }
+ if (data.containsKey("giftName")) {
+ this.giftName = data.getString("giftName")
+ }
+ if (data.containsKey("giftUrl")) {
+ this.giftUrl = data.getString("giftUrl")
+ }
+ }
+}
\ No newline at end of file