From 1c24c805df08c13fba5f166fc23f6dac73fc37bb Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 1 Feb 2024 10:32:48 +0100 Subject: [PATCH] Started audio only layout for conference --- app/build.gradle | 1 + .../ConferenceActiveSpeakerFragment.kt | 14 ++- .../fragment/ConferenceAudioOnlyFragment.kt | 98 +++++++++++++++++++ .../call/fragment/ConferenceGridFragment.kt | 12 ++- .../main/res/layout/call_active_fragment.xml | 48 ++++++--- .../call_conference_audio_only_cell.xml | 93 ++++++++++++++++++ .../call_conference_audio_only_fragment.xml | 42 ++++++++ .../res/layout/call_conference_grid_cell.xml | 1 + .../layout/call_conference_grid_fragment.xml | 3 +- .../res/navigation/conference_nav_graph.xml | 30 ++++++ app/src/main/res/values/dimen.xml | 1 + 11 files changed, 329 insertions(+), 14 deletions(-) create mode 100644 app/src/main/java/org/linphone/ui/call/fragment/ConferenceAudioOnlyFragment.kt create mode 100644 app/src/main/res/layout/call_conference_audio_only_cell.xml create mode 100644 app/src/main/res/layout/call_conference_audio_only_fragment.xml diff --git a/app/build.gradle b/app/build.gradle index 7ec0536ba..3a01cb69c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -140,6 +140,7 @@ dependencies { implementation "androidx.recyclerview:recyclerview:1.3.2" implementation "androidx.slidingpanelayout:slidingpanelayout:1.2.0" implementation "androidx.window:window:1.2.0" + implementation 'androidx.gridlayout:gridlayout:1.0.0' def nav_version = "2.7.6" implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" 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 index 0c9682c58..f494b20e7 100644 --- a/app/src/main/java/org/linphone/ui/call/fragment/ConferenceActiveSpeakerFragment.kt +++ b/app/src/main/java/org/linphone/ui/call/fragment/ConferenceActiveSpeakerFragment.kt @@ -65,13 +65,25 @@ class ConferenceActiveSpeakerFragment : GenericCallFragment() { callViewModel.conferenceModel.conferenceLayout.observe(viewLifecycleOwner) { when (it) { ConferenceModel.GRID_LAYOUT -> { - Log.i("$TAG Conference layout changed to mosaic, navigating to Grid fragment") + Log.i( + "$TAG Conference layout changed to mosaic, navigating to matching fragment" + ) if (findNavController().currentDestination?.id == R.id.conferenceActiveSpeakerFragment) { findNavController().navigate( R.id.action_conferenceActiveSpeakerFragment_to_conferenceGridFragment ) } } + ConferenceModel.AUDIO_ONLY_LAYOUT -> { + Log.i( + "$TAG Conference layout changed to audio only, navigating to matching fragment" + ) + if (findNavController().currentDestination?.id == R.id.conferenceActiveSpeakerFragment) { + findNavController().navigate( + R.id.action_conferenceActiveSpeakerFragment_to_conferenceAudioOnlyFragment + ) + } + } else -> { } } diff --git a/app/src/main/java/org/linphone/ui/call/fragment/ConferenceAudioOnlyFragment.kt b/app/src/main/java/org/linphone/ui/call/fragment/ConferenceAudioOnlyFragment.kt new file mode 100644 index 000000000..455dcf5a3 --- /dev/null +++ b/app/src/main/java/org/linphone/ui/call/fragment/ConferenceAudioOnlyFragment.kt @@ -0,0 +1,98 @@ +/* + * 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.CallConferenceAudioOnlyFragmentBinding +import org.linphone.ui.call.model.ConferenceModel +import org.linphone.ui.call.viewmodel.CurrentCallViewModel +@UiThread +class ConferenceAudioOnlyFragment : GenericCallFragment() { + companion object { + private const val TAG = "[Conference Audio Only Fragment]" + } + + private lateinit var binding: CallConferenceAudioOnlyFragmentBinding + + private lateinit var callViewModel: CurrentCallViewModel + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + binding = CallConferenceAudioOnlyFragmentBinding.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 matching fragment" + ) + if (findNavController().currentDestination?.id == R.id.conferenceAudioOnlyFragment) { + findNavController().navigate( + R.id.action_conferenceAudioOnlyFragment_to_conferenceActiveSpeakerFragment + ) + } + } + ConferenceModel.GRID_LAYOUT -> { + Log.i( + "$TAG Conference layout changed to mosaic, navigating to matching fragment" + ) + if (findNavController().currentDestination?.id == R.id.conferenceAudioOnlyFragment) { + findNavController().navigate( + R.id.action_conferenceAudioOnlyFragment_to_conferenceGridFragment + ) + } + } + else -> { + } + } + } + } + + override fun onResume() { + super.onResume() + + Log.i("$TAG Making sure we are not in full-screen mode") + callViewModel.fullScreenMode.value = false + } +} 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 index 88ddef5a5..ee413e119 100644 --- a/app/src/main/java/org/linphone/ui/call/fragment/ConferenceGridFragment.kt +++ b/app/src/main/java/org/linphone/ui/call/fragment/ConferenceGridFragment.kt @@ -65,7 +65,7 @@ class ConferenceGridFragment : GenericCallFragment() { when (it) { ConferenceModel.ACTIVE_SPEAKER_LAYOUT -> { Log.i( - "$TAG Conference layout changed to active speaker, navigating to Active Speaker fragment" + "$TAG Conference layout changed to active speaker, navigating to matching fragment" ) if (findNavController().currentDestination?.id == R.id.conferenceGridFragment) { findNavController().navigate( @@ -73,6 +73,16 @@ class ConferenceGridFragment : GenericCallFragment() { ) } } + ConferenceModel.AUDIO_ONLY_LAYOUT -> { + Log.i( + "$TAG Conference layout changed to audio only, navigating to matching fragment" + ) + if (findNavController().currentDestination?.id == R.id.conferenceGridFragment) { + findNavController().navigate( + R.id.action_conferenceGridFragment_to_conferenceAudioOnlyFragment + ) + } + } else -> { } } diff --git a/app/src/main/res/layout/call_active_fragment.xml b/app/src/main/res/layout/call_active_fragment.xml index e79d36158..83e3840ab 100644 --- a/app/src/main/res/layout/call_active_fragment.xml +++ b/app/src/main/res/layout/call_active_fragment.xml @@ -61,7 +61,7 @@ android:layout_marginStart="12dp" android:layout_marginEnd="12dp" android:layout_marginBottom="@dimen/call_main_actions_menu_margin" - app:layout_constraintTop_toBottomOf="@id/media_encryption" + app:layout_constraintTop_toBottomOf="@id/media_encryption_icon" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" /> @@ -80,7 +80,7 @@ app:layout_constraintEnd_toEndOf="@id/background" app:layout_constraintStart_toStartOf="@id/background" app:layout_constraintTop_toTopOf="@id/background" - app:layout_constraintBottom_toTopOf="@id/address"/> + app:layout_constraintBottom_toTopOf="@id/display_name"/> + + @@ -181,26 +194,39 @@ android:visibility="@{viewModel.isPaused || viewModel.isPausedByRemote ? View.VISIBLE : View.GONE, default=gone}" app:layout_constraintHorizontal_bias="0" app:layout_constraintStart_toEndOf="@id/separator" - app:layout_constraintEnd_toStartOf="@id/media_encryption" app:layout_constraintTop_toTopOf="@id/name"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/call_conference_audio_only_fragment.xml b/app/src/main/res/layout/call_conference_audio_only_fragment.xml new file mode 100644 index 000000000..4f60cd933 --- /dev/null +++ b/app/src/main/res/layout/call_conference_audio_only_fragment.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + \ 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 8f15cd2c4..d03e4db69 100644 --- a/app/src/main/res/layout/call_conference_grid_cell.xml +++ b/app/src/main/res/layout/call_conference_grid_cell.xml @@ -20,6 +20,7 @@ android:id="@+id/participant_device_background" android:layout_width="match_parent" android:layout_height="match_parent" + android:contentDescription="@null" android:background="@drawable/shape_round_in_call_cell_gray_background" /> + android:layout_height="match_parent" + android:background="@color/gray_900"> + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/dimen.xml b/app/src/main/res/values/dimen.xml index 9a963a03d..7329c15e6 100644 --- a/app/src/main/res/values/dimen.xml +++ b/app/src/main/res/values/dimen.xml @@ -52,6 +52,7 @@ 15dp 30dp + 100dp 120dp 66dp