diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 936a06623..7e2f54cb8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -74,6 +74,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View companion object { var screenWidth = 0 var screenHeight = 0 + var wasDecodedByGlide = false } override fun onCreate(savedInstanceState: Bundle?) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index c46fbf60e..22005b630 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -221,6 +221,7 @@ class PhotoFragment : ViewPagerFragment() { private fun addZoomableView() { if ((medium.isImage()) && isFragmentVisible && view.subsampling_view.isGone()) { + ViewPagerActivity.wasDecodedByGlide = false view.subsampling_view.apply { setBitmapDecoderClass(GlideDecoder::class.java) maxScale = 10f @@ -233,7 +234,8 @@ class PhotoFragment : ViewPagerFragment() { override fun onReady() { background = ColorDrawable(if (context.config.darkBackground) Color.BLACK else context.config.backgroundColor) - setDoubleTapZoomScale(getDoubleTapZoomScale()) + val zoomScale = if (ViewPagerActivity.wasDecodedByGlide) 1f else getDoubleTapZoomScale() + setDoubleTapZoomScale(zoomScale) } override fun onTileLoadError(e: Exception?) { @@ -264,13 +266,18 @@ class PhotoFragment : ViewPagerFragment() { val height = bitmapOptions.outHeight val bitmapAspectRatio = height / (width).toFloat() - if (context == null) + if (context == null) { return 2f + } return if (context!!.portrait && bitmapAspectRatio <= 1f) { ViewPagerActivity.screenHeight / height.toFloat() + } else if (context!!.portrait && bitmapAspectRatio > 1f) { + ViewPagerActivity.screenHeight / width.toFloat() } else if (!context!!.portrait && bitmapAspectRatio >= 1f) { ViewPagerActivity.screenWidth / width.toFloat() + } else if (!context!!.portrait && bitmapAspectRatio < 1f) { + ViewPagerActivity.screenWidth / height.toFloat() } else { 2f } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/GlideDecoder.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/GlideDecoder.kt index 78ea3c9dc..55e12722a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/GlideDecoder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/GlideDecoder.kt @@ -23,6 +23,7 @@ class GlideDecoder : ImageDecoder { val targetWidth = if (ViewPagerActivity.screenWidth == 0) Target.SIZE_ORIGINAL else ViewPagerActivity.screenWidth val targetHeight = if (ViewPagerActivity.screenHeight == 0) Target.SIZE_ORIGINAL else ViewPagerActivity.screenHeight + ViewPagerActivity.wasDecodedByGlide = true val options = RequestOptions() .signature(uri.path.getFileSignature()) .diskCacheStrategy(DiskCacheStrategy.RESOURCE)