feat: Show a preview for playable audio attachments (#426)
This commit is contained in:
parent
7fc8a5fb1e
commit
5a51310af8
|
@ -517,9 +517,8 @@ abstract class StatusBaseViewHolder<T : IStatusViewData> protected constructor(i
|
||||||
if (useBlurhash) attachment.blurhash else null,
|
if (useBlurhash) attachment.blurhash else null,
|
||||||
)
|
)
|
||||||
val type = attachment.type
|
val type = attachment.type
|
||||||
if (showingContent && (type === Attachment.Type.VIDEO || type === Attachment.Type.GIFV)) {
|
if (showingContent && type.isPlayable()) {
|
||||||
imageView.foreground =
|
imageView.foreground = ContextCompat.getDrawable(context, R.drawable.play_indicator_overlay)
|
||||||
ContextCompat.getDrawable(context, R.drawable.play_indicator_overlay)
|
|
||||||
} else {
|
} else {
|
||||||
imageView.foreground = null
|
imageView.foreground = null
|
||||||
}
|
}
|
||||||
|
@ -900,10 +899,8 @@ abstract class StatusBaseViewHolder<T : IStatusViewData> protected constructor(i
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
protected fun hasPreviewableAttachment(attachments: List<Attachment>): Boolean {
|
protected fun hasPreviewableAttachment(attachments: List<Attachment>): Boolean {
|
||||||
for ((_, _, _, _, type) in attachments) {
|
for (attachment in attachments) {
|
||||||
if (type === Attachment.Type.AUDIO || type === Attachment.Type.UNKNOWN) {
|
if (attachment.type == Attachment.Type.UNKNOWN) return false
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -940,3 +937,12 @@ abstract class StatusBaseViewHolder<T : IStatusViewData> protected constructor(i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return True if this attachment type is playable and should show the playable indicator,
|
||||||
|
* otherwise false.
|
||||||
|
*/
|
||||||
|
fun Attachment.Type.isPlayable() = when (this) {
|
||||||
|
Attachment.Type.AUDIO, Attachment.Type.GIFV, Attachment.Type.VIDEO -> true
|
||||||
|
Attachment.Type.IMAGE, Attachment.Type.UNKNOWN -> false
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue