Hide call controls when in full screen

This commit is contained in:
Sylvain Berfini 2023-09-08 14:01:55 +02:00
parent 16a467b7d1
commit 85a904e173
4 changed files with 25 additions and 2 deletions

View file

@ -101,6 +101,16 @@ class TelecomCallControlCallback constructor(
callControl.availableEndpoints.onEach { list ->
Log.i("$TAG New available audio endpoints list")
if (availableEndpoints.size != list.size) {
Log.i(
"$TAG List size of available audio endpoints has changed, reload sound devices in SDK"
)
coreContext.postOnCoreThread { core ->
core.reloadSoundDevices()
Log.i("$TAG Sound devices reloaded")
}
}
availableEndpoints = list
for (endpoint in list) {
Log.i("$TAG Available audio endpoint [${endpoint.name}]")

View file

@ -30,6 +30,7 @@ import androidx.lifecycle.ViewModelProvider
import com.google.android.material.bottomsheet.BottomSheetBehavior
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.R
import org.linphone.core.tools.Log
import org.linphone.databinding.VoipActiveCallFragmentBinding
import org.linphone.ui.voip.VoipActivity
import org.linphone.ui.voip.model.ZrtpSasConfirmationDialogModel
@ -41,6 +42,10 @@ import org.linphone.utils.Event
@UiThread
class ActiveCallFragment : GenericCallFragment() {
companion object {
private const val TAG = "[Active Call Fragment]"
}
private lateinit var binding: VoipActiveCallFragmentBinding
private lateinit var callViewModel: CurrentCallViewModel
@ -91,11 +96,15 @@ class ActiveCallFragment : GenericCallFragment() {
binding.lifecycleOwner = viewLifecycleOwner
binding.viewModel = callViewModel
val standardBottomSheetBehavior = BottomSheetBehavior.from(binding.bottomBar.root)
standardBottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
sharedViewModel = requireActivity().run {
ViewModelProvider(this)[SharedCallViewModel::class.java]
}
callViewModel.fullScreenMode.observe(viewLifecycleOwner) { hide ->
Log.i("$TAG Switching full screen mode to ${if (hide) "ON" else "OFF"}")
sharedViewModel.toggleFullScreenEvent.value = Event(hide)
}
@ -143,7 +152,6 @@ class ActiveCallFragment : GenericCallFragment() {
binding.chronometer.start()
}
val standardBottomSheetBehavior = BottomSheetBehavior.from(binding.bottomBar.root)
callViewModel.toggleExtraActionsBottomSheetEvent.observe(viewLifecycleOwner) {
it.consume {
val state = standardBottomSheetBehavior.state
@ -158,7 +166,7 @@ class ActiveCallFragment : GenericCallFragment() {
standardBottomSheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
override fun onStateChanged(bottomSheet: View, newState: Int) {
when (newState) {
BottomSheetBehavior.STATE_COLLAPSED -> {
BottomSheetBehavior.STATE_COLLAPSED, BottomSheetBehavior.STATE_HIDDEN -> {
callViewModel.isActionsMenuExpanded.value = false
}
BottomSheetBehavior.STATE_EXPANDED -> {

View file

@ -242,8 +242,12 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
}
if (list.size > 2) {
Log.i("$TAG Found more than two devices, showing list to let user choose")
showAudioDevicesListEvent.postValue(Event(list))
} else {
Log.i(
"$TAG Found less than two devices, simply switching between earpiece & speaker"
)
if (::call.isInitialized) {
if (routeAudioToSpeaker) {
AudioRouteUtils.routeAudioToSpeaker(call)

View file

@ -183,6 +183,7 @@
<include
android:id="@+id/bottom_bar"
android:visibility="@{viewModel.fullScreenMode ? View.GONE : View.VISIBLE}"
layout="@layout/voip_call_extra_actions"
bind:viewModel="@{viewModel}"/>