Skip to content

Commit

Permalink
Update MessageItemFactory.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
nmscode committed Oct 14, 2022
1 parent 6252fb4 commit d3dc0af
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

package im.vector.app.features.home.room.detail.timeline.factory

import android.graphics.BitmapFactory
import android.graphics.ImageDecoder
import android.graphics.drawable.AnimatedImageDrawable
import android.net.Uri
import android.text.Spannable
import android.text.SpannableStringBuilder
Expand Down Expand Up @@ -120,6 +123,7 @@ import org.matrix.android.sdk.api.session.room.timeline.getLastMessageContent
import org.matrix.android.sdk.api.settings.LightweightSettingsStorage
import org.matrix.android.sdk.api.util.MimeTypes
import timber.log.Timber
import java.nio.file.Files
import javax.inject.Inject

class MessageItemFactory @Inject constructor(
Expand Down Expand Up @@ -162,16 +166,29 @@ class MessageItemFactory @Inject constructor(
private val textRenderer by lazy {
textRendererFactory.create(roomId)
}

suspend fun decryptEmote(raw: Map<String, EncryptedFileInfo>): Map<String,String> {
val final = mutableMapOf<String, String>()
Timber.v("hell"+raw.toString())
//Timber.v("hell"+raw.toString())
for ((key, value) in raw) {
val file=(session.fileService().downloadFile(
var file=(session.fileService().downloadFile(
fileName = key,
mimeType = "image/*",
url = value.url,
elementToDecrypt = value.toElementToDecrypt()
))
val source=ImageDecoder.createSource(file)
val drawable = ImageDecoder.decodeDrawable(source)
if (drawable is AnimatedImageDrawable) {
file=(session.fileService().downloadFile(
fileName = key,
mimeType = "image/gif",
url = value.url,
elementToDecrypt = value.toElementToDecrypt()
))
}

//Timber.v("hello "+MimeTypeMap.getFileExtensionFromUrl(file.toString()))
final[":" + key + ":"] = "<img style='height:80px;' src='file:///" + file.absolutePath + "'/>"
//Timber.v("emote:",final[":" + key + ":"])
}
Expand Down

0 comments on commit d3dc0af

Please sign in to comment.