From 3156410965eb913de7606d276962ae0dc715faef Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Mon, 7 Mar 2022 15:52:19 +0300 Subject: [PATCH] Code review fixes. --- .../src/main/res/values/stylable_audio_waveform_view.xml | 0 .../home/room/detail/composer/voice/VoiceMessageViews.kt | 2 +- .../home/room/detail/timeline/factory/MessageItemFactory.kt | 1 + .../features/home/room/detail/timeline/item/MessageVoiceItem.kt | 2 +- 4 files changed, 3 insertions(+), 2 deletions(-) rename vector/src/main/res/values/audio_waveform_attr.xml => library/ui-styles/src/main/res/values/stylable_audio_waveform_view.xml (100%) diff --git a/vector/src/main/res/values/audio_waveform_attr.xml b/library/ui-styles/src/main/res/values/stylable_audio_waveform_view.xml similarity index 100% rename from vector/src/main/res/values/audio_waveform_attr.xml rename to library/ui-styles/src/main/res/values/stylable_audio_waveform_view.xml diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageViews.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageViews.kt index f3b1fc918d..7a76657923 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageViews.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageViews.kt @@ -83,7 +83,7 @@ class VoiceMessageViews( observeMicButton(actions) } - private fun getTouchedPositionPercentage(motionEvent: MotionEvent, view: View) = motionEvent.x / view.width + private fun getTouchedPositionPercentage(motionEvent: MotionEvent, view: View) = (motionEvent.x / view.width).coerceIn(0f, 1f) @SuppressLint("ClickableViewAccessibility") private fun observeMicButton(actions: Actions) { diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt index 865e8f80bd..e8e8927b6d 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt @@ -709,6 +709,7 @@ class MessageItemFactory @Inject constructor( return this ?.filterNotNull() ?.map { + // Value comes from AudioWaveformView.MAX_FFT, and 1024 is the max value in the Matrix spec it * AudioWaveformView.MAX_FFT / 1024 } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageVoiceItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageVoiceItem.kt index d1c134a743..722e0f620a 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageVoiceItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageVoiceItem.kt @@ -134,7 +134,7 @@ abstract class MessageVoiceItem : AbsMessageItem() { } } - private fun getTouchedPositionPercentage(motionEvent: MotionEvent, view: View) = motionEvent.x / view.width + private fun getTouchedPositionPercentage(motionEvent: MotionEvent, view: View) = (motionEvent.x / view.width).coerceIn(0f, 1f) private fun renderIdleState(holder: Holder, idleColor: Int, playedColor: Int) { holder.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_play)