mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-18 20:29:10 +03:00
Add additional information in listening tile
This commit is contained in:
parent
72a1acec89
commit
930c856728
5 changed files with 75 additions and 7 deletions
|
@ -34,6 +34,7 @@ import im.vector.app.features.voicebroadcast.model.VoiceBroadcastState
|
|||
import im.vector.app.features.voicebroadcast.model.asVoiceBroadcastEvent
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.getRoom
|
||||
import org.matrix.android.sdk.api.session.getUser
|
||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -61,10 +62,19 @@ class VoiceBroadcastItemFactory @Inject constructor(
|
|||
val mostRecentEvent = mostRecentTimelineEvent.root.asVoiceBroadcastEvent()
|
||||
val mostRecentMessageContent = mostRecentEvent?.content ?: return null
|
||||
val isRecording = mostRecentMessageContent.voiceBroadcastState != VoiceBroadcastState.STOPPED && mostRecentEvent.root.stateKey == session.myUserId
|
||||
val recorderName = mostRecentTimelineEvent.root.stateKey?.let { session.getUser(it) }?.displayName ?: mostRecentTimelineEvent.root.stateKey
|
||||
return if (isRecording) {
|
||||
createRecordingItem(params.event.roomId, highlight, callback, attributes)
|
||||
} else {
|
||||
createListeningItem(params.event.roomId, eventsGroup.groupId, mostRecentMessageContent.voiceBroadcastState, highlight, callback, attributes)
|
||||
createListeningItem(
|
||||
params.event.roomId,
|
||||
eventsGroup.groupId,
|
||||
mostRecentMessageContent.voiceBroadcastState,
|
||||
recorderName,
|
||||
highlight,
|
||||
callback,
|
||||
attributes
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,6 +100,7 @@ class VoiceBroadcastItemFactory @Inject constructor(
|
|||
roomId: String,
|
||||
voiceBroadcastId: String,
|
||||
voiceBroadcastState: VoiceBroadcastState?,
|
||||
broadcasterName: String?,
|
||||
highlight: Boolean,
|
||||
callback: TimelineEventController.Callback?,
|
||||
attributes: AbsMessageItem.Attributes,
|
||||
|
@ -104,6 +115,7 @@ class VoiceBroadcastItemFactory @Inject constructor(
|
|||
.voiceBroadcastPlayer(voiceBroadcastPlayer)
|
||||
.voiceBroadcastId(voiceBroadcastId)
|
||||
.voiceBroadcastState(voiceBroadcastState)
|
||||
.broadcasterName(broadcasterName)
|
||||
.leftGuideline(avatarSizeProvider.leftGuideline)
|
||||
.callback(callback)
|
||||
}
|
||||
|
|
|
@ -48,6 +48,9 @@ abstract class MessageVoiceBroadcastListeningItem : AbsMessageItem<MessageVoiceB
|
|||
@EpoxyAttribute
|
||||
var voiceBroadcastState: VoiceBroadcastState? = null
|
||||
|
||||
@EpoxyAttribute
|
||||
var broadcasterName: String? = null
|
||||
|
||||
@EpoxyAttribute
|
||||
lateinit var colorProvider: ColorProvider
|
||||
|
||||
|
@ -84,6 +87,7 @@ abstract class MessageVoiceBroadcastListeningItem : AbsMessageItem<MessageVoiceB
|
|||
attributes.avatarRenderer.render(it, roomAvatarImageView)
|
||||
titleText.text = it.displayName
|
||||
}
|
||||
broadcasterNameText.text = broadcasterName
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +118,6 @@ abstract class MessageVoiceBroadcastListeningItem : AbsMessageItem<MessageVoiceB
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
private fun renderActiveMedia(holder: Holder, state: VoiceBroadcastPlayer.State) {
|
||||
with(holder) {
|
||||
bufferingView.isVisible = state == VoiceBroadcastPlayer.State.BUFFERING
|
||||
|
@ -166,6 +169,7 @@ abstract class MessageVoiceBroadcastListeningItem : AbsMessageItem<MessageVoiceB
|
|||
val titleText by bind<TextView>(R.id.titleText)
|
||||
val playPauseButton by bind<ImageButton>(R.id.playPauseButton)
|
||||
val bufferingView by bind<View>(R.id.bufferingView)
|
||||
val broadcasterNameText by bind<TextView>(R.id.broadcasterNameText)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
android:singleLine="true"
|
||||
android:text="@string/voice_broadcast_live"
|
||||
android:textColor="?colorOnError"
|
||||
app:drawableStartCompat="@drawable/ic_live_broadcast_16"
|
||||
app:drawableStartCompat="@drawable/ic_voice_broadcast_16"
|
||||
app:drawableTint="?colorOnError"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
@ -36,7 +36,7 @@
|
|||
android:contentDescription="@string/avatar"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:src="@sample/user_round_avatars" />
|
||||
tools:src="@sample/room_round_avatars" />
|
||||
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
android:id="@+id/avatarRightBarrier"
|
||||
|
@ -54,7 +54,59 @@
|
|||
android:contentDescription="@string/avatar"
|
||||
app:layout_constraintStart_toEndOf="@id/avatarRightBarrier"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:src="@sample/users.json/data/displayName" />
|
||||
tools:src="@sample/rooms.json/data/name" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/broadcasterViewGroup"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintStart_toEndOf="@id/avatarRightBarrier"
|
||||
app:layout_constraintTop_toBottomOf="@id/titleText">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/broadcasterIcon"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:src="@drawable/ic_microphone"
|
||||
app:tint="?vctr_content_secondary" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/broadcasterNameText"
|
||||
style="@style/Widget.Vector.TextView.Caption"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="@sample/users.json/data/displayName" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/voiceBroadcastViewGroup"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintStart_toEndOf="@id/avatarRightBarrier"
|
||||
app:layout_constraintTop_toBottomOf="@id/broadcasterViewGroup">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/voiceBroadcastIcon"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:src="@drawable/ic_voice_broadcast_16"
|
||||
app:tint="?vctr_content_secondary" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/voiceBroadcastText"
|
||||
style="@style/Widget.Vector.TextView.Caption"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/attachment_type_voice_broadcast" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
android:id="@+id/headerBottomBarrier"
|
||||
|
@ -62,7 +114,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
app:barrierDirection="bottom"
|
||||
app:barrierMargin="12dp"
|
||||
app:constraint_referenced_ids="roomAvatarImageView,titleText" />
|
||||
app:constraint_referenced_ids="roomAvatarImageView,titleText,broadcasterViewGroup,voiceBroadcastViewGroup" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/playPauseButton"
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
android:singleLine="true"
|
||||
android:text="@string/voice_broadcast_live"
|
||||
android:textColor="?colorOnError"
|
||||
app:drawableStartCompat="@drawable/ic_live_broadcast_16"
|
||||
app:drawableStartCompat="@drawable/ic_voice_broadcast_16"
|
||||
app:drawableTint="?colorOnError"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
|
Loading…
Add table
Reference in a new issue