Skip to content

Commit

Permalink
Fix issue #92
Browse files Browse the repository at this point in the history
  • Loading branch information
Anggrayudi Hardiannico committed Jul 15, 2022
1 parent 710dc65 commit 193adb5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ fun DocumentFile.getBasePath(context: Context): String {
isRawFile -> File(path).getBasePath(context)

isDocumentsDocument -> {
"Documents/${path.substringAfterLast("/document/home:", "")}".trimEnd('/')
"${Environment.DIRECTORY_DOCUMENTS}/${path.substringAfterLast("/document/home:", "")}".trimEnd('/')
}

isExternalStorageDocument && path.contains("/document/$storageID:") -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ object MimeType {
*/
@JvmStatic
fun getMimeTypeFromExtension(fileExtension: String): String {
return if (fileExtension == "bin") BINARY_FILE else MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension) ?: UNKNOWN
return if (fileExtension.equals("bin", ignoreCase = true)) BINARY_FILE else MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension) ?: UNKNOWN
}

@JvmStatic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ class FileDescription @JvmOverloads constructor(
private var _mimeType: String? = MimeType.BINARY_FILE

val mimeType: String
get() = _mimeType ?: MimeType.getMimeTypeFromFileName(name)
get() {
var type = _mimeType
if (type.isNullOrEmpty() || MimeType.hasExtension(name) && (type == MimeType.BINARY_FILE || type == MimeType.UNKNOWN)) {
type = MimeType.getMimeTypeFromFileName(name)
}
_mimeType = type
return type
}

constructor(name: String, subFolder: String, mimeType: String?) : this(name, subFolder) {
_mimeType = mimeType?.takeIf { !it.contains("*") }
Expand Down

0 comments on commit 193adb5

Please sign in to comment.