Media messages send status implementation.
This commit is contained in:
parent
c741916d9f
commit
0b98dfc976
@ -33,7 +33,12 @@ import org.matrix.android.sdk.api.session.Session
|
|||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
import org.matrix.android.sdk.api.session.room.model.ReferencesAggregatedContent
|
import org.matrix.android.sdk.api.session.room.model.ReferencesAggregatedContent
|
||||||
|
import org.matrix.android.sdk.api.session.room.model.message.MessageAudioContent
|
||||||
|
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
||||||
|
import org.matrix.android.sdk.api.session.room.model.message.MessageFileContent
|
||||||
|
import org.matrix.android.sdk.api.session.room.model.message.MessageImageContent
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessageVerificationRequestContent
|
import org.matrix.android.sdk.api.session.room.model.message.MessageVerificationRequestContent
|
||||||
|
import org.matrix.android.sdk.api.session.room.model.message.MessageVideoContent
|
||||||
import org.matrix.android.sdk.api.session.room.send.SendState
|
import org.matrix.android.sdk.api.session.room.send.SendState
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.getLastMessageContent
|
import org.matrix.android.sdk.api.session.room.timeline.getLastMessageContent
|
||||||
@ -73,7 +78,14 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses
|
|||||||
|
|
||||||
val isSentByMe = event.root.senderId == session.myUserId
|
val isSentByMe = event.root.senderId == session.myUserId
|
||||||
val sendStateDecoration = if (isSentByMe) {
|
val sendStateDecoration = if (isSentByMe) {
|
||||||
getSendStateDecoration(event.root.sendState, prevEvent?.root?.sendState, event.readReceipts.any { it.user.userId != session.myUserId })
|
val isMedia = when (event.root.content?.toModel<MessageContent>()) {
|
||||||
|
is MessageImageContent,
|
||||||
|
is MessageVideoContent,
|
||||||
|
is MessageAudioContent,
|
||||||
|
is MessageFileContent -> true
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
getSendStateDecoration(event.root.sendState, prevEvent?.root?.sendState, event.readReceipts.any { it.user.userId != session.myUserId }, isMedia)
|
||||||
} else {
|
} else {
|
||||||
SendStateDecoration.NONE
|
SendStateDecoration.NONE
|
||||||
}
|
}
|
||||||
@ -124,9 +136,9 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getSendStateDecoration(eventSendState: SendState, prevEventSendState: SendState?, anyReadReceipts: Boolean): SendStateDecoration {
|
private fun getSendStateDecoration(eventSendState: SendState, prevEventSendState: SendState?, anyReadReceipts: Boolean, isMedia: Boolean): SendStateDecoration {
|
||||||
return if (eventSendState.isSending()) {
|
return if (eventSendState.isSending()) {
|
||||||
SendStateDecoration.SENDING
|
if (isMedia) SendStateDecoration.SENDING_MEDIA else SendStateDecoration.SENDING_NON_MEDIA
|
||||||
} else if (eventSendState.hasFailed()) {
|
} else if (eventSendState.hasFailed()) {
|
||||||
SendStateDecoration.FAILED
|
SendStateDecoration.FAILED
|
||||||
} else if (eventSendState.isSent() && !prevEventSendState?.isSent().orFalse() && !anyReadReceipts) {
|
} else if (eventSendState.isSent() && !prevEventSendState?.isSent().orFalse() && !anyReadReceipts) {
|
||||||
|
@ -19,6 +19,7 @@ package im.vector.app.features.home.room.detail.timeline.item
|
|||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
|
import android.widget.ProgressBar
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.annotation.IdRes
|
import androidx.annotation.IdRes
|
||||||
import androidx.core.view.isInvisible
|
import androidx.core.view.isInvisible
|
||||||
@ -85,23 +86,28 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
|
|||||||
|
|
||||||
// Render send state indicator
|
// Render send state indicator
|
||||||
holder.sendStateImageView.isVisible = true
|
holder.sendStateImageView.isVisible = true
|
||||||
|
holder.eventSendingIndicator.isVisible = false
|
||||||
when (attributes.informationData.sendStateDecoration) {
|
when (attributes.informationData.sendStateDecoration) {
|
||||||
SendStateDecoration.SENDING -> {
|
SendStateDecoration.SENDING_NON_MEDIA -> {
|
||||||
holder.sendStateImageView
|
holder.sendStateImageView
|
||||||
.apply { setImageResource(R.drawable.ic_sending_message) }
|
.apply { setImageResource(R.drawable.ic_sending_message) }
|
||||||
.apply { contentDescription = context.getString(R.string.event_status_a11y_sending) }
|
.apply { contentDescription = context.getString(R.string.event_status_a11y_sending) }
|
||||||
}
|
}
|
||||||
SendStateDecoration.SENT -> {
|
SendStateDecoration.SENT -> {
|
||||||
holder.sendStateImageView
|
holder.sendStateImageView
|
||||||
.apply { setImageResource(R.drawable.ic_message_sent) }
|
.apply { setImageResource(R.drawable.ic_message_sent) }
|
||||||
.apply { contentDescription = context.getString(R.string.event_status_a11y_sent) }
|
.apply { contentDescription = context.getString(R.string.event_status_a11y_sent) }
|
||||||
}
|
}
|
||||||
SendStateDecoration.FAILED -> {
|
SendStateDecoration.FAILED -> {
|
||||||
holder.sendStateImageView
|
holder.sendStateImageView
|
||||||
.apply { setImageResource(R.drawable.ic_sending_message_failed) }
|
.apply { setImageResource(R.drawable.ic_sending_message_failed) }
|
||||||
.apply { contentDescription = context.getString(R.string.event_status_a11y_failed) }
|
.apply { contentDescription = context.getString(R.string.event_status_a11y_failed) }
|
||||||
}
|
}
|
||||||
SendStateDecoration.NONE -> holder.sendStateImageView.isVisible = false
|
SendStateDecoration.SENDING_MEDIA -> {
|
||||||
|
holder.sendStateImageView.isVisible = false
|
||||||
|
holder.eventSendingIndicator.isVisible = true
|
||||||
|
}
|
||||||
|
SendStateDecoration.NONE -> holder.sendStateImageView.isVisible = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,6 +127,7 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
|
|||||||
val memberNameView by bind<TextView>(R.id.messageMemberNameView)
|
val memberNameView by bind<TextView>(R.id.messageMemberNameView)
|
||||||
val timeView by bind<TextView>(R.id.messageTimeView)
|
val timeView by bind<TextView>(R.id.messageTimeView)
|
||||||
val sendStateImageView by bind<ImageView>(R.id.messageSendStateImageView)
|
val sendStateImageView by bind<ImageView>(R.id.messageSendStateImageView)
|
||||||
|
val eventSendingIndicator by bind<ProgressBar>(R.id.eventSendingIndicator)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,13 +87,6 @@ abstract class MessageFileItem : AbsMessageItem<MessageFileItem.Holder>() {
|
|||||||
holder.fileImageWrapper.setOnClickListener(attributes.itemClickListener)
|
holder.fileImageWrapper.setOnClickListener(attributes.itemClickListener)
|
||||||
holder.fileImageWrapper.setOnLongClickListener(attributes.itemLongClickListener)
|
holder.fileImageWrapper.setOnLongClickListener(attributes.itemLongClickListener)
|
||||||
holder.filenameView.paintFlags = (holder.filenameView.paintFlags or Paint.UNDERLINE_TEXT_FLAG)
|
holder.filenameView.paintFlags = (holder.filenameView.paintFlags or Paint.UNDERLINE_TEXT_FLAG)
|
||||||
|
|
||||||
holder.eventSendingIndicator.isVisible = when (attributes.informationData.sendState) {
|
|
||||||
SendState.UNSENT,
|
|
||||||
SendState.ENCRYPTING,
|
|
||||||
SendState.SENDING -> true
|
|
||||||
else -> false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun unbind(holder: Holder) {
|
override fun unbind(holder: Holder) {
|
||||||
@ -111,7 +104,6 @@ abstract class MessageFileItem : AbsMessageItem<MessageFileItem.Holder>() {
|
|||||||
val fileImageWrapper by bind<ViewGroup>(R.id.messageFileImageView)
|
val fileImageWrapper by bind<ViewGroup>(R.id.messageFileImageView)
|
||||||
val fileDownloadProgress by bind<ProgressBar>(R.id.messageFileProgressbar)
|
val fileDownloadProgress by bind<ProgressBar>(R.id.messageFileProgressbar)
|
||||||
val filenameView by bind<TextView>(R.id.messageFilenameView)
|
val filenameView by bind<TextView>(R.id.messageFilenameView)
|
||||||
val eventSendingIndicator by bind<ProgressBar>(R.id.eventSendingIndicator)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -69,16 +69,7 @@ abstract class MessageImageVideoItem : AbsMessageItem<MessageImageVideoItem.Hold
|
|||||||
ViewCompat.setTransitionName(holder.imageView, "imagePreview_${id()}")
|
ViewCompat.setTransitionName(holder.imageView, "imagePreview_${id()}")
|
||||||
holder.mediaContentView.setOnClickListener(attributes.itemClickListener)
|
holder.mediaContentView.setOnClickListener(attributes.itemClickListener)
|
||||||
holder.mediaContentView.setOnLongClickListener(attributes.itemLongClickListener)
|
holder.mediaContentView.setOnLongClickListener(attributes.itemLongClickListener)
|
||||||
// The sending state color will be apply to the progress text
|
|
||||||
renderSendState(holder.imageView, null, holder.failedToSendIndicator)
|
|
||||||
holder.playContentView.visibility = if (playable) View.VISIBLE else View.GONE
|
holder.playContentView.visibility = if (playable) View.VISIBLE else View.GONE
|
||||||
|
|
||||||
holder.eventSendingIndicator.isVisible = when (attributes.informationData.sendState) {
|
|
||||||
SendState.UNSENT,
|
|
||||||
SendState.ENCRYPTING,
|
|
||||||
SendState.SENDING -> true
|
|
||||||
else -> false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun unbind(holder: Holder) {
|
override fun unbind(holder: Holder) {
|
||||||
@ -96,10 +87,7 @@ abstract class MessageImageVideoItem : AbsMessageItem<MessageImageVideoItem.Hold
|
|||||||
val progressLayout by bind<ViewGroup>(R.id.messageMediaUploadProgressLayout)
|
val progressLayout by bind<ViewGroup>(R.id.messageMediaUploadProgressLayout)
|
||||||
val imageView by bind<ImageView>(R.id.messageThumbnailView)
|
val imageView by bind<ImageView>(R.id.messageThumbnailView)
|
||||||
val playContentView by bind<ImageView>(R.id.messageMediaPlayView)
|
val playContentView by bind<ImageView>(R.id.messageMediaPlayView)
|
||||||
|
|
||||||
val mediaContentView by bind<ViewGroup>(R.id.messageContentMedia)
|
val mediaContentView by bind<ViewGroup>(R.id.messageContentMedia)
|
||||||
val failedToSendIndicator by bind<ImageView>(R.id.messageFailToSendIndicator)
|
|
||||||
val eventSendingIndicator by bind<ProgressBar>(R.id.eventSendingIndicator)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -87,7 +87,8 @@ enum class E2EDecoration {
|
|||||||
|
|
||||||
enum class SendStateDecoration {
|
enum class SendStateDecoration {
|
||||||
NONE,
|
NONE,
|
||||||
SENDING,
|
SENDING_NON_MEDIA,
|
||||||
|
SENDING_MEDIA,
|
||||||
SENT,
|
SENT,
|
||||||
FAILED
|
FAILED
|
||||||
}
|
}
|
||||||
|
@ -80,8 +80,8 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/messageMemberNameView"
|
android:layout_below="@id/messageMemberNameView"
|
||||||
android:layout_toEndOf="@id/messageStartGuideline"
|
|
||||||
android:layout_toStartOf="@id/messageSendStateImageView"
|
android:layout_toStartOf="@id/messageSendStateImageView"
|
||||||
|
android:layout_toEndOf="@id/messageStartGuideline"
|
||||||
android:addStatesFromChildren="true">
|
android:addStatesFromChildren="true">
|
||||||
|
|
||||||
<ViewStub
|
<ViewStub
|
||||||
@ -138,12 +138,28 @@
|
|||||||
android:id="@+id/messageSendStateImageView"
|
android:id="@+id/messageSendStateImageView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:src="@drawable/ic_sending_message"
|
|
||||||
android:layout_alignBottom="@+id/viewStubContainer"
|
android:layout_alignBottom="@+id/viewStubContainer"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:contentDescription="@string/event_status_a11y_sending" />
|
android:layout_marginBottom="4dp"
|
||||||
|
android:contentDescription="@string/event_status_a11y_sending"
|
||||||
|
android:src="@drawable/ic_sending_message"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/eventSendingIndicator"
|
||||||
|
style="?android:attr/progressBarStyleSmall"
|
||||||
|
android:layout_width="16dp"
|
||||||
|
android:layout_height="16dp"
|
||||||
|
android:layout_alignBottom="@+id/viewStubContainer"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:layout_marginBottom="4dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/informationBottom"
|
android:id="@+id/informationBottom"
|
||||||
|
@ -55,16 +55,6 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:text="A filename here" />
|
tools:text="A filename here" />
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/eventSendingIndicator"
|
|
||||||
style="?android:attr/progressBarStyleSmall"
|
|
||||||
android:layout_width="16dp"
|
|
||||||
android:layout_height="16dp"
|
|
||||||
android:visibility="gone"
|
|
||||||
app:layout_constraintStart_toEndOf="@id/messageFilenameView"
|
|
||||||
app:layout_constraintTop_toTopOf="@id/messageFilenameView"
|
|
||||||
tools:visibility="visible" />
|
|
||||||
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.Barrier
|
<androidx.constraintlayout.widget.Barrier
|
||||||
android:id="@+id/horizontalBarrier"
|
android:id="@+id/horizontalBarrier"
|
||||||
|
@ -18,27 +18,6 @@
|
|||||||
tools:layout_height="300dp"
|
tools:layout_height="300dp"
|
||||||
tools:src="@tools:sample/backgrounds/scenic" />
|
tools:src="@tools:sample/backgrounds/scenic" />
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/messageFailToSendIndicator"
|
|
||||||
android:layout_width="14dp"
|
|
||||||
android:layout_height="14dp"
|
|
||||||
android:layout_marginStart="2dp"
|
|
||||||
android:contentDescription="@string/a11y_error_message_not_sent"
|
|
||||||
android:src="@drawable/ic_warning_badge"
|
|
||||||
android:visibility="gone"
|
|
||||||
app:layout_constraintStart_toEndOf="@id/messageThumbnailView"
|
|
||||||
app:layout_constraintTop_toTopOf="@id/messageThumbnailView"
|
|
||||||
tools:visibility="visible" />
|
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/eventSendingIndicator"
|
|
||||||
style="?android:attr/progressBarStyleSmall"
|
|
||||||
android:layout_width="16dp"
|
|
||||||
android:layout_height="16dp"
|
|
||||||
android:visibility="gone"
|
|
||||||
app:layout_constraintStart_toEndOf="@id/messageThumbnailView"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/messageFailToSendIndicator" />
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/messageMediaPlayView"
|
android:id="@+id/messageMediaPlayView"
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user