Kaynağa Gözat

Merge branch 'fixCopyFileWrongUri' into 'master'

修正含有%字元的URI錯誤

See merge request kdanandroid/pdf/pdfreaderreadermodule!44
Wayne Huang 5 yıl önce
ebeveyn
işleme
1ad82daba8

+ 2 - 12
src/main/java/com/kdanmobile/reader/copyfile/CopyFileInfoFactory.kt

@@ -92,18 +92,8 @@ class CopyFileInfoFactory {
         return if (isFileExist(applicationContext, uri)) {
             uri
         } else {
-            val prefix = "content://"
-            if (uri.toString().length < prefix.length) return uri
-            val path = uri.toString().substring(prefix.length)
-            if (path.isEmpty()) return uri
-            val split = path.split("/")
-            val builder = StringBuilder()
-            builder.append(prefix)
-            for (str in split) {
-                builder.append(URLEncoder.encode(str, "UTF-8"))
-                builder.append("/")
-            }
-            val fileUri = Uri.parse(builder.deleteCharAt(builder.length - 1).toString())
+            val encodeChar = URLEncoder.encode("%", "UTF-8")
+            val fileUri = Uri.parse(uri.toString().replace("%", encodeChar))
             if (isFileExist(applicationContext, fileUri)) {
                 fileUri
             } else {