mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
Some checks failed
update fork / build (push) Has been cancelled
Test Build / prepare (push) Has been cancelled
Test Build / build (app, release) (push) Has been cancelled
Test Build / build (app, releaseA) (push) Has been cancelled
Test Build / prerelease (push) Has been cancelled
Test Build / lanzou (push) Has been cancelled
Test Build / test_Branch (push) Has been cancelled
Test Build / telegram (push) Has been cancelled
Some checks failed
update fork / build (push) Has been cancelled
Test Build / prepare (push) Has been cancelled
Test Build / build (app, release) (push) Has been cancelled
Test Build / build (app, releaseA) (push) Has been cancelled
Test Build / prerelease (push) Has been cancelled
Test Build / lanzou (push) Has been cancelled
Test Build / test_Branch (push) Has been cancelled
Test Build / telegram (push) Has been cancelled
This commit is contained in:
@@ -42,7 +42,7 @@ class HandleFileContract :
|
||||
|
||||
override fun parseResult(resultCode: Int, intent: Intent?): Result {
|
||||
val uri = if (resultCode != RESULT_OK || intent?.data == null ||
|
||||
RealPathUtil.getPath(appCtx, intent.data!!)
|
||||
RealPathUtil.getTreePath(intent.data!!)
|
||||
?.startsWith(appCtx.externalFiles.parent!!) == true
|
||||
) {
|
||||
null
|
||||
|
||||
@@ -86,6 +86,22 @@ object RealPathUtil {
|
||||
return uri.path
|
||||
}
|
||||
|
||||
fun getTreePath(uri: Uri): String? {
|
||||
if (!DocumentsContractCompat.isTreeUri(uri) || !isExternalStorageDocument(uri)) {
|
||||
return null
|
||||
}
|
||||
val docId = DocumentsContract.getTreeDocumentId(uri)
|
||||
val split = docId.split(":")
|
||||
if (split.size < 2) {
|
||||
return null
|
||||
}
|
||||
val type = split[0]
|
||||
if ("primary".equals(type, ignoreCase = true)) {
|
||||
return Environment.getExternalStorageDirectory().toString() + "/" + split[1]
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the data column for this Uri. This is useful for
|
||||
* MediaStore Uris, and other file-based ContentProviders.
|
||||
|
||||
Reference in New Issue
Block a user