use proper orientation at otg images
This commit is contained in:
parent
c25513fbcf
commit
04d42d6772
1 changed files with 5 additions and 3 deletions
|
@ -24,6 +24,7 @@ import com.bumptech.glide.request.target.Target
|
||||||
import com.davemorrissey.labs.subscaleview.ImageSource
|
import com.davemorrissey.labs.subscaleview.ImageSource
|
||||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
|
import com.simplemobiletools.commons.helpers.OTG_PATH
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.PhotoActivity
|
import com.simplemobiletools.gallery.activities.PhotoActivity
|
||||||
import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
||||||
|
@ -314,11 +315,12 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
var orient = defaultOrientation
|
var orient = defaultOrientation
|
||||||
|
|
||||||
try {
|
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)
|
orient = exif.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, defaultOrientation)
|
||||||
|
|
||||||
if (orient == defaultOrientation) {
|
if (orient == defaultOrientation || medium.path.startsWith(OTG_PATH)) {
|
||||||
val uri = if (medium.path.startsWith("content:/")) Uri.parse(medium.path) else Uri.fromFile(File(medium.path))
|
val uri = if (pathToLoad.startsWith("content:/")) Uri.parse(pathToLoad) else Uri.fromFile(File(pathToLoad))
|
||||||
val inputStream = context!!.contentResolver.openInputStream(uri)
|
val inputStream = context!!.contentResolver.openInputStream(uri)
|
||||||
val exif2 = ExifInterface()
|
val exif2 = ExifInterface()
|
||||||
exif2.readExif(inputStream, ExifInterface.Options.OPTION_ALL)
|
exif2.readExif(inputStream, ExifInterface.Options.OPTION_ALL)
|
||||||
|
|
Loading…
Reference in a new issue