diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt index 902003374..7d839b8dd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt @@ -455,11 +455,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList { override fun onLoadFailed(e: GlideException?, model: Any?, target: Target?, isFirstResource: Boolean): Boolean { @@ -433,11 +433,10 @@ class PhotoFragment : ViewPagerFragment() { private fun addZoomableView() { val rotation = degreesForRotation(mImageOrientation) - val path = getPathToLoad(mMedium) mIsSubsamplingVisible = true val bitmapDecoder = object : DecoderFactory { - override fun make() = PicassoDecoder(path, Picasso.get(), rotation) + override fun make() = PicassoDecoder(mMedium.path, Picasso.get(), rotation) } val regionDecoder = object : DecoderFactory { @@ -461,7 +460,7 @@ class PhotoFragment : ViewPagerFragment() { rotationEnabled = config.allowRotatingWithGestures isOneToOneZoomEnabled = config.allowOneToOneZoom orientation = newOrientation - setImage(path) + setImage(mMedium.path) onImageEventListener = object : SubsamplingScaleImageView.OnImageEventListener { override fun onReady() { background = ColorDrawable(if (config.blackBackground) Color.BLACK else config.backgroundColor) @@ -524,12 +523,12 @@ class PhotoFragment : ViewPagerFragment() { var orient = defaultOrientation try { - val pathToLoad = getPathToLoad(mMedium) - val exif = android.media.ExifInterface(pathToLoad) + val path = mMedium.path + val exif = android.media.ExifInterface(path) orient = exif.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, defaultOrientation) if (orient == defaultOrientation || context!!.isPathOnOTG(mMedium.path)) { - val uri = if (pathToLoad.startsWith("content:/")) Uri.parse(pathToLoad) else Uri.fromFile(File(pathToLoad)) + val uri = if (path.startsWith("content:/")) Uri.parse(path) else Uri.fromFile(File(path)) val inputStream = context!!.contentResolver.openInputStream(uri) val exif2 = ExifInterface() exif2.readExif(inputStream, ExifInterface.Options.OPTION_ALL) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/ViewPagerFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/ViewPagerFragment.kt index 839f67b14..479e28f29 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/ViewPagerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/ViewPagerFragment.kt @@ -76,8 +76,6 @@ abstract class ViewPagerFragment : Fragment() { return details.toString().trim() } - fun getPathToLoad(medium: Medium) = medium.path //if (context!!.isPathOnOTG(medium.path)) medium.path.getOTGPublicPath(context!!) else medium.path - private fun getFileLastModified(file: File): String { val projection = arrayOf(MediaStore.Images.Media.DATE_MODIFIED) val uri = MediaStore.Files.getContentUri("external") diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt index c532bf4ff..84cebabbb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt @@ -2,7 +2,6 @@ package com.simplemobiletools.gallery.pro.helpers import android.content.Context import android.database.Cursor -import android.net.Uri import android.provider.MediaStore import android.text.format.DateFormat import com.simplemobiletools.commons.extensions.* @@ -26,15 +25,8 @@ class MediaFetcher(val context: Context) { } val curMedia = ArrayList() - if (context.isPathOnOTG(curPath)) { - if (context.hasOTGConnected()) { - val newMedia = getMediaOnOTG(curPath, isPickImage, isPickVideo, filterMedia, favoritePaths, getVideoDurations) - curMedia.addAll(newMedia) - } - } else { - val newMedia = getMediaInFolder(curPath, isPickImage, isPickVideo, filterMedia, getProperDateTaken, favoritePaths, getVideoDurations) - curMedia.addAll(newMedia) - } + val newMedia = getMediaInFolder(curPath, isPickImage, isPickVideo, filterMedia, getProperDateTaken, favoritePaths, getVideoDurations) + curMedia.addAll(newMedia) if (sortMedia) { sortMedia(curMedia, context.config.getFileSorting(curPath)) @@ -259,71 +251,6 @@ class MediaFetcher(val context: Context) { return media } - private fun getMediaOnOTG(folder: String, isPickImage: Boolean, isPickVideo: Boolean, filterMedia: Int, favoritePaths: ArrayList, - getVideoDurations: Boolean): ArrayList { - val media = ArrayList() - val files = context.getDocumentFile(folder)?.listFiles() ?: return media - val doExtraCheck = context.config.doExtraCheck - val showHidden = context.config.shouldShowHidden - - for (file in files) { - if (shouldStop) { - break - } - - val filename = file.name ?: continue - val isImage = filename.isImageFast() - val isVideo = if (isImage) false else filename.isVideoFast() - val isGif = if (isImage || isVideo) false else filename.isGif() - val isRaw = if (isImage || isVideo || isGif) false else filename.isRawFast() - val isSvg = if (isImage || isVideo || isGif || isRaw) false else filename.isSvg() - - if (!isImage && !isVideo && !isGif && !isRaw && !isSvg) - continue - - if (isVideo && (isPickImage || filterMedia and TYPE_VIDEOS == 0)) - continue - - if (isImage && (isPickVideo || filterMedia and TYPE_IMAGES == 0)) - continue - - if (isGif && filterMedia and TYPE_GIFS == 0) - continue - - if (isRaw && filterMedia and TYPE_RAWS == 0) - continue - - if (isSvg && filterMedia and TYPE_SVGS == 0) - continue - - if (!showHidden && filename.startsWith('.')) - continue - - val size = file.length() - if (size <= 0L || (doExtraCheck && !file.exists())) - continue - - val dateTaken = file.lastModified() - val dateModified = file.lastModified() - - val type = when { - isVideo -> TYPE_VIDEOS - isGif -> TYPE_GIFS - isRaw -> TYPE_RAWS - isSvg -> TYPE_SVGS - else -> TYPE_IMAGES - } - - val path = Uri.decode(file.uri.toString().replaceFirst("${context.config.OTGTreeUri}/document/${context.config.OTGPartition}%3A", context.config.OTGPath)) - val videoDuration = if (getVideoDurations) path.getVideoDuration() else 0 - val isFavorite = favoritePaths.contains(path) - val medium = Medium(null, filename, path, folder, dateModified, dateTaken, size, type, videoDuration, isFavorite, 0L) - media.add(medium) - } - - return media - } - private fun getFolderDateTakens(folder: String): HashMap { val projection = arrayOf( MediaStore.Images.Media.DISPLAY_NAME,