From f0c762183252b59f8526c3b54a2bcb64ce974104 Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Mon, 8 Jul 2024 09:49:16 +1000 Subject: [PATCH] Rotating controls on rotation --- .../securesms/calls/WebRtcCallActivity.kt | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/calls/WebRtcCallActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/calls/WebRtcCallActivity.kt index 598ce624bd..19e12f354f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/calls/WebRtcCallActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/calls/WebRtcCallActivity.kt @@ -275,6 +275,7 @@ class WebRtcCallActivity : PassphraseRequiredActionBarActivity(), SensorEventLis if (currentOrientation != lastOrientation) { lastOrientation = currentOrientation viewModel.deviceOrientation = currentOrientation + updateControlsRotation() } } } @@ -295,15 +296,31 @@ class WebRtcCallActivity : PassphraseRequiredActionBarActivity(), SensorEventLis ContextCompat.startForegroundService(this, answerIntent) } - private fun updateControlsRotation(newRotation: Int) { + private fun updateControlsRotation() { with (binding) { - val rotation = newRotation.toFloat() - remoteRecipient.rotation = rotation - speakerPhoneButton.rotation = rotation - microphoneButton.rotation = rotation - enableCameraButton.rotation = rotation - switchCameraButton.rotation = rotation - endCallButton.rotation = rotation + val rotation = when(viewModel.deviceOrientation){ + Orientation.LANDSCAPE -> -90f + Orientation.REVERSED_LANDSCAPE -> 90f + else -> 0f + } + + 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() } }