Просмотр исходного кода

feat:家族群聊支持幸运礼物,家族申请红点消除适配 (#25)

* feat:适配一键清除家族申请红点逻辑

* feat:群聊适配幸运礼物

* bugfix:家族群聊有3个人在线,成员1给成员2送幸运礼物,成员1和成员2出现送礼动画,成员3没有出现送礼动画

* bugfix:软键盘在群聊界面适配问题
LiuFJie 7 месяцев назад
Родитель
Сommit
67167af83f

+ 10 - 1
app/src/main/java/com/adealink/weparty/module/family/FamilyModule.kt

@@ -12,7 +12,8 @@ import com.adealink.weparty.R
 import com.adealink.weparty.module.anchor.data.AnchorMessage
 import com.adealink.weparty.module.anchor.data.AnchorMessageReplyCode
 import com.adealink.weparty.module.family.data.FamilyInfo
-import com.adealink.weparty.module.family.data.FamilyLevelConfig
+import com.adealink.weparty.module.family.data.FamilyMemberApplyRecordReq
+import com.adealink.weparty.module.family.data.FamilyMemberApplyRecordRsp
 import com.adealink.weparty.module.family.data.FamilyMemberRelationReq
 import com.adealink.weparty.module.family.data.FamilyMemberRelationRsp
 import com.adealink.weparty.module.family.data.GroupGagReq
@@ -163,6 +164,10 @@ object FamilyModule : BaseDynamicModule<IFamilyService>(IFamilyService::class),
 
             }
 
+            override suspend fun getFamilyMemberApplyRecord(req: FamilyMemberApplyRecordReq): Rlt<FamilyMemberApplyRecordRsp?> {
+                return Rlt.Failed(IError())
+            }
+
             override suspend fun getNewApplyCount(): Rlt<Int> {
                 return Rlt.Failed(IError())
             }
@@ -219,4 +224,8 @@ object FamilyModule : BaseDynamicModule<IFamilyService>(IFamilyService::class),
     override fun removeManagerListener(listener: IFamilyListener) {
         getService().removeManagerListener(listener)
     }
+
+    override suspend fun getFamilyMemberApplyRecord(req: FamilyMemberApplyRecordReq): Rlt<FamilyMemberApplyRecordRsp?> {
+        return getService().getFamilyMemberApplyRecord(req)
+    }
 }

+ 4 - 1
app/src/main/java/com/adealink/weparty/module/family/IFamilyService.kt

@@ -9,7 +9,8 @@ import com.adealink.frame.network.data.Res
 import com.adealink.weparty.module.anchor.data.AnchorMessage
 import com.adealink.weparty.module.anchor.data.AnchorMessageReplyCode
 import com.adealink.weparty.module.family.data.FamilyInfo
-import com.adealink.weparty.module.family.data.FamilyLevelConfig
+import com.adealink.weparty.module.family.data.FamilyMemberApplyRecordReq
+import com.adealink.weparty.module.family.data.FamilyMemberApplyRecordRsp
 import com.adealink.weparty.module.family.data.FamilyMemberRelationReq
 import com.adealink.weparty.module.family.data.FamilyMemberRelationRsp
 import com.adealink.weparty.module.family.data.GroupGagReq
@@ -72,4 +73,6 @@ interface IFamilyService : IService<IFamilyService> {
     fun addManagerListener(listener: IFamilyListener)
 
     fun removeManagerListener(listener: IFamilyListener)
+
+    suspend fun getFamilyMemberApplyRecord(req: FamilyMemberApplyRecordReq): Rlt<FamilyMemberApplyRecordRsp?>
 }

+ 1 - 0
app/src/main/java/com/adealink/weparty/module/gift/viewmodel/IGiftViewModel.kt

