From a571b7711722247990fd698422a0a069e355c68f Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 24 Nov 2023 14:30:29 +0100 Subject: [PATCH] Started conference layout bottom sheet --- .../java/org/linphone/ui/call/CallActivity.kt | 12 ++++ .../ConferenceLayoutMenuDialogFragment.kt | 72 +++++++++++++++++++ .../linphone/ui/call/model/ConferenceModel.kt | 16 ++++- .../call_conference_actions_bottom_sheet.xml | 2 + .../layout/call_conference_layout_menu.xml | 15 ++++ 5 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/org/linphone/ui/call/fragment/ConferenceLayoutMenuDialogFragment.kt diff --git a/app/src/main/java/org/linphone/ui/call/CallActivity.kt b/app/src/main/java/org/linphone/ui/call/CallActivity.kt index 8146a8dbd..e352bb22a 100644 --- a/app/src/main/java/org/linphone/ui/call/CallActivity.kt +++ b/app/src/main/java/org/linphone/ui/call/CallActivity.kt @@ -45,6 +45,7 @@ import org.linphone.ui.GenericActivity import org.linphone.ui.call.fragment.ActiveCallFragmentDirections import org.linphone.ui.call.fragment.ActiveConferenceCallFragmentDirections import org.linphone.ui.call.fragment.AudioDevicesMenuDialogFragment +import org.linphone.ui.call.fragment.ConferenceLayoutMenuDialogFragment import org.linphone.ui.call.fragment.IncomingCallFragmentDirections import org.linphone.ui.call.fragment.OutgoingCallFragmentDirections import org.linphone.ui.call.model.AudioDeviceModel @@ -103,6 +104,12 @@ class CallActivity : GenericActivity() { } } + callViewModel.conferenceModel.showLayoutMenuEvent.observe(this) { + it.consume { + showConferenceLayoutMenu() + } + } + callViewModel.showLowWifiSignalEvent.observe(this) { it.consume { show -> val tag = "LOW_WIFI_SIGNAL" @@ -408,4 +415,9 @@ class CallActivity : GenericActivity() { val modalBottomSheet = AudioDevicesMenuDialogFragment(devicesList) modalBottomSheet.show(supportFragmentManager, AudioDevicesMenuDialogFragment.TAG) } + + private fun showConferenceLayoutMenu() { + val modalBottomSheet = ConferenceLayoutMenuDialogFragment(callViewModel.conferenceModel) + modalBottomSheet.show(supportFragmentManager, ConferenceLayoutMenuDialogFragment.TAG) + } } diff --git a/app/src/main/java/org/linphone/ui/call/fragment/ConferenceLayoutMenuDialogFragment.kt b/app/src/main/java/org/linphone/ui/call/fragment/ConferenceLayoutMenuDialogFragment.kt new file mode 100644 index 000000000..06bcfb8ff --- /dev/null +++ b/app/src/main/java/org/linphone/ui/call/fragment/ConferenceLayoutMenuDialogFragment.kt @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2010-2023 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 . + */ +package org.linphone.ui.call.fragment + +import android.content.DialogInterface +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.annotation.UiThread +import com.google.android.material.bottomsheet.BottomSheetDialogFragment +import org.linphone.databinding.CallConferenceLayoutMenuBinding +import org.linphone.ui.call.model.ConferenceModel + +@UiThread +class ConferenceLayoutMenuDialogFragment( + val conferenceModel: ConferenceModel, + private val onDismiss: (() -> Unit)? = null +) : BottomSheetDialogFragment() { + companion object { + const val TAG = "ConferenceLayoutMenuDialogFragment" + } + + override fun onCancel(dialog: DialogInterface) { + onDismiss?.invoke() + super.onCancel(dialog) + } + + override fun onDismiss(dialog: DialogInterface) { + onDismiss?.invoke() + super.onDismiss(dialog) + } + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + val view = CallConferenceLayoutMenuBinding.inflate(layoutInflater) + + view.viewModel = conferenceModel + + view.setGridClickListener { + dismiss() + } + view.setActiveSpeakerClickListener { + dismiss() + } + view.setAudioOnlyClickListener { + dismiss() + } + + return view.root + } +} diff --git a/app/src/main/java/org/linphone/ui/call/model/ConferenceModel.kt b/app/src/main/java/org/linphone/ui/call/model/ConferenceModel.kt index 0dd434812..02fc5c423 100644 --- a/app/src/main/java/org/linphone/ui/call/model/ConferenceModel.kt +++ b/app/src/main/java/org/linphone/ui/call/model/ConferenceModel.kt @@ -19,6 +19,7 @@ */ package org.linphone.ui.call.model +import androidx.annotation.UiThread import androidx.annotation.WorkerThread import androidx.lifecycle.MutableLiveData import org.linphone.R @@ -29,6 +30,7 @@ import org.linphone.core.Participant import org.linphone.core.ParticipantDevice import org.linphone.core.tools.Log import org.linphone.utils.AppUtils +import org.linphone.utils.Event class ConferenceModel { companion object { @@ -45,10 +47,14 @@ class ConferenceModel { val participantsLabel = MutableLiveData() - private lateinit var conference: Conference - val isCurrentCallInConference = MutableLiveData() + val showLayoutMenuEvent: MutableLiveData> by lazy { + MutableLiveData>() + } + + private lateinit var conference: Conference + private val conferenceListener = object : ConferenceListenerStub() { @WorkerThread override fun onParticipantAdded(conference: Conference, participant: Participant) { @@ -154,6 +160,11 @@ class ConferenceModel { } } + @UiThread + fun showLayoutMenu() { + showLayoutMenuEvent.value = Event(true) + } + @WorkerThread private fun computeParticipants() { participants.value.orEmpty().forEach(ConferenceParticipantModel::destroy) @@ -209,6 +220,7 @@ class ConferenceModel { ) } + @WorkerThread private fun sortParticipantDevicesList(devices: List): ArrayList { val sortedList = arrayListOf() sortedList.addAll(devices) diff --git a/app/src/main/res/layout/call_conference_actions_bottom_sheet.xml b/app/src/main/res/layout/call_conference_actions_bottom_sheet.xml index c0d84171b..5ced09083 100644 --- a/app/src/main/res/layout/call_conference_actions_bottom_sheet.xml +++ b/app/src/main/res/layout/call_conference_actions_bottom_sheet.xml @@ -101,6 +101,7 @@ + + + +