|
|
|
@ -262,13 +262,12 @@ class VisibleMessageView : LinearLayout {
|
|
|
|
|
|
|
|
|
|
// Get details regarding how we should display the message (it's delivery icon, icon tint colour, and
|
|
|
|
|
// the resource string for what text to display (R.string.delivery_status_sent etc.).
|
|
|
|
|
val (iconID, iconColor, textId) = getMessageStatusInfo(message)
|
|
|
|
|
|
|
|
|
|
// If we get any nulls then a message isn't one with a state that we care about (i.e., control messages
|
|
|
|
|
// If we get a null messageStatus then the message isn't one with a state that we care about (i.e., control messages
|
|
|
|
|
// etc.) - so bail. See: `DisplayRecord.is<WHATEVER>` for the full suite of message state methods.
|
|
|
|
|
// Also: We set all delivery status elements visibility to false just to make sure we don't display any
|
|
|
|
|
// stale data.
|
|
|
|
|
if (textId == null) return
|
|
|
|
|
val messageStatus = getMessageStatusInfo(message) ?: return
|
|
|
|
|
|
|
|
|
|
binding.messageInnerLayout.modifyLayoutParams<FrameLayout.LayoutParams> {
|
|
|
|
|
gravity = if (message.isOutgoing) Gravity.END else Gravity.START
|
|
|
|
@ -277,16 +276,17 @@ class VisibleMessageView : LinearLayout {
|
|
|
|
|
horizontalBias = if (message.isOutgoing) 1f else 0f
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If the message is incoming AND it is not scheduled to disappear then don't show any status or timer details
|
|
|
|
|
// If the message is incoming AND it is not scheduled to disappear
|
|
|
|
|
// OR it is a deleted message then don't show any status or timer details
|
|
|
|
|
val scheduledToDisappear = message.expiresIn > 0
|
|
|
|
|
if (message.isIncoming && !scheduledToDisappear) return
|
|
|
|
|
if (message.isDeleted || message.isIncoming && !scheduledToDisappear) return
|
|
|
|
|
|
|
|
|
|
// Set text & icons as appropriate for the message state. Note: Possible message states we care
|
|
|
|
|
// about are: isFailed, isSyncFailed, isPending, isSyncing, isResyncing, isRead, and isSent.
|
|
|
|
|
textId.let(binding.messageStatusTextView::setText)
|
|
|
|
|
iconColor?.let(binding.messageStatusTextView::setTextColor)
|
|
|
|
|
iconID?.let { ContextCompat.getDrawable(context, it) }
|
|
|
|
|
?.run { iconColor?.let { mutate().apply { setTint(it) } } ?: this }
|
|
|
|
|
messageStatus.messageText?.let(binding.messageStatusTextView::setText)
|
|
|
|
|
messageStatus.iconTint?.let(binding.messageStatusTextView::setTextColor)
|
|
|
|
|
messageStatus.iconId?.let { ContextCompat.getDrawable(context, it) }
|
|
|
|
|
?.run { messageStatus.iconTint?.let { mutate().apply { setTint(it) } } ?: this }
|
|
|
|
|
?.let(binding.messageStatusImageView::setImageDrawable)
|
|
|
|
|
|
|
|
|
|
// Potential options at this point are that the message is:
|
|
|
|
@ -363,7 +363,7 @@ class VisibleMessageView : LinearLayout {
|
|
|
|
|
@ColorInt val iconTint: Int?,
|
|
|
|
|
@StringRes val messageText: Int?)
|
|
|
|
|
|
|
|
|
|
private fun getMessageStatusInfo(message: MessageRecord): MessageStatusInfo = when {
|
|
|
|
|
private fun getMessageStatusInfo(message: MessageRecord): MessageStatusInfo? = when {
|
|
|
|
|
message.isFailed ->
|
|
|
|
|
MessageStatusInfo(R.drawable.ic_delivery_status_failed,
|
|
|
|
|
getThemedColor(context, R.attr.danger),
|
|
|
|
@ -399,10 +399,15 @@ class VisibleMessageView : LinearLayout {
|
|
|
|
|
context.getColorFromAttr(R.attr.message_status_color),
|
|
|
|
|
R.string.delivery_status_sent
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// deleted messages do not have a status but we care about styling them so they need to return something
|
|
|
|
|
message.isDeleted ->
|
|
|
|
|
MessageStatusInfo(null, null, null)
|
|
|
|
|
|
|
|
|
|
else -> {
|
|
|
|
|
// The message isn't one we care about for message statuses we display to the user (i.e.,
|
|
|
|
|
// control messages etc. - see the `DisplayRecord.is<WHATEVER>` suite of methods for options).
|
|
|
|
|
MessageStatusInfo(null, null, null)
|
|
|
|
|
null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|