removing some code related to OTG file special handling
This commit is contained in:
parent
3624091994
commit
574c3138c9
4 changed files with 13 additions and 93 deletions
|
@ -455,11 +455,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
|||
medium_check?.background?.applyColorFilter(primaryColor)
|
||||
}
|
||||
|
||||
var path = medium.path
|
||||
if (hasOTGConnected && context.isPathOnOTG(path)) {
|
||||
path = path.getOTGPublicPath(context)
|
||||
}
|
||||
|
||||
val path = medium.path
|
||||
if (loadImageInstantly) {
|
||||
activity.loadImage(medium.type, path, medium_thumbnail, scrollHorizontally, animateGifs, cropThumbnails, rotatedImagePaths)
|
||||
} else {
|
||||
|
|
|
@ -325,11 +325,11 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
|
||||
private fun loadGif() {
|
||||
try {
|
||||
val pathToLoad = getPathToLoad(mMedium)
|
||||
val source = if (pathToLoad.startsWith("content://") || pathToLoad.startsWith("file://")) {
|
||||
InputSource.UriSource(context!!.contentResolver, Uri.parse(pathToLoad))
|
||||
val path = mMedium.path
|
||||
val source = if (path.startsWith("content://") || path.startsWith("file://")) {
|
||||
InputSource.UriSource(context!!.contentResolver, Uri.parse(path))
|
||||
} else {
|
||||
InputSource.FileSource(pathToLoad)
|
||||
InputSource.FileSource(path)
|
||||
}
|
||||
|
||||
mView.apply {
|
||||
|
@ -365,7 +365,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
}
|
||||
|
||||
Glide.with(context!!)
|
||||
.load(getPathToLoad(mMedium))
|
||||
.load(mMedium.path)
|
||||
.apply(options)
|
||||
.listener(object : RequestListener<Drawable> {
|
||||
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, 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<ImageDecoder> {
|
||||
override fun make() = PicassoDecoder(path, Picasso.get(), rotation)
|
||||
override fun make() = PicassoDecoder(mMedium.path, Picasso.get(), rotation)
|
||||
}
|
||||
|
||||
val regionDecoder = object : DecoderFactory<ImageRegionDecoder> {
|
||||
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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<Medium>()
|
||||
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)
|
||||
}
|
||||
|
||||
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<String>,
|
||||
getVideoDurations: Boolean): ArrayList<Medium> {
|
||||
val media = ArrayList<Medium>()
|
||||
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<String, Long> {
|
||||
val projection = arrayOf(
|
||||
MediaStore.Images.Media.DISPLAY_NAME,
|
||||
|
|
Loading…
Reference in a new issue