Prevent UI from being hidden in video call while interacting with it
This commit is contained in:
parent
e974335a06
commit
bb4328f216
4 changed files with 35 additions and 0 deletions
|
@ -64,6 +64,12 @@ class CallActivity : ProximitySensorActivity() {
|
|||
}
|
||||
})
|
||||
|
||||
sharedViewModel.resetHiddenInterfaceTimerInVideoCallEvent.observe(this, Observer {
|
||||
it.consume {
|
||||
viewModel.showMomentarily()
|
||||
}
|
||||
})
|
||||
|
||||
coreContext.core.nativeVideoWindowId = binding.remoteVideoSurface
|
||||
coreContext.core.nativePreviewWindowId = binding.localPreviewVideoSurface
|
||||
|
||||
|
|
|
@ -30,13 +30,16 @@ import androidx.lifecycle.Observer
|
|||
import androidx.lifecycle.ViewModelProvider
|
||||
import org.linphone.activities.call.viewmodels.CallsViewModel
|
||||
import org.linphone.activities.call.viewmodels.ControlsViewModel
|
||||
import org.linphone.activities.call.viewmodels.SharedCallViewModel
|
||||
import org.linphone.activities.main.MainActivity
|
||||
import org.linphone.databinding.CallControlsFragmentBinding
|
||||
import org.linphone.utils.Event
|
||||
|
||||
class ControlsFragment : Fragment() {
|
||||
private lateinit var binding: CallControlsFragmentBinding
|
||||
private lateinit var callsViewModel: CallsViewModel
|
||||
private lateinit var controlsViewModel: ControlsViewModel
|
||||
private lateinit var sharedViewModel: SharedCallViewModel
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
|
@ -52,6 +55,10 @@ class ControlsFragment : Fragment() {
|
|||
|
||||
binding.lifecycleOwner = this
|
||||
|
||||
sharedViewModel = activity?.run {
|
||||
ViewModelProvider(this).get(SharedCallViewModel::class.java)
|
||||
} ?: throw Exception("Invalid Activity")
|
||||
|
||||
callsViewModel = ViewModelProvider(this).get(CallsViewModel::class.java)
|
||||
binding.viewModel = callsViewModel
|
||||
|
||||
|
@ -103,5 +110,11 @@ class ControlsFragment : Fragment() {
|
|||
startActivity(intent)
|
||||
}
|
||||
})
|
||||
|
||||
controlsViewModel.somethingClickedEvent.observe(viewLifecycleOwner, Observer {
|
||||
it.consume {
|
||||
sharedViewModel.resetHiddenInterfaceTimerInVideoCallEvent.value = Event(true)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,9 +72,12 @@ class ControlsViewModel : ViewModel() {
|
|||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
val somethingClickedEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
||||
val onKeyClick: NumpadDigitListener = object : NumpadDigitListener {
|
||||
override fun handleClick(key: Char) {
|
||||
coreContext.core.playDtmf(key, 1)
|
||||
somethingClickedEvent.value = Event(true)
|
||||
}
|
||||
|
||||
override fun handleLongClick(key: Char): Boolean {
|
||||
|
@ -140,12 +143,14 @@ class ControlsViewModel : ViewModel() {
|
|||
}
|
||||
|
||||
fun toggleMuteMicrophone() {
|
||||
somethingClickedEvent.value = Event(true)
|
||||
val micEnabled = coreContext.core.micEnabled()
|
||||
coreContext.core.enableMic(!micEnabled)
|
||||
updateMuteMicState()
|
||||
}
|
||||
|
||||
fun toggleSpeaker() {
|
||||
somethingClickedEvent.value = Event(true)
|
||||
val audioDevice = coreContext.core.outputAudioDevice
|
||||
if (audioDevice?.type == AudioDevice.Type.Speaker) {
|
||||
forceEarpieceAudioRoute()
|
||||
|
@ -155,6 +160,7 @@ class ControlsViewModel : ViewModel() {
|
|||
}
|
||||
|
||||
fun switchCamera() {
|
||||
somethingClickedEvent.value = Event(true)
|
||||
coreContext.switchCamera()
|
||||
}
|
||||
|
||||
|
@ -184,18 +190,22 @@ class ControlsViewModel : ViewModel() {
|
|||
}
|
||||
|
||||
fun toggleOptionsMenu() {
|
||||
somethingClickedEvent.value = Event(true)
|
||||
optionsVisibility.value = optionsVisibility.value != true
|
||||
}
|
||||
|
||||
fun toggleNumpadVisibility() {
|
||||
somethingClickedEvent.value = Event(true)
|
||||
numpadVisibility.value = numpadVisibility.value != true
|
||||
}
|
||||
|
||||
fun toggleRoutesMenu() {
|
||||
somethingClickedEvent.value = Event(true)
|
||||
audioRoutesVisibility.value = audioRoutesVisibility.value != true
|
||||
}
|
||||
|
||||
fun toggleRecording(closeMenu: Boolean) {
|
||||
somethingClickedEvent.value = Event(true)
|
||||
val currentCall = coreContext.core.currentCall
|
||||
if (currentCall != null) {
|
||||
if (currentCall.isRecording) {
|
||||
|
@ -223,11 +233,13 @@ class ControlsViewModel : ViewModel() {
|
|||
}
|
||||
|
||||
fun startConference() {
|
||||
somethingClickedEvent.value = Event(true)
|
||||
coreContext.core.addAllToConference()
|
||||
toggleOptionsMenu()
|
||||
}
|
||||
|
||||
fun forceEarpieceAudioRoute() {
|
||||
somethingClickedEvent.value = Event(true)
|
||||
for (audioDevice in coreContext.core.audioDevices) {
|
||||
if (audioDevice.type == AudioDevice.Type.Earpiece) {
|
||||
Log.i("[Call] Found earpiece audio device [${audioDevice.deviceName}], routing audio to it")
|
||||
|
@ -239,6 +251,7 @@ class ControlsViewModel : ViewModel() {
|
|||
}
|
||||
|
||||
fun forceSpeakerAudioRoute() {
|
||||
somethingClickedEvent.value = Event(true)
|
||||
for (audioDevice in coreContext.core.audioDevices) {
|
||||
if (audioDevice.type == AudioDevice.Type.Speaker) {
|
||||
Log.i("[Call] Found speaker audio device [${audioDevice.deviceName}], routing audio to it")
|
||||
|
@ -250,6 +263,7 @@ class ControlsViewModel : ViewModel() {
|
|||
}
|
||||
|
||||
fun forceBluetoothAudioRoute() {
|
||||
somethingClickedEvent.value = Event(true)
|
||||
for (audioDevice in coreContext.core.audioDevices) {
|
||||
if ((audioDevice.type == AudioDevice.Type.Bluetooth) && audioDevice.hasCapability(AudioDevice.Capabilities.CapabilityPlay)) {
|
||||
Log.i("[Call] Found bluetooth audio device [${audioDevice.deviceName}], routing audio to it")
|
||||
|
|
|
@ -25,4 +25,6 @@ import org.linphone.utils.Event
|
|||
|
||||
class SharedCallViewModel : ViewModel() {
|
||||
val toggleDrawerEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
||||
val resetHiddenInterfaceTimerInVideoCallEvent = MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue