-
Notifications
You must be signed in to change notification settings - Fork 782
Voice Broadcast - Improve timeline rendering code #7448
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
Merged
Florian14
merged 12 commits into
resilience-rc
from
feature/fre/voice_broadcast_timeline_improvements
Oct 26, 2022
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6a88c61
Group voice broadcast controller buttons in a Flow
1566adb
Timeline - Add abstraction on voice broadcast items
4defc3d
Voice Broadcast - Add style for the "live" indicator
a7c24b2
Improve VoiceBroadcastItemFactory
2c14461
Improve recording state rendering if app has been relaunched
f31429c
Rename renderLiveIcon method
649747b
Move voice broadcast item attributes to dedicated class
5130975
Fix kdoc issue
0f21f40
Add changelog
6091ec4
Fix wrong content description
8fe3b5e
Rename method renderPlayingState to renderRecordingState
1554d79
Change listeners Map variable to immutable
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[Voice Broadcast] Improve timeline items factory and handle bad recording state display |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
library/ui-styles/src/main/res/values/stylable_voice_broadcast_metadata_view.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<declare-styleable name="VoiceBroadcastMetadataView"> | ||
<attr name="metadataIcon" format="reference" /> | ||
<attr name="metadataValue" format="string" /> | ||
</declare-styleable> | ||
|
||
</resources> |
19 changes: 19 additions & 0 deletions
19
library/ui-styles/src/main/res/values/styles_voice_broadcast.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<style name="VoiceBroadcastLiveIndicator" parent="Widget.AppCompat.TextView"> | ||
<item name="android:layout_width">wrap_content</item> | ||
<item name="android:layout_height">20dp</item> | ||
<item name="android:backgroundTint">?colorError</item> | ||
<item name="android:drawablePadding">4dp</item> | ||
<item name="android:ellipsize">end</item> | ||
<item name="android:gravity">center_vertical</item> | ||
<item name="android:maxWidth">100dp</item> | ||
<item name="android:paddingEnd">4dp</item> | ||
<item name="android:paddingStart">4dp</item> | ||
<item name="android:singleLine">true</item> | ||
<item name="android:textColor">?colorOnError</item> | ||
<item name="drawableTint">?colorOnError</item> | ||
</style> | ||
|
||
</resources> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
...ava/im/vector/app/features/home/room/detail/timeline/item/AbsMessageVoiceBroadcastItem.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* Copyright (c) 2022 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package im.vector.app.features.home.room.detail.timeline.item | ||
|
||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import androidx.annotation.IdRes | ||
import androidx.core.view.isVisible | ||
import com.airbnb.epoxy.EpoxyAttribute | ||
import im.vector.app.R | ||
import im.vector.app.core.extensions.tintBackground | ||
import im.vector.app.core.resources.ColorProvider | ||
import im.vector.app.core.resources.DrawableProvider | ||
import im.vector.app.features.voicebroadcast.VoiceBroadcastPlayer | ||
import im.vector.app.features.voicebroadcast.VoiceBroadcastRecorder | ||
import im.vector.app.features.voicebroadcast.model.VoiceBroadcastState | ||
import org.matrix.android.sdk.api.util.MatrixItem | ||
|
||
abstract class AbsMessageVoiceBroadcastItem<H : AbsMessageVoiceBroadcastItem.Holder> : AbsMessageItem<H>() { | ||
|
||
@EpoxyAttribute | ||
lateinit var voiceBroadcastAttributes: Attributes | ||
|
||
protected val voiceBroadcastId get() = voiceBroadcastAttributes.voiceBroadcastId | ||
protected val voiceBroadcastState get() = voiceBroadcastAttributes.voiceBroadcastState | ||
protected val recorderName get() = voiceBroadcastAttributes.recorderName | ||
protected val recorder get() = voiceBroadcastAttributes.recorder | ||
protected val player get() = voiceBroadcastAttributes.player | ||
protected val roomItem get() = voiceBroadcastAttributes.roomItem | ||
protected val colorProvider get() = voiceBroadcastAttributes.colorProvider | ||
protected val drawableProvider get() = voiceBroadcastAttributes.drawableProvider | ||
protected val avatarRenderer get() = attributes.avatarRenderer | ||
protected val callback get() = attributes.callback | ||
|
||
override fun isCacheable(): Boolean = false | ||
|
||
override fun bind(holder: H) { | ||
super.bind(holder) | ||
renderHeader(holder) | ||
} | ||
|
||
private fun renderHeader(holder: H) { | ||
with(holder) { | ||
roomItem?.let { | ||
avatarRenderer.render(it, roomAvatarImageView) | ||
titleText.text = it.displayName | ||
} | ||
} | ||
renderLiveIndicator(holder) | ||
renderMetadata(holder) | ||
} | ||
|
||
private fun renderLiveIndicator(holder: H) { | ||
with(holder) { | ||
when (voiceBroadcastState) { | ||
VoiceBroadcastState.STARTED, | ||
VoiceBroadcastState.RESUMED -> { | ||
liveIndicator.tintBackground(colorProvider.getColorFromAttribute(R.attr.colorError)) | ||
liveIndicator.isVisible = true | ||
} | ||
VoiceBroadcastState.PAUSED -> { | ||
liveIndicator.tintBackground(colorProvider.getColorFromAttribute(R.attr.vctr_content_quaternary)) | ||
liveIndicator.isVisible = true | ||
} | ||
VoiceBroadcastState.STOPPED, null -> { | ||
liveIndicator.isVisible = false | ||
} | ||
} | ||
} | ||
} | ||
|
||
abstract fun renderMetadata(holder: H) | ||
|
||
abstract class Holder(@IdRes stubId: Int) : AbsMessageItem.Holder(stubId) { | ||
val liveIndicator by bind<TextView>(R.id.liveIndicator) | ||
val roomAvatarImageView by bind<ImageView>(R.id.roomAvatarImageView) | ||
val titleText by bind<TextView>(R.id.titleText) | ||
} | ||
|
||
data class Attributes( | ||
val voiceBroadcastId: String, | ||
val voiceBroadcastState: VoiceBroadcastState?, | ||
val recorderName: String, | ||
val recorder: VoiceBroadcastRecorder?, | ||
val player: VoiceBroadcastPlayer, | ||
val roomItem: MatrixItem?, | ||
val colorProvider: ColorProvider, | ||
val drawableProvider: DrawableProvider, | ||
) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 ofSession
here?There was a problem hiding this comment.
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