From bf9a22c1b03cc87946deeeaeae466256a77fa2b4 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Tue, 10 Aug 2021 13:59:39 +0300 Subject: [PATCH] Fix flickering lock view. --- .../home/room/detail/composer/VoiceMessageRecorderView.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/VoiceMessageRecorderView.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/VoiceMessageRecorderView.kt index 48195dc8f1..00ab67656c 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/VoiceMessageRecorderView.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/VoiceMessageRecorderView.kt @@ -220,6 +220,9 @@ class VoiceMessageRecorderView @JvmOverloads constructor( } RecordingState.STARTED -> { showRecordingViews() + val translationAmount = distanceX.coerceAtMost(distanceToCancel) + views.voiceMessageMicButton.translationX = -translationAmount * rtlXMultiplier + views.voiceMessageSlideToCancel.translationX = -translationAmount / 2 * rtlXMultiplier } RecordingState.NONE -> Timber.d("VoiceMessageRecorderView shouldn't be in NONE state while moving.") RecordingState.PLAYBACK -> Timber.d("VoiceMessageRecorderView shouldn't be in PLAYBACK state while moving.") @@ -235,7 +238,7 @@ class VoiceMessageRecorderView @JvmOverloads constructor( if (recordingState == RecordingState.STARTED) { // Determine if cancelling or locking for the first move action. if (((currentX < firstX && rtlXMultiplier == 1) || (currentX > firstX && rtlXMultiplier == -1)) - && distanceX > distanceY) { + && distanceX > distanceY && distanceX > lastDistanceX) { recordingState = RecordingState.CANCELLING } else if (currentY < firstY && distanceY > distanceX) { recordingState = RecordingState.LOCKING