mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-25 09:10:53 +01:00
Stop proximity sensor while sharing screen.
This commit is contained in:
parent
cf3d145cd6
commit
9a1dbb27d4
@ -156,9 +156,10 @@ class VectorCallViewModel @AssistedInject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAudioDevicesChange() {
|
||||
val currentSoundDevice = callManager.audioManager.selectedDevice ?: return
|
||||
if (currentSoundDevice == CallAudioManager.Device.Phone) {
|
||||
override fun onAudioDevicesChange() = withState { state ->
|
||||
val currentSoundDevice = callManager.audioManager.selectedDevice ?: return@withState
|
||||
val webRtcCall = callManager.getCallById(state.callId)
|
||||
if (webRtcCall != null && shouldActivateProximitySensor(webRtcCall)) {
|
||||
proximityManager.start()
|
||||
} else {
|
||||
proximityManager.stop()
|
||||
@ -205,7 +206,7 @@ class VectorCallViewModel @AssistedInject constructor(
|
||||
callManager.addListener(callManagerListener)
|
||||
webRtcCall.addListener(callListener)
|
||||
val currentSoundDevice = callManager.audioManager.selectedDevice
|
||||
if (currentSoundDevice == CallAudioManager.Device.Phone) {
|
||||
if (shouldActivateProximitySensor(webRtcCall)) {
|
||||
proximityManager.start()
|
||||
}
|
||||
setState {
|
||||
@ -232,6 +233,10 @@ class VectorCallViewModel @AssistedInject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun shouldActivateProximitySensor(webRtcCall: WebRtcCall): Boolean {
|
||||
return callManager.audioManager.selectedDevice == CallAudioManager.Device.Phone && !webRtcCall.isSharingScreen()
|
||||
}
|
||||
|
||||
private fun WebRtcCall.extractCallInfo(): VectorCallViewState.CallInfo {
|
||||
val assertedIdentity = this.remoteAssertedIdentity
|
||||
val matrixItem = if (assertedIdentity != null) {
|
||||
@ -351,6 +356,7 @@ class VectorCallViewModel @AssistedInject constructor(
|
||||
}
|
||||
is VectorCallViewActions.StartScreenSharing -> {
|
||||
call?.startSharingScreen(action.videoCapturer)
|
||||
proximityManager.stop()
|
||||
setState {
|
||||
copy(isSharingScreen = true)
|
||||
}
|
||||
@ -367,6 +373,9 @@ class VectorCallViewModel @AssistedInject constructor(
|
||||
_viewEvents.post(
|
||||
VectorCallViewEvents.StopScreenSharingService
|
||||
)
|
||||
if (callManager.audioManager.selectedDevice == CallAudioManager.Device.Phone) {
|
||||
proximityManager.start()
|
||||
}
|
||||
} else {
|
||||
_viewEvents.post(
|
||||
VectorCallViewEvents.ShowScreenSharingPermissionDialog
|
||||
|
Loading…
Reference in New Issue
Block a user