From 7b67089ed46e8c114541a29db5f43d6a4e946182 Mon Sep 17 00:00:00 2001 From: Victor Carreras <34163765+vicajilau@users.noreply.github.com> Date: Mon, 4 Mar 2024 13:59:42 +0100 Subject: [PATCH 1/6] Gallery import on Android --- .../CunningDocumentScannerPlugin.kt | 7 ++++--- lib/cunning_document_scanner.dart | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/android/src/main/kotlin/biz/cunning/cunning_document_scanner/CunningDocumentScannerPlugin.kt b/android/src/main/kotlin/biz/cunning/cunning_document_scanner/CunningDocumentScannerPlugin.kt index 3bacabf..4f48353 100644 --- a/android/src/main/kotlin/biz/cunning/cunning_document_scanner/CunningDocumentScannerPlugin.kt +++ b/android/src/main/kotlin/biz/cunning/cunning_document_scanner/CunningDocumentScannerPlugin.kt @@ -40,8 +40,9 @@ class CunningDocumentScannerPlugin : FlutterPlugin, MethodCallHandler, ActivityA override fun onMethodCall(call: MethodCall, result: Result) { if (call.method == "getPictures") { val noOfPages = call.argument("noOfPages") ?: 50; + val isGalleryImportAllowed = call.argument("isGalleryImportAllowed") ?: false; this.pendingResult = result - startScan(noOfPages) + startScan(noOfPages, isGalleryImportAllowed) } else { result.notImplemented() } @@ -105,9 +106,9 @@ class CunningDocumentScannerPlugin : FlutterPlugin, MethodCallHandler, ActivityA /** * add document scanner result handler and launch the document scanner */ - private fun startScan(noOfPages: Int) { + private fun startScan(noOfPages: Int, isGalleryImportAllowed: Boolean) { val options = GmsDocumentScannerOptions.Builder() - .setGalleryImportAllowed(false) + .setGalleryImportAllowed(isGalleryImportAllowed) .setPageLimit(noOfPages) .setResultFormats(RESULT_FORMAT_JPEG) .setScannerMode(SCANNER_MODE_FULL) diff --git a/lib/cunning_document_scanner.dart b/lib/cunning_document_scanner.dart index 8e7ffe9..7570739 100644 --- a/lib/cunning_document_scanner.dart +++ b/lib/cunning_document_scanner.dart @@ -9,7 +9,7 @@ class CunningDocumentScanner { /// Call this to start get Picture workflow. static Future?> getPictures( - {int noOfPages = 100}) async { + {int noOfPages = 100, bool isGalleryImportAllowed = false}) async { Map statuses = await [ Permission.camera, ].request(); @@ -18,8 +18,10 @@ class CunningDocumentScanner { throw Exception("Permission not granted"); } - final List? pictures = await _channel.invokeMethod('getPictures', - {'noOfPages': noOfPages}); + final List? pictures = await _channel.invokeMethod('getPictures', { + 'noOfPages': noOfPages, + 'isGalleryImportAllowed': isGalleryImportAllowed + }); return pictures?.map((e) => e as String).toList(); } } From 37cfba55490c7dafd45f0b1b4851dbdeb992b838 Mon Sep 17 00:00:00 2001 From: Victor Carreras <34163765+vicajilau@users.noreply.github.com> Date: Mon, 4 Mar 2024 14:02:24 +0100 Subject: [PATCH 2/6] Update README.md with isGalleryImportAllowed --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f737ad9..0ff5c29 100644 --- a/README.md +++ b/README.md @@ -61,12 +61,18 @@ The easiest way to get a list of images is: final imagesPath = await CunningDocumentScanner.getPictures() ``` -Additionally you can limit the number of pages as follows: +You can limit the number of pages as follows: ``` final imagesPath = await CunningDocumentScanner.getPictures(noOfPages: 1) ``` +In addition, and only on Android for now, you can allow importing images from the gallery: + +``` + final imagesPath = await CunningDocumentScanner.getPictures(isGalleryImportAllowed: true) +``` + This would limit the number of pages to one. ## Contributing From 8bc60c47ab636a371a2445c0fbfe96c0216aead5 Mon Sep 17 00:00:00 2001 From: Victor Carreras <34163765+vicajilau@users.noreply.github.com> Date: Mon, 4 Mar 2024 15:16:22 +0100 Subject: [PATCH 3/6] Update Pubspec.lock of Example's project --- example/pubspec.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index f7975dc..e28c753 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -47,7 +47,7 @@ packages: path: ".." relative: true source: path - version: "1.1.5" + version: "1.2.0" cupertino_icons: dependency: "direct main" description: From 8166f178c636679aa5a198c74fa47ad2cdef11fd Mon Sep 17 00:00:00 2001 From: Victor Carreras <34163765+vicajilau@users.noreply.github.com> Date: Mon, 4 Mar 2024 17:39:06 +0100 Subject: [PATCH 4/6] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 0ff5c29..4d9e19c 100644 --- a/README.md +++ b/README.md @@ -67,14 +67,13 @@ You can limit the number of pages as follows: final imagesPath = await CunningDocumentScanner.getPictures(noOfPages: 1) ``` +This would limit the number of pages to one. noOfPages also only works on Android. The parameter is never used in the iOS implementation. In addition, and only on Android for now, you can allow importing images from the gallery: ``` final imagesPath = await CunningDocumentScanner.getPictures(isGalleryImportAllowed: true) ``` -This would limit the number of pages to one. - ## Contributing ### Step 1 From 7aefdced1fe9c277811f767cafbe6106245035b5 Mon Sep 17 00:00:00 2001 From: Victor Carreras <34163765+vicajilau@users.noreply.github.com> Date: Mon, 4 Mar 2024 18:21:50 +0100 Subject: [PATCH 5/6] Another clarification on README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4d9e19c..e335345 100644 --- a/README.md +++ b/README.md @@ -61,14 +61,15 @@ The easiest way to get a list of images is: final imagesPath = await CunningDocumentScanner.getPictures() ``` +On Android there are some features that can be adjusted that will be ignored on iOS. You can limit the number of pages as follows: ``` final imagesPath = await CunningDocumentScanner.getPictures(noOfPages: 1) ``` -This would limit the number of pages to one. noOfPages also only works on Android. The parameter is never used in the iOS implementation. -In addition, and only on Android for now, you can allow importing images from the gallery: +This would limit the number of pages to one. As it is said, noOfPages also only works on Android (the parameter is never used in the iOS implementation). +In addition, and only on Android too, you can allow importing images from the gallery: ``` final imagesPath = await CunningDocumentScanner.getPictures(isGalleryImportAllowed: true) From 65153e4d03df80098ef86188f993648d00072f26 Mon Sep 17 00:00:00 2001 From: Victor Carreras <34163765+vicajilau@users.noreply.github.com> Date: Tue, 5 Mar 2024 07:16:04 +0100 Subject: [PATCH 6/6] Redefinition of README.md --- README.md | 104 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 80 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index e335345..19a9ed3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,15 @@ -# cunning_document_scanner +# Cunning Document Scanner + +Cunning Document Scanner is a Flutter-based document scanner application that enables you to capture images of paper documents and convert them into digital files effortlessly. This application is designed to run on Android and iOS devices with minimum API levels of 21 and 13, respectively. + +## Key Features + +- Fast and easy document scanning. +- Conversion of document images into digital files. +- Support for both Android and iOS platforms. +- Minimum requirements: API 21 on Android, iOS 13 on iOS. +- Limit the number of scannable files on Android. +- Allows selection of images from the gallery on Android. A state of the art document scanner with automatic cropping function. @@ -6,19 +17,42 @@ A state of the art document scanner with automatic cropping function. +## Project Setup +Follow the steps below to set up your Flutter project on Android and iOS. -## Getting Started +### **Android** -Handle camera access permission +#### Minimum Version Configuration +Ensure you meet the minimum version requirements to run the application on Android devices. +In the `android/app/build.gradle` file, verify that `minSdkVersion` is at least 21: + +```gradle +android { + ... + defaultConfig { + ... + minSdkVersion 21 + ... + } + ... +} +``` ### **IOS** +#### Minimum Version Configuration +Ensure you meet the minimum version requirements to run the application on iOS devices. +In the `ios/Podfile` file, make sure the iOS platform version is at least 13.0: -1. Add a String property to the app's Info.plist file with the key NSCameraUsageDescription and the value as the description for why your app needs camera access. +```ruby +platform :ios, '13.0' +``` +#### Permission Configuration +1. Add a String property to the app's Info.plist file with the key [NSCameraUsageDescription](https://developer.apple.com/documentation/bundleresources/information_property_list/nscamerausagedescription) and the value as the description for why your app needs camera access. NSCameraUsageDescription Camera Permission Description -2. The permission_handler dependency used by cunning_document_scanner use [macros](https://github.com/Baseflow/flutter-permission-handler/blob/master/permission_handler_apple/ios/Classes/PermissionHandlerEnums.h) to control whether a permission is enabled. Add the following to your `Podfile` file: +2. The [permission_handler](https://pub.dev/packages/permission_handler) dependency used by cunning_document_scanner use [macros](https://github.com/Baseflow/flutter-permission-handler/blob/master/permission_handler_apple/ios/Classes/PermissionHandlerEnums.h) to control whether a permission is enabled. Add the following to your `Podfile` file: ```ruby post_install do |installer| @@ -48,11 +82,6 @@ Handle camera access permission end ``` -### **Android** - -minSdkVersion should be at least 21 - - ## How to use ? The easiest way to get a list of images is: @@ -60,32 +89,59 @@ The easiest way to get a list of images is: ``` final imagesPath = await CunningDocumentScanner.getPictures() ``` +### Android Specific -On Android there are some features that can be adjusted that will be ignored on iOS. -You can limit the number of pages as follows: +There are some features in Android that allow you to adjust the scanner that will be ignored in iOS: ``` - final imagesPath = await CunningDocumentScanner.getPictures(noOfPages: 1) + final imagesPath = await CunningDocumentScanner.getPictures( + noOfPages: 1, // Limit the number of pages to 1 + isGalleryImportAllowed, // Allow the user to also pick an image from his gallery + ) ``` -This would limit the number of pages to one. As it is said, noOfPages also only works on Android (the parameter is never used in the iOS implementation). -In addition, and only on Android too, you can allow importing images from the gallery: +## Installation -``` - final imagesPath = await CunningDocumentScanner.getPictures(isGalleryImportAllowed: true) -``` +Before you begin, make sure you have Flutter and Dart installed on your system. You can follow the [Flutter installation guide](https://flutter.dev/docs/get-started/install) for more information. -## Contributing +1. Clone this repository: -### Step 1 + ```bash + git clone https://github.com/jachzen/cunning_document_scanner.git + ``` + +2. Navigate to the project directory: + + ```bash + cd cunning_document_scanner + ``` -- Fork this project's repo : +3. Install dependencies: -### Step 2 + ```bash + flutter pub get + ``` -- Create a new pull request. +4. Run the application: + ```bash + flutter run + ``` +## Contributions + +Contributions are welcome. If you want to contribute to the development of Cunning Document Scanner, follow these steps: + +1. Fork the repository. +2. Create a branch for your contribution: `git checkout -b your_feature` +3. Make your changes and commit: `git commit -m 'Add a new feature'` +4. Push the branch: `git push origin your_feature` +5. Open a pull request on GitHub. + +## Issues and Support + +If you encounter any issues or have questions, please open an [issue](https://github.com/jachzen/cunning_document_scanner/issues). We're here to help. ## License -This project is licensed under the MIT License - see the LICENSE.md file for details + +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details. \ No newline at end of file