mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Prevent proximity sensor to turn screen off while on incoming/outgoing call fragments
This commit is contained in:
parent
0895db1a62
commit
483443fd60
3 changed files with 29 additions and 1 deletions
|
|
@ -81,4 +81,15 @@ class IncomingCallFragment : GenericFragment<VoipCallIncomingFragmentBinding>()
|
|||
coreContext.core.nativeVideoWindowId = binding.remoteVideoSurface
|
||||
}
|
||||
}
|
||||
|
||||
// We don't want the proximity sensor to turn screen OFF in this fragment
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
controlsViewModel.forceDisableProximitySensor.value = true
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
controlsViewModel.forceDisableProximitySensor.value = false
|
||||
super.onPause()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,4 +83,15 @@ class OutgoingCallFragment : GenericVideoPreviewFragment<VoipCallOutgoingFragmen
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We don't want the proximity sensor to turn screen OFF in this fragment
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
controlsViewModel.forceDisableProximitySensor.value = true
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
controlsViewModel.forceDisableProximitySensor.value = false
|
||||
super.onPause()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ class ControlsViewModel : ViewModel() {
|
|||
|
||||
val proximitySensorEnabled = MediatorLiveData<Boolean>()
|
||||
|
||||
val forceDisableProximitySensor = MutableLiveData<Boolean>()
|
||||
|
||||
val showTakeSnapshotButton = MutableLiveData<Boolean>()
|
||||
|
||||
val goToConferenceParticipantsListEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
|
|
@ -199,6 +201,7 @@ class ControlsViewModel : ViewModel() {
|
|||
extraButtonsMenuTranslateY.value = AppUtils.getDimension(R.dimen.voip_call_extra_buttons_translate_y)
|
||||
audioRoutesMenuTranslateY.value = AppUtils.getDimension(R.dimen.voip_audio_routes_menu_translate_y)
|
||||
audioRoutesSelected.value = false
|
||||
forceDisableProximitySensor.value = false
|
||||
|
||||
nonEarpieceOutputAudioDevice.value = coreContext.core.outputAudioDevice?.type != AudioDevice.Type.Earpiece
|
||||
proximitySensorEnabled.value = shouldProximitySensorBeEnabled()
|
||||
|
|
@ -208,6 +211,9 @@ class ControlsViewModel : ViewModel() {
|
|||
proximitySensorEnabled.addSource(nonEarpieceOutputAudioDevice) {
|
||||
proximitySensorEnabled.value = shouldProximitySensorBeEnabled()
|
||||
}
|
||||
proximitySensorEnabled.addSource(forceDisableProximitySensor) {
|
||||
proximitySensorEnabled.value = shouldProximitySensorBeEnabled()
|
||||
}
|
||||
|
||||
updateUI()
|
||||
|
||||
|
|
@ -448,6 +454,6 @@ class ControlsViewModel : ViewModel() {
|
|||
}
|
||||
|
||||
private fun shouldProximitySensorBeEnabled(): Boolean {
|
||||
return !(isVideoEnabled.value ?: false) && !(nonEarpieceOutputAudioDevice.value ?: false)
|
||||
return forceDisableProximitySensor.value == false && !(isVideoEnabled.value ?: false) && !(nonEarpieceOutputAudioDevice.value ?: false)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue