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 Broadcast - Improve timeline rendering code #7448

Merged

Conversation

Florian14
Copy link
Contributor

Type of change

  • WIP Feature
  • Bugfix
  • Technical
  • Other :

Content

  • Improve the codebase behind the rendering of a voice broadcast in the timeline.
  • Reduce duplicated code by adding some abstraction
  • Rework layouts
  • Better handling of the recording state after restarting the app (the "recorder" is not active anymore but the voice broadcast is still in a recording state)

Motivation and context

Improve the code and manage unhandled state

Screenshots / GIFs

(Non-exhaustive screenshots, rendering is almost the same as before, only some padding changes)

Recording Playing
image image

Tests

Play with voice broadcast and observe timeline update according to the recording & listening state changes

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@Florian14 Florian14 requested review from a team and jonnyandrew and removed request for a team October 25, 2022 14:58
@giomfo giomfo requested a review from mnaturel October 25, 2022 16:34
val voiceBroadcastAttributes = AbsMessageVoiceBroadcastItem.Attributes(
voiceBroadcastId = voiceBroadcastId,
voiceBroadcastState = voiceBroadcastContent.voiceBroadcastState,
recorderName = params.event.root.stateKey?.let { session.getUserOrDefault(it) }?.toMatrixItem()?.getBestName().orEmpty(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we inject ActiveSessionHolder instead of Session here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so, the factory is not a singleton and we should not be able to display a timeline if there is no session, it will fail in a previous step in that case

@@ -128,49 +60,34 @@ abstract class MessageVoiceBroadcastListeningItem : AbsMessageItem<MessageVoiceB
VoiceBroadcastPlayer.State.PLAYING -> {
playPauseButton.setImageResource(R.drawable.ic_play_pause_pause)
playPauseButton.contentDescription = view.resources.getString(R.string.a11y_play_voice_broadcast)
Copy link
Contributor

@mnaturel mnaturel Oct 26, 2022

Choose a reason for hiding this comment

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

I think content description should be R.string.a11y_pause_voice_broadcast here no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, good catch

@@ -128,49 +60,34 @@ abstract class MessageVoiceBroadcastListeningItem : AbsMessageItem<MessageVoiceB
VoiceBroadcastPlayer.State.PLAYING -> {
playPauseButton.setImageResource(R.drawable.ic_play_pause_pause)
playPauseButton.contentDescription = view.resources.getString(R.string.a11y_play_voice_broadcast)
playPauseButton.onClick { attributes.callback?.onTimelineItemAction(RoomDetailAction.VoiceBroadcastAction.Listening.Pause) }
playPauseButton.onClick { callback?.onTimelineItemAction(RoomDetailAction.VoiceBroadcastAction.Listening.Pause) }
}
VoiceBroadcastPlayer.State.IDLE,
VoiceBroadcastPlayer.State.PAUSED -> {
playPauseButton.setImageResource(R.drawable.ic_play_pause_play)
playPauseButton.contentDescription = view.resources.getString(R.string.a11y_pause_voice_broadcast)
Copy link
Contributor

Choose a reason for hiding this comment

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

Here I think content description should be R.string.a11y_play_voice_broadcast.

}
}

private fun renderPlayingState(holder: Holder) = with(holder) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe to be consistent, we could rename the method to renderRecordingState?

/**
* Map voiceBroadcastId to listeners.
*/
private var listeners: MutableMap<String, CopyOnWriteArrayList<Listener>> = mutableMapOf()
Copy link
Contributor

Choose a reason for hiding this comment

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

It could be a val instead.

@ElementBot
Copy link

Warnings
⚠️

vector/src/main/res/drawable/ic_voice_broadcast.xml#L7 - Very long vector path (1082 characters), which is bad for performance. Considering reducing precision, removing minor details or rasterizing vector.

⚠️

vector/src/main/res/drawable/ic_voice_broadcast.xml#L7 - Very long vector path (1082 characters), which is bad for performance. Considering reducing precision, removing minor details or rasterizing vector.

⚠️

vector/src/main/res/drawable/ic_voice_broadcast.xml#L10 - Very long vector path (1022 characters), which is bad for performance. Considering reducing precision, removing minor details or rasterizing vector.

⚠️

vector/src/main/res/drawable/ic_voice_broadcast.xml#L10 - Very long vector path (1022 characters), which is bad for performance. Considering reducing precision, removing minor details or rasterizing vector.

⚠️

vector/src/main/res/drawable/ic_voice_broadcast.xml#L13 - Very long vector path (997 characters), which is bad for performance. Considering reducing precision, removing minor details or rasterizing vector.

⚠️

vector/src/main/res/drawable/ic_voice_broadcast.xml#L13 - Very long vector path (997 characters), which is bad for performance. Considering reducing precision, removing minor details or rasterizing vector.

⚠️

vector/src/main/res/drawable/ic_voice_broadcast.xml#L16 - Very long vector path (928 characters), which is bad for performance. Considering reducing precision, removing minor details or rasterizing vector.

⚠️

vector/src/main/res/drawable/ic_voice_broadcast.xml#L16 - Very long vector path (928 characters), which is bad for performance. Considering reducing precision, removing minor details or rasterizing vector.

Generated by 🚫 dangerJS against 1554d79

@sonarcloud
Copy link

sonarcloud bot commented Oct 26, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@Florian14 Florian14 merged commit 6f1e0b5 into resilience-rc Oct 26, 2022
@Florian14 Florian14 deleted the feature/fre/voice_broadcast_timeline_improvements branch October 26, 2022 09:53
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.

None yet

3 participants