From 30374930bddeb4d24a8a9f154344a166aa4b829f Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 29 Dec 2017 21:35:13 +0100 Subject: [PATCH] properly handle zooming at images rotated by exif --- .../gallery/fragments/PhotoFragment.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 1a76b3571..35796660a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -6,6 +6,7 @@ import android.graphics.BitmapFactory import android.graphics.Color import android.graphics.Matrix import android.graphics.drawable.ColorDrawable +import android.media.ExifInterface.* import android.net.Uri import android.os.Bundle import android.view.LayoutInflater @@ -137,9 +138,9 @@ class PhotoFragment : ViewPagerFragment() { } private fun degreesForRotation(orientation: Int) = when (orientation) { - 8 -> 270 - 3 -> 180 - 6 -> 90 + ORIENTATION_ROTATE_270 -> 270 + ORIENTATION_ROTATE_180 -> 180 + ORIENTATION_ROTATE_90 -> 90 else -> 0 } @@ -253,7 +254,9 @@ class PhotoFragment : ViewPagerFragment() { override fun onReady() { background = ColorDrawable(if (context.config.blackBackground) Color.BLACK else context.config.backgroundColor) - setDoubleTapZoomScale(getDoubleTapZoomScale(sWidth, sHeight)) + val useWidth = if (orient == ORIENTATION_ROTATE_90 || orient == ORIENTATION_ROTATE_270) sHeight else sWidth + val useHeight = if (orient == ORIENTATION_ROTATE_90 || orient == ORIENTATION_ROTATE_270) sWidth else sHeight + setDoubleTapZoomScale(getDoubleTapZoomScale(useWidth, useHeight)) } override fun onTileLoadError(e: Exception?) {