mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-05-02 13:36:24 +00:00
Check if lateinit conference was initialized
This commit is contained in:
parent
2b040c9c72
commit
8ef5adc06d
1 changed files with 109 additions and 94 deletions
|
|
@ -366,15 +366,17 @@ class ConferenceViewModel
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
fun goToConversation() {
|
fun goToConversation() {
|
||||||
coreContext.postOnCoreThread { core ->
|
if (::conference.isInitialized) {
|
||||||
Log.i("$TAG Navigating to conference's conversation")
|
coreContext.postOnCoreThread { core ->
|
||||||
val chatRoom = conference.chatRoom
|
Log.i("$TAG Navigating to conference's conversation")
|
||||||
if (chatRoom != null) {
|
val chatRoom = conference.chatRoom
|
||||||
goToConversationEvent.postValue(Event(LinphoneUtils.getConversationId(chatRoom)))
|
if (chatRoom != null) {
|
||||||
} else {
|
goToConversationEvent.postValue(Event(LinphoneUtils.getConversationId(chatRoom)))
|
||||||
Log.e(
|
} else {
|
||||||
"$TAG No chat room available for current conference [${conference.conferenceAddress?.asStringUriOnly()}]"
|
Log.e(
|
||||||
)
|
"$TAG No chat room available for current conference [${conference.conferenceAddress?.asStringUriOnly()}]"
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -393,82 +395,93 @@ class ConferenceViewModel
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
fun inviteSipUrisIntoConference(uris: List<String>) {
|
fun inviteSipUrisIntoConference(uris: List<String>) {
|
||||||
coreContext.postOnCoreThread { core ->
|
if (::conference.isInitialized) {
|
||||||
val addresses = arrayListOf<Address>()
|
coreContext.postOnCoreThread { core ->
|
||||||
for (uri in uris) {
|
val addresses = arrayListOf<Address>()
|
||||||
val address = core.interpretUrl(uri, false)
|
for (uri in uris) {
|
||||||
if (address != null) {
|
val address = core.interpretUrl(uri, false)
|
||||||
addresses.add(address)
|
if (address != null) {
|
||||||
Log.i("$TAG Address [${address.asStringUriOnly()}] will be added to conference")
|
addresses.add(address)
|
||||||
} else {
|
Log.i("$TAG Address [${address.asStringUriOnly()}] will be added to conference")
|
||||||
Log.e(
|
} else {
|
||||||
"$TAG Failed to parse SIP URI [$uri] into address, can't add it to the conference!"
|
Log.e(
|
||||||
)
|
"$TAG Failed to parse SIP URI [$uri] into address, can't add it to the conference!"
|
||||||
showRedToast(R.string.conference_failed_to_add_participant_invalid_address_toast, R.drawable.warning_circle)
|
)
|
||||||
|
showRedToast(
|
||||||
|
R.string.conference_failed_to_add_participant_invalid_address_toast,
|
||||||
|
R.drawable.warning_circle
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
val addressesArray = arrayOfNulls<Address>(addresses.size)
|
||||||
|
addresses.toArray(addressesArray)
|
||||||
|
Log.i("$TAG Trying to add [${addressesArray.size}] new participant(s) into conference")
|
||||||
|
conference.addParticipants(addressesArray)
|
||||||
}
|
}
|
||||||
val addressesArray = arrayOfNulls<Address>(addresses.size)
|
|
||||||
addresses.toArray(addressesArray)
|
|
||||||
Log.i("$TAG Trying to add [${addressesArray.size}] new participant(s) into conference")
|
|
||||||
conference.addParticipants(addressesArray)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
fun kickParticipant(participant: Participant) {
|
fun kickParticipant(participant: Participant) {
|
||||||
coreContext.postOnCoreThread {
|
if (::conference.isInitialized) {
|
||||||
Log.i(
|
coreContext.postOnCoreThread {
|
||||||
"$TAG Kicking participant [${participant.address.asStringUriOnly()}] out of conference"
|
Log.i(
|
||||||
)
|
"$TAG Kicking participant [${participant.address.asStringUriOnly()}] out of conference"
|
||||||
conference.removeParticipant(participant)
|
)
|
||||||
|
conference.removeParticipant(participant)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
fun setNewLayout(newLayout: Int) {
|
fun setNewLayout(newLayout: Int) {
|
||||||
val call = conference.call
|
if (::conference.isInitialized) {
|
||||||
if (call != null) {
|
val call = conference.call
|
||||||
val params = call.core.createCallParams(call)
|
if (call != null) {
|
||||||
if (params != null) {
|
val params = call.core.createCallParams(call)
|
||||||
val currentLayout = getCurrentLayout(call)
|
if (params != null) {
|
||||||
if (currentLayout != newLayout) {
|
val currentLayout = getCurrentLayout(call)
|
||||||
when (newLayout) {
|
if (currentLayout != newLayout) {
|
||||||
AUDIO_ONLY_LAYOUT -> {
|
when (newLayout) {
|
||||||
Log.i("$TAG Changing conference layout to [Audio Only]")
|
AUDIO_ONLY_LAYOUT -> {
|
||||||
params.isVideoEnabled = false
|
Log.i("$TAG Changing conference layout to [Audio Only]")
|
||||||
}
|
params.isVideoEnabled = false
|
||||||
ACTIVE_SPEAKER_LAYOUT -> {
|
}
|
||||||
Log.i("$TAG Changing conference layout to [Active Speaker]")
|
|
||||||
params.conferenceVideoLayout = Conference.Layout.ActiveSpeaker
|
|
||||||
}
|
|
||||||
GRID_LAYOUT -> {
|
|
||||||
Log.i("$TAG Changing conference layout to [Grid]")
|
|
||||||
params.conferenceVideoLayout = Conference.Layout.Grid
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentLayout == AUDIO_ONLY_LAYOUT) {
|
ACTIVE_SPEAKER_LAYOUT -> {
|
||||||
// Previous layout was audio only, make sure video isn't sent without user consent when switching layout
|
Log.i("$TAG Changing conference layout to [Active Speaker]")
|
||||||
Log.i(
|
params.conferenceVideoLayout = Conference.Layout.ActiveSpeaker
|
||||||
"$TAG Previous layout was [Audio Only], enabling video but in receive only direction"
|
}
|
||||||
|
|
||||||
|
GRID_LAYOUT -> {
|
||||||
|
Log.i("$TAG Changing conference layout to [Grid]")
|
||||||
|
params.conferenceVideoLayout = Conference.Layout.Grid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentLayout == AUDIO_ONLY_LAYOUT) {
|
||||||
|
// Previous layout was audio only, make sure video isn't sent without user consent when switching layout
|
||||||
|
Log.i(
|
||||||
|
"$TAG Previous layout was [Audio Only], enabling video but in receive only direction"
|
||||||
|
)
|
||||||
|
params.isVideoEnabled = true
|
||||||
|
params.videoDirection = MediaDirection.RecvOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.i("$TAG Updating conference's call params")
|
||||||
|
call.update(params)
|
||||||
|
conferenceLayout.postValue(newLayout)
|
||||||
|
} else {
|
||||||
|
Log.w(
|
||||||
|
"$TAG The conference is already using selected layout, aborting layout change"
|
||||||
)
|
)
|
||||||
params.isVideoEnabled = true
|
|
||||||
params.videoDirection = MediaDirection.RecvOnly
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.i("$TAG Updating conference's call params")
|
|
||||||
call.update(params)
|
|
||||||
conferenceLayout.postValue(newLayout)
|
|
||||||
} else {
|
} else {
|
||||||
Log.w(
|
Log.e("$TAG Failed to create call params, aborting layout change")
|
||||||
"$TAG The conference is already using selected layout, aborting layout change"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e("$TAG Failed to create call params, aborting layout change")
|
Log.e("$TAG Failed to get call from conference, aborting layout change")
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Log.e("$TAG Failed to get call from conference, aborting layout change")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -691,36 +704,38 @@ class ConferenceViewModel
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
private fun addParticipant(participant: Participant) {
|
private fun addParticipant(participant: Participant) {
|
||||||
val list = arrayListOf<ConferenceParticipantModel>()
|
if (::conference.isInitialized) {
|
||||||
list.addAll(participants.value.orEmpty())
|
val list = arrayListOf<ConferenceParticipantModel>()
|
||||||
|
list.addAll(participants.value.orEmpty())
|
||||||
|
|
||||||
val avatarModel = coreContext.contactsManager.getContactAvatarModelForAddress(
|
val avatarModel = coreContext.contactsManager.getContactAvatarModelForAddress(
|
||||||
participant.address
|
participant.address
|
||||||
)
|
|
||||||
val newModel = ConferenceParticipantModel(
|
|
||||||
participant,
|
|
||||||
avatarModel,
|
|
||||||
isMeAdmin.value == true,
|
|
||||||
false,
|
|
||||||
{ participant -> // Remove from conference
|
|
||||||
removeParticipantEvent.postValue(
|
|
||||||
Event(Pair(avatarModel.name.value.orEmpty(), participant))
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{ participant, setAdmin -> // Change admin status
|
|
||||||
conference.setParticipantAdminStatus(participant, setAdmin)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
list.add(newModel)
|
|
||||||
|
|
||||||
participants.postValue(sortParticipantList(list))
|
|
||||||
participantsLabel.postValue(
|
|
||||||
AppUtils.getStringWithPlural(
|
|
||||||
R.plurals.conference_participants_list_title,
|
|
||||||
list.size,
|
|
||||||
"${list.size}"
|
|
||||||
)
|
)
|
||||||
)
|
val newModel = ConferenceParticipantModel(
|
||||||
|
participant,
|
||||||
|
avatarModel,
|
||||||
|
isMeAdmin.value == true,
|
||||||
|
false,
|
||||||
|
{ participant -> // Remove from conference
|
||||||
|
removeParticipantEvent.postValue(
|
||||||
|
Event(Pair(avatarModel.name.value.orEmpty(), participant))
|
||||||
|
)
|
||||||
|
},
|
||||||
|
{ participant, setAdmin -> // Change admin status
|
||||||
|
conference.setParticipantAdminStatus(participant, setAdmin)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
list.add(newModel)
|
||||||
|
|
||||||
|
participants.postValue(sortParticipantList(list))
|
||||||
|
participantsLabel.postValue(
|
||||||
|
AppUtils.getStringWithPlural(
|
||||||
|
R.plurals.conference_participants_list_title,
|
||||||
|
list.size,
|
||||||
|
"${list.size}"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue