From acdd1a0852f80c13eeca4f232c010d441e395f53 Mon Sep 17 00:00:00 2001 From: The Grizzly Labs Date: Wed, 19 Jun 2024 10:12:00 +0000 Subject: [PATCH] Update demos for version 5.1.0 --- android/demo-custom/build.gradle | 2 +- .../geniusscansdk/demo/enhance/Filter.java | 25 +++++++++++++ .../demo/enhance/ImageProcessingActivity.java | 31 ++++++---------- .../com/geniusscansdk/demo/model/Page.java | 16 ++++----- .../demo/processing/PageProcessor.java | 3 +- .../src/main/res/values/strings.xml | 3 +- android/demo-simple/build.gradle | 2 +- .../simpledemo/MainActivity.java | 5 +++ cordova-plugin-genius-scan-demo/config.xml | 2 +- dotnet-maui/SimpleDemo.csproj | 4 +-- flutter-plugin-genius-scan-demo/pubspec.lock | 2 +- flutter-plugin-genius-scan-demo/pubspec.yaml | 2 +- .../GSSDKCustomDemo.xcodeproj/project.pbxproj | 2 +- .../GSSDKCustomDemo/Sources/AppDelegate.swift | 2 +- .../Sources/CameraViewController.swift | 36 +++++++++---------- .../GSSDKSimpleDemo.xcodeproj/project.pbxproj | 2 +- .../ios/Podfile.lock | 6 ---- react-native-genius-scan-demo/package.json | 2 +- 18 files changed, 81 insertions(+), 66 deletions(-) create mode 100644 android/demo-custom/src/main/java/com/geniusscansdk/demo/enhance/Filter.java diff --git a/android/demo-custom/build.gradle b/android/demo-custom/build.gradle index a03d056..8c533bf 100644 --- a/android/demo-custom/build.gradle +++ b/android/demo-custom/build.gradle @@ -24,7 +24,7 @@ android { } dependencies { - implementation 'com.geniusscansdk:gssdk:5.0.8' + implementation 'com.geniusscansdk:gssdk:5.1.0' implementation 'androidx.fragment:fragment:1.6.2' implementation 'androidx.appcompat:appcompat:1.6.1' diff --git a/android/demo-custom/src/main/java/com/geniusscansdk/demo/enhance/Filter.java b/android/demo-custom/src/main/java/com/geniusscansdk/demo/enhance/Filter.java new file mode 100644 index 0000000..6abcf37 --- /dev/null +++ b/android/demo-custom/src/main/java/com/geniusscansdk/demo/enhance/Filter.java @@ -0,0 +1,25 @@ +package com.geniusscansdk.demo.enhance; + +import com.geniusscansdk.core.FilterConfiguration; +import com.geniusscansdk.core.FilterConfiguration.Color.Palette; +import com.geniusscansdk.core.ScanProcessor.Enhancement; +import com.geniusscansdk.core.ScanProcessor.FilterStyle; + +public enum Filter { + NONE, + AUTO, + BLACK_AND_WHITE, + COLOR, + PHOTO; + + public Enhancement toEnhancement() { + switch(this) { + case NONE: return Enhancement.none(); + case AUTO: return Enhancement.automatic(); + case PHOTO: return Enhancement.withFilterConfiguration(FilterConfiguration.photo()); + case BLACK_AND_WHITE: return Enhancement.automatic(FilterStyle.DOCUMENT, Palette.GRAYSCALE); + case COLOR: return Enhancement.automatic(FilterStyle.DOCUMENT, Palette.COLOR); + default: throw new IllegalArgumentException(); + } + } +} diff --git a/android/demo-custom/src/main/java/com/geniusscansdk/demo/enhance/ImageProcessingActivity.java b/android/demo-custom/src/main/java/com/geniusscansdk/demo/enhance/ImageProcessingActivity.java index cc268b3..a339b39 100644 --- a/android/demo-custom/src/main/java/com/geniusscansdk/demo/enhance/ImageProcessingActivity.java +++ b/android/demo-custom/src/main/java/com/geniusscansdk/demo/enhance/ImageProcessingActivity.java @@ -2,7 +2,6 @@ import android.app.AlertDialog; import android.app.ProgressDialog; -import android.content.DialogInterface; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -11,7 +10,8 @@ import android.view.View; import android.widget.ImageView; -import com.geniusscansdk.core.FilterType; +import androidx.appcompat.app.AppCompatActivity; + import com.geniusscansdk.core.RotationAngle; import com.geniusscansdk.demo.MainActivity; import com.geniusscansdk.demo.R; @@ -20,8 +20,6 @@ import java.io.File; -import androidx.appcompat.app.AppCompatActivity; - public class ImageProcessingActivity extends AppCompatActivity { @SuppressWarnings("unused") @@ -74,23 +72,16 @@ public void changeEnhancement(View view) { .setTitle(R.string.enhancement_dialog_title) .setItems(new CharSequence[]{ getString(R.string.image_type_none), + getString(R.string.image_type_auto), + getString(R.string.image_type_black_white), getString(R.string.image_type_color), - getString(R.string.image_type_whiteboard), - getString(R.string.image_type_black_white) - },new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - FilterType filterType = new FilterType[] { - FilterType.NONE, - FilterType.PHOTO, - FilterType.COLOR, - FilterType.BLACK_WHITE - }[which]; - page.setFilterType(filterType); - progressDialog.show(); - enhance(); - } - }).show(); + getString(R.string.image_type_photo) + }, (dialog, which) -> { + Filter filterType = Filter.values()[which]; + page.setFilter(filterType); + progressDialog.show(); + enhance(); + }).show(); } public void toggleDistortionCorrection(View view) { diff --git a/android/demo-custom/src/main/java/com/geniusscansdk/demo/model/Page.java b/android/demo-custom/src/main/java/com/geniusscansdk/demo/model/Page.java index 14035dd..cc1dc50 100644 --- a/android/demo-custom/src/main/java/com/geniusscansdk/demo/model/Page.java +++ b/android/demo-custom/src/main/java/com/geniusscansdk/demo/model/Page.java @@ -4,8 +4,8 @@ import android.os.Parcel; import android.os.Parcelable; -import com.geniusscansdk.core.FilterType; import com.geniusscansdk.core.Quadrangle; +import com.geniusscansdk.demo.enhance.Filter; import java.io.File; @@ -18,7 +18,7 @@ public Page(File originalImage) { private final File originalImage; private File enhancedImage; private Quadrangle quadrangle; - private FilterType filterType; + private Filter filter; private boolean distortionCorrectionEnabled = true; private boolean automaticallyOriented = false; @@ -45,12 +45,12 @@ public Quadrangle getQuadrangle() { return quadrangle; } - public void setFilterType(FilterType filterType) { - this.filterType = filterType; + public void setFilter(Filter filter) { + this.filter = filter; } - public FilterType getFilterType() { - return filterType; + public Filter getFilter() { + return filter; } public void setDistortionCorrectionEnabled(boolean distortionCorrectionEnabled) { @@ -79,7 +79,7 @@ public void writeToParcel(Parcel dest, int flags) { dest.writeString(originalImage.getAbsolutePath()); dest.writeString(enhancedImage == null ? "" : enhancedImage.getAbsolutePath()); dest.writeParcelable(quadrangle, flags); - dest.writeSerializable(filterType); + dest.writeSerializable(filter); dest.writeByte((byte) (distortionCorrectionEnabled ? 1 : 0)); dest.writeByte((byte) (automaticallyOriented ? 1 : 0)); } @@ -89,7 +89,7 @@ protected Page(Parcel in) { String enhancedImagePath = in.readString(); enhancedImage = enhancedImagePath.isEmpty() ? null : new File(enhancedImagePath); quadrangle = in.readParcelable(Quadrangle.class.getClassLoader()); - filterType = (FilterType) in.readSerializable(); + filter = (Filter) in.readSerializable(); distortionCorrectionEnabled = in.readByte() != 0; automaticallyOriented = in.readByte() != 0; } diff --git a/android/demo-custom/src/main/java/com/geniusscansdk/demo/processing/PageProcessor.java b/android/demo-custom/src/main/java/com/geniusscansdk/demo/processing/PageProcessor.java index 2c25f00..92648d0 100644 --- a/android/demo-custom/src/main/java/com/geniusscansdk/demo/processing/PageProcessor.java +++ b/android/demo-custom/src/main/java/com/geniusscansdk/demo/processing/PageProcessor.java @@ -26,7 +26,7 @@ public void processPage(Context context, Page page) throws LicenseException, Pro Configuration configuration = new Configuration<>( page.getQuadrangle() == null ? PerspectiveCorrection.automatic() : PerspectiveCorrection.withQuadrangle(page.getQuadrangle()), CurvatureCorrection.create(page.isDistortionCorrectionEnabled()), - page.getFilterType() == null ? Enhancement.automatic() : Enhancement.withFilter(page.getFilterType()), + page.getFilter() == null ? Enhancement.automatic() : page.getFilter().toEnhancement(), page.isAutomaticallyOriented() ? Rotation.none() : Rotation.automatic(), OutputConfiguration.file(context.getExternalFilesDir(null)) ); @@ -46,7 +46,6 @@ public void processPage(Context context, Page page) throws LicenseException, Pro } page.setQuadrangle(appliedQuadrangle); - page.setFilterType(result.appliedFilter); if (!page.isAutomaticallyOriented()) { page.setAutomaticallyOriented(true); } diff --git a/android/demo-custom/src/main/res/values/strings.xml b/android/demo-custom/src/main/res/values/strings.xml index bcc1735..2cea054 100644 --- a/android/demo-custom/src/main/res/values/strings.xml +++ b/android/demo-custom/src/main/res/values/strings.xml @@ -7,8 +7,9 @@ Capture Please select the enhancement to apply None + Automatic Color - Whiteboard + Photo Black & White diff --git a/android/demo-simple/build.gradle b/android/demo-simple/build.gradle index 635225a..fea35eb 100644 --- a/android/demo-simple/build.gradle +++ b/android/demo-simple/build.gradle @@ -25,7 +25,7 @@ android { } dependencies { - implementation 'com.geniusscansdk:gssdk:5.0.8' + implementation 'com.geniusscansdk:gssdk:5.1.0' implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.google.android.material:material:1.10.0' diff --git a/android/demo-simple/src/main/java/com/geniusscansdk/simpledemo/MainActivity.java b/android/demo-simple/src/main/java/com/geniusscansdk/simpledemo/MainActivity.java index fb2685f..fd7d97d 100644 --- a/android/demo-simple/src/main/java/com/geniusscansdk/simpledemo/MainActivity.java +++ b/android/demo-simple/src/main/java/com/geniusscansdk/simpledemo/MainActivity.java @@ -1,5 +1,7 @@ package com.geniusscansdk.simpledemo; +import static com.geniusscansdk.scanflow.ScanConfiguration.Filter.*; + import android.app.Activity; import android.app.AlertDialog; import android.content.Intent; @@ -65,6 +67,9 @@ private ScanConfiguration createBaseConfiguration() { scanConfiguration.backgroundColor = Color.WHITE; scanConfiguration.foregroundColor = ContextCompat.getColor(this, R.color.colorPrimary); scanConfiguration.highlightColor = ContextCompat.getColor(this, R.color.colorAccent); + scanConfiguration.availableFilters = Arrays.asList(NONE, AUTOMATIC, AUTOMATIC_BLACK_AND_WHITE, + AUTOMATIC_COLOR, PHOTO, SOFT_GRAYSCALE, SOFT_COLOR, STRONG_MONOCHROME + ); ScanConfiguration.OcrConfiguration ocrConfiguration = new ScanConfiguration.OcrConfiguration(); ocrConfiguration.languages = Arrays.asList("en-US"); diff --git a/cordova-plugin-genius-scan-demo/config.xml b/cordova-plugin-genius-scan-demo/config.xml index 115842f..478eea3 100644 --- a/cordova-plugin-genius-scan-demo/config.xml +++ b/cordova-plugin-genius-scan-demo/config.xml @@ -38,7 +38,7 @@ - + diff --git a/dotnet-maui/SimpleDemo.csproj b/dotnet-maui/SimpleDemo.csproj index f28846a..88e4d11 100644 --- a/dotnet-maui/SimpleDemo.csproj +++ b/dotnet-maui/SimpleDemo.csproj @@ -55,10 +55,10 @@ - + - + diff --git a/flutter-plugin-genius-scan-demo/pubspec.lock b/flutter-plugin-genius-scan-demo/pubspec.lock index 54c3d4b..638e3b6 100644 --- a/flutter-plugin-genius-scan-demo/pubspec.lock +++ b/flutter-plugin-genius-scan-demo/pubspec.lock @@ -84,7 +84,7 @@ packages: name: flutter_genius_scan url: "https://pub.dartlang.org" source: hosted - version: "5.0.8" + version: "5.1.0" flutter_test: dependency: "direct dev" description: flutter diff --git a/flutter-plugin-genius-scan-demo/pubspec.yaml b/flutter-plugin-genius-scan-demo/pubspec.yaml index 5d324b6..8e39f9e 100644 --- a/flutter-plugin-genius-scan-demo/pubspec.yaml +++ b/flutter-plugin-genius-scan-demo/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: open_filex: ^4.3.4 flutter_genius_scan: - version: 5.0.8 + version: 5.1.0 path_provider: ^2.1.1 dev_dependencies: diff --git a/ios/GSSDKCustomDemo/GSSDKCustomDemo.xcodeproj/project.pbxproj b/ios/GSSDKCustomDemo/GSSDKCustomDemo.xcodeproj/project.pbxproj index 9ef3539..ecc53cf 100644 --- a/ios/GSSDKCustomDemo/GSSDKCustomDemo.xcodeproj/project.pbxproj +++ b/ios/GSSDKCustomDemo/GSSDKCustomDemo.xcodeproj/project.pbxproj @@ -449,7 +449,7 @@ repositoryURL = "https://github.com/thegrizzlylabs/geniusscan-sdk-spm"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 5.0.8; + minimumVersion = 5.1.0; }; }; /* End XCRemoteSwiftPackageReference section */ diff --git a/ios/GSSDKCustomDemo/GSSDKCustomDemo/Sources/AppDelegate.swift b/ios/GSSDKCustomDemo/GSSDKCustomDemo/Sources/AppDelegate.swift index 0860ee2..b2126e9 100644 --- a/ios/GSSDKCustomDemo/GSSDKCustomDemo/Sources/AppDelegate.swift +++ b/ios/GSSDKCustomDemo/GSSDKCustomDemo/Sources/AppDelegate.swift @@ -27,7 +27,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { let cameraSession = GSKCameraSession(configuration: configuration) window = UIWindow(frame: UIScreen.main.bounds) - let cameraViewController = CameraViewController(cameraSession: cameraSession)! + let cameraViewController = CameraViewController(cameraSession: cameraSession) let navigationController = UINavigationController(rootViewController: cameraViewController) if #available(iOS 13.0, *) { diff --git a/ios/GSSDKCustomDemo/GSSDKCustomDemo/Sources/CameraViewController.swift b/ios/GSSDKCustomDemo/GSSDKCustomDemo/Sources/CameraViewController.swift index f834434..4d2e7fb 100644 --- a/ios/GSSDKCustomDemo/GSSDKCustomDemo/Sources/CameraViewController.swift +++ b/ios/GSSDKCustomDemo/GSSDKCustomDemo/Sources/CameraViewController.swift @@ -44,7 +44,7 @@ final class CameraViewController: GSKCameraViewController { userGuidanceLabel.textColor = UIColor.white userGuidanceLabel.textAlignment = NSTextAlignment.center userGuidanceLabel.adjustsFontSizeToFitWidth = true - cameraView.addSubview(userGuidanceLabel) + captureView.addSubview(userGuidanceLabel) return userGuidanceLabel }() @@ -77,8 +77,8 @@ final class CameraViewController: GSKCameraViewController { /** We just received a photo from the camera. We could do some post-processing immediately but here we choose to immediately show the interface that lets the user edit the crop area. */ - override func cameraSession(_ cameraSession: GSKCameraSession, didGenerate scan: GSKScan) { - super.cameraSession(cameraSession, didGenerate: scan) + override func cameraSession(_ cameraSession: GSKCameraSession, didGenerateScan scan: GSKScan) { + super.cameraSession(cameraSession, didGenerateScan: scan) DispatchQueue.main.async { // We re-enable the camera button @@ -90,29 +90,29 @@ final class CameraViewController: GSKCameraViewController { } } - override func cameraSessionFailed(toFindQuadrangle cameraSession: GSKCameraSession) { - super.cameraSessionFailed(toFindQuadrangle: cameraSession) + override func cameraSessionFailedToFindQuadrangle(_ cameraSession: GSKCameraSession) { + super.cameraSessionFailedToFindQuadrangle(cameraSession) showUserGuidance(with: NSLocalizedString("Searching for document…", comment: "")) removePulseAnimation() } - override func cameraSession(_ cameraSession: GSKCameraSession, didFind quadrangle: GSKQuadrangle) { - super.cameraSession(cameraSession, didFind: quadrangle) + override func cameraSession(_ cameraSession: GSKCameraSession, didFindQuadrangle quadrangle: GSKQuadrangle) { + super.cameraSession(cameraSession, didFindQuadrangle: quadrangle) showUserGuidance(with: NSLocalizedString("Document found. Remain steady.", comment: "")) } - override func cameraSessionIsAbout(toChooseQuadrangle cameraSession: GSKCameraSession) { - super.cameraSessionIsAbout(toChooseQuadrangle: cameraSession) + override func cameraSessionIsAboutToChooseQuadrangle(_ cameraSession: GSKCameraSession) { + super.cameraSessionIsAboutToChooseQuadrangle(cameraSession) // We are indicating to the user that the photo will be taken momentarily by // making the shutter button pulse. addPulseAnimation() } - override func cameraSession(_ cameraSession: GSKCameraSession, willAutoTriggerWith quadrangle: GSKQuadrangle) { - super.cameraSession(cameraSession, willAutoTriggerWith: quadrangle) + override func cameraSession(_ cameraSession: GSKCameraSession, willAutoTriggerWithQuadrangle quadrangle: GSKQuadrangle) { + super.cameraSession(cameraSession, willAutoTriggerWithQuadrangle: quadrangle) removePulseAnimation() } @@ -149,24 +149,24 @@ final class CameraViewController: GSKCameraViewController { } private func setupConstraints() { - cameraView.translatesAutoresizingMaskIntoConstraints = false + captureView.translatesAutoresizingMaskIntoConstraints = false let topMargin: CGFloat = 40 let bottomToolbarHeight: CGFloat = 124 NSLayoutConstraint.activate([ - cameraView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - cameraView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - cameraView.topAnchor.constraint(equalTo: view.topAnchor, constant: topMargin), - cameraView.bottomAnchor.constraint(equalTo: toolbar.topAnchor), + captureView.leadingAnchor.constraint(equalTo: view.leadingAnchor), + captureView.trailingAnchor.constraint(equalTo: view.trailingAnchor), + captureView.topAnchor.constraint(equalTo: view.topAnchor, constant: topMargin), + captureView.bottomAnchor.constraint(equalTo: toolbar.topAnchor), toolbar.heightAnchor.constraint(equalToConstant: bottomToolbarHeight), toolbar.bottomAnchor.constraint(equalTo: view.bottomAnchor), toolbar.leadingAnchor.constraint(equalTo: view.leadingAnchor), toolbar.trailingAnchor.constraint(equalTo: view.trailingAnchor), cameraButton.centerXAnchor.constraint(equalTo: toolbar.centerXAnchor), cameraButton.centerYAnchor.constraint(equalTo: toolbar.centerYAnchor), - userGuidanceLabel.centerXAnchor.constraint(equalTo: cameraView.centerXAnchor), - userGuidanceLabel.leadingAnchor.constraint(equalTo: cameraView.layoutMarginsGuide.leadingAnchor), + userGuidanceLabel.centerXAnchor.constraint(equalTo: captureView.centerXAnchor), + userGuidanceLabel.leadingAnchor.constraint(equalTo: captureView.layoutMarginsGuide.leadingAnchor), toolbar.topAnchor.constraint(equalToSystemSpacingBelow: userGuidanceLabel.bottomAnchor, multiplier: 1) ]) } diff --git a/ios/GSSDKSimpleDemo/GSSDKSimpleDemo.xcodeproj/project.pbxproj b/ios/GSSDKSimpleDemo/GSSDKSimpleDemo.xcodeproj/project.pbxproj index 1e2a5e5..81849c3 100644 --- a/ios/GSSDKSimpleDemo/GSSDKSimpleDemo.xcodeproj/project.pbxproj +++ b/ios/GSSDKSimpleDemo/GSSDKSimpleDemo.xcodeproj/project.pbxproj @@ -539,7 +539,7 @@ repositoryURL = "https://github.com/thegrizzlylabs/geniusscan-sdk-spm"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 5.0.8; + minimumVersion = 5.1.0; }; }; /* End XCRemoteSwiftPackageReference section */ diff --git a/react-native-genius-scan-demo/ios/Podfile.lock b/react-native-genius-scan-demo/ios/Podfile.lock index 91d9a70..c515bd4 100644 --- a/react-native-genius-scan-demo/ios/Podfile.lock +++ b/react-native-genius-scan-demo/ios/Podfile.lock @@ -352,8 +352,6 @@ PODS: - React-perflogger (= 0.71.14) - RNFileViewer (2.1.4): - React-Core - - RNFS (2.20.0): - - React-Core - RNGeniusScan (1.0.0): - React - Yoga (1.14.0) @@ -395,7 +393,6 @@ DEPENDENCIES: - React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`) - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) - RNFileViewer (from `../node_modules/react-native-file-viewer`) - - RNFS (from `../node_modules/react-native-fs`) - "RNGeniusScan (from `../node_modules/@thegrizzlylabs/react-native-genius-scan`)" - Yoga (from `../node_modules/react-native/ReactCommon/yoga`) @@ -473,8 +470,6 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon" RNFileViewer: :path: "../node_modules/react-native-file-viewer" - RNFS: - :path: "../node_modules/react-native-fs" RNGeniusScan: :path: "../node_modules/@thegrizzlylabs/react-native-genius-scan" Yoga: @@ -517,7 +512,6 @@ SPEC CHECKSUMS: React-runtimeexecutor: ffe826b7b1cfbc32a35ed5b64d5886c0ff75f501 ReactCommon: 7f3dd5e98a9ec627c6b03d26c062bf37ea9fc888 RNFileViewer: 83cc066ad795b1f986791d03b56fe0ee14b6a69f - RNFS: 4ac0f0ea233904cb798630b3c077808c06931688 RNGeniusScan: d9ffb40cb8ebf416612aae9668ae9a448a89ca93 Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9 diff --git a/react-native-genius-scan-demo/package.json b/react-native-genius-scan-demo/package.json index 43b62ce..ec43ceb 100644 --- a/react-native-genius-scan-demo/package.json +++ b/react-native-genius-scan-demo/package.json @@ -10,7 +10,7 @@ "lint": "eslint ." }, "dependencies": { - "@thegrizzlylabs/react-native-genius-scan": "^5.0.8", + "@thegrizzlylabs/react-native-genius-scan": "^5.1.0", "react": "18.2.0", "react-native": "0.71.14", "react-native-file-viewer": "^2.1.4"