@react-native-documents/picker 10.1.1 → 10.1.2

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
- queryContentResolverMetadata(contentResolver, metadataBuilder, context)
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
- context: Context
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
- arrayOf(
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 (DocumentsContract.isDocumentUri(context, forUri)) {
116
+ if (couldBeVirtualFile) {
110
117
  val cursorValue: Int =
111
118
  getCursorValue(
112
119
  cursor, DocumentsContract.Document.COLUMN_FLAGS, Int::class.java
@@ -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, reactApplicationContext)
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-documents/picker",
3
- "version": "10.1.1",
3
+ "version": "10.1.2",
4
4
  "description": "A react native interface to access documents from dropbox, google drive, iCloud...",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",