Merge branch 'gif-support'

This commit is contained in:
Philipp Heckel 2025-09-19 13:14:08 -04:00
commit 7fdaa91c2a
3 changed files with 13 additions and 6 deletions

View file

@ -139,6 +139,11 @@ dependencies {
// Image viewer
implementation 'com.github.stfalcon-studio:StfalconImageViewer:1.0.1'
// Glide (GIF support)
def glide_version = "5.0.5"
implementation "com.github.bumptech.glide:glide:$glide_version"
ksp "com.github.bumptech.glide:ksp:$glide_version"
// Better click handling for links
implementation 'me.saket:better-link-movement-method:2.2.0'

View file

@ -25,6 +25,7 @@ import androidx.core.view.allViews
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.google.android.material.button.MaterialButton
import com.stfalcon.imageviewer.StfalconImageViewer
import io.heckel.ntfy.R
@ -205,7 +206,7 @@ class DetailAdapter(private val activity: Activity, private val lifecycleScope:
val attachment = notification.attachment
val image = attachment.contentUri != null && supportedImage(attachment.type) && previewableImage(attachmentFileStat)
val bitmap = if (image) attachment.contentUri?.readBitmapFromUriOrNull(context) else null
maybeRenderAttachmentImage(context, bitmap)
maybeRenderAttachmentImage(context, bitmap, attachment)
maybeRenderAttachmentBox(context, notification, attachment, attachmentFileStat, bitmap)
}
@ -380,16 +381,17 @@ class DetailAdapter(private val activity: Activity, private val lifecycleScope:
}
}
private fun maybeRenderAttachmentImage(context: Context, bitmap: Bitmap?) {
private fun maybeRenderAttachmentImage(context: Context, bitmap: Bitmap?, attachment: Attachment) {
if (bitmap == null) {
attachmentImageView.visibility = View.GONE
return
}
try {
attachmentImageView.setImageBitmap(bitmap)
Glide.with(context).load(attachment.contentUri).fitCenter().into(attachmentImageView)
attachmentImageView.setOnClickListener {
val loadImage = { view: ImageView, image: Bitmap -> view.setImageBitmap(image) }
StfalconImageViewer.Builder(context, listOf(bitmap), loadImage)
StfalconImageViewer.Builder<Any?>(context, listOf(bitmap)) { imageView, image ->
Glide.with(context).load(attachment.contentUri).into(imageView)
}
.allowZooming(true)
.withTransitionFrom(attachmentImageView)
.withHiddenStatusBar(false)

View file

@ -333,7 +333,7 @@ fun mimeTypeToIconResource(mimeType: String?): Int {
}
fun supportedImage(mimeType: String?): Boolean {
return listOf("image/jpeg", "image/png").contains(mimeType)
return listOf("image/jpeg", "image/png", "image/gif").contains(mimeType)
}
// Google Play doesn't allow us to install received .apk files anymore.