fix #1124, properly handle playing animated WebP files

This commit is contained in:
tibbi 2020-09-25 21:23:47 +02:00
parent 03a83f5341
commit f3c55e1df8
3 changed files with 28 additions and 18 deletions

View file

@ -77,7 +77,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.simplemobiletools:commons:5.30.12' implementation 'com.simplemobiletools:commons:5.30.14'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'it.sephiroth.android.exif:library:1.0.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'
@ -92,6 +92,7 @@ dependencies {
implementation 'com.github.tibbi:gestureviews:512f929d82' implementation 'com.github.tibbi:gestureviews:512f929d82'
implementation 'com.github.tibbi:subsampling-scale-image-view:81c021514c' implementation 'com.github.tibbi:subsampling-scale-image-view:81c021514c'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'com.github.penfeizhou.android.animation:awebp:2.4.2'
kapt 'com.github.bumptech.glide:compiler:4.10.0' kapt 'com.github.bumptech.glide:compiler:4.10.0'

View file

@ -81,7 +81,8 @@ fun Activity.launchCamera() {
fun SimpleActivity.launchAbout() { fun SimpleActivity.launchAbout() {
val licenses = LICENSE_GLIDE or LICENSE_CROPPER or LICENSE_RTL or LICENSE_SUBSAMPLING or LICENSE_PATTERN or LICENSE_REPRINT or LICENSE_GIF_DRAWABLE or val licenses = LICENSE_GLIDE or LICENSE_CROPPER or LICENSE_RTL or LICENSE_SUBSAMPLING or LICENSE_PATTERN or LICENSE_REPRINT or LICENSE_GIF_DRAWABLE or
LICENSE_PICASSO or LICENSE_EXOPLAYER or LICENSE_PANORAMA_VIEW or LICENSE_SANSELAN or LICENSE_FILTERS or LICENSE_GESTURE_VIEWS LICENSE_PICASSO or LICENSE_EXOPLAYER or LICENSE_PANORAMA_VIEW or LICENSE_SANSELAN or LICENSE_FILTERS or LICENSE_GESTURE_VIEWS or
LICENSE_APNG
val faqItems = arrayListOf( val faqItems = arrayListOf(
FAQItem(R.string.faq_5_title_commons, R.string.faq_5_text_commons), FAQItem(R.string.faq_5_title_commons, R.string.faq_5_text_commons),

View file

@ -36,6 +36,7 @@ import com.davemorrissey.labs.subscaleview.DecoderFactory
import com.davemorrissey.labs.subscaleview.ImageDecoder import com.davemorrissey.labs.subscaleview.ImageDecoder
import com.davemorrissey.labs.subscaleview.ImageRegionDecoder import com.davemorrissey.labs.subscaleview.ImageRegionDecoder
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
import com.github.penfeizhou.animation.webp.WebPDrawable
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.ensureBackgroundThread
@ -405,8 +406,14 @@ class PhotoFragment : ViewPagerFragment() {
return return
} }
val path = getFilePathToShow()
if (path.isWebP()) {
val drawable = WebPDrawable.fromFile(path)
drawable.setLoopLimit(0)
mView.gestures_view.setImageDrawable(drawable)
} else {
Glide.with(context!!) Glide.with(context!!)
.load(getFilePathToShow()) .load(path)
.apply(options) .apply(options)
.listener(object : RequestListener<Drawable> { .listener(object : RequestListener<Drawable> {
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean { override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
@ -425,6 +432,7 @@ class PhotoFragment : ViewPagerFragment() {
} }
}).into(mView.gestures_view) }).into(mView.gestures_view)
} }
}
private fun tryLoadingWithPicasso(addZoomableView: Boolean) { private fun tryLoadingWithPicasso(addZoomableView: Boolean) {
var pathToLoad = if (getFilePathToShow().startsWith("content://")) getFilePathToShow() else "file://${getFilePathToShow()}" var pathToLoad = if (getFilePathToShow().startsWith("content://")) getFilePathToShow() else "file://${getFilePathToShow()}"