Skip to content

Commit

Permalink
Merge branch 'dev-2.21'
Browse files Browse the repository at this point in the history
  • Loading branch information
birdofpreyru committed Oct 12, 2023
2 parents 5f51497 + 2d39c25 commit 4a86a9f
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,31 @@ static private void closeIgnoringException(Closeable closeable) {

ReactNativeFsModule(ReactApplicationContext context) {
super(context);
}

ReactActivity activity = (ReactActivity)getCurrentActivity();
ActivityResultRegistry registry = activity.getActivityResultRegistry();
pickFileLauncher = registry.register(
"RNFS_pickFile",
new OpenDocument(),
new ActivityResultCallback<Uri>() {
@Override
public void onActivityResult(Uri uri) {
WritableArray res = Arguments.createArray();
res.pushString(uri.toString());
pendingPickFilePromises.pop().resolve(res);
private ActivityResultLauncher<String[]> getPickFileLauncher() {
if (pickFileLauncher == null) {
ReactActivity activity = (ReactActivity)getCurrentActivity();
ActivityResultRegistry registry = activity.getActivityResultRegistry();
pickFileLauncher = registry.register(
"RNFS_pickFile",
new OpenDocument(),
new ActivityResultCallback<Uri>() {
@Override
public void onActivityResult(Uri uri) {
WritableArray res = Arguments.createArray();
res.pushString(uri.toString());
pendingPickFilePromises.pop().resolve(res);
}
}
}
);
);
}
return pickFileLauncher;
}

@Override
protected void finalize() throws Throwable {
pickFileLauncher.unregister();
if (pickFileLauncher != null) pickFileLauncher.unregister();
super.finalize();
}

Expand Down Expand Up @@ -533,7 +538,7 @@ public void pickFile(ReadableMap options, Promise promise) {
// promises in FILO stack we should be able to resolve them in the correct
// order.
pendingPickFilePromises.push(promise);
pickFileLauncher.launch(mimeTypes);
getPickFileLauncher().launch(mimeTypes);
}

@ReactMethod
Expand Down
1 change: 1 addition & 0 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">127.0.0.1</domain>
<domain includeSubdomains="true">10.0.2.2</domain>
</domain-config>
</network-security-config>
Loading

0 comments on commit 4a86a9f

Please sign in to comment.