Skip to content

Commit

Permalink
Update demos for version 5.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
The Grizzly Labs committed Jun 19, 2024
1 parent ea1ebae commit acdd1a0
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 66 deletions.
2 changes: 1 addition & 1 deletion android/demo-custom/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -20,8 +20,6 @@

import java.io.File;

import androidx.appcompat.app.AppCompatActivity;

public class ImageProcessingActivity extends AppCompatActivity {

@SuppressWarnings("unused")
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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) {
Expand Down Expand Up @@ -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));
}
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void processPage(Context context, Page page) throws LicenseException, Pro
Configuration<File> 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))
);
Expand All @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion android/demo-custom/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
<string name="capture">Capture</string>
<string name="enhancement_dialog_title">Please select the enhancement to apply</string>
<string name="image_type_none">None</string>
<string name="image_type_auto">Automatic</string>
<string name="image_type_color">Color</string>
<string name="image_type_whiteboard">Whiteboard</string>
<string name="image_type_photo">Photo</string>
<string name="image_type_black_white">Black &amp; White</string>

<plurals name="page_count">
Expand Down
2 changes: 1 addition & 1 deletion android/demo-simple/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion cordova-plugin-genius-scan-demo/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<engine name="android" spec="~12.0.0" />
<plugin name="cordova-plugin-file" spec="^6.0.1" />
<plugin name="cordova-plugin-preview-any-file" spec="^0.2.9" />
<plugin name="@thegrizzlylabs/cordova-plugin-genius-scan" spec="@thegrizzlylabs/cordova-plugin-genius-scan@5.0.8">
<plugin name="@thegrizzlylabs/cordova-plugin-genius-scan" spec="@thegrizzlylabs/cordova-plugin-genius-scan@5.1.0">
<variable name="CAMERA_USAGE_DESCRIPTION" value="Access camera for demo" />
</plugin>
</widget>
4 changes: 2 additions & 2 deletions dotnet-maui/SimpleDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
<PackageReference Include="GeniusScanSDK.ScanFlow.Android" Version="5.0.8" />
<PackageReference Include="GeniusScanSDK.ScanFlow.Android" Version="5.1.0" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
<PackageReference Include="GeniusScanSDK.ScanFlow.iOS" Version="5.0.8" />
<PackageReference Include="GeniusScanSDK.ScanFlow.iOS" Version="5.1.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion flutter-plugin-genius-scan-demo/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion flutter-plugin-genius-scan-demo/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, *) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}()

Expand Down Expand Up @@ -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
Expand All @@ -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()
}
Expand Down Expand Up @@ -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)
])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
6 changes: 0 additions & 6 deletions react-native-genius-scan-demo/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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`)

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -517,7 +512,6 @@ SPEC CHECKSUMS:
React-runtimeexecutor: ffe826b7b1cfbc32a35ed5b64d5886c0ff75f501
ReactCommon: 7f3dd5e98a9ec627c6b03d26c062bf37ea9fc888
RNFileViewer: 83cc066ad795b1f986791d03b56fe0ee14b6a69f
RNFS: 4ac0f0ea233904cb798630b3c077808c06931688
RNGeniusScan: d9ffb40cb8ebf416612aae9668ae9a448a89ca93
Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9

Expand Down
Loading

0 comments on commit acdd1a0

Please sign in to comment.