Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Voice Message Playback Scrolling Support #5404

Merged
merged 15 commits into from
Mar 23, 2022

Conversation

onurays
Copy link
Contributor

@onurays onurays commented Mar 2, 2022

Fixes #5426.

vm_scrollbar.mp4

Voice Message related UI and state classes became to be messy. We should plan to refactor them by rethinking all states and flow between them.

@onurays onurays requested a review from bmarty March 2, 2022 14:55
@github-actions
Copy link

github-actions bot commented Mar 2, 2022

Unit Test Results

106 files  ±0  106 suites  ±0   1m 9s ⏱️ +6s
188 tests ±0  188 ✔️ ±0  0 💤 ±0  0 ±0 
622 runs  ±0  622 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit 7ead3f9. ± Comparison against base commit 20b2af4.

♻️ This comment has been updated with latest results.

@onurays onurays marked this pull request as ready for review March 4, 2022 15:05
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor remark.
Static review OK!
It should deserve some manual test though.

@@ -69,6 +83,8 @@ class VoiceMessageViews(
observeMicButton(actions)
}

private fun getTouchedPositionPercentage(motionEvent: MotionEvent, view: View) = motionEvent.x / view.width
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not tested, but show probably use coerceIn(0,1) to avoid overflow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More secure, done.

@@ -695,8 +709,7 @@ class MessageItemFactory @Inject constructor(
return this
?.filterNotNull()
?.map {
// Value comes from AudioRecordView.maxReportableAmp, and 1024 is the max value in the Matrix spec
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is still valuable, no? Maybe just update the part about AudioRecordView.maxReportableAmp to AudioWaveformView.MAX_FFT

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, done.

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be moved to https://github.com/vector-im/element-android/tree/main/library/ui-styles/src/main/res/values and its name should start with stylable_

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@onurays onurays requested a review from bmarty March 8, 2022 08:54
@ouchadam
Copy link
Contributor

when scrubbing the play head, should the audio continue to play? at the moment we're pausing each time we change the play head position 🤔

mediaPlayer?.stop()
stopPlaybackTicker()
}

fun movePlaybackTo(id: String, percentage: Float, totalDuration: Int) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we use the mediaPlayer?.duration then we'll be able to avoid inferring the duration from the UI countdown ticker
would that be possible? (it would assume the media player is in the prepared state)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a single mediaplayer which is initialized when users start the playback. But users are able to scroll idle recordings and the mediaplayer is null at this stage.

is VoiceMessagePlaybackTracker.Listener.State.Idle -> renderIdleState(holder)
is VoiceMessagePlaybackTracker.Listener.State.Playing -> renderPlayingState(holder, state)
is VoiceMessagePlaybackTracker.Listener.State.Paused -> renderPausedState(holder, state)
// Don't track and don't try to update UI before view is present
Copy link
Contributor

@ouchadam ouchadam Mar 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this because we're relying on holder.voicePlaybackWaveform.post? if so we should move the tracker logic to the same post body to better couple the logic together (it seems that we're relying on the audio view to be fully drawn because it only updates its internal state as a side effect of the drawing)

actually... do we need any of the posting? 🤔

Copy link
Contributor Author

@onurays onurays Mar 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we need post because the width of the view is 0 (not calculated yet) when it is bind. Do you mean holder.voicePlaybackWaveform.setOnTouchListener should be inside post block?

Copy link
Contributor

@ouchadam ouchadam Mar 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might be safer to rely on viewWithLateWidth.doOnPreDraw { } or doOnLayout { } if we need the width/height at some point~

for the moving I meant moving the tracker calls to be inside the same holder.voicePlaybackWaveform.post as the comment suggests the view doesn't exist yet but they should be inflated at the same time as the parent 🤔 so I'm assuming the lack of data inside the voicePlaybackWaveform is causing trouble, which would be fixed by moving the tracker into the same post block 🤞 If I've understood correctly!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarification! Done, if I understood you correctly.

@onurays
Copy link
Contributor Author

onurays commented Mar 17, 2022

when scrubbing the play head, should the audio continue to play? at the moment we're pausing each time we change the play head position 🤔

Ideally yes, I couldn't find an easy way to implement it and I am not sure this is a blocker.

Copy link
Contributor

@ouchadam ouchadam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the update! 💯

@DoM1niC
Copy link

DoM1niC commented Mar 22, 2022

@onurays the Player visual events freeze for me after skip play and stop a Voice Message and play a another one above the timeline.

Onuray Sahin added 2 commits March 23, 2022 13:32
* develop: (429 commits)
  fixing the onboarding sanity test failing - adds tapping the new take me home button within the sanity test
  Fix lint issues on weblate sync
  fixing view model tests not collecting flow results - the switch from runBlockingTest to runTest means we need to provide a separate scope from the test in order to asynchronously collect the flow results
  Do not suggest collapse if there is only one section
  Translated using Weblate (Spanish)
  Translated using Weblate (Spanish)
  runBlocking -> runTest https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-test/MIGRATION.md
  runBlockingTest -> runTest https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-test/MIGRATION.md
  Small cleanup
  The `.exhaustive` trick is not needed anymore in Kotlin 1.6.0 https://kotlinlang.org/docs/whatsnew16.html#stable-exhaustive-when-statements-for-enum-sealed-and-boolean-subjects
  Also upgrade the coroutine lib
  Fix compilation warning (exhaustive when)
  Fix compilation warning (exhaustive when)
  Format file (no other change)
  Fix compilation warning (exhaustive when)
  Bump moshi from 1.12.0 to 1.13.0
  Bump kotlin-gradle-plugin from 1.5.31 to 1.6.0
  fixing presence icon anchoring to the middle of the room icon - creates a secondary verification shield and aligns to the start of the room title when presence is present
  PR remarks
  Increase the thread summaries limit
  ...

# Conflicts:
#	vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageRecorderView.kt
#	vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageVoiceItem.kt
@onurays
Copy link
Contributor Author

onurays commented Mar 23, 2022

@onurays the Player visual events freeze for me after skip play and stop a Voice Message and play a another one above the timeline.

Good catch, thank you. I will fix this in another PR.

@onurays onurays merged commit 6d0b823 into develop Mar 23, 2022
@onurays onurays deleted the feature/ons/voice_message_scrubbing branch March 23, 2022 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow scrolling position of Voice Message playback
4 participants