@react-native-documents/picker 10.1.5 → 10.1.7
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.
- package/android/src/main/java/com/reactnativedocumentpicker/MetadataGetter.kt +3 -5
- package/android/src/main/java/com/reactnativedocumentpicker/RNDocumentPickerModule.kt +3 -10
- package/android/src/main/java/com/reactnativedocumentpicker/RNDocumentPickerPackage.kt +35 -0
- package/ios/RNDocumentPicker.mm +0 -4
- package/package.json +1 -1
- package/android/src/main/java/com/reactnativedocumentpicker/RNDocumentPickerPackage.java +0 -49
|
@@ -138,7 +138,7 @@ class MetadataGetter(private val uriMap: MutableMap<String, Uri>) {
|
|
|
138
138
|
private fun <T> getCursorValue(cursor: Cursor, columnName: String, valueType: Class<T>): T? {
|
|
139
139
|
val columnIndex = cursor.getColumnIndex(columnName)
|
|
140
140
|
if (columnIndex != -1 && !cursor.isNull(columnIndex)) {
|
|
141
|
-
return
|
|
141
|
+
return runCatching {
|
|
142
142
|
when (valueType) {
|
|
143
143
|
String::class.java -> cursor.getString(columnIndex) as T
|
|
144
144
|
Int::class.java -> cursor.getInt(columnIndex) as T
|
|
@@ -147,10 +147,8 @@ class MetadataGetter(private val uriMap: MutableMap<String, Uri>) {
|
|
|
147
147
|
Float::class.java -> cursor.getFloat(columnIndex) as T
|
|
148
148
|
else -> null
|
|
149
149
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
null
|
|
153
|
-
}
|
|
150
|
+
// throw should not happen but if it does, we return null
|
|
151
|
+
}.getOrNull()
|
|
154
152
|
}
|
|
155
153
|
return null
|
|
156
154
|
}
|
|
@@ -83,12 +83,8 @@ class RNDocumentPickerModule(reactContext: ReactApplicationContext) :
|
|
|
83
83
|
|
|
84
84
|
@ReactMethod
|
|
85
85
|
override fun pick(opts: ReadableMap, promise: Promise) {
|
|
86
|
-
val currentActivity = currentActivity
|
|
86
|
+
val currentActivity = reactApplicationContext.currentActivity ?: return rejectWithNullActivity(promise)
|
|
87
87
|
|
|
88
|
-
if (currentActivity == null) {
|
|
89
|
-
rejectWithNullActivity(promise)
|
|
90
|
-
return
|
|
91
|
-
}
|
|
92
88
|
if (!promiseWrapper.trySetPromiseRejectingIncoming(promise, "pick")) {
|
|
93
89
|
return
|
|
94
90
|
}
|
|
@@ -145,11 +141,8 @@ class RNDocumentPickerModule(reactContext: ReactApplicationContext) :
|
|
|
145
141
|
|
|
146
142
|
@ReactMethod
|
|
147
143
|
override fun pickDirectory(opts: ReadableMap, promise: Promise) {
|
|
148
|
-
val currentActivity = currentActivity
|
|
149
|
-
|
|
150
|
-
rejectWithNullActivity(promise)
|
|
151
|
-
return
|
|
152
|
-
}
|
|
144
|
+
val currentActivity = reactApplicationContext.currentActivity ?: return rejectWithNullActivity(promise)
|
|
145
|
+
|
|
153
146
|
if (!promiseWrapper.trySetPromiseRejectingIncoming(promise, "pickDirectory")) {
|
|
154
147
|
return
|
|
155
148
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// LICENSE: see License.md in the package root
|
|
2
|
+
package com.reactnativedocumentpicker
|
|
3
|
+
|
|
4
|
+
import com.facebook.react.BaseReactPackage
|
|
5
|
+
import com.facebook.react.bridge.NativeModule
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
8
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
9
|
+
|
|
10
|
+
class RNDocumentPickerPackage : BaseReactPackage() {
|
|
11
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
+
return if (name == NativeDocumentPickerSpec.NAME) {
|
|
13
|
+
RNDocumentPickerModule(reactContext)
|
|
14
|
+
} else {
|
|
15
|
+
null
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
20
|
+
return ReactModuleInfoProvider {
|
|
21
|
+
val isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
22
|
+
val moduleInfos = mapOf(
|
|
23
|
+
NativeDocumentPickerSpec.NAME to ReactModuleInfo(
|
|
24
|
+
NativeDocumentPickerSpec.NAME,
|
|
25
|
+
NativeDocumentPickerSpec.NAME, // "DocumentPickerModule",
|
|
26
|
+
false, // canOverrideExistingModule
|
|
27
|
+
false, // needsEagerInit
|
|
28
|
+
false, // isCxxModule
|
|
29
|
+
isTurboModule // isTurboModule
|
|
30
|
+
)
|
|
31
|
+
)
|
|
32
|
+
moduleInfos
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
package/ios/RNDocumentPicker.mm
CHANGED
|
@@ -14,10 +14,6 @@
|
|
|
14
14
|
#import "react_native_document_picker-Swift.h"
|
|
15
15
|
#endif
|
|
16
16
|
|
|
17
|
-
// for UIModalPresentationStyle conversion
|
|
18
|
-
// remove after https://github.com/facebook/react-native/commit/2d547a3252b328251e49dabfeec85f8d46c85411 is released
|
|
19
|
-
#import <React/RCTModalHostViewManager.h>
|
|
20
|
-
|
|
21
17
|
@interface RNDocumentPicker ()
|
|
22
18
|
@end
|
|
23
19
|
|
package/package.json
CHANGED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// LICENSE: see License.md in the package root
|
|
2
|
-
package com.reactnativedocumentpicker;
|
|
3
|
-
|
|
4
|
-
import androidx.annotation.NonNull;
|
|
5
|
-
import androidx.annotation.Nullable;
|
|
6
|
-
|
|
7
|
-
import com.facebook.react.TurboReactPackage;
|
|
8
|
-
import com.facebook.react.bridge.NativeModule;
|
|
9
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
|
-
import com.facebook.react.module.model.ReactModuleInfo;
|
|
11
|
-
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
|
12
|
-
|
|
13
|
-
import java.util.HashMap;
|
|
14
|
-
import java.util.Map;
|
|
15
|
-
|
|
16
|
-
public class RNDocumentPickerPackage extends TurboReactPackage {
|
|
17
|
-
|
|
18
|
-
@Nullable
|
|
19
|
-
@Override
|
|
20
|
-
public NativeModule getModule(String name, @NonNull ReactApplicationContext reactContext) {
|
|
21
|
-
if (name.equals(RNDocumentPickerModule.NAME)) {
|
|
22
|
-
return new RNDocumentPickerModule(reactContext);
|
|
23
|
-
} else {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@Override
|
|
29
|
-
public ReactModuleInfoProvider getReactModuleInfoProvider() {
|
|
30
|
-
return () -> {
|
|
31
|
-
boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
|
|
32
|
-
final Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
|
|
33
|
-
moduleInfos.put(
|
|
34
|
-
RNDocumentPickerModule.NAME,
|
|
35
|
-
// deprecated in RN 0.73
|
|
36
|
-
new ReactModuleInfo(
|
|
37
|
-
RNDocumentPickerModule.NAME,
|
|
38
|
-
RNDocumentPickerModule.NAME,
|
|
39
|
-
// "DocumentPickerModule",
|
|
40
|
-
false, // canOverrideExistingModule
|
|
41
|
-
false, // needsEagerInit
|
|
42
|
-
false, // hasConstants
|
|
43
|
-
false, // isCxxModule
|
|
44
|
-
isTurboModule // isTurboModule
|
|
45
|
-
));
|
|
46
|
-
return moduleInfos;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
}
|