From 6ad5f7573b46a45328e9c335581a107239b79d44 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 31 Oct 2024 10:20:31 +0100 Subject: [PATCH] Fixed auto full screen issue in conference --- .../fragment/ActiveConferenceCallFragment.kt | 11 +++++++++++ .../viewmodel/ConferenceViewModel.kt | 19 ++++++++++++++++++- .../ui/call/viewmodel/CurrentCallViewModel.kt | 11 +++++++---- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/linphone/ui/call/conference/fragment/ActiveConferenceCallFragment.kt b/app/src/main/java/org/linphone/ui/call/conference/fragment/ActiveConferenceCallFragment.kt index 517103c7f..ca7fb648b 100644 --- a/app/src/main/java/org/linphone/ui/call/conference/fragment/ActiveConferenceCallFragment.kt +++ b/app/src/main/java/org/linphone/ui/call/conference/fragment/ActiveConferenceCallFragment.kt @@ -226,6 +226,17 @@ class ActiveConferenceCallFragment : GenericCallFragment() { } } + callViewModel.conferenceModel.firstParticipantOtherThanOurselvesJoinedEvent.observe( + viewLifecycleOwner + ) { + it.consume { + if (callViewModel.fullScreenMode.value == false) { + Log.i("$TAG First participant joined conference, switching to full screen mode") + callViewModel.toggleFullScreen() + } + } + } + callViewModel.goToCallEvent.observe(viewLifecycleOwner) { it.consume { if (findNavController().currentDestination?.id == R.id.activeConferenceCallFragment) { diff --git a/app/src/main/java/org/linphone/ui/call/conference/viewmodel/ConferenceViewModel.kt b/app/src/main/java/org/linphone/ui/call/conference/viewmodel/ConferenceViewModel.kt index cb1ec805c..6950789ba 100644 --- a/app/src/main/java/org/linphone/ui/call/conference/viewmodel/ConferenceViewModel.kt +++ b/app/src/main/java/org/linphone/ui/call/conference/viewmodel/ConferenceViewModel.kt @@ -73,6 +73,10 @@ class ConferenceViewModel @UiThread constructor() : GenericViewModel() { val isMeAdmin = MutableLiveData() + val firstParticipantOtherThanOurselvesJoinedEvent: MutableLiveData> by lazy { + MutableLiveData>() + } + val showLayoutMenuEvent: MutableLiveData> by lazy { MutableLiveData>() } @@ -90,6 +94,11 @@ class ConferenceViewModel @UiThread constructor() : GenericViewModel() { "$TAG Participant added: ${participant.address.asStringUriOnly()}" ) addParticipant(participant) + + if (conference.participantList.size == 1) { // we do not count + Log.i("$TAG First participant other than ourselves joined the conference") + firstParticipantOtherThanOurselvesJoinedEvent.postValue(Event(true)) + } } @WorkerThread @@ -226,9 +235,13 @@ class ConferenceViewModel @UiThread constructor() : GenericViewModel() { if (conference.state == Conference.State.Created) { val isIn = conference.isIn isPaused.postValue(!isIn) - Log.i("$TAG We ${if (isIn) "are" else "aren't"} in the conference") + Log.i("$TAG We [${if (isIn) "are" else "aren't"}] in the conference") computeParticipants(false) + if (conference.participantList.size >= 1) { // we do not count + Log.i("$TAG Joined conference already has at least another participant") + firstParticipantOtherThanOurselvesJoinedEvent.postValue(Event(true)) + } } } } @@ -278,6 +291,10 @@ class ConferenceViewModel @UiThread constructor() : GenericViewModel() { if (conference.state == Conference.State.Created) { computeParticipants(false) + if (conference.participantList.size >= 1) { // we do not count + Log.i("$TAG Joined conference already has at least another participant") + firstParticipantOtherThanOurselvesJoinedEvent.postValue(Event(true)) + } } val currentLayout = getCurrentLayout(call) diff --git a/app/src/main/java/org/linphone/ui/call/viewmodel/CurrentCallViewModel.kt b/app/src/main/java/org/linphone/ui/call/viewmodel/CurrentCallViewModel.kt index 607b73040..341b82fc7 100644 --- a/app/src/main/java/org/linphone/ui/call/viewmodel/CurrentCallViewModel.kt +++ b/app/src/main/java/org/linphone/ui/call/viewmodel/CurrentCallViewModel.kt @@ -1198,10 +1198,13 @@ class CurrentCallViewModel @UiThread constructor() : GenericViewModel() { if (((isReceiving) && !wasReceiving)) { if (fullScreenMode.value != true) { - Log.i( - "$TAG Video is being received (it wasn't before), switching to full-screen mode" - ) - fullScreenMode.postValue(true) + val inConference = conferenceModel.isCurrentCallInConference.value == true + if (!inConference) { + Log.i( + "$TAG Video is being received (it wasn't before), switching to full-screen mode" + ) + fullScreenMode.postValue(true) + } } } else if (!isSending && !isReceiving && fullScreenMode.value == true) { Log.w("$TAG Video is no longer enabled, leaving full screen mode")