Show video preview in calls list & conference participants list fragments

This commit is contained in:
Sylvain Berfini 2025-02-07 15:34:10 +01:00
parent 3e5a0c22f8
commit 30fc60c0ef
4 changed files with 86 additions and 0 deletions

View file

@ -30,10 +30,12 @@ import android.view.ViewGroup
import android.view.animation.Animation
import android.view.animation.AnimationUtils
import android.widget.PopupWindow
import androidx.core.view.doOnLayout
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.R
import org.linphone.core.Participant
import org.linphone.core.tools.Log
@ -129,6 +131,32 @@ class ConferenceParticipantsListFragment : GenericCallFragment() {
showKickParticipantDialog(displayName, participant)
}
}
viewModel.isSendingVideo.observe(viewLifecycleOwner) { sending ->
coreContext.postOnCoreThread { core ->
core.nativePreviewWindowId = if (sending) {
Log.i("$TAG We are sending video, setting capture preview surface")
binding.localPreviewVideoSurface
} else {
Log.i("$TAG We are not sending video, clearing capture preview surface")
null
}
}
}
}
override fun onResume() {
super.onResume()
(binding.root as? ViewGroup)?.doOnLayout {
setupVideoPreview(binding.localPreviewVideoSurface)
}
}
override fun onPause() {
super.onPause()
cleanVideoPreview(binding.localPreviewVideoSurface)
}
private fun showKickParticipantDialog(displayName: String, participant: Participant) {

View file

@ -23,14 +23,17 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.doOnLayout
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.core.tools.Log
import org.linphone.databinding.CallsListFragmentBinding
import org.linphone.ui.call.adapter.CallsListAdapter
import org.linphone.ui.call.viewmodel.CallsViewModel
import org.linphone.ui.call.viewmodel.CurrentCallViewModel
import org.linphone.utils.ConfirmationDialogModel
import org.linphone.utils.DialogUtils
@ -43,6 +46,8 @@ class CallsListFragment : GenericCallFragment() {
private lateinit var viewModel: CallsViewModel
private lateinit var callViewModel: CurrentCallViewModel
private lateinit var adapter: CallsListAdapter
private var bottomSheetDialog: BottomSheetDialogFragment? = null
@ -73,6 +78,11 @@ class CallsListFragment : GenericCallFragment() {
binding.viewModel = viewModel
observeToastEvents(viewModel)
callViewModel = requireActivity().run {
ViewModelProvider(this)[CurrentCallViewModel::class.java]
}
observeToastEvents(callViewModel)
binding.callsList.setHasFixedSize(true)
binding.callsList.layoutManager = LinearLayoutManager(requireContext())
@ -101,6 +111,18 @@ class CallsListFragment : GenericCallFragment() {
showMergeCallsIntoConferenceConfirmationDialog()
}
callViewModel.isSendingVideo.observe(viewLifecycleOwner) { sending ->
coreContext.postOnCoreThread { core ->
core.nativePreviewWindowId = if (sending) {
Log.i("$TAG We are sending video, setting capture preview surface")
binding.localPreviewVideoSurface
} else {
Log.i("$TAG We are not sending video, clearing capture preview surface")
null
}
}
}
viewModel.calls.observe(viewLifecycleOwner) {
Log.i("$TAG Calls list updated with [${it.size}] items")
adapter.submitList(it)
@ -113,11 +135,21 @@ class CallsListFragment : GenericCallFragment() {
}
}
override fun onResume() {
super.onResume()
(binding.root as? ViewGroup)?.doOnLayout {
setupVideoPreview(binding.localPreviewVideoSurface)
}
}
override fun onPause() {
super.onPause()
bottomSheetDialog?.dismiss()
bottomSheetDialog = null
cleanVideoPreview(binding.localPreviewVideoSurface)
}
private fun showMergeCallsIntoConferenceConfirmationDialog() {

View file

@ -82,6 +82,19 @@
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintBottom_toBottomOf="parent"/>
<org.linphone.ui.call.view.RoundCornersTextureView
android:id="@+id/local_preview_video_surface"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
app:alignTopRight="true"
app:displayMode="black_bars"
roundCornersRadius="@dimen/call_round_corners_texture_view_radius"
app:layout_constraintBottom_toTopOf="@id/add_participants"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_max="@dimen/call_video_preview_max_size"
app:layout_constraintWidth_max="@dimen/call_video_preview_max_size" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/add_participants"
android:onClick="@{addParticipantsClickListener}"

View file

@ -81,6 +81,19 @@
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintBottom_toBottomOf="parent"/>
<org.linphone.ui.call.view.RoundCornersTextureView
android:id="@+id/local_preview_video_surface"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
app:alignTopRight="true"
app:displayMode="black_bars"
roundCornersRadius="@dimen/call_round_corners_texture_view_radius"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_max="@dimen/call_video_preview_max_size"
app:layout_constraintWidth_max="@dimen/call_video_preview_max_size" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>