diff --git a/android/src/main/java/com/pspdfkit/react/PSPDFKitModule.java b/android/src/main/java/com/pspdfkit/react/PSPDFKitModule.java index 60109ce9..e0d2bd90 100644 --- a/android/src/main/java/com/pspdfkit/react/PSPDFKitModule.java +++ b/android/src/main/java/com/pspdfkit/react/PSPDFKitModule.java @@ -300,25 +300,34 @@ public void onActivityResult(Activity activity, final int requestCode, final int // Forward the result to all our fragments. FragmentActivity fragmentActivity = (FragmentActivity) activity; for (final Fragment fragment : fragmentActivity.getSupportFragmentManager().getFragments()) { - if (fragment instanceof PdfFragment || - fragment instanceof GalleryImagePickerFragment || - fragment instanceof CameraImagePickerFragment) { - // When starting an intent from a fragment its request code is shifted to make it unique, - // we undo it here manually since react by default eats all activity results. - int requestIndex = requestCode >> REQUEST_CODE_TO_INDEX; - if (requestIndex != 0) { - // We need to wait until the next frame with delivering the result to the fragment, - // otherwise the app will crash since the fragment won't be ready. - activityResultHandler.post(new Runnable() { - @Override - public void run() { - fragment.onActivityResult(requestCode & MASKED_REQUEST_CODE_TO_REAL_CODE, resultCode, data); - } - }); + handleFragment(fragment, requestCode, resultCode, data); + } + } + } + + private void handleFragment(@NonNull final Fragment fragment, final int requestCode, final int resultCode, @NonNull final Intent data) { + if (fragment instanceof PdfFragment || + fragment instanceof GalleryImagePickerFragment || + fragment instanceof CameraImagePickerFragment) { + // When starting an intent from a fragment its request code is shifted to make it unique, + // we undo it here manually since react by default eats all activity results. + int requestIndex = requestCode >> REQUEST_CODE_TO_INDEX; + if (requestIndex != 0) { + // We need to wait until the next frame with delivering the result to the fragment, + // otherwise the app will crash since the fragment won't be ready. + activityResultHandler.post(new Runnable() { + @Override + public void run() { + fragment.onActivityResult(requestCode & MASKED_REQUEST_CODE_TO_REAL_CODE, resultCode, data); } - } + }); } } + + // Also send this to all child fragments so we ensure the result is handled. + for (final Fragment childFragment : fragment.getChildFragmentManager().getFragments()) { + handleFragment(childFragment, requestCode, resultCode, data); + } } @Override diff --git a/package-lock.json b/package-lock.json index f7801c57..28e24624 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "react-native-pspdfkit", - "version": "1.29.7", + "version": "1.29.8", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 4d0cb7d8..b286b1ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-pspdfkit", - "version": "1.29.7", + "version": "1.29.8", "description": "A React Native module for the PSPDFKit library.", "keywords": [ "react native", diff --git a/samples/Catalog/package.json b/samples/Catalog/package.json index 6ca1b432..110bfcf7 100644 --- a/samples/Catalog/package.json +++ b/samples/Catalog/package.json @@ -1,6 +1,6 @@ { "name": "Catalog", - "version": "1.29.7", + "version": "1.29.8", "private": true, "scripts": { "start": "react-native start", diff --git a/samples/NativeCatalog/package.json b/samples/NativeCatalog/package.json index 1c156f99..26d240b2 100644 --- a/samples/NativeCatalog/package.json +++ b/samples/NativeCatalog/package.json @@ -1,6 +1,6 @@ { "name": "NativeCatalog", - "version": "1.29.7", + "version": "1.29.8", "private": true, "scripts": { "android": "react-native run-android",