mirror of
https://github.com/binwiederhier/ntfy-android.git
synced 2024-05-17 11:02:36 +12:00
Add gif preview support
This commit is contained in:
parent
c15efff72c
commit
746bd63fa7
|
@ -128,4 +128,9 @@ dependencies {
|
|||
|
||||
// Image viewer
|
||||
implementation 'com.github.stfalcon-studio:StfalconImageViewer:v1.0.1'
|
||||
|
||||
//Glide
|
||||
implementation 'com.github.bumptech.glide:glide:4.16.0'
|
||||
kapt 'com.github.bumptech.glide:compiler:4.16.0'
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,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
|
||||
|
@ -176,7 +177,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)
|
||||
}
|
||||
|
||||
|
@ -351,16 +352,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)
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue