From f23510da3a16bc110c5562b0ce8c3e6ed231b31d Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 25 Jan 2024 16:24:26 +0100 Subject: [PATCH] More work for having both grid & active speaker layout but not at the same time --- .../java/org/linphone/ui/call/CallActivity.kt | 2 +- .../fragment/ActiveConferenceCallFragment.kt | 18 ---- .../ConferenceActiveSpeakerFragment.kt | 85 +++++++++++++++++++ .../call/fragment/ConferenceGridFragment.kt | 81 ++++++++++++++++++ ...ape_round_in_call_cell_gray_background.xml | 5 ++ .../call_active_conference_fragment.xml | 64 ++------------ .../call_conference_active_speaker_cell.xml | 2 +- ...all_conference_active_speaker_fragment.xml | 65 ++++++++++++++ .../res/layout/call_conference_grid_cell.xml | 2 +- .../layout/call_conference_grid_fragment.xml | 35 ++++++++ .../res/navigation/conference_nav_graph.xml | 33 +++++++ 11 files changed, 315 insertions(+), 77 deletions(-) create mode 100644 app/src/main/java/org/linphone/ui/call/fragment/ConferenceActiveSpeakerFragment.kt create mode 100644 app/src/main/java/org/linphone/ui/call/fragment/ConferenceGridFragment.kt create mode 100644 app/src/main/res/drawable/shape_round_in_call_cell_gray_background.xml create mode 100644 app/src/main/res/layout/call_conference_active_speaker_fragment.xml create mode 100644 app/src/main/res/layout/call_conference_grid_fragment.xml create mode 100644 app/src/main/res/navigation/conference_nav_graph.xml 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 14fd17b08..80a4749f0 100644 --- a/app/src/main/java/org/linphone/ui/call/CallActivity.kt +++ b/app/src/main/java/org/linphone/ui/call/CallActivity.kt @@ -244,7 +244,7 @@ class CallActivity : GenericActivity() { super.onDestroy() coreContext.postOnCoreThread { core -> - Log.i("$TAG Activity destroyed, removing native video window ID") + Log.i("$TAG Clearing native video window ID") core.nativeVideoWindowId = null } } diff --git a/app/src/main/java/org/linphone/ui/call/fragment/ActiveConferenceCallFragment.kt b/app/src/main/java/org/linphone/ui/call/fragment/ActiveConferenceCallFragment.kt index 4d7f30a1f..fe11b23cd 100644 --- a/app/src/main/java/org/linphone/ui/call/fragment/ActiveConferenceCallFragment.kt +++ b/app/src/main/java/org/linphone/ui/call/fragment/ActiveConferenceCallFragment.kt @@ -33,7 +33,6 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior import org.linphone.LinphoneApplication.Companion.coreContext import org.linphone.core.tools.Log import org.linphone.databinding.CallActiveConferenceFragmentBinding -import org.linphone.ui.call.model.ConferenceModel import org.linphone.ui.call.viewmodel.CallsViewModel import org.linphone.ui.call.viewmodel.CurrentCallViewModel import org.linphone.utils.Event @@ -100,23 +99,6 @@ class ActiveConferenceCallFragment : GenericCallFragment() { } callViewModel.conferenceModel.conferenceLayout.observe(viewLifecycleOwner) { layout -> - coreContext.postOnCoreThread { core -> - when (layout) { - ConferenceModel.ACTIVE_SPEAKER_LAYOUT -> { - Log.i( - "$TAG Current layout is active speaker, setting native video window ID" - ) - core.nativeVideoWindowId = binding.activeSpeakerSurface - } - else -> { - Log.i( - "$TAG Current layout isn't active speaker, removing native video window ID" - ) - core.nativeVideoWindowId = null - } - } - } - // Collapse bottom sheet after changing conference layout actionsBottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED } diff --git a/app/src/main/java/org/linphone/ui/call/fragment/ConferenceActiveSpeakerFragment.kt b/app/src/main/java/org/linphone/ui/call/fragment/ConferenceActiveSpeakerFragment.kt new file mode 100644 index 000000000..0c9682c58 --- /dev/null +++ b/app/src/main/java/org/linphone/ui/call/fragment/ConferenceActiveSpeakerFragment.kt @@ -0,0 +1,85 @@ +/* + * 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.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.annotation.UiThread +import androidx.lifecycle.ViewModelProvider +import androidx.navigation.fragment.findNavController +import org.linphone.LinphoneApplication.Companion.coreContext +import org.linphone.R +import org.linphone.core.tools.Log +import org.linphone.databinding.CallConferenceActiveSpeakerFragmentBinding +import org.linphone.ui.call.model.ConferenceModel +import org.linphone.ui.call.viewmodel.CurrentCallViewModel +@UiThread +class ConferenceActiveSpeakerFragment : GenericCallFragment() { + companion object { + private const val TAG = "[Conference Active Speaker Fragment]" + } + + private lateinit var binding: CallConferenceActiveSpeakerFragmentBinding + + private lateinit var callViewModel: CurrentCallViewModel + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + binding = CallConferenceActiveSpeakerFragmentBinding.inflate(layoutInflater) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + callViewModel = requireActivity().run { + ViewModelProvider(this)[CurrentCallViewModel::class.java] + } + + binding.lifecycleOwner = viewLifecycleOwner + binding.viewModel = callViewModel + binding.conferenceViewModel = callViewModel.conferenceModel + + callViewModel.conferenceModel.conferenceLayout.observe(viewLifecycleOwner) { + when (it) { + ConferenceModel.GRID_LAYOUT -> { + Log.i("$TAG Conference layout changed to mosaic, navigating to Grid fragment") + if (findNavController().currentDestination?.id == R.id.conferenceActiveSpeakerFragment) { + findNavController().navigate( + R.id.action_conferenceActiveSpeakerFragment_to_conferenceGridFragment + ) + } + } + else -> { + } + } + } + + coreContext.postOnCoreThread { core -> + Log.i("$TAG Setting native video window ID") + core.nativeVideoWindowId = binding.activeSpeakerSurface + } + } +} diff --git a/app/src/main/java/org/linphone/ui/call/fragment/ConferenceGridFragment.kt b/app/src/main/java/org/linphone/ui/call/fragment/ConferenceGridFragment.kt new file mode 100644 index 000000000..88ddef5a5 --- /dev/null +++ b/app/src/main/java/org/linphone/ui/call/fragment/ConferenceGridFragment.kt @@ -0,0 +1,81 @@ +/* + * 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.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.annotation.UiThread +import androidx.lifecycle.ViewModelProvider +import androidx.navigation.fragment.findNavController +import org.linphone.R +import org.linphone.core.tools.Log +import org.linphone.databinding.CallConferenceGridFragmentBinding +import org.linphone.ui.call.model.ConferenceModel +import org.linphone.ui.call.viewmodel.CurrentCallViewModel +@UiThread +class ConferenceGridFragment : GenericCallFragment() { + companion object { + private const val TAG = "[Conference Grid Fragment]" + } + + private lateinit var binding: CallConferenceGridFragmentBinding + + private lateinit var callViewModel: CurrentCallViewModel + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + binding = CallConferenceGridFragmentBinding.inflate(layoutInflater) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + callViewModel = requireActivity().run { + ViewModelProvider(this)[CurrentCallViewModel::class.java] + } + + binding.lifecycleOwner = viewLifecycleOwner + binding.viewModel = callViewModel + binding.conferenceViewModel = callViewModel.conferenceModel + + callViewModel.conferenceModel.conferenceLayout.observe(viewLifecycleOwner) { + when (it) { + ConferenceModel.ACTIVE_SPEAKER_LAYOUT -> { + Log.i( + "$TAG Conference layout changed to active speaker, navigating to Active Speaker fragment" + ) + if (findNavController().currentDestination?.id == R.id.conferenceGridFragment) { + findNavController().navigate( + R.id.action_conferenceGridFragment_to_conferenceActiveSpeakerFragment + ) + } + } + else -> { + } + } + } + } +} diff --git a/app/src/main/res/drawable/shape_round_in_call_cell_gray_background.xml b/app/src/main/res/drawable/shape_round_in_call_cell_gray_background.xml new file mode 100644 index 000000000..62367e1b1 --- /dev/null +++ b/app/src/main/res/drawable/shape_round_in_call_cell_gray_background.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/call_active_conference_fragment.xml b/app/src/main/res/layout/call_active_conference_fragment.xml index 735f8a19b..ca8527bf4 100644 --- a/app/src/main/res/layout/call_active_conference_fragment.xml +++ b/app/src/main/res/layout/call_active_conference_fragment.xml @@ -96,67 +96,19 @@ app:layout_constraintStart_toStartOf="@id/background" app:layout_constraintEnd_toEndOf="@id/background"/> - - - - - - - - - - - + app:layout_constraintBottom_toBottomOf="parent"/> + android:background="@drawable/shape_round_in_call_cell_gray_background" /> + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/call_conference_grid_cell.xml b/app/src/main/res/layout/call_conference_grid_cell.xml index 603c32995..d1dedd27e 100644 --- a/app/src/main/res/layout/call_conference_grid_cell.xml +++ b/app/src/main/res/layout/call_conference_grid_cell.xml @@ -20,7 +20,7 @@ android:id="@+id/participant_device_background" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@drawable/shape_round_in_call_gray_background" /> + android:background="@drawable/shape_round_in_call_cell_gray_background" /> + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/navigation/conference_nav_graph.xml b/app/src/main/res/navigation/conference_nav_graph.xml new file mode 100644 index 000000000..441dfa748 --- /dev/null +++ b/app/src/main/res/navigation/conference_nav_graph.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + \ No newline at end of file