Fixed active speaker conference layout when alone or 2 for foldables + fixed UI issues

This commit is contained in:
Sylvain Berfini 2022-09-07 13:52:37 +02:00
parent 36286b0259
commit 98aae5af37
4 changed files with 38 additions and 32 deletions

View file

@ -217,7 +217,7 @@ dependencies {
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
implementation "androidx.slidingpanelayout:slidingpanelayout:1.2.0"
implementation 'androidx.constraintlayout:constraintlayout:2.2.0-alpha03'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.gridlayout:gridlayout:1.0.0"
implementation 'androidx.recyclerview:recyclerview:1.3.0-beta02'

View file

@ -258,6 +258,8 @@ class ConferenceCallFragment : GenericFragment<VoipConferenceCallFragmentBinding
val binding = DataBindingUtil.bind<ViewDataBinding>(inflated)
binding?.lifecycleOwner = viewLifecycleOwner
startTimer(R.id.active_conference_timer)
adjustActiveSpeakerLayout()
}
binding.stubbedConferenceGridLayout.setOnInflateListener { _, inflated ->
@ -304,17 +306,8 @@ class ConferenceCallFragment : GenericFragment<VoipConferenceCallFragmentBinding
override fun onResume() {
super.onResume()
if (conferenceViewModel.conferenceDisplayMode.value != ConferenceDisplayMode.ACTIVE_SPEAKER)
return
if (conferenceViewModel.conferenceCreationPending.value == false) {
val participantsCount = conferenceViewModel.conferenceParticipantDevices.value.orEmpty().size
Log.i("[Conference Call] Fragment resumed, updating layout for [$participantsCount] participants")
when (participantsCount) {
1 -> switchToActiveSpeakerLayoutWhenAlone()
2 -> switchToActiveSpeakerLayoutForTwoParticipants()
else -> switchToActiveSpeakerLayoutForMoreThanTwoParticipants()
}
if (conferenceViewModel.conferenceDisplayMode.value == ConferenceDisplayMode.ACTIVE_SPEAKER) {
adjustActiveSpeakerLayout()
}
}
@ -397,19 +390,39 @@ class ConferenceCallFragment : GenericFragment<VoipConferenceCallFragmentBinding
set.applyTo(constraintLayout)
}
private fun adjustActiveSpeakerLayout() {
if (conferenceViewModel.conferenceCreationPending.value == false) {
val participantsCount = conferenceViewModel.conferenceParticipantDevices.value.orEmpty().size
Log.i("[Conference Call] Updating active speaker layout for [$participantsCount] participants")
when (participantsCount) {
1 -> switchToActiveSpeakerLayoutWhenAlone()
2 -> switchToActiveSpeakerLayoutForTwoParticipants()
else -> switchToActiveSpeakerLayoutForMoreThanTwoParticipants()
}
}
}
private fun getConstraintSet(constraintLayout: ConstraintLayout): ConstraintSet {
val set = ConstraintSet()
set.clone(constraintLayout)
set.clear(R.id.local_participant_background, ConstraintSet.TOP)
set.clear(R.id.local_participant_background, ConstraintSet.START)
set.clear(R.id.local_participant_background, ConstraintSet.LEFT)
set.clear(R.id.local_participant_background, ConstraintSet.BOTTOM)
set.clear(R.id.local_participant_background, ConstraintSet.END)
set.clear(R.id.local_participant_background, ConstraintSet.RIGHT)
return set
}
private fun switchToActiveSpeakerLayoutForMoreThanTwoParticipants() {
if (conferenceViewModel.conferenceDisplayMode.value != ConferenceDisplayMode.ACTIVE_SPEAKER) return
val constraintLayout =
binding.root.findViewById<ConstraintLayout>(R.id.conference_constraint_layout)
?: return
val set = ConstraintSet()
set.clone(constraintLayout)
set.clear(R.id.local_participant_background, ConstraintSet.TOP)
set.clear(R.id.local_participant_background, ConstraintSet.START)
set.clear(R.id.local_participant_background, ConstraintSet.BOTTOM)
set.clear(R.id.local_participant_background, ConstraintSet.END)
val set = getConstraintSet(constraintLayout)
val margin = resources.getDimension(R.dimen.voip_active_speaker_miniature_margin).toInt()
val portraitOrientation = resources.configuration.orientation != Configuration.ORIENTATION_LANDSCAPE
@ -483,19 +496,13 @@ class ConferenceCallFragment : GenericFragment<VoipConferenceCallFragmentBinding
val constraintLayout =
binding.root.findViewById<ConstraintLayout>(R.id.conference_constraint_layout)
?: return
val set = ConstraintSet()
set.clone(constraintLayout)
set.clear(R.id.local_participant_background, ConstraintSet.TOP)
set.clear(R.id.local_participant_background, ConstraintSet.START)
set.clear(R.id.local_participant_background, ConstraintSet.BOTTOM)
set.clear(R.id.local_participant_background, ConstraintSet.END)
val set = getConstraintSet(constraintLayout)
val margin = resources.getDimension(R.dimen.voip_active_speaker_miniature_margin).toInt()
set.connect(
R.id.local_participant_background,
ConstraintSet.BOTTOM,
R.id.conference_constraint_layout,
R.id.hinge_bottom,
ConstraintSet.BOTTOM,
margin
)
@ -532,13 +539,12 @@ class ConferenceCallFragment : GenericFragment<VoipConferenceCallFragmentBinding
val constraintLayout =
binding.root.findViewById<ConstraintLayout>(R.id.conference_constraint_layout)
?: return
val set = ConstraintSet()
set.clone(constraintLayout)
val set = getConstraintSet(constraintLayout)
set.connect(
R.id.local_participant_background,
ConstraintSet.BOTTOM,
R.id.conference_constraint_layout,
R.id.hinge_bottom,
ConstraintSet.BOTTOM,
0
)

View file

@ -224,7 +224,7 @@
app:layout_constraintTop_toBottomOf="@id/top_barrier"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toBottomOf="@id/hinge_bottom"
android:layout_marginTop="@{controlsViewModel.fullScreenMode ? @dimen/margin_0dp : @dimen/voip_active_speaker_top_margin, default=@dimen/voip_active_speaker_top_margin}"
android:background="@drawable/shape_remote_background"
android:onClick="@{() -> controlsViewModel.toggleFullScreen()}"/>

View file

@ -224,7 +224,7 @@
app:layout_constraintTop_toBottomOf="@id/top_barrier"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toBottomOf="@id/hinge_bottom"
android:layout_marginTop="@{controlsViewModel.fullScreenMode ? @dimen/margin_0dp : @dimen/voip_active_speaker_top_margin, default=@dimen/voip_active_speaker_top_margin}"
android:background="@drawable/shape_remote_background"
android:onClick="@{() -> controlsViewModel.toggleFullScreen()}"/>