Rotating controls on rotation

This commit is contained in:
ThomasSession 2024-07-08 09:49:16 +10:00
parent f9e9bc86d2
commit f0c7621832

View File

@ -275,6 +275,7 @@ class WebRtcCallActivity : PassphraseRequiredActionBarActivity(), SensorEventLis
if (currentOrientation != lastOrientation) { if (currentOrientation != lastOrientation) {
lastOrientation = currentOrientation lastOrientation = currentOrientation
viewModel.deviceOrientation = currentOrientation viewModel.deviceOrientation = currentOrientation
updateControlsRotation()
} }
} }
} }
@ -295,15 +296,31 @@ class WebRtcCallActivity : PassphraseRequiredActionBarActivity(), SensorEventLis
ContextCompat.startForegroundService(this, answerIntent) ContextCompat.startForegroundService(this, answerIntent)
} }
private fun updateControlsRotation(newRotation: Int) { private fun updateControlsRotation() {
with (binding) { with (binding) {
val rotation = newRotation.toFloat() val rotation = when(viewModel.deviceOrientation){
remoteRecipient.rotation = rotation Orientation.LANDSCAPE -> -90f
speakerPhoneButton.rotation = rotation Orientation.REVERSED_LANDSCAPE -> 90f
microphoneButton.rotation = rotation else -> 0f
enableCameraButton.rotation = rotation }
switchCameraButton.rotation = rotation
endCallButton.rotation = rotation remoteRecipient.animate().cancel()
remoteRecipient.animate().rotation(rotation).start()
speakerPhoneButton.animate().cancel()
speakerPhoneButton.animate().rotation(rotation).start()
microphoneButton.animate().cancel()
microphoneButton.animate().rotation(rotation).start()
enableCameraButton.animate().cancel()
enableCameraButton.animate().rotation(rotation).start()
switchCameraButton.animate().cancel()
switchCameraButton.animate().rotation(rotation).start()
endCallButton.animate().cancel()
endCallButton.animate().rotation(rotation).start()
} }
} }