|
@@ -7,7 +7,6 @@ import com.kdanmobile.reader.utils.UriToPathUtil
|
|
|
import java.io.File
|
|
|
import java.io.FileNotFoundException
|
|
|
import java.net.URLEncoder
|
|
|
-import java.util.regex.Pattern
|
|
|
|
|
|
class CopyFileInfoFactory {
|
|
|
fun createInfo(applicationContext: Context, intent: Intent, kdanPdfReaderFolder: File): CopyFileInfo {
|
|
@@ -28,17 +27,21 @@ class CopyFileInfoFactory {
|
|
|
// workaround
|
|
|
if (filePath.isNullOrEmpty()) {
|
|
|
val folderName = if (kdanPdfReaderFolder.name.last() == File.separatorChar) kdanPdfReaderFolder.name else (kdanPdfReaderFolder.name + File.separatorChar)
|
|
|
- uri.path?.also {
|
|
|
- val index = it.indexOf(folderName)
|
|
|
+
|
|
|
+ fun fixFilePath(path: String) {
|
|
|
+ val index = path.indexOf(folderName)
|
|
|
if (index != -1) {
|
|
|
- val filename = it.substring(index + folderName.length)
|
|
|
- val path = "${kdanPdfReaderFolder.absolutePath}/$filename"
|
|
|
- val file = File(path)
|
|
|
+ val filename = path.substring(index + folderName.length)
|
|
|
+ val file = File("${kdanPdfReaderFolder.absolutePath}/$filename")
|
|
|
if (file.exists()) {
|
|
|
filePath = file.absolutePath
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ uri.path?.also {
|
|
|
+ fixFilePath(it)
|
|
|
+ }
|
|
|
}
|
|
|
if (null != filePath && !File(filePath).exists()) {
|
|
|
filePath = Uri.decode(filePath)
|