@@ -46,6 +46,7 @@ interface IGiftViewModel {
     val sendUidSetLD: ExtLiveData<Set<Long>>
     val luckyGiftRewardNotifyLD: ExtLiveData<LuckyGiftLotteryNotify>
     val chatLuckyGiftRewardNotifyLD: ExtLiveData<LuckyGiftLotteryNotify>
+    val groupChatLuckyGiftRewardNotifyLD: ExtLiveData<LuckyGiftLotteryNotify>
     val giftBackpackItemSelectLD: ExtLiveData<UserPackageInfo>
     val sendBackpackItemNotifyLD: ExtLiveData<SendBackpackItemNotify>
     val timeLimitGiftUntilExpiredLD: ExtLiveData<Long>

+ 6 - 1
module/family/src/main/java/com/adealink/weparty/family/FamilyServiceImpl.kt

@@ -27,7 +27,8 @@ import com.adealink.weparty.module.anchor.data.AnchorMessageReplyCode
 import com.adealink.weparty.module.anchor.data.AnchorMessageType
 import com.adealink.weparty.module.family.IFamilyService
 import com.adealink.weparty.module.family.data.FamilyInfo
-import com.adealink.weparty.module.family.data.FamilyLevelConfig
+import com.adealink.weparty.module.family.data.FamilyMemberApplyRecordReq
+import com.adealink.weparty.module.family.data.FamilyMemberApplyRecordRsp
 import com.adealink.weparty.module.family.data.FamilyMemberRelationReq
 import com.adealink.weparty.module.family.data.FamilyMemberRelationRsp
 import com.adealink.weparty.module.family.data.GroupGagReq
@@ -163,6 +164,10 @@ class FamilyServiceImpl : IFamilyService {
         familyManager.removeListener(listener)
     }
 
+    override suspend fun getFamilyMemberApplyRecord(req: FamilyMemberApplyRecordReq): Rlt<FamilyMemberApplyRecordRsp?> {
+        return familyManager.getFamilyMemberApplyRecord(req)
+    }
+
     override suspend fun getNewApplyCount(): Rlt<Int> {
         return familyManager.getNewApplyCount()
     }

+ 18 - 0
module/family/src/main/java/com/adealink/weparty/family/manager/FamilyManager.kt

@@ -31,6 +31,8 @@ import com.adealink.weparty.module.family.data.FamilyDetailReq
 import com.adealink.weparty.module.family.data.FamilyInfo
 import com.adealink.weparty.module.family.data.FamilyInfoDetail
 import com.adealink.weparty.module.family.data.FamilyJoinMode
+import com.adealink.weparty.module.family.data.FamilyMemberApplyRecordReq
+import com.adealink.weparty.module.family.data.FamilyMemberApplyRecordRsp
 import com.adealink.weparty.module.family.data.FamilyMemberInfo
 import com.adealink.weparty.module.family.data.FamilyMemberInfoReq
 import com.adealink.weparty.module.family.data.FamilyMemberListRes
@@ -605,6 +607,22 @@ class FamilyManager : BaseFrame<IFamilyListener>(), IFamilyManager, ILoginListen
         dispatch { it.onFamilyUpgradeSuccess(familyInfo) }
     }
 
+    override suspend fun getFamilyMemberApplyRecord(req: FamilyMemberApplyRecordReq): Rlt<FamilyMemberApplyRecordRsp?> {
+        return when (val result = familyHttpService.getFamilyMemberApplyRecord(req)) {
+            is Rlt.Success -> {
+                if (result.data.data == null) {
+                    Rlt.Failed(CommonDataNullError())
+                } else {
+                    Rlt.Success(result.data.data)
+                }
+            }
+
+            is Rlt.Failed -> {
+                result
+            }
+        }
+    }
+
     suspend fun updateFamilyInfo(familyId: Long) {
         getFamilyInfo(
             familyId, listOf(

+ 4 - 1
module/family/src/main/java/com/adealink/weparty/family/manager/IFamilyManager.kt

@@ -7,7 +7,8 @@ import com.adealink.weparty.module.family.data.FamilyCreateRsp
 import com.adealink.weparty.module.family.data.FamilyInfo
 import com.adealink.weparty.module.family.data.FamilyInfoDetail
 import com.adealink.weparty.module.family.data.FamilyJoinMode
-import com.adealink.weparty.module.family.data.FamilyLevelConfig
+import com.adealink.weparty.module.family.data.FamilyMemberApplyRecordReq
+import com.adealink.weparty.module.family.data.FamilyMemberApplyRecordRsp
 import com.adealink.weparty.module.family.data.FamilyMemberInfo
 import com.adealink.weparty.module.family.data.FamilyMemberInfoReq
 import com.adealink.weparty.module.family.data.FamilyMemberListRes
@@ -91,4 +92,6 @@ interface IFamilyManager : IBaseFrame<IFamilyListener> {
 
     fun joinFamilySuccessAnchorMsg(familyInfo: FamilyInfo)
     fun onFamilyUpgradeSuccess(familyInfo: FamilyInfo)
+
+    suspend fun getFamilyMemberApplyRecord(req: FamilyMemberApplyRecordReq): Rlt<FamilyMemberApplyRecordRsp?>
 }

+ 3 - 1
module/family/src/main/java/com/adealink/weparty/family/viewmodel/message/FamilyMessageViewModel.kt

@@ -5,6 +5,7 @@ import androidx.lifecycle.MutableLiveData
 import com.adealink.frame.base.CommonDataNullError
 import com.adealink.frame.base.Rlt
 import com.adealink.frame.base.fastLazy
+import com.adealink.frame.dot.NumDot
 import com.adealink.frame.mvvm.livedata.OnceMutableLiveData
 import com.adealink.frame.mvvm.viewmodel.BaseViewModel
 import com.adealink.weparty.App
@@ -15,6 +16,7 @@ import com.adealink.weparty.module.family.data.FamilyMemberApplyRecordReq
 import com.adealink.weparty.module.family.data.FamilyMemberApplyRecordRsp
 import com.adealink.weparty.module.family.data.FamilyMemberApplyReviewReq
 import com.adealink.weparty.module.family.viewmodel.IFamilyMessageViewModel
+import com.adealink.weparty.module.message.dot.familyApplyMsgDot
 
 /**
  * Created by LfJ on 2025/7/1.
@@ -39,7 +41,7 @@ class FamilyMessageViewModel : BaseViewModel(), IFamilyMessageViewModel {
                     } else {
                         liveData.send(Rlt.Failed(CommonDataNullError()))
                     }
-
+                    familyApplyMsgDot.show(NumDot(0))
                 }
 
                 is Rlt.Failed -> {

+ 2 - 0
module/gift/src/main/java/com/adealink/weparty/gift/listener/IGiftListener.kt

@@ -30,6 +30,8 @@ interface IGiftListener : IListener {
 
     fun onChatLuckyGiftRewardNotify(notify: LuckyGiftLotteryNotify)
 
+    fun onGroupChatLuckyGiftRewardNotify(notify: LuckyGiftLotteryNotify)
+
     fun onSendBackpackItemNotify(notify: SendBackpackItemNotify)
 
     fun onPersonalBackpackItemNotify(notify: SendBackpackItemNotify)

+ 20 - 0
module/gift/src/main/java/com/adealink/weparty/gift/manager/GiftManager.kt

@@ -158,6 +158,19 @@ class GiftManager : BaseFrame<IGiftListener>(), IGiftManager, IRoomListener {
         }
     }
 
+    private val groupChatLuckyGiftRewardNotify = object : ISocketNotify<LuckyGiftLotteryNotify> {
+
+        override val uri: String = "LUCKYGIFT_LOTTERY_NOTIFY_FAMILY"
+
+        override fun needHandle(data: LuckyGiftLotteryNotify?): Boolean {
+            return data != null
+        }
+
+        override fun onNotify(data: LuckyGiftLotteryNotify) {
+            handleGroupChatLuckyGiftRewardNotify(data)
+        }
+    }
+
     private val sendBackpackItemNotify = object : ISocketNotify<SendBackpackItemNotify> {
 
         override val uri: String = "GOODS_SEND_NOTIFY"
@@ -218,6 +231,7 @@ class GiftManager : BaseFrame<IGiftListener>(), IGiftManager, IRoomListener {
         App.instance.networkService.subscribeNotify(newerSendGiftNotify)
         App.instance.networkService.subscribeNotify(luckyGiftRewardNotify)
         App.instance.networkService.subscribeNotify(chatLuckyGiftRewardNotify)
+        App.instance.networkService.subscribeNotify(groupChatLuckyGiftRewardNotify)
         App.instance.networkService.subscribeNotify(sendBackpackItemNotify)
         App.instance.networkService.subscribeNotify(sendPersonalBackpackItemNotify)
         App.instance.networkService.subscribeNotify(chatSendGiftNotify)
@@ -1070,6 +1084,12 @@ class GiftManager : BaseFrame<IGiftListener>(), IGiftManager, IRoomListener {
         }
     }
 
+    private fun handleGroupChatLuckyGiftRewardNotify(notify: LuckyGiftLotteryNotify) {
+        dispatch {
+            it.onGroupChatLuckyGiftRewardNotify(notify)
+        }
+    }
+
     private fun handleSendBackpackItemNotify(notify: SendBackpackItemNotify) {
         Log.d(TAG_GIFT_SEND, "handleSendBackpackItemNotify, $notify")
         dispatch {

+ 5 - 0
module/gift/src/main/java/com/adealink/weparty/gift/viewmodel/GiftViewModel.kt

@@ -87,6 +87,7 @@ class GiftViewModel : BaseViewModel(), IGiftViewModel, IGiftListener {
     override val sendUidSetLD: ExtLiveData<Set<Long>> = ExtMutableLiveData()
     override val luckyGiftRewardNotifyLD: ExtLiveData<LuckyGiftLotteryNotify> = ExtMutableLiveData()
     override val chatLuckyGiftRewardNotifyLD: ExtLiveData<LuckyGiftLotteryNotify> = ExtMutableLiveData()
+    override val groupChatLuckyGiftRewardNotifyLD: ExtLiveData<LuckyGiftLotteryNotify> = ExtMutableLiveData()
     override val giftBackpackItemSelectLD: ExtLiveData<UserPackageInfo> = ExtMutableLiveData()
     override val sendBackpackItemNotifyLD: ExtLiveData<SendBackpackItemNotify> = ExtMutableLiveData()
     override val timeLimitGiftUntilExpiredLD: ExtLiveData<Long> = ExtMutableLiveData()
@@ -554,6 +555,10 @@ class GiftViewModel : BaseViewModel(), IGiftViewModel, IGiftListener {
         chatLuckyGiftRewardNotifyLD.send(notify, false)
     }
 
+    override fun onGroupChatLuckyGiftRewardNotify(notify: LuckyGiftLotteryNotify) {
+        groupChatLuckyGiftRewardNotifyLD.send(notify, false)
+    }
+
     override fun onSendBackpackItemNotify(notify: SendBackpackItemNotify) {
         sendBackpackItemNotifyLD.send(notify, false)
     }

+ 51 - 8
module/message/src/main/java/com/adealink/weparty/message/conversation/comp/GroupChatGiftComp.kt

@@ -2,8 +2,10 @@ package com.adealink.weparty.message.conversation.comp
 
 import android.content.Intent
 import android.graphics.PointF
+import android.os.Bundle
 import android.widget.ImageView
 import androidx.lifecycle.LifecycleOwner
+import com.adealink.frame.aab.util.getCompatString
 import com.adealink.frame.base.Rlt
 import com.adealink.frame.base.fastLazy
 import com.adealink.frame.effect.svga.data.PathType
@@ -11,10 +13,13 @@ import com.adealink.frame.effect.svga.data.SVGAEffectEntity
 import com.adealink.frame.effect.video.data.VideoEffectEntity
 import com.adealink.frame.effect.view.EffectView
 import com.adealink.frame.mvvm.view.ViewComponent
+import com.adealink.frame.router.Router
 import com.adealink.frame.tceffect.effect.data.TCEffectEntity
 import com.adealink.frame.util.getCenterLocationInWindow
 import com.adealink.frame.util.getLocationInWindow
+import com.adealink.weparty.commonui.dialogfragment.BaseDialogFragment
 import com.adealink.weparty.commonui.ext.dp
+import com.adealink.weparty.commonui.toast.util.showToast
 import com.adealink.weparty.effect.EffectAnimType
 import com.adealink.weparty.effect.EffectSaveResource
 import com.adealink.weparty.message.constant.MESSAGE_FROM_USER_AVATAR_KEY
@@ -25,18 +30,23 @@ import com.adealink.weparty.message.effect.GiftEffectListener
 import com.adealink.weparty.message.effect.SendStaticGiftEffectEntity
 import com.adealink.weparty.message.effect.StaticGiftEffectLayout
 import com.adealink.weparty.module.anchor.data.FromScene
+import com.adealink.weparty.module.gift.Gift
 import com.adealink.weparty.module.gift.GiftModule
 import com.adealink.weparty.module.gift.data.DEFAULT_GIFT_EFFECT_TIMEOUT_MS
 import com.adealink.weparty.module.gift.data.DynamicEntityType
 import com.adealink.weparty.module.gift.data.GiftDynamicEntity
 import com.adealink.weparty.module.gift.data.GiftInfo
+import com.adealink.weparty.module.gift.data.LuckyGiftLotteryNotify
 import com.adealink.weparty.module.gift.data.SendGiftNotify
 import com.adealink.weparty.module.gift.data.getSVGAGiftDynamicEntity
 import com.adealink.weparty.module.gift.data.getTCFetchResource
 import com.adealink.weparty.module.gift.data.getVapFetchResource
 import com.adealink.weparty.module.gift.effect.SendGiftNoticeLayout
+import com.adealink.weparty.module.gift.effect.luckygift.LuckyGiftBigRewardEffectEntity
+import com.adealink.weparty.module.gift.effect.luckygift.LuckyGiftRewardEffectEntity
 import com.adealink.weparty.module.profile.ProfileModule
 import com.adealink.weparty.module.profile.data.UserInfo
+import com.adealink.weparty.module.wallet.WalletModule
 
 class GroupChatGiftComp(
     lifecycleOwner: LifecycleOwner,
@@ -48,6 +58,10 @@ class GroupChatGiftComp(
 ) : ViewComponent(lifecycleOwner) {
     private val giftViewModel by fastLazy { GiftModule.getGiftViewModel(requireActivity()) }
 
+    companion object {
+        private const val LOTTERY_RATIO_BIG_REWARD_EFFECT = 300
+    }
+
     override fun onCreate() {
         super.onCreate()
         observerViewModel()
@@ -58,15 +72,44 @@ class GroupChatGiftComp(
             if (sendGiftNotify.giftScene != FromScene.GROUP_IM.scene) {
                 return@observeWithoutCache
             }
-            val myUid = ProfileModule.getMyUid()
-            if (sendGiftNotify.fromUid == myUid || sendGiftNotify.toUidSet.contains(myUid)) {
-                handleSendGiftNotify(
-                    sendGiftNotify,
-                    sendGiftNotify.gitInfo,
-                    sendGiftNotify.toUidSet,
-                    sendGiftNotify.count,
-                    sendGiftNotify.notifyUserInfo ?: mapOf()
+            handleSendGiftNotify(
+                sendGiftNotify,
+                sendGiftNotify.gitInfo,
+                sendGiftNotify.toUidSet,
+                sendGiftNotify.count,
+                sendGiftNotify.notifyUserInfo ?: mapOf()
+            )
+        }
+        giftViewModel?.groupChatLuckyGiftRewardNotifyLD?.observeWithoutCache(viewLifecycleOwner) { notify ->
+            handleLuckGiftRewardNotify(notify)
+        }
+    }
+
+    private fun handleLuckGiftRewardNotify(notify: LuckyGiftLotteryNotify) {
+        if (notify.userInfo.uid == ProfileModule.getMyUid()) {
+            if (notify.giftInfo.isComboGift == 1) {
+                //幸运礼物combo弹toast提醒
+                showToast(
+                    getCompatString(
+                        com.adealink.weparty.R.string.common_lucky_gift_reward,
+                        notify.giftInfo.name,
+                        notify.lotteryRatio
+                    )
                 )
+            } else {
+                Router.getRouterInstance<BaseDialogFragment>(Gift.LuckyGiftReward.PATH)?.apply {
+                    this.arguments = Bundle().apply {
+                        putParcelable(Gift.LuckyGiftReward.EXTRA_LUCKY_GIFT_REWARD, notify)
+                    }
+                }?.show(fragmentManager)
+            }
+            WalletModule.getWalletViewModel(requireActivity())?.getMyCoinCount()
+        }
+        if (notify.showPlace == 1) {
+            if (notify.lotteryRatio >= LOTTERY_RATIO_BIG_REWARD_EFFECT) {
+                giftEffectView.add(LuckyGiftBigRewardEffectEntity("", notify))
+            } else {
+                giftEffectView.add(LuckyGiftRewardEffectEntity("", notify))
             }
         }
     }

+ 3 - 0
module/message/src/main/java/com/adealink/weparty/message/conversation/group/GroupConversationActivity.kt

@@ -33,6 +33,9 @@ class GroupConversationActivity : BaseActivity() {
     @BindExtra(name = Message.Common.EXTRA_MENTION_UID, desc = "艾特人的uid")
     var mentionUid: Long = 0
 
+    override val forceFitNavigationBar: Boolean
+        get() = true
+
     override fun onBeforeCreate() {
         super.onBeforeCreate()
         Router.bind(this)

+ 6 - 0
module/message/src/main/java/com/adealink/weparty/message/conversationlist/viewmodel/ConversationListViewModel.kt

@@ -47,10 +47,13 @@ import com.adealink.weparty.message.listener.IIMUserInfoListener
 import com.adealink.weparty.message.manager.messageManager
 import com.adealink.weparty.message.userinfo.IMUserInfoManager
 import com.adealink.weparty.message.userinfo.model.IMUserInfo
+import com.adealink.weparty.module.family.FamilyModule
+import com.adealink.weparty.module.family.data.FamilyMemberApplyRecordReq
 import com.adealink.weparty.module.message.data.GetSessionListReq
 import com.adealink.weparty.module.message.data.GetSessionListRes
 import com.adealink.weparty.module.message.data.UpdateSessionListOperate
 import com.adealink.weparty.module.message.data.UpdateSessionListReq
+import com.adealink.weparty.module.message.dot.familyApplyMsgDot
 import com.adealink.weparty.module.moment.MomentModule
 import com.adealink.weparty.module.moment.dot.momentMsgDot
 import com.adealink.weparty.module.profile.data.OnlineInRoomStatus
@@ -1032,6 +1035,9 @@ open class ConversationListViewModel(
                     showToast(rlt)
                 }
             }
+            FamilyModule.getFamilyMemberApplyRecord(FamilyMemberApplyRecordReq(1, 20)).onSuccess {
+                familyApplyMsgDot.show(NumDot(0))
+            }
         }
     }