give proper folder names to OTG subfolders

This commit is contained in:
tibbi 2018-02-20 11:22:04 +01:00
parent 0419ef90a7
commit d5496e04ba
2 changed files with 9 additions and 2 deletions

View file

@ -49,7 +49,13 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
context.internalStoragePath -> context.getString(R.string.internal)
context.sdCardPath -> context.getString(R.string.sd_card)
OTG_PATH -> context.getString(R.string.otg)
else -> parentDir.getFilenameFromPath()
else -> {
if (parentDir.startsWith(OTG_PATH)) {
parentDir.getParentPath().trimEnd('/').substringAfterLast('/')
} else {
parentDir.getFilenameFromPath()
}
}
}
if (File(parentDir).containsNoMedia()) {

View file

@ -2,6 +2,7 @@ package com.simplemobiletools.gallery.helpers
import android.content.Context
import android.database.Cursor
import android.net.Uri
import android.provider.MediaStore
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.*
@ -349,7 +350,7 @@ class MediaFetcher(val context: Context) {
else -> TYPE_GIF
}
val path = file.uri.toString().replaceFirst("${context.config.OTGBasePath}%3A", OTG_PATH)
val path = Uri.decode(file.uri.toString().replaceFirst("${context.config.OTGBasePath}%3A", OTG_PATH))
val medium = Medium(filename, path, dateModified, dateTaken, size, type)
val isAlreadyAdded = curMedia.any { it.path == path }
if (!isAlreadyAdded) {