From 04d42d6772fa4fa5ff214243783327d672cf88ca Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 20 Feb 2018 16:37:22 +0100 Subject: [PATCH] use proper orientation at otg images --- .../simplemobiletools/gallery/fragments/PhotoFragment.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 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 d53a36a04..b13b06422 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -24,6 +24,7 @@ import com.bumptech.glide.request.target.Target import com.davemorrissey.labs.subscaleview.ImageSource import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView import com.simplemobiletools.commons.extensions.* +import com.simplemobiletools.commons.helpers.OTG_PATH import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.activities.PhotoActivity import com.simplemobiletools.gallery.activities.ViewPagerActivity @@ -314,11 +315,12 @@ class PhotoFragment : ViewPagerFragment() { var orient = defaultOrientation try { - val exif = android.media.ExifInterface(medium.path) + val pathToLoad = getPathToLoad(medium) + val exif = android.media.ExifInterface(pathToLoad) orient = exif.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, defaultOrientation) - if (orient == defaultOrientation) { - val uri = if (medium.path.startsWith("content:/")) Uri.parse(medium.path) else Uri.fromFile(File(medium.path)) + if (orient == defaultOrientation || medium.path.startsWith(OTG_PATH)) { + val uri = if (pathToLoad.startsWith("content:/")) Uri.parse(pathToLoad) else Uri.fromFile(File(pathToLoad)) val inputStream = context!!.contentResolver.openInputStream(uri) val exif2 = ExifInterface() exif2.readExif(inputStream, ExifInterface.Options.OPTION_ALL)