@react-native-documents/picker 10.1.1 → 10.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -65,7 +65,8 @@ class MetadataGetter(private val uriMap: MutableMap<String, Uri>) {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
val couldBeVirtualFile = pickOptions.allowVirtualFiles && DocumentsContract.isDocumentUri(context, sourceUri)
|
|
69
|
+
queryContentResolverMetadata(contentResolver, metadataBuilder, couldBeVirtualFile)
|
|
69
70
|
|
|
70
71
|
metadataBuilder
|
|
71
72
|
}
|
|
@@ -73,18 +74,24 @@ class MetadataGetter(private val uriMap: MutableMap<String, Uri>) {
|
|
|
73
74
|
fun queryContentResolverMetadata(
|
|
74
75
|
contentResolver: ContentResolver,
|
|
75
76
|
metadataBuilder: DocumentMetadataBuilder,
|
|
76
|
-
|
|
77
|
+
couldBeVirtualFile: Boolean
|
|
77
78
|
) {
|
|
78
79
|
val forUri = metadataBuilder.getUri()
|
|
80
|
+
|
|
81
|
+
val projection = mutableListOf(
|
|
82
|
+
DocumentsContract.Document.COLUMN_MIME_TYPE,
|
|
83
|
+
OpenableColumns.DISPLAY_NAME,
|
|
84
|
+
OpenableColumns.SIZE,
|
|
85
|
+
).apply {
|
|
86
|
+
if (couldBeVirtualFile) {
|
|
87
|
+
add(DocumentsContract.Document.COLUMN_FLAGS)
|
|
88
|
+
}
|
|
89
|
+
}.toTypedArray()
|
|
90
|
+
|
|
79
91
|
contentResolver
|
|
80
92
|
.query(
|
|
81
93
|
forUri,
|
|
82
|
-
|
|
83
|
-
DocumentsContract.Document.COLUMN_MIME_TYPE,
|
|
84
|
-
OpenableColumns.DISPLAY_NAME,
|
|
85
|
-
OpenableColumns.SIZE,
|
|
86
|
-
DocumentsContract.Document.COLUMN_FLAGS,
|
|
87
|
-
),
|
|
94
|
+
projection,
|
|
88
95
|
null,
|
|
89
96
|
null,
|
|
90
97
|
null
|
|
@@ -106,7 +113,7 @@ class MetadataGetter(private val uriMap: MutableMap<String, Uri>) {
|
|
|
106
113
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
107
114
|
// https://developer.android.com/training/data-storage/shared/documents-files#open-virtual-file
|
|
108
115
|
val isVirtual =
|
|
109
|
-
if (
|
|
116
|
+
if (couldBeVirtualFile) {
|
|
110
117
|
val cursorValue: Int =
|
|
111
118
|
getCursorValue(
|
|
112
119
|
cursor, DocumentsContract.Document.COLUMN_FLAGS, Int::class.java
|
|
@@ -254,12 +254,12 @@ class RNDocumentPickerModule(reactContext: ReactApplicationContext) :
|
|
|
254
254
|
reactApplicationContext.contentResolver.takePersistableUriPermission(uri, takeFlags)
|
|
255
255
|
val encodedBookmark =
|
|
256
256
|
Base64.encodeToString(uri.toString().toByteArray(Charsets.UTF_8), Base64.DEFAULT)
|
|
257
|
-
map.putString("
|
|
257
|
+
map.putString("bookmarkStatus", "success")
|
|
258
258
|
map.putString("bookmark", encodedBookmark)
|
|
259
259
|
} catch (e: Exception) {
|
|
260
260
|
val error =
|
|
261
261
|
e.localizedMessage ?: e.message ?: "Unknown error with takePersistableUriPermission"
|
|
262
|
-
map.putString("
|
|
262
|
+
map.putString("bookmarkStatus", "error")
|
|
263
263
|
map.putString("bookmarkError", error)
|
|
264
264
|
}
|
|
265
265
|
}
|
|
@@ -272,7 +272,7 @@ class RNDocumentPickerModule(reactContext: ReactApplicationContext) :
|
|
|
272
272
|
val targetUriString = if (options.hasKey("uri")) options.getString("uri") else null
|
|
273
273
|
|
|
274
274
|
val metadataBuilder = fileOps.writeDocumentImpl(currentUriOfFileBeingExported, targetUriString, reactApplicationContext)
|
|
275
|
-
metadataGetter.queryContentResolverMetadata(reactApplicationContext.contentResolver, metadataBuilder,
|
|
275
|
+
metadataGetter.queryContentResolverMetadata(reactApplicationContext.contentResolver, metadataBuilder, couldBeVirtualFile = false)
|
|
276
276
|
|
|
277
277
|
val arrayWithSingleResult = Arguments.createArray().apply {
|
|
278
278
|
val resultMap = metadataBuilder.build()
|
package/package.json
CHANGED