Render edited caption.
This commit is contained in:
parent
b054bebce7
commit
4d00f968b7
17 changed files with 38 additions and 13 deletions
|
|
@ -87,6 +87,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
||||||
filename = messageType.filename,
|
filename = messageType.filename,
|
||||||
caption = messageType.caption?.trimEnd(),
|
caption = messageType.caption?.trimEnd(),
|
||||||
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
||||||
|
isEdited = content.isEdited,
|
||||||
mediaSource = messageType.source,
|
mediaSource = messageType.source,
|
||||||
thumbnailSource = messageType.info?.thumbnailSource,
|
thumbnailSource = messageType.info?.thumbnailSource,
|
||||||
mimeType = messageType.info?.mimetype ?: MimeTypes.OctetStream,
|
mimeType = messageType.info?.mimetype ?: MimeTypes.OctetStream,
|
||||||
|
|
@ -106,6 +107,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
||||||
filename = messageType.filename,
|
filename = messageType.filename,
|
||||||
caption = messageType.caption?.trimEnd(),
|
caption = messageType.caption?.trimEnd(),
|
||||||
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
||||||
|
isEdited = content.isEdited,
|
||||||
mediaSource = messageType.source,
|
mediaSource = messageType.source,
|
||||||
thumbnailSource = messageType.info?.thumbnailSource,
|
thumbnailSource = messageType.info?.thumbnailSource,
|
||||||
mimeType = messageType.info?.mimetype ?: MimeTypes.OctetStream,
|
mimeType = messageType.info?.mimetype ?: MimeTypes.OctetStream,
|
||||||
|
|
@ -143,6 +145,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
||||||
filename = messageType.filename,
|
filename = messageType.filename,
|
||||||
caption = messageType.caption?.trimEnd(),
|
caption = messageType.caption?.trimEnd(),
|
||||||
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
||||||
|
isEdited = content.isEdited,
|
||||||
thumbnailSource = messageType.info?.thumbnailSource,
|
thumbnailSource = messageType.info?.thumbnailSource,
|
||||||
videoSource = messageType.source,
|
videoSource = messageType.source,
|
||||||
mimeType = messageType.info?.mimetype ?: MimeTypes.OctetStream,
|
mimeType = messageType.info?.mimetype ?: MimeTypes.OctetStream,
|
||||||
|
|
@ -162,6 +165,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
||||||
filename = messageType.filename,
|
filename = messageType.filename,
|
||||||
caption = messageType.caption?.trimEnd(),
|
caption = messageType.caption?.trimEnd(),
|
||||||
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
||||||
|
isEdited = content.isEdited,
|
||||||
mediaSource = messageType.source,
|
mediaSource = messageType.source,
|
||||||
duration = messageType.info?.duration ?: Duration.ZERO,
|
duration = messageType.info?.duration ?: Duration.ZERO,
|
||||||
mimeType = messageType.info?.mimetype ?: MimeTypes.OctetStream,
|
mimeType = messageType.info?.mimetype ?: MimeTypes.OctetStream,
|
||||||
|
|
@ -177,6 +181,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
||||||
filename = messageType.filename,
|
filename = messageType.filename,
|
||||||
caption = messageType.caption?.trimEnd(),
|
caption = messageType.caption?.trimEnd(),
|
||||||
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
||||||
|
isEdited = content.isEdited,
|
||||||
mediaSource = messageType.source,
|
mediaSource = messageType.source,
|
||||||
duration = messageType.info?.duration ?: Duration.ZERO,
|
duration = messageType.info?.duration ?: Duration.ZERO,
|
||||||
mimeType = messageType.info?.mimetype ?: MimeTypes.OctetStream,
|
mimeType = messageType.info?.mimetype ?: MimeTypes.OctetStream,
|
||||||
|
|
@ -188,6 +193,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
||||||
filename = messageType.filename,
|
filename = messageType.filename,
|
||||||
caption = messageType.caption?.trimEnd(),
|
caption = messageType.caption?.trimEnd(),
|
||||||
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
||||||
|
isEdited = content.isEdited,
|
||||||
mediaSource = messageType.source,
|
mediaSource = messageType.source,
|
||||||
duration = messageType.info?.duration ?: Duration.ZERO,
|
duration = messageType.info?.duration ?: Duration.ZERO,
|
||||||
mimeType = messageType.info?.mimetype ?: MimeTypes.OctetStream,
|
mimeType = messageType.info?.mimetype ?: MimeTypes.OctetStream,
|
||||||
|
|
@ -203,6 +209,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
||||||
filename = messageType.filename,
|
filename = messageType.filename,
|
||||||
caption = messageType.caption?.trimEnd(),
|
caption = messageType.caption?.trimEnd(),
|
||||||
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
formattedCaption = parseHtml(messageType.formattedCaption) ?: messageType.caption?.withLinks(),
|
||||||
|
isEdited = content.isEdited,
|
||||||
thumbnailSource = messageType.info?.thumbnailSource,
|
thumbnailSource = messageType.info?.thumbnailSource,
|
||||||
fileSource = messageType.source,
|
fileSource = messageType.source,
|
||||||
mimeType = messageType.info?.mimetype ?: MimeTypes.fromFileExtension(fileExtension),
|
mimeType = messageType.info?.mimetype ?: MimeTypes.fromFileExtension(fileExtension),
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ class TimelineItemContentStickerFactory @Inject constructor(
|
||||||
filename = content.filename,
|
filename = content.filename,
|
||||||
caption = content.body,
|
caption = content.body,
|
||||||
formattedCaption = null,
|
formattedCaption = null,
|
||||||
|
isEdited = false,
|
||||||
mediaSource = content.source,
|
mediaSource = content.source,
|
||||||
thumbnailSource = content.info.thumbnailSource,
|
thumbnailSource = content.info.thumbnailSource,
|
||||||
mimeType = content.info.mimetype ?: MimeTypes.OctetStream,
|
mimeType = content.info.mimetype ?: MimeTypes.OctetStream,
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ data class TimelineItemAudioContent(
|
||||||
override val filename: String,
|
override val filename: String,
|
||||||
override val caption: String?,
|
override val caption: String?,
|
||||||
override val formattedCaption: CharSequence?,
|
override val formattedCaption: CharSequence?,
|
||||||
|
override val isEdited: Boolean,
|
||||||
val duration: Duration,
|
val duration: Duration,
|
||||||
val mediaSource: MediaSource,
|
val mediaSource: MediaSource,
|
||||||
val mimeType: String,
|
val mimeType: String,
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ fun aTimelineItemAudioContent(fileName: String = "A sound.mp3") = TimelineItemAu
|
||||||
filename = fileName,
|
filename = fileName,
|
||||||
caption = null,
|
caption = null,
|
||||||
formattedCaption = null,
|
formattedCaption = null,
|
||||||
|
isEdited = false,
|
||||||
mimeType = MimeTypes.Mp3,
|
mimeType = MimeTypes.Mp3,
|
||||||
formattedFileSize = "100kB",
|
formattedFileSize = "100kB",
|
||||||
fileExtension = "mp3",
|
fileExtension = "mp3",
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,15 @@ sealed interface TimelineItemEventContent {
|
||||||
val type: String
|
val type: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface TimelineItemEventMutableContent {
|
||||||
|
/** Whether the event has been edited. */
|
||||||
|
val isEdited: Boolean
|
||||||
|
}
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
sealed interface TimelineItemEventContentWithAttachment : TimelineItemEventContent {
|
sealed interface TimelineItemEventContentWithAttachment :
|
||||||
|
TimelineItemEventContent,
|
||||||
|
TimelineItemEventMutableContent {
|
||||||
val filename: String
|
val filename: String
|
||||||
val caption: String?
|
val caption: String?
|
||||||
val formattedCaption: CharSequence?
|
val formattedCaption: CharSequence?
|
||||||
|
|
@ -74,9 +81,7 @@ fun TimelineItemEventContent.canReact(): Boolean =
|
||||||
/**
|
/**
|
||||||
* Whether the event content has been edited.
|
* Whether the event content has been edited.
|
||||||
*/
|
*/
|
||||||
fun TimelineItemEventContent.isEdited(): Boolean =
|
fun TimelineItemEventContent.isEdited(): Boolean = when (this) {
|
||||||
when (this) {
|
is TimelineItemEventMutableContent -> isEdited
|
||||||
is TimelineItemTextBasedContent -> isEdited
|
else -> false
|
||||||
is TimelineItemPollContent -> isEdited
|
}
|
||||||
else -> false
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ data class TimelineItemFileContent(
|
||||||
override val filename: String,
|
override val filename: String,
|
||||||
override val caption: String?,
|
override val caption: String?,
|
||||||
override val formattedCaption: CharSequence?,
|
override val formattedCaption: CharSequence?,
|
||||||
|
override val isEdited: Boolean,
|
||||||
val fileSource: MediaSource,
|
val fileSource: MediaSource,
|
||||||
val thumbnailSource: MediaSource?,
|
val thumbnailSource: MediaSource?,
|
||||||
val formattedFileSize: String,
|
val formattedFileSize: String,
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ fun aTimelineItemFileContent(
|
||||||
filename = fileName,
|
filename = fileName,
|
||||||
caption = null,
|
caption = null,
|
||||||
formattedCaption = null,
|
formattedCaption = null,
|
||||||
|
isEdited = false,
|
||||||
thumbnailSource = null,
|
thumbnailSource = null,
|
||||||
fileSource = MediaSource(url = ""),
|
fileSource = MediaSource(url = ""),
|
||||||
mimeType = MimeTypes.Pdf,
|
mimeType = MimeTypes.Pdf,
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ data class TimelineItemImageContent(
|
||||||
override val filename: String,
|
override val filename: String,
|
||||||
override val caption: String?,
|
override val caption: String?,
|
||||||
override val formattedCaption: CharSequence?,
|
override val formattedCaption: CharSequence?,
|
||||||
|
override val isEdited: Boolean,
|
||||||
val mediaSource: MediaSource,
|
val mediaSource: MediaSource,
|
||||||
val thumbnailSource: MediaSource?,
|
val thumbnailSource: MediaSource?,
|
||||||
val formattedFileSize: String,
|
val formattedFileSize: String,
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ fun aTimelineItemImageContent(
|
||||||
filename = filename,
|
filename = filename,
|
||||||
caption = caption,
|
caption = caption,
|
||||||
formattedCaption = null,
|
formattedCaption = null,
|
||||||
|
isEdited = false,
|
||||||
mediaSource = MediaSource(""),
|
mediaSource = MediaSource(""),
|
||||||
thumbnailSource = null,
|
thumbnailSource = null,
|
||||||
mimeType = MimeTypes.IMAGE_JPEG,
|
mimeType = MimeTypes.IMAGE_JPEG,
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@ data class TimelineItemPollContent(
|
||||||
val answerItems: List<PollAnswerItem>,
|
val answerItems: List<PollAnswerItem>,
|
||||||
val pollKind: PollKind,
|
val pollKind: PollKind,
|
||||||
val isEnded: Boolean,
|
val isEnded: Boolean,
|
||||||
val isEdited: Boolean
|
override val isEdited: Boolean,
|
||||||
) : TimelineItemEventContent {
|
) : TimelineItemEventContent,
|
||||||
|
TimelineItemEventMutableContent {
|
||||||
override val type: String = "TimelineItemPollContent"
|
override val type: String = "TimelineItemPollContent"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ data class TimelineItemStickerContent(
|
||||||
override val filename: String,
|
override val filename: String,
|
||||||
override val caption: String?,
|
override val caption: String?,
|
||||||
override val formattedCaption: CharSequence?,
|
override val formattedCaption: CharSequence?,
|
||||||
|
override val isEdited: Boolean,
|
||||||
val mediaSource: MediaSource,
|
val mediaSource: MediaSource,
|
||||||
val thumbnailSource: MediaSource?,
|
val thumbnailSource: MediaSource?,
|
||||||
val formattedFileSize: String,
|
val formattedFileSize: String,
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ fun aTimelineItemStickerContent(
|
||||||
filename = "a sticker.gif",
|
filename = "a sticker.gif",
|
||||||
caption = "a body",
|
caption = "a body",
|
||||||
formattedCaption = null,
|
formattedCaption = null,
|
||||||
|
isEdited = false,
|
||||||
mediaSource = MediaSource(""),
|
mediaSource = MediaSource(""),
|
||||||
thumbnailSource = null,
|
thumbnailSource = null,
|
||||||
mimeType = MimeTypes.IMAGE_JPEG,
|
mimeType = MimeTypes.IMAGE_JPEG,
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,9 @@ import org.jsoup.nodes.Document
|
||||||
* Represents a text based content of a timeline item event (a message, a notice, an emote event...).
|
* Represents a text based content of a timeline item event (a message, a notice, an emote event...).
|
||||||
*/
|
*/
|
||||||
@Immutable
|
@Immutable
|
||||||
sealed interface TimelineItemTextBasedContent : TimelineItemEventContent {
|
sealed interface TimelineItemTextBasedContent :
|
||||||
|
TimelineItemEventContent,
|
||||||
|
TimelineItemEventMutableContent {
|
||||||
/** The raw body of the event, in Markdown format. */
|
/** The raw body of the event, in Markdown format. */
|
||||||
val body: String
|
val body: String
|
||||||
|
|
||||||
|
|
@ -30,9 +32,6 @@ sealed interface TimelineItemTextBasedContent : TimelineItemEventContent {
|
||||||
/** The plain text version of the event body. This is the Markdown version without actual Markdown formatting. */
|
/** The plain text version of the event body. This is the Markdown version without actual Markdown formatting. */
|
||||||
val plainText: String
|
val plainText: String
|
||||||
|
|
||||||
/** Whether the event has been edited. */
|
|
||||||
val isEdited: Boolean
|
|
||||||
|
|
||||||
/** The raw HTML body of the event. */
|
/** The raw HTML body of the event. */
|
||||||
val htmlBody: String?
|
val htmlBody: String?
|
||||||
get() = htmlDocument?.body()?.html()
|
get() = htmlDocument?.body()?.html()
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ data class TimelineItemVideoContent(
|
||||||
override val filename: String,
|
override val filename: String,
|
||||||
override val caption: String?,
|
override val caption: String?,
|
||||||
override val formattedCaption: CharSequence?,
|
override val formattedCaption: CharSequence?,
|
||||||
|
override val isEdited: Boolean,
|
||||||
val duration: Duration,
|
val duration: Duration,
|
||||||
val videoSource: MediaSource,
|
val videoSource: MediaSource,
|
||||||
val thumbnailSource: MediaSource?,
|
val thumbnailSource: MediaSource?,
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ fun aTimelineItemVideoContent(
|
||||||
filename = "Video.mp4",
|
filename = "Video.mp4",
|
||||||
caption = null,
|
caption = null,
|
||||||
formattedCaption = null,
|
formattedCaption = null,
|
||||||
|
isEdited = false,
|
||||||
thumbnailSource = null,
|
thumbnailSource = null,
|
||||||
blurHash = blurhash,
|
blurHash = blurhash,
|
||||||
aspectRatio = aspectRatio,
|
aspectRatio = aspectRatio,
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ data class TimelineItemVoiceContent(
|
||||||
override val filename: String,
|
override val filename: String,
|
||||||
override val caption: String?,
|
override val caption: String?,
|
||||||
override val formattedCaption: CharSequence?,
|
override val formattedCaption: CharSequence?,
|
||||||
|
override val isEdited: Boolean,
|
||||||
val duration: Duration,
|
val duration: Duration,
|
||||||
val mediaSource: MediaSource,
|
val mediaSource: MediaSource,
|
||||||
val mimeType: String,
|
val mimeType: String,
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ fun aTimelineItemVoiceContent(
|
||||||
filename = filename,
|
filename = filename,
|
||||||
caption = caption,
|
caption = caption,
|
||||||
formattedCaption = null,
|
formattedCaption = null,
|
||||||
|
isEdited = false,
|
||||||
duration = duration,
|
duration = duration,
|
||||||
mediaSource = mediaSource,
|
mediaSource = mediaSource,
|
||||||
mimeType = mimeType,
|
mimeType = mimeType,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue