Properly display conference participants in incoming call fragment

This commit is contained in:
Sylvain Berfini 2022-05-18 17:27:11 +02:00
parent 2838d207ca
commit 3c2640d4bf
6 changed files with 83 additions and 32 deletions

View file

@ -20,6 +20,7 @@
package org.linphone.activities.voip.data
import android.view.View
import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.MutableLiveData
import java.util.*
import kotlinx.coroutines.*
@ -48,6 +49,9 @@ open class CallData(val call: Call) : GenericContactData(call.remoteAddress) {
val isInRemoteConference = MutableLiveData<Boolean>()
val remoteConferenceSubject = MutableLiveData<String>()
val isConferenceCall = MediatorLiveData<Boolean>()
val conferenceParticipants = MutableLiveData<List<ConferenceInfoParticipantData>>()
val conferenceParticipantsCountLabel = MutableLiveData<String>()
val isOutgoing = MutableLiveData<Boolean>()
val isIncoming = MutableLiveData<Boolean>()
@ -110,6 +114,13 @@ open class CallData(val call: Call) : GenericContactData(call.remoteAddress) {
isRemotelyRecorded.value = call.remoteParams?.isRecording
displayableAddress.value = LinphoneUtils.getDisplayableAddress(call.remoteAddress)
isConferenceCall.addSource(remoteConferenceSubject) {
isConferenceCall.value = remoteConferenceSubject.value.orEmpty().isNotEmpty() || conferenceParticipants.value.orEmpty().isNotEmpty()
}
isConferenceCall.addSource(conferenceParticipants) {
isConferenceCall.value = remoteConferenceSubject.value.orEmpty().isNotEmpty() || conferenceParticipants.value.orEmpty().isNotEmpty()
}
update()
}
@ -231,6 +242,15 @@ open class CallData(val call: Call) : GenericContactData(call.remoteAddress) {
conference.subject
}
Log.d("[Call] Found conference related to this call with subject [${remoteConferenceSubject.value}]")
val participantsList = arrayListOf<ConferenceInfoParticipantData>()
for (participant in conference.participantList) {
val participantData = ConferenceInfoParticipantData(participant.address)
participantsList.add(participantData)
}
conferenceParticipants.value = participantsList
conferenceParticipantsCountLabel.value = coreContext.context.getString(R.string.conference_participants_title, participantsList.size)
} else {
val remoteContact = call.remoteContact
Log.d("[Call] Call's remote contact is $remoteContact")
@ -239,6 +259,25 @@ open class CallData(val call: Call) : GenericContactData(call.remoteAddress) {
if (conferenceInfo != null) {
Log.d("[Call] Found matching conference info with subject: ${conferenceInfo.subject}")
remoteConferenceSubject.value = conferenceInfo.subject
val participantsList = arrayListOf<ConferenceInfoParticipantData>()
for (participant in conferenceInfo.participants) {
val participantData = ConferenceInfoParticipantData(participant)
participantsList.add(participantData)
}
// Add organizer if not in participants list
val organizer = conferenceInfo.organizer
if (organizer != null) {
val found = participantsList.find { it.participant.weakEqual(organizer) }
if (found == null) {
val participantData = ConferenceInfoParticipantData(organizer)
participantsList.add(0, participantData)
}
}
conferenceParticipants.value = participantsList
conferenceParticipantsCountLabel.value = coreContext.context.getString(R.string.conference_participants_title, participantsList.size)
}
}
}

View file

@ -0,0 +1,31 @@
/*
* Copyright (c) 2010-2022 Belledonne Communications SARL.
*
* This file is part of linphone-android
* (see https://www.linphone.org).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.linphone.activities.voip.data
import org.linphone.contact.GenericContactData
import org.linphone.core.*
import org.linphone.utils.LinphoneUtils
class ConferenceInfoParticipantData(
val participant: Address
) :
GenericContactData(participant) {
val sipUri: String get() = LinphoneUtils.getDisplayableAddress(participant)
}

View file

@ -42,7 +42,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@{callsViewModel.currentCallData.remoteConferenceSubject.length > 0 ? @string/conference_incoming_title : @string/call_incoming_title, default=@string/call_incoming_title}"
android:text="@{callsViewModel.currentCallData.isConferenceCall ? @string/conference_incoming_title : @string/call_incoming_title, default=@string/call_incoming_title}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/progress" />
@ -129,7 +129,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="20dp"
android:layout_marginBottom="10dp"
android:background="@drawable/event_decoration_gray"
android:gravity="center"
android:orientation="horizontal"
@ -145,7 +145,7 @@
android:lineSpacingExtra="0sp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Participants (6)" /><!-- TODO -->
android:text="@{callsViewModel.currentCallData.conferenceParticipantsCountLabel, default=`Participants (6)`}" />
</LinearLayout>
@ -167,30 +167,9 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/voip_conference_incoming_participant_cell" />
<include layout="@layout/voip_conference_incoming_participant_cell" />
<include layout="@layout/voip_conference_incoming_participant_cell" />
<include layout="@layout/voip_conference_incoming_participant_cell" />
<include layout="@layout/voip_conference_incoming_participant_cell" />
<include layout="@layout/voip_conference_incoming_participant_cell" />
<include layout="@layout/voip_conference_incoming_participant_cell" />
<include layout="@layout/voip_conference_incoming_participant_cell" />
<include layout="@layout/voip_conference_incoming_participant_cell" />
<include layout="@layout/voip_conference_incoming_participant_cell" />
<!-- TODO -->
</LinearLayout>
android:orientation="vertical"
app:entries="@{callsViewModel.currentCallData.conferenceParticipants}"
app:layout="@{@layout/voip_conference_incoming_participant_cell}" />
</androidx.core.widget.NestedScrollView>
@ -198,14 +177,14 @@
android:id="@+id/single_call_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="@{callsViewModel.currentCallData.remoteConferenceSubject.length > 0 ? View.GONE : View.VISIBLE, default=visible}"
android:visibility="@{callsViewModel.currentCallData.isConferenceCall ? View.GONE : View.VISIBLE, default=visible}"
app:constraint_referenced_ids="incoming_call_timer, avatar, caller_name, sipAddress" />
<androidx.constraintlayout.widget.Group
android:id="@+id/conference_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="@{callsViewModel.currentCallData.remoteConferenceSubject.length > 0 ? View.VISIBLE : View.GONE, default=gone}"
android:visibility="@{callsViewModel.currentCallData.isConferenceCall ? View.VISIBLE : View.GONE, default=gone}"
app:constraint_referenced_ids="incoming_conference_subject, conference_avatar, participants_count, participants_list" />
<include

View file

@ -5,7 +5,7 @@
<import type="android.view.View"/>
<variable
name="data"
type="org.linphone.activities.voip.data.ConferenceParticipantData" />
type="org.linphone.activities.voip.data.ConferenceInfoParticipantData" />
</data>
<LinearLayout
@ -20,7 +20,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="Bilbo Baggins" />
android:text="@{data.contact.name ?? data.displayName, default=`Bilbo Baggins`}" />
<org.linphone.views.MarqueeTextView
style="@style/sip_uri_font"
@ -28,7 +28,7 @@
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end"
android:text="sip:bilbo.baggins@sip.linphone.org" />
android:text="@{data.sipUri, default=`sip:bilbo.baggins@sip.linphone.org`}" />
</LinearLayout>

View file

@ -723,4 +723,5 @@
<string name="conference_group_call_summary">Informations de l\'appel de groupe</string>
<string name="conference_group_call_create">Démarrer l\'appel de groupe</string>
<string name="incoming_group_call_notification_title">Appel de groupe entrant</string>
<string name="conference_participants_title">Participants (%d)</string>
</resources>

View file

@ -294,6 +294,7 @@
<string name="conference_first_to_join">You\'re the first to join the group call</string>
<string name="conference_last_user">All other participants have left the group call</string>
<string name="conference_incoming_title">Incoming group call</string>
<string name="conference_participants_title">Participants (%d)</string>
<!-- Call -->
<string name="call_incoming_title">Incoming Call</string>