support for narratives
This commit is contained in:
@@ -103,6 +103,7 @@
|
||||
<string name="message_attachments_artist">Artist</string>
|
||||
<string name="message_attachments_audio_playlist">Playlist</string>
|
||||
<string name="message_attachments_podcast">Podcast</string>
|
||||
<string name="message_attachments_narrative">Narrative</string>
|
||||
|
||||
<string name="chat_interaction_uploading_file">Uploading file</string>
|
||||
<string name="chat_interaction_uploading_photo">Uploading photo</string>
|
||||
|
||||
@@ -25,7 +25,8 @@ enum class AttachmentType(var value: String) {
|
||||
WIDGET("widget"),
|
||||
ARTIST("artist"),
|
||||
AUDIO_PLAYLIST("audio_playlist"),
|
||||
PODCAST("podcast");
|
||||
PODCAST("podcast"),
|
||||
NARRATIVE("narrative");
|
||||
|
||||
fun isMultiple(): Boolean = this in listOf(PHOTO, VIDEO, AUDIO, FILE)
|
||||
|
||||
|
||||
+3
-1
@@ -30,7 +30,8 @@ data class VkAttachmentItemData(
|
||||
@Json(name = "artist") val artist: VkArtistData?,
|
||||
@Json(name = "audios") val audios: List<VkAudioData>?,
|
||||
@Json(name = "audio_playlist") val audioPlaylist: VkAudioPlaylistData?,
|
||||
@Json(name = "podcast") val podcast: VkPodcastData?
|
||||
@Json(name = "podcast") val podcast: VkPodcastData?,
|
||||
@Json(name = "narrative") val narrative: VkNarrativeData?
|
||||
) {
|
||||
fun toDomain(): VkAttachment = when (AttachmentType.parse(type)) {
|
||||
AttachmentType.UNKNOWN -> VkUnknownAttachment
|
||||
@@ -56,5 +57,6 @@ data class VkAttachmentItemData(
|
||||
AttachmentType.ARTIST -> artist?.toDomain()
|
||||
AttachmentType.AUDIO_PLAYLIST -> audioPlaylist?.toDomain()
|
||||
AttachmentType.PODCAST -> podcast?.toDomain()
|
||||
AttachmentType.NARRATIVE -> narrative?.toDomain()
|
||||
} ?: VkUnknownAttachment
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.meloda.app.fast.model.api.data
|
||||
|
||||
import com.meloda.app.fast.model.api.domain.VkNarrativeDomain
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class VkNarrativeData(
|
||||
@Json(name = "id") val id: Int,
|
||||
@Json(name = "title") val title: String?
|
||||
) : VkAttachmentData {
|
||||
|
||||
fun toDomain(): VkNarrativeDomain = VkNarrativeDomain(
|
||||
id = id,
|
||||
title = title
|
||||
)
|
||||
}
|
||||
@@ -3,5 +3,5 @@ package com.meloda.app.fast.model.api.domain
|
||||
import com.meloda.app.fast.model.api.data.AttachmentType
|
||||
|
||||
interface VkAttachment {
|
||||
val type: AttachmentType get() = AttachmentType.UNKNOWN
|
||||
val type: AttachmentType
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.meloda.app.fast.model.api.domain
|
||||
|
||||
import com.meloda.app.fast.model.api.data.AttachmentType
|
||||
|
||||
data class VkNarrativeDomain(
|
||||
val id: Int,
|
||||
val title: String?
|
||||
) : VkAttachment {
|
||||
|
||||
override val type: AttachmentType = AttachmentType.NARRATIVE
|
||||
}
|
||||
@@ -2,8 +2,8 @@ package com.meloda.app.fast.model.database
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import com.meloda.app.fast.model.api.domain.VkAttachment
|
||||
import com.meloda.app.fast.model.api.domain.VkMessage
|
||||
import com.meloda.app.fast.model.api.domain.VkUnknownAttachment
|
||||
|
||||
@Entity(tableName = "messages")
|
||||
data class VkMessageEntity(
|
||||
@@ -46,7 +46,7 @@ fun VkMessageEntity.asExternalModel(): VkMessage = VkMessage(
|
||||
important = important,
|
||||
forwards = emptyList(),//forwards.orEmpty().map(VkMessageEntity::asExternalModel),
|
||||
// TODO: 05/05/2024, Danil Nikolaev: restore attachments
|
||||
attachments = attachments.orEmpty().map { object : VkAttachment {} },
|
||||
attachments = attachments.orEmpty().map { VkUnknownAttachment },
|
||||
replyMessage = null,//replyMessage?.asExternalModel(),
|
||||
geoType = geoType,
|
||||
user = null,
|
||||
|
||||
+2
@@ -610,6 +610,7 @@ private fun getAttachmentIconByType(attachmentType: AttachmentType): UiImage? {
|
||||
AttachmentType.ARTIST -> null
|
||||
AttachmentType.AUDIO_PLAYLIST -> null
|
||||
AttachmentType.PODCAST -> null
|
||||
AttachmentType.NARRATIVE -> null
|
||||
}?.let(UiImage::Resource)
|
||||
}
|
||||
|
||||
@@ -755,6 +756,7 @@ private fun getAttachmentUiText(
|
||||
AttachmentType.ARTIST -> UiR.string.message_attachments_artist
|
||||
AttachmentType.AUDIO_PLAYLIST -> UiR.string.message_attachments_audio_playlist
|
||||
AttachmentType.PODCAST -> UiR.string.message_attachments_podcast
|
||||
AttachmentType.NARRATIVE -> UiR.string.message_attachments_narrative
|
||||
}.let(UiText::Resource)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user