Преглед на файлове

feat: 1v1呼叫消息音频切换

DoggyZhang преди 1 месец
родител
ревизия
2602282a28

+ 2 - 12
module/call/src/main/java/com/adealink/weparty/call/comp/CallBottomComp.kt

@@ -134,27 +134,17 @@ class CallBottomComp(
                 R.drawable.call_mic_enable_ic
             }
         )
-//        buttonMicrophone.textView.text = if (microphoneStatus == DeviceStatus.OFF) {
-//            context.getString(R.string.callview_toast_enable_mute)
-//        } else {
-//            context.getString(R.string.callview_toast_disable_mute)
-//        }
     }
 
     private fun updateAudioRouteButton(audioRoute: AudioRoute) {
         val isSpeaker = audioRoute == AudioRoute.SPEAKERPHONE
-//        val resId =
-//            if (isSpeaker) R.string.callview_text_speaker else R.string.callview_text_use_earpiece
         binding.btnSpeaker.setImageResource(
             if (isSpeaker) {
-                R.drawable.call_speaker_disable_ic
-            } else {
                 R.drawable.call_speaker_enable_ic
+            } else {
+                R.drawable.call_speaker_disable_ic
             }
         )
-//        buttonAudioDevice.textView.text = context.getString(resId)
-//        buttonAudioDevice.imageView.isActivated = isSpeaker
-//        buttonAudioDevice.imageView.setImageResource(R.drawable.callview_bg_audio_device)
     }
 
 }

+ 1 - 0
module/im/src/main/java/com/adealink/weparty/im/session/comp/SessionOrderTopBarComp.kt

@@ -4,6 +4,7 @@ import androidx.fragment.app.FragmentContainerView
 import androidx.lifecycle.LifecycleOwner
 import com.adealink.frame.base.fastLazy
 import com.adealink.frame.mvvm.view.ViewComponent
+import com.adealink.frame.mvvm.viewmodel.activityViewModels
 import com.adealink.frame.mvvm.viewmodel.viewModels
 import com.adealink.weparty.commonui.ext.gone
 import com.adealink.weparty.commonui.ext.show

+ 16 - 0
module/im/src/main/java/com/adealink/weparty/im/session/comp/SessionTopComp.kt

@@ -30,6 +30,8 @@ class SessionTopComp(
     private val profileViewModel by fastLazy { ProfileModule.getProfileViewModel(viewModelStoreOwner) }
     private val followViewModel by fastLazy { ProfileModule.getFollowViewModel(viewModelStoreOwner) }
 
+    private var chatUserInfo: UserInfo? = null
+
     override fun onCreate() {
         super.onCreate()
         initView()
@@ -69,7 +71,9 @@ class SessionTopComp(
 
     private fun observeViewModel() {
         profileViewModel?.userInfoLD?.observe(viewLifecycleOwner) {
+            this@SessionTopComp.chatUserInfo = it
             updateUserInfo(it)
+            updateCallButton()
         }
 
         chatInfo?.let { chatInfo ->
@@ -100,6 +104,18 @@ class SessionTopComp(
         }
     }
 
+    private fun updateCallButton() {
+        val chatUserInfo = this@SessionTopComp.chatUserInfo
+        if (chatUserInfo == null) {
+            topBar.btnCall.gone()
+            return
+        }
+        //通话按钮展示条件, 至少有一个陪玩师
+        val hasPlaymate =
+            chatUserInfo.isPlaymate() || ProfileModule.getMyUserInfo()?.isPlaymate() == true
+        topBar.btnCall.show(hasPlaymate)
+    }
+
     private fun updateUserInfo(userInfo: UserInfo?) {
         topBar.ivAvatar.setImageUrl(userInfo?.avatar)
         topBar.tvUserName.text = userInfo?.nickName

+ 3 - 1
module/im/src/main/res/layout/layout_session_top_bar.xml

@@ -105,10 +105,12 @@
             android:layout_width="24dp"
             android:layout_height="24dp"
             android:layout_marginEnd="16dp"
+            android:visibility="gone"
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintEnd_toStartOf="@id/btn_setting"
             app:layout_constraintTop_toTopOf="parent"
-            app:srcCompat="@drawable/im_session_call_ic" />
+            app:srcCompat="@drawable/im_session_call_ic"
+            tools:visibility="visible" />
 
         <androidx.appcompat.widget.AppCompatImageView
             android:id="@+id/btn_setting"