mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-04 03:06:41 -04:00
Improved the getFilePathWithFolderFromUri
, and getFullFilePathFromFilePath
methods to properly resolve the other folders uri.
This commit is contained in:
parent
96e9b8913f
commit
946b5cc260
@ -186,7 +186,9 @@ object FileUtils {
|
|||||||
var actualFilePath: String? = null
|
var actualFilePath: String? = null
|
||||||
if (filePath?.isNotEmpty() == true) {
|
if (filePath?.isNotEmpty() == true) {
|
||||||
getStorageVolumesList(context).forEach { volume ->
|
getStorageVolumesList(context).forEach { volume ->
|
||||||
val file = File("$volume/$filePath")
|
// Check if the volume is part of the file path and remove it
|
||||||
|
val trimmedFilePath = filePath.removePrefix(volume)
|
||||||
|
val file = File("$volume/$trimmedFilePath")
|
||||||
if (file.isFileExist()) {
|
if (file.isFileExist()) {
|
||||||
actualFilePath = file.path
|
actualFilePath = file.path
|
||||||
}
|
}
|
||||||
@ -283,7 +285,9 @@ object FileUtils {
|
|||||||
if (pathSegments.isNotEmpty()) {
|
if (pathSegments.isNotEmpty()) {
|
||||||
// Returns the path of the folder containing the file with the specified fileName,
|
// Returns the path of the folder containing the file with the specified fileName,
|
||||||
// from which the user selects the file.
|
// from which the user selects the file.
|
||||||
return pathSegments.drop(1).joinToString(separator = "/")
|
return pathSegments.drop(1)
|
||||||
|
.filterNot { it.startsWith("0") } // remove the prefix of primary storage device
|
||||||
|
.joinToString(separator = "/")
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user