Fixed active speaker alone layout when in fact there is at least one other participant

This commit is contained in:
Sylvain Berfini 2022-10-24 14:19:16 +02:00
parent 59a9290832
commit e01ffc0211
4 changed files with 21 additions and 7 deletions

View file

@ -213,7 +213,7 @@ dependencies {
implementation 'androidx.recyclerview:recyclerview:1.3.0-rc01'
// https://github.com/material-components/material-components-android/blob/master/LICENSE Apache v2.0
implementation 'com.google.android.material:material:1.6.1'
implementation 'com.google.android.material:material:1.7.0'
// https://github.com/google/flexbox-layout/blob/main/LICENSE Apache v2.0
implementation 'com.google.android.flexbox:flexbox:3.0.0'
@ -230,7 +230,7 @@ dependencies {
// https://github.com/Baseflow/PhotoView/blob/master/LICENSE Apache v2.0
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
implementation platform('com.google.firebase:firebase-bom:30.3.2')
implementation platform('com.google.firebase:firebase-bom:31.0.1')
if (crashlyticsEnabled) {
implementation 'com.google.firebase:firebase-crashlytics-ndk'
} else {

View file

@ -23,7 +23,9 @@ import android.Manifest
import android.content.Intent
import android.content.pm.PackageManager
import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import androidx.annotation.RequiresApi
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.findNavController
@ -186,6 +188,7 @@ class CallActivity : ProximitySensorActivity() {
}
}
@RequiresApi(Build.VERSION_CODES.O)
override fun onPictureInPictureModeChanged(
isInPictureInPictureMode: Boolean,
newConfig: Configuration
@ -195,6 +198,7 @@ class CallActivity : ProximitySensorActivity() {
// To hide UI except for TextureViews
controlsViewModel.pipMode.value = isInPictureInPictureMode
}
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
}
override fun onResume() {

View file

@ -262,6 +262,7 @@ class ConferenceCallFragment : GenericFragment<VoipConferenceCallFragmentBinding
super.onResume()
if (conferenceViewModel.conferenceDisplayMode.value == ConferenceDisplayMode.ACTIVE_SPEAKER) {
Log.i("[Conference Call] Conference fragment is resuming, current display mode is active speaker, adjusting layout")
adjustActiveSpeakerLayout()
}
}
@ -346,7 +347,7 @@ class ConferenceCallFragment : GenericFragment<VoipConferenceCallFragmentBinding
}
private fun adjustActiveSpeakerLayout() {
if (conferenceViewModel.conferenceCreationPending.value == false) {
if (conferenceViewModel.conference.value?.state == Conference.State.Created) {
val participantsCount = conferenceViewModel.conferenceParticipantDevices.value.orEmpty().size
Log.i("[Conference Call] Updating active speaker layout for [$participantsCount] participants")
when (participantsCount) {
@ -354,6 +355,8 @@ class ConferenceCallFragment : GenericFragment<VoipConferenceCallFragmentBinding
2 -> switchToActiveSpeakerLayoutForTwoParticipants()
else -> switchToActiveSpeakerLayoutForMoreThanTwoParticipants()
}
} else {
Log.w("[Conference] Active speaker layout not adjusted, conference state is: ${conferenceViewModel.conference.value?.state}")
}
}

View file

@ -89,6 +89,7 @@ class ConferenceViewModel : ViewModel() {
updateParticipantsList(conference)
if (conferenceParticipants.value.orEmpty().isEmpty()) {
speakingParticipant.value?.videoEnabled?.value = false
allParticipantsLeftEvent.value = Event(true)
}
}
@ -190,7 +191,6 @@ class ConferenceViewModel : ViewModel() {
when (state) {
Conference.State.Created -> {
configureConference(conference)
conferenceCreationPending.value = false
}
Conference.State.TerminationPending -> {
terminateConference(conference)
@ -210,6 +210,10 @@ class ConferenceViewModel : ViewModel() {
if (state == Conference.State.Instantiated) {
conferenceCreationPending.value = true
initConference(conference)
} else if (state == Conference.State.Created) {
if (conferenceCreationPending.value == true) {
conferenceCreationPending.value = false
}
}
}
}
@ -239,10 +243,13 @@ class ConferenceViewModel : ViewModel() {
Log.i("[Conference] Found an existing conference: $conference in state $state")
if (state != Conference.State.TerminationPending && state != Conference.State.Terminated) {
initConference(conference)
if (state == Conference.State.Created) {
configureConference(conference)
} else {
if (state == Conference.State.Instantiated) {
conferenceCreationPending.value = true
} else if (state == Conference.State.Created) {
if (conferenceCreationPending.value == true) {
conferenceCreationPending.value = false
}
configureConference(conference)
}
}
}