From 8e58bf4fee1cda7d943dd4754113446a6ef0ff4c Mon Sep 17 00:00:00 2001 From: Ishpreet Kaur Date: Thu, 4 Jun 2026 16:19:04 +0530 Subject: [PATCH] feat(android): add galleryImportAllowed option to scanDocument Adds a new `galleryImportAllowed` boolean option that lets users import images from the device gallery in addition to capturing with the camera. Wires through to GmsDocumentScannerOptions.setGalleryImportAllowed(). Defaults to false to preserve existing behaviour. --- .../main/java/com/documentscanner/DocumentScannerModule.kt | 7 +++++++ src/NativeDocumentScanner.ts | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/android/src/main/java/com/documentscanner/DocumentScannerModule.kt b/android/src/main/java/com/documentscanner/DocumentScannerModule.kt index fbb6836..4328da2 100644 --- a/android/src/main/java/com/documentscanner/DocumentScannerModule.kt +++ b/android/src/main/java/com/documentscanner/DocumentScannerModule.kt @@ -49,9 +49,16 @@ class DocumentScannerModule(reactContext: ReactApplicationContext) : val currentActivity = reactApplicationContext.getCurrentActivity() val response: WritableMap = WritableNativeMap() + val galleryImportAllowed: Boolean = if (options.hasKey("galleryImportAllowed")) { + options.getBoolean("galleryImportAllowed") + } else { + false + } + val documentScannerOptionsBuilder = GmsDocumentScannerOptions.Builder() .setResultFormats(GmsDocumentScannerOptions.RESULT_FORMAT_JPEG) .setScannerMode(GmsDocumentScannerOptions.SCANNER_MODE_FULL) + .setGalleryImportAllowed(galleryImportAllowed) if (options.hasKey("maxNumDocuments")) { documentScannerOptionsBuilder.setPageLimit( diff --git a/src/NativeDocumentScanner.ts b/src/NativeDocumentScanner.ts index 449eeb0..e142f9a 100644 --- a/src/NativeDocumentScanner.ts +++ b/src/NativeDocumentScanner.ts @@ -17,6 +17,13 @@ export interface ScanDocumentOptions { */ maxNumDocuments?: number; + /** + * Android only: Whether to allow the user to import images from the gallery + * in addition to capturing with the camera. + * @default: false + */ + galleryImportAllowed?: boolean; + /** * The response comes back in this format on success. It can be the document * scan image file paths or base64 images.