mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Started active speaker layout
This commit is contained in:
parent
51c6037f3f
commit
7eb756cae6
8 changed files with 217 additions and 10 deletions
|
|
@ -42,6 +42,7 @@ import androidx.window.layout.WindowLayoutInfo
|
|||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.CallActivityBinding
|
||||
|
|
@ -239,6 +240,15 @@ class CallActivity : GenericActivity() {
|
|||
bottomSheetDialog = null
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
|
||||
coreContext.postOnCoreThread { core ->
|
||||
Log.i("$TAG Activity destroyed, removing native video window ID")
|
||||
core.nativeVideoWindowId = null
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior
|
|||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.CallActiveConferenceFragmentBinding
|
||||
import org.linphone.ui.call.model.ConferenceModel
|
||||
import org.linphone.ui.call.viewmodel.CallsViewModel
|
||||
import org.linphone.ui.call.viewmodel.CurrentCallViewModel
|
||||
import org.linphone.utils.Event
|
||||
|
|
@ -98,6 +99,28 @@ class ActiveConferenceCallFragment : GenericCallFragment() {
|
|||
sharedViewModel.toggleFullScreenEvent.value = Event(hide)
|
||||
}
|
||||
|
||||
callViewModel.conferenceModel.conferenceLayout.observe(viewLifecycleOwner) { layout ->
|
||||
coreContext.postOnCoreThread { core ->
|
||||
when (layout) {
|
||||
ConferenceModel.ACTIVE_SPEAKER_LAYOUT -> {
|
||||
Log.i(
|
||||
"$TAG Current layout is active speaker, setting native video window ID"
|
||||
)
|
||||
core.nativeVideoWindowId = binding.activeSpeakerSurface
|
||||
}
|
||||
else -> {
|
||||
Log.i(
|
||||
"$TAG Current layout isn't active speaker, removing native video window ID"
|
||||
)
|
||||
core.nativeVideoWindowId = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Collapse bottom sheet after changing conference layout
|
||||
actionsBottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||
}
|
||||
|
||||
binding.setCallsListClickListener {
|
||||
Log.i("$TAG Going to calls list fragment")
|
||||
val action = ActiveConferenceCallFragmentDirections.actionActiveConferenceCallFragmentToCallsListFragment()
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ class ConferenceModel {
|
|||
|
||||
val participantsLabel = MutableLiveData<String>()
|
||||
|
||||
val activeSpeakerName = MutableLiveData<String>()
|
||||
|
||||
val isCurrentCallInConference = MutableLiveData<Boolean>()
|
||||
|
||||
val conferenceLayout = MutableLiveData<Int>()
|
||||
|
|
@ -80,6 +82,24 @@ class ConferenceModel {
|
|||
removeParticipant(participant)
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
override fun onActiveSpeakerParticipantDevice(
|
||||
conference: Conference,
|
||||
participantDevice: ParticipantDevice
|
||||
) {
|
||||
val found = participantDevices.value.orEmpty().find {
|
||||
it.device == participantDevice
|
||||
}
|
||||
if (found != null) {
|
||||
val name = found.avatarModel.contactName ?: participantDevice.name ?: participantDevice.address.username
|
||||
Log.i("$TAG Newly active speaker participant is [$name]")
|
||||
activeSpeakerName.postValue(name.orEmpty())
|
||||
} else {
|
||||
Log.i("$TAG Failed to find actively speaking participant...")
|
||||
activeSpeakerName.postValue(participantDevice.name)
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
override fun onParticipantAdminStatusChanged(
|
||||
conference: Conference,
|
||||
|
|
@ -278,6 +298,12 @@ class ConferenceModel {
|
|||
for (device in participant.devices) {
|
||||
val model = ConferenceParticipantDeviceModel(device)
|
||||
devicesList.add(model)
|
||||
|
||||
if (device.isSpeaking) {
|
||||
val name = model.avatarModel.contactName ?: device.name ?: device.address.username
|
||||
Log.i("$TAG Using participant is [$name] as current active speaker")
|
||||
activeSpeakerName.postValue(name.orEmpty())
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.i(
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class ConferenceParticipantDeviceModel @WorkerThread constructor(
|
|||
|
||||
@WorkerThread
|
||||
override fun onIsMuted(participantDevice: ParticipantDevice, muted: Boolean) {
|
||||
Log.i(
|
||||
Log.d(
|
||||
"$TAG Participant device [${participantDevice.address.asStringUriOnly()}] is ${if (participantDevice.isMuted) "muted" else "no longer muted"}"
|
||||
)
|
||||
isMuted.postValue(participantDevice.isMuted)
|
||||
|
|
@ -74,10 +74,10 @@ class ConferenceParticipantDeviceModel @WorkerThread constructor(
|
|||
participantDevice: ParticipantDevice,
|
||||
speaking: Boolean
|
||||
) {
|
||||
Log.i(
|
||||
Log.d(
|
||||
"$TAG Participant device [${participantDevice.address.asStringUriOnly()}] is ${if (participantDevice.isSpeaking) "speaking" else "no longer speaking"}"
|
||||
)
|
||||
isSpeaking.postValue(participantDevice.isSpeaking)
|
||||
isSpeaking.postValue(speaking)
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
@ -86,11 +86,10 @@ class ConferenceParticipantDeviceModel @WorkerThread constructor(
|
|||
available: Boolean,
|
||||
streamType: StreamType?
|
||||
) {
|
||||
Log.i(
|
||||
Log.d(
|
||||
"$TAG Participant device [${participantDevice.address.asStringUriOnly()}] stream [$streamType] availability changed to ${if (available) "available" else "not available"}"
|
||||
)
|
||||
if (streamType == StreamType.Video) {
|
||||
val available = participantDevice.getStreamAvailability(StreamType.Video)
|
||||
isVideoAvailable.postValue(available)
|
||||
if (available) {
|
||||
updateWindowId(textureView)
|
||||
|
|
@ -104,13 +103,12 @@ class ConferenceParticipantDeviceModel @WorkerThread constructor(
|
|||
direction: MediaDirection?,
|
||||
streamType: StreamType?
|
||||
) {
|
||||
Log.i(
|
||||
Log.d(
|
||||
"$TAG Participant device [${participantDevice.address.asStringUriOnly()}] stream [$streamType] capability changed to [$direction]"
|
||||
)
|
||||
if (streamType == StreamType.Video) {
|
||||
val videoCapability = participantDevice.getStreamCapability(StreamType.Video)
|
||||
isSendingVideo.postValue(
|
||||
videoCapability == MediaDirection.SendRecv || videoCapability == MediaDirection.SendOnly
|
||||
direction == MediaDirection.SendRecv || direction == MediaDirection.SendOnly
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<data>
|
||||
<import type="android.view.View" />
|
||||
<import type="org.linphone.core.ChatRoom.SecurityLevel" />
|
||||
<import type="org.linphone.ui.call.model.ConferenceModel" />
|
||||
<variable
|
||||
name="shareConferenceClickListener"
|
||||
type="View.OnClickListener" />
|
||||
|
|
@ -63,7 +64,7 @@
|
|||
android:layout_marginStart="5dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:text="@string/conference_call_empty"
|
||||
android:textColor="?attr/color_main2_000"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="22sp"
|
||||
android:gravity="center"
|
||||
android:visibility="@{conferenceViewModel.participantDevices.size() > 1 ? View.GONE : View.VISIBLE}"
|
||||
|
|
@ -102,7 +103,7 @@
|
|||
android:layout_marginBottom="@{viewModel.fullScreenMode || viewModel.pipMode ? @dimen/zero : @dimen/call_main_actions_menu_margin, default=@dimen/call_main_actions_menu_margin}"
|
||||
android:layout_marginTop="@{viewModel.fullScreenMode || viewModel.pipMode ? @dimen/zero : @dimen/call_top_bar_info_height, default=@dimen/call_top_bar_info_height}"
|
||||
android:onClick="@{() -> viewModel.toggleFullScreen()}"
|
||||
android:visibility="@{conferenceViewModel.participantDevices.size() > 1 ? View.VISIBLE : View.GONE, default=gone}"
|
||||
android:visibility="@{conferenceViewModel.conferenceLayout == ConferenceModel.GRID_LAYOUT && conferenceViewModel.participantDevices.size() > 1 ? View.VISIBLE : View.GONE, default=gone}"
|
||||
entries="@{conferenceViewModel.participantDevices}"
|
||||
layout="@{@layout/call_conference_grid_cell}"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
|
@ -110,6 +111,53 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<org.linphone.ui.call.view.RoundCornersTextureView
|
||||
android:id="@+id/active_speaker_surface"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="@{viewModel.fullScreenMode || viewModel.pipMode || viewModel.halfOpenedFolded ? @dimen/zero : @dimen/call_main_actions_menu_margin, default=@dimen/call_main_actions_menu_margin}"
|
||||
android:layout_marginTop="@{viewModel.fullScreenMode || viewModel.pipMode || viewModel.halfOpenedFolded ? @dimen/zero : @dimen/call_top_bar_info_height, default=@dimen/call_top_bar_info_height}"
|
||||
android:onClick="@{() -> viewModel.toggleFullScreen()}"
|
||||
android:visibility="@{conferenceViewModel.conferenceLayout == ConferenceModel.ACTIVE_SPEAKER_LAYOUT && conferenceViewModel.participantDevices.size() > 1 ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_500"
|
||||
android:id="@+id/active_speaker_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:text="@{conferenceViewModel.activeSpeakerName, default=`John Doe`}"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/active_speaker_miniatures_layout"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<HorizontalScrollView
|
||||
android:id="@+id/active_speaker_miniatures_layout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@{viewModel.fullScreenMode || viewModel.pipMode ? @dimen/zero : @dimen/call_main_actions_menu_margin, default=@dimen/call_main_actions_menu_margin}"
|
||||
android:onClick="@{() -> viewModel.toggleFullScreen()}"
|
||||
android:visibility="@{conferenceViewModel.conferenceLayout == ConferenceModel.ACTIVE_SPEAKER_LAYOUT && conferenceViewModel.participantDevices.size() > 1 ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:orientation="horizontal"
|
||||
entries="@{conferenceViewModel.participantDevices}"
|
||||
layout="@{@layout/call_conference_active_speaker_cell}"/>
|
||||
|
||||
</HorizontalScrollView>
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/header_info_visibility"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,97 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<data>
|
||||
<import type="android.view.View" />
|
||||
<import type="org.linphone.core.ChatRoom.SecurityLevel" />
|
||||
<variable
|
||||
name="model"
|
||||
type="org.linphone.ui.call.model.ConferenceParticipantDeviceModel" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="@dimen/call_conference_active_speaker_miniature_size"
|
||||
android:layout_height="@dimen/call_conference_active_speaker_miniature_size"
|
||||
android:padding="2dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/participant_device_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/shape_round_in_call_gray_background" />
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
style="@style/avatar_imageview"
|
||||
android:id="@+id/avatar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:visibility="@{model.isSendingVideo ? View.GONE : View.VISIBLE}"
|
||||
coilCallAvatar="@{model.avatarModel}"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintWidth_max="@dimen/avatar_in_active_speaker_miniature_conference_call_size"
|
||||
app:layout_constraintHeight_max="@dimen/avatar_in_active_speaker_miniature_conference_call_size"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/trust_badge"
|
||||
android:layout_width="@dimen/avatar_presence_badge_in_active_speaker_miniature_conference_call_size"
|
||||
android:layout_height="@dimen/avatar_presence_badge_in_active_speaker_miniature_conference_call_size"
|
||||
android:src="@{model.avatarModel.trust == SecurityLevel.Safe ? @drawable/trusted : @drawable/not_trusted, default=@drawable/trusted}"
|
||||
android:visibility="@{model.avatarModel.trust == SecurityLevel.Safe || model.avatarModel.trust == SecurityLevel.Unsafe ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintStart_toStartOf="@id/avatar"
|
||||
app:layout_constraintBottom_toBottomOf="@id/avatar"/>
|
||||
|
||||
<org.linphone.ui.call.view.RoundCornersTextureView
|
||||
android:id="@+id/participant_video_surface"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:alignTopRight="false"
|
||||
app:displayMode="hybrid"
|
||||
participantTextureView="@{model}"
|
||||
android:visibility="@{model.isSendingVideo ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/muted"
|
||||
android:layout_width="@dimen/small_icon_size"
|
||||
android:layout_height="@dimen/small_icon_size"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:padding="2dp"
|
||||
android:src="@drawable/microphone_slash"
|
||||
android:background="@drawable/shape_circle_white_call_background"
|
||||
android:visibility="@{model.isMuted ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_500"
|
||||
android:id="@+id/name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="@{model.avatarModel.name, default=`John Doe`}"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="11sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/speaking"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/shape_squircle_main2_200_call_border"
|
||||
android:visibility="@{model.isSpeaking ? View.VISIBLE : View.GONE}" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
|
|
@ -28,6 +28,7 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:visibility="@{model.isSendingVideo ? View.GONE : View.VISIBLE}"
|
||||
coilCallAvatar="@{model.avatarModel}"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintWidth_max="@dimen/avatar_in_call_size"
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
<dimen name="avatar_favorite_list_cell_size">50dp</dimen>
|
||||
<dimen name="avatar_big_size">100dp</dimen>
|
||||
<dimen name="avatar_in_call_size">120dp</dimen>
|
||||
<dimen name="avatar_in_active_speaker_miniature_conference_call_size">50dp</dimen>
|
||||
|
||||
<dimen name="avatar_bubble_presence_badge_size">8dp</dimen>
|
||||
<dimen name="avatar_presence_badge_size">12dp</dimen>
|
||||
|
|
@ -26,6 +27,7 @@
|
|||
<dimen name="avatar_presence_badge_big_size">22dp</dimen>
|
||||
<dimen name="avatar_presence_badge_big_padding">3dp</dimen>
|
||||
<dimen name="avatar_presence_badge_big_end_margin">5dp</dimen>
|
||||
<dimen name="avatar_presence_badge_in_active_speaker_miniature_conference_call_size">14dp</dimen>
|
||||
|
||||
<dimen name="avatar_trust_border_width">2dp</dimen>
|
||||
|
||||
|
|
@ -50,6 +52,8 @@
|
|||
<dimen name="call_button_icon_padding">15dp</dimen>
|
||||
<dimen name="call_extra_button_top_margin">30dp</dimen>
|
||||
|
||||
<dimen name="call_conference_active_speaker_miniature_size">120dp</dimen>
|
||||
|
||||
<dimen name="meeting_list_decoration_height">66dp</dimen>
|
||||
|
||||
<dimen name="toast_max_width">400dp</dimen>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue