More work for having both grid & active speaker layout but not at the same time

This commit is contained in:
Sylvain Berfini 2024-01-25 16:24:26 +01:00
parent bf99bd402f
commit f23510da3a
11 changed files with 315 additions and 77 deletions

View file

@ -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
}
}

View file

@ -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
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
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
}
}
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
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 -> {
}
}
}
}
}

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="20dp" />
<solid android:color="@color/gray_600"/>
</shape>

View file

@ -96,67 +96,19 @@
app:layout_constraintStart_toStartOf="@id/background"
app:layout_constraintEnd_toEndOf="@id/background"/>
<org.linphone.ui.call.view.GridBoxLayout
android:id="@+id/grid_box_layout"
<androidx.fragment.app.FragmentContainerView
android:id="@+id/conference_layout_nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="@{viewModel.fullScreenMode || viewModel.pipMode ? @dimen/zero : @dimen/call_main_actions_menu_margin, default=@dimen/call_main_actions_menu_margin}"
android:layout_marginTop="@{viewModel.fullScreenMode || viewModel.pipMode ? @dimen/zero : @dimen/call_top_bar_info_height, default=@dimen/call_top_bar_info_height}"
android:onClick="@{() -> viewModel.toggleFullScreen()}"
android:visibility="@{conferenceViewModel.conferenceLayout == ConferenceModel.GRID_LAYOUT &amp;&amp; conferenceViewModel.participantDevices.size() > 1 ? View.VISIBLE : View.GONE, default=gone}"
entries="@{conferenceViewModel.participantDevices}"
layout="@{@layout/call_conference_grid_cell}"
android:visibility="@{conferenceViewModel.participantDevices.size() > 1 ? View.VISIBLE : View.GONE}"
app:navGraph="@navigation/conference_nav_graph"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<org.linphone.ui.call.view.RoundCornersTextureView
android:id="@+id/active_speaker_surface"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="@{viewModel.fullScreenMode || viewModel.pipMode || viewModel.halfOpenedFolded ? @dimen/zero : @dimen/call_main_actions_menu_margin, default=@dimen/call_main_actions_menu_margin}"
android:layout_marginTop="@{viewModel.fullScreenMode || viewModel.pipMode || viewModel.halfOpenedFolded ? @dimen/zero : @dimen/call_top_bar_info_height, default=@dimen/call_top_bar_info_height}"
android:onClick="@{() -> viewModel.toggleFullScreen()}"
android:visibility="@{conferenceViewModel.conferenceLayout == ConferenceModel.ACTIVE_SPEAKER_LAYOUT &amp;&amp; conferenceViewModel.participantDevices.size() > 1 ? View.VISIBLE : View.GONE, default=gone}"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_500"
android:id="@+id/active_speaker_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginBottom="10dp"
android:text="@{conferenceViewModel.activeSpeakerName, default=`John Doe`}"
android:textColor="@color/white"
android:textSize="20sp"
app:layout_constraintBottom_toTopOf="@id/active_speaker_miniatures_layout"
app:layout_constraintStart_toStartOf="parent" />
<HorizontalScrollView
android:id="@+id/active_speaker_miniatures_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@{viewModel.fullScreenMode || viewModel.pipMode ? @dimen/zero : @dimen/call_main_actions_menu_margin, default=@dimen/call_main_actions_menu_margin}"
android:onClick="@{() -> viewModel.toggleFullScreen()}"
android:visibility="@{conferenceViewModel.conferenceLayout == ConferenceModel.ACTIVE_SPEAKER_LAYOUT &amp;&amp; conferenceViewModel.participantDevices.size() > 1 ? View.VISIBLE : View.GONE, default=gone}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:orientation="horizontal"
entries="@{conferenceViewModel.participantDevices}"
layout="@{@layout/call_conference_active_speaker_cell}"/>
</HorizontalScrollView>
app:layout_constraintBottom_toBottomOf="parent"/>
<androidx.constraintlayout.widget.Group
android:id="@+id/header_info_visibility"

View file

@ -19,7 +19,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" />
<com.google.android.material.imageview.ShapeableImageView
style="@style/avatar_imageview"

View file

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="android.view.View" />
<import type="org.linphone.ui.call.model.ConferenceModel" />
<variable
name="viewModel"
type="org.linphone.ui.call.viewmodel.CurrentCallViewModel" />
<variable
name="conferenceViewModel"
type="org.linphone.ui.call.model.ConferenceModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraint_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<org.linphone.ui.call.view.RoundCornersTextureView
android:id="@+id/active_speaker_surface"
android:layout_width="0dp"
android:layout_height="0dp"
android:onClick="@{() -> viewModel.toggleFullScreen()}"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_500"
android:id="@+id/active_speaker_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginBottom="10dp"
android:text="@{conferenceViewModel.activeSpeakerName, default=`John Doe`}"
android:textColor="@color/white"
android:textSize="20sp"
app:layout_constraintBottom_toTopOf="@id/active_speaker_miniatures_layout"
app:layout_constraintStart_toStartOf="parent" />
<HorizontalScrollView
android:id="@+id/active_speaker_miniatures_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:onClick="@{() -> viewModel.toggleFullScreen()}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:orientation="horizontal"
entries="@{conferenceViewModel.participantDevices}"
layout="@{@layout/call_conference_active_speaker_cell}"/>
</HorizontalScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View file

@ -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" />
<com.google.android.material.imageview.ShapeableImageView
style="@style/avatar_imageview"

View file

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="android.view.View" />
<import type="org.linphone.ui.call.model.ConferenceModel" />
<variable
name="viewModel"
type="org.linphone.ui.call.viewmodel.CurrentCallViewModel" />
<variable
name="conferenceViewModel"
type="org.linphone.ui.call.model.ConferenceModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraint_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<org.linphone.ui.call.view.GridBoxLayout
android:id="@+id/grid_box_layout"
android:layout_width="0dp"
android:layout_height="0dp"
android:onClick="@{() -> viewModel.toggleFullScreen()}"
entries="@{conferenceViewModel.participantDevices}"
layout="@{@layout/call_conference_grid_cell}"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/conference_nav_graph"
app:startDestination="@id/conferenceActiveSpeakerFragment">
<fragment
android:id="@+id/conferenceGridFragment"
android:name="org.linphone.ui.call.fragment.ConferenceGridFragment"
android:label="ConferenceGridFragment"
tools:layout="@layout/call_conference_grid_fragment">
<action
android:id="@+id/action_conferenceGridFragment_to_conferenceActiveSpeakerFragment"
app:destination="@id/conferenceActiveSpeakerFragment"
app:launchSingleTop="true"
app:popUpTo="@id/conferenceActiveSpeakerFragment"
app:popUpToInclusive="true" />
</fragment>
<fragment
android:id="@+id/conferenceActiveSpeakerFragment"
android:name="org.linphone.ui.call.fragment.ConferenceActiveSpeakerFragment"
android:label="ConferenceActiveSpeakerFragment"
tools:layout="@layout/call_conference_active_speaker_fragment">
<action
android:id="@+id/action_conferenceActiveSpeakerFragment_to_conferenceGridFragment"
app:destination="@id/conferenceGridFragment"
app:launchSingleTop="true"
app:popUpTo="@id/conferenceGridFragment"
app:popUpToInclusive="true" />
</fragment>
</navigation>