diff --git a/example/RNExampleApp/android/app/build.gradle b/example/RNExampleApp/android/app/build.gradle
index 451d14b2..664baaa3 100644
--- a/example/RNExampleApp/android/app/build.gradle
+++ b/example/RNExampleApp/android/app/build.gradle
@@ -139,6 +139,13 @@ android {
pickFirst 'lib/x86/libgnustl_shared.so'
pickFirst 'lib/*/libc++_shared.so'
}
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+
+
}
diff --git a/example/RNExampleApp/android/build.gradle b/example/RNExampleApp/android/build.gradle
index 614eb496..92b66c2a 100644
--- a/example/RNExampleApp/android/build.gradle
+++ b/example/RNExampleApp/android/build.gradle
@@ -2,7 +2,7 @@
buildscript {
ext {
- minSdkVersion = 19
+ minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
@@ -43,7 +43,7 @@ allprojects {
}
-task wrapper(type: Wrapper) {
- gradleVersion = '4.7'
- distributionUrl = distributionUrl.replace("bin", "all")
-}
+//task wrapper(type: Wrapper) {
+// gradleVersion = '5.4'
+// distributionUrl = distributionUrl.replace("bin", "all")
+//}
diff --git a/example/RNExampleApp/android/gradle/wrapper/gradle-wrapper.properties b/example/RNExampleApp/android/gradle/wrapper/gradle-wrapper.properties
index b10568fb..7a14979b 100644
--- a/example/RNExampleApp/android/gradle/wrapper/gradle-wrapper.properties
+++ b/example/RNExampleApp/android/gradle/wrapper/gradle-wrapper.properties
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip
diff --git a/example/RNExampleApp/config/DocumentConfig.js b/example/RNExampleApp/config/DocumentConfig.js
index a8be4259..88c553e1 100755
--- a/example/RNExampleApp/config/DocumentConfig.js
+++ b/example/RNExampleApp/config/DocumentConfig.js
@@ -57,6 +57,11 @@ export default {
},
"cancelOnResult": true
},
+ "document": {
+ "manualCaptureButton": {
+ "buttonColor": "0099ff"
+ }
+ },
quality: 90
},
}
diff --git a/example/RNExampleApp/config/TINConfig.js b/example/RNExampleApp/config/TINConfig.js
index bb2aae00..0fb40e27 100644
--- a/example/RNExampleApp/config/TINConfig.js
+++ b/example/RNExampleApp/config/TINConfig.js
@@ -16,49 +16,48 @@ export default {
'NE9tUzVraWdNUVZLaW8vaWlJS2tIVEVUdUxjYWJEWWtacExZdVR2YnU1S1hIc0R6\n' +
'b1NxUUJTL3ZFS3VYUHhhCjNnanZnS285M3lrSjJKQjVBZjZiSkE9PQo=',
options: {
- camera: {
- captureResolution: '720p',
- },
- flash: {
- mode: 'manual',
- alignment: 'bottom_right',
- imageOn: 'flash_on',
- imageOff: 'flash_off',
- },
- viewPlugin: {
- plugin: {
- id: 'TIN',
- ocrPlugin: {
- tinConfig: {},
- },
+ "camera": {
+ "captureResolution": "720p"
},
- cutoutConfig: {
- style: 'rect',
- width: 720,
- alignment: 'center',
- maxWidthPercent: '80%',
- ratioFromSize: {
- width: 720,
- height: 144,
- },
- outerColor: '000000',
- outerAlpha: 0.3,
- strokeWidth: 2,
- strokeColor: 'FFFFFF',
- cornerRadius: 2,
- feedbackStrokeColor: '0099FF',
+ "flash": {
+ "mode": "manual",
+ "alignment": "bottom_right"
},
- scanFeedback: {
- animation: 'traverse_multi',
- animationDuration: 250,
- style: 'contour_rect',
- strokeWidth: 2,
- strokeColor: '0099FF',
- beepOnResult: true,
- vibrateOnResult: true,
- blinkAnimationOnResult: true,
- },
- cancelOnResult: true,
- },
- },
-};
+ "viewPlugin" : {
+ "plugin": {
+ "id": "TIN",
+ "ocrPlugin": {
+ "tinConfig":{
+ }
+ }
+ },
+ "cutoutConfig" : {
+ "style": "rect",
+ "width": 720,
+ "alignment": "center",
+ "maxWidthPercent": "80%",
+ "ratioFromSize": {
+ "width": 720,
+ "height": 144
+ },
+ "outerColor": "000000",
+ "outerAlpha": 0.3,
+ "strokeWidth": 2,
+ "strokeColor": "FFFFFF",
+ "cornerRadius": 2,
+ "feedbackStrokeColor": "0099FF"
+ },
+ "scanFeedback" : {
+ "animation": "traverse_multi",
+ "animationDuration" : 250,
+ "style": "contour_rect",
+ "strokeWidth": 2,
+ "strokeColor": "0099FF",
+ "beepOnResult": true,
+ "vibrateOnResult": true,
+ "blinkAnimationOnResult": true
+ },
+ "cancelOnResult" : true
+ }
+ }
+}
diff --git a/example/RNExampleApp/ios/RNExampleApp/Info.plist b/example/RNExampleApp/ios/RNExampleApp/Info.plist
index 0fa729c2..75a0c005 100644
--- a/example/RNExampleApp/ios/RNExampleApp/Info.plist
+++ b/example/RNExampleApp/ios/RNExampleApp/Info.plist
@@ -23,7 +23,7 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 20.0.0
+ 21.0.0
CFBundleSignature
????
CFBundleVersion
diff --git a/example/RNExampleApp/package.json b/example/RNExampleApp/package.json
index a0ef571e..934415f5 100644
--- a/example/RNExampleApp/package.json
+++ b/example/RNExampleApp/package.json
@@ -1,6 +1,6 @@
{
"name": "RNExampleApp",
- "version": "20.0.0",
+ "version": "21.0.0",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
diff --git a/example/RNExampleApp/src/Overview_old.js b/example/RNExampleApp/src/Overview_old.js
deleted file mode 100755
index 2a15f106..00000000
--- a/example/RNExampleApp/src/Overview_old.js
+++ /dev/null
@@ -1,214 +0,0 @@
-/**
- * Created by jonas on 14.03.17.
- */
-import React from 'react';
-import { Button, Platform, StyleSheet, Text, View, ScrollView } from 'react-native';
-
-export default function Overview({ openAnyline, checkCameraPermissionAndOpen, disabled }) {
-
- const platformPermissionCheck = (Platform.OS === 'android') ? checkCameraPermissionAndOpen : openAnyline;
-
- return (
-
-
- METER READING
-
-
-
-
-
-
-
-
-
-
-
-
- ID
-
-
-
-
-
-
-
-
-
-
-
-
-
- VEHICLE
-
-
-
-
-
- OCR
-
-
-
-
-
-
- MRO
-
-
-
-
-
-
-
-
-
-
-
-
- OTHER
-
-
-
-
-
-
-
-
-
-
-
- );
-}
-
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- // justifyContent: 'space-between',
- backgroundColor: '#303030',
- marginTop: '40%',
- marginBottom: '20%'
- },
- buttons: {
- margin: 5
- },
- text: {
- color: 'white',
- textAlign: 'center',
- fontSize: 20,
- marginTop: 25
- }
-
-});
diff --git a/example/RNExampleApp/src/Result.js b/example/RNExampleApp/src/Result.js
index 5c4a83cf..e1fedf8b 100755
--- a/example/RNExampleApp/src/Result.js
+++ b/example/RNExampleApp/src/Result.js
@@ -147,6 +147,7 @@ const styles = StyleSheet.create({
fontWeight: 'bold',
marginTop: 10,
marginRight: 20,
+
},
scrollContainer: {
display: 'flex',
@@ -158,13 +159,12 @@ const styles = StyleSheet.create({
backButton: {
marginTop: 25,
- width: '100%',
+ width: Dimensions.get('window').width/4,
alignSelf: 'center',
},
titleText: {
color: '#0099FF',
- fontSize: 20,
- fontWeight: 'bold',
+ fontSize: 20
},
});
diff --git a/example/RNExampleApp/src/index_old.js b/example/RNExampleApp/src/index_old.js
deleted file mode 100755
index fa8e39b8..00000000
--- a/example/RNExampleApp/src/index_old.js
+++ /dev/null
@@ -1,294 +0,0 @@
-import React, {Component} from 'react';
-import {
- AppRegistry,
- BackHandler,
- LayoutAnimation,
- PermissionsAndroid,
- ScrollView,
- StyleSheet,
- Text,
-} from 'react-native';
-
-import AnylineOCR from 'anyline-ocr-react-native-module';
-
-import Result from './Result';
-import Overview from './Overview';
-
-import BarcodeConfig from '../config/BarcodeConfig';
-import BarcodePDF417Config from '../config/Barcode_PDF417Config';
-import DocumentConfig from '../config/DocumentConfig';
-import MRZConfig from '../config/MRZConfig';
-import AutoEnergyConfig from '../config/AutoEnergyConfig';
-import AnalogEnergyConfig from '../config/AnalogMeterConfig';
-import DigitalEnergyConfig from '../config/DigitalMeterConfig';
-import DialEnergyConfig from '../config/DialMeterConfig';
-import IBANConfig from '../config/IbanConfig';
-import VoucherConfig from '../config/VoucherConfig';
-import DrivingLicenseConfig from '../config/DrivingLicenseConfig';
-import LicensePlateConfig from '../config/LicensePlateConfig';
-import SerialNumberConfig from '../config/SerialNumber';
-import VinConfig from '../config/VINConfig';
-import USNRConfig from "../config/USNRConfig";
-import ShipConConfig from "../config/ContainerShipConfig";
-import CattleTagConfig from "../config/CattleTagConfig";
-import GermanIDFrontConfig from '../config/GermanIDFrontConfig';
-import VerticalContainerConfig from '../config/VerticalContainerConfig';
-import SerialScanningConfig from '../config/SerialScanningConfig';
-import TinConfig from '../config/TINConfig';
-
-
-// Disable Warnings
-console.disableYellowBox = true;
-
-class Anyline extends Component {
-
- state = {
- hasScanned: false,
- result: '',
- imagePath: '',
- fullImagePath: '',
- currentScanMode: '',
- buttonsDisabled: false,
- SDKVersion: '',
- };
- componentDidMount = async () => {
- const SDKVersion = await AnylineOCR.getSDKVersion();
- this.setState({SDKVersion: SDKVersion});
- }
-
- componentWillUpdate() {
- LayoutAnimation.easeInEaseOut();
- }
-
- openAnyline = async (type) => {
-
- this.setState({buttonsDisabled: true});
- let config;
-
- this.setState({
- currentScanMode: type
- });
- switch (type) {
- case 'AUTO_ANALOG_DIGITAL_METER':
- config = AutoEnergyConfig;
- break;
- case 'DIAL_METER':
- config = DialEnergyConfig;
- break;
- case 'SERIAL_NUMBER':
- config = SerialNumberConfig;
- break;
- case 'DOT_MATRIX_METER':
- config = AutoEnergyConfig;
- break;
- case 'BARCODE':
- config = BarcodeConfig;
- break;
- case 'BARCODE_PDF417':
- config = BarcodePDF417Config;
- break;
- case 'IBAN':
- type = 'ANYLINE_OCR';
- config = IBANConfig;
- break;
- case 'VOUCHER':
- type = 'ANYLINE_OCR';
- config = VoucherConfig;
- break;
- case 'DRIVING_LICENSE':
- type = 'ANYLINE_OCR';
- config = DrivingLicenseConfig;
- break;
- case 'VIN':
- type = 'ANYLINE_OCR';
- config = VinConfig;
- break;
- case 'TIN':
- type = 'ANYLINE_OCR';
- config = TinConfig;
- break;
- case 'USNR':
- type = 'ANYLINE_OCR';
- config = USNRConfig;
- break;
- case 'SHIPPING_CONTAINER':
- type = 'ANYLINE_OCR';
- config = ShipConConfig;
- break;
- case 'CATTLE_TAG':
- type = 'ANYLINE_OCR';
- config = CattleTagConfig;
- break;
- case 'MRZ':
- config = MRZConfig;
- break;
- case 'GERMAN_ID_FRONT':
- config = GermanIDFrontConfig;
- break;
- case 'LICENSE_PLATE':
- config = LicensePlateConfig;
- break;
- case 'DOCUMENT':
- config = DocumentConfig;
- break;
- case 'ANALOG_METER':
- config = AnalogEnergyConfig;
- break;
- case 'DIGITAL_METER':
- config = DigitalEnergyConfig;
- break;
- case 'VERTICAL_CONTAINER':
- config = VerticalContainerConfig;
- break;
- case 'SERIAL_SCANNING':
- config = SerialScanningConfig;
- break;
- }
-
-
- try {
- const result = await AnylineOCR.setupPromise(JSON.stringify(config), 'scan');
-
- console.log(result);
- this.setState({buttonsDisabled: false});
-
- const data = JSON.parse(result);
- LayoutAnimation.easeInEaseOut();
- const fullImagePath = data.fullImagePath;
- const imagePath = data.imagePath;
- delete data.fullImagePath;
- delete data.imagePath;
-
- this.setState({
- hasScanned: true,
- result: data,
- imagePath: imagePath,
- fullImagePath: fullImagePath,
- });
- } catch (error) {
- if (error !== 'Canceled') {
- console.log(error);
- }
- }
- this.setState({buttonsDisabled: false});
- };
-
- requestCameraPermission = async (type) => {
-
- try {
- const granted = await PermissionsAndroid.request(
- PermissionsAndroid.PERMISSIONS.CAMERA,
- {
- 'title': 'Anyline Camera Permissions',
- 'message': 'Allow Anyline to access you camera?'
- }
- );
- if (granted === PermissionsAndroid.RESULTS.GRANTED) {
- console.log('Camera permission allowed');
- this.openAnyline(type);
- } else {
- console.log("Camera permission denied");
- }
- } catch (err) {
- console.warn(err);
- }
- };
-
- hasCameraPermission = async () => {
- try {
- return await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.CAMERA);
- } catch (err) {
- console.warn(err, 'PERMISSION CHECK');
- }
- };
-
- checkCameraPermissionAndOpen = (type) => {
- this.hasCameraPermission().then((hasCameraPermission) => {
- console.log('hasCameraPermission result is ' + hasCameraPermission);
- if (hasCameraPermission) {
- console.log('Opening OCR directly');
- this.openAnyline(type);
- } else {
- this.requestCameraPermission(type);
- }
- });
- };
-
- emptyResult = () => {
- this.setState({
- hasScanned: false,
- result: '',
- imagePath: '',
- fullImagePath: ''
- });
- };
-
-
- render() {
-
- const {
- hasScanned,
- result,
- imagePath,
- fullImagePath,
- currentScanMode,
- buttonsDisabled,
- SDKVersion
- } = this.state;
-
- BackHandler.addEventListener('hardwareBackPress', () => {
- if (hasScanned) {
- this.emptyResult();
- return true;
- } else {
- BackHandler.exitApp();
- }
- });
-
- return (
-
- Anyline React-Native Example
- {hasScanned ? (
-
- ) : }
- SDK Version: {SDKVersion}
- RN-Build Number: 1
-
- );
- }
-}
-
-
-const styles = StyleSheet.create({
- versions: {
- color: "white",
- marginTop: 10
- },
- container: {
- flex: 1,
- width: "100%",
- backgroundColor: '#303030'
- },
- ContainerContent: {
- alignItems: 'center',
- justifyContent: 'space-around',
- },
- headline: {
- fontSize: 20,
- fontWeight: 'bold',
- color: "white",
- marginTop: 50
- }
-});
-
-AppRegistry.registerComponent('RNExampleApp', () => Anyline);
diff --git a/plugin/android/build.gradle b/plugin/android/build.gradle
index 4f642cd6..b5b79842 100755
--- a/plugin/android/build.gradle
+++ b/plugin/android/build.gradle
@@ -6,7 +6,8 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.1.3'
+ classpath 'com.android.tools.build:gradle:3.2.1'
+
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -24,7 +25,7 @@ android {
compileSdkVersion 28
defaultConfig {
- minSdkVersion 19
+ minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
@@ -48,6 +49,12 @@ android {
pickFirst('lib/*/libgnustl_shared.so')
pickFirst('lib/*/libopencv_java3.so')
}
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+
}
repositories {
@@ -61,8 +68,7 @@ repositories {
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
- implementation 'io.anyline:anylinesdk:20@aar'
-
+ implementation 'io.anyline:anylinesdk:21@aar'
implementation 'com.google.firebase:firebase-ml-vision:19.0.2'
implementation 'com.google.firebase:firebase-ml-vision-face-model:17.0.2'
implementation "com.facebook.react:react-native:+" // From node_modules
diff --git a/plugin/android/src/main/java/com/anyline/reactnative/Anyline4Activity.java b/plugin/android/src/main/java/com/anyline/reactnative/Anyline4Activity.java
index 6aa10baf..f2991d7d 100644
--- a/plugin/android/src/main/java/com/anyline/reactnative/Anyline4Activity.java
+++ b/plugin/android/src/main/java/com/anyline/reactnative/Anyline4Activity.java
@@ -453,7 +453,7 @@ public void onCameraOpened(CameraController cameraController, int width, int hei
public void run() {
if (radioGroup != null) {
//orig: Rect rect = anylineScanView.getScanViewPlugin().getCutoutImageOnSurface(); // =cutoutRect.rectOnVisibleView
- Rect rect = ((MeterScanViewPlugin) scanViewPlugin).getCutoutRectOnVisibleView();
+ Rect rect = ((MeterScanViewPlugin) scanViewPlugin).getCutoutRect().rectOnVisibleView;
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) radioGroup.getLayoutParams();
// lp.setMargins(50 + anylineUIConfig.getOffsetX(), anylineUIConfig.getOffsetY(), 0,
diff --git a/plugin/android/src/main/java/com/anyline/reactnative/Document4Activity.java b/plugin/android/src/main/java/com/anyline/reactnative/Document4Activity.java
index f4b4169e..47816a02 100644
--- a/plugin/android/src/main/java/com/anyline/reactnative/Document4Activity.java
+++ b/plugin/android/src/main/java/com/anyline/reactnative/Document4Activity.java
@@ -4,6 +4,7 @@
import android.animation.ValueAnimator;
import android.app.ProgressDialog;
import android.graphics.Bitmap;
+import android.graphics.Color;
import android.graphics.PointF;
import android.os.Bundle;
import android.util.Log;
@@ -14,6 +15,7 @@
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
+import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
@@ -54,13 +56,15 @@ public class Document4Activity extends AnylineBaseActivity implements CameraOpen
private long lastErrorRecieved = 0;
private int quality = 100;
private Runnable errorMessageCleanup;
+ private ImageButton btnCapture;
+ JSONObject jsonResult;
private android.os.Handler handler = new android.os.Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(getResources().getIdentifier("activity_scan_scanview", "layout", getPackageName()));
+ setContentView(getResources().getIdentifier("activity_scan_document", "layout", getPackageName()));
// takes care of fading the error message out after some time with no error reported from the SDK
@@ -101,14 +105,53 @@ public void run() {
documentScanView.setCameraOpenListener(this);
// the view can be configured via a json file in the assets, and this config is set here
+ JSONObject json = null;
try {
- final JSONObject json = new JSONObject(configJson);
+ json = new JSONObject(configJson);
documentScanView.setScanConfig(json, licenseKey);
} catch (Exception e) {
e.printStackTrace();
+ Log.i(TAG, "**************** Exception: " + e);
}
+ btnCapture = findViewById(getResources().getIdentifier("capture", "id", getPackageName()));
+ // get Document specific Configs
+ if (json.has("document")) {
+ try {
+ // Get the Document specific Config
+ JSONObject documentConfig = json.getJSONObject("document");
+
+ // set manual capture Button Config
+ if (documentConfig.has("manualCaptureButton")) {
+ JSONObject manCapBtnConf = documentConfig.getJSONObject("manualCaptureButton");
+
+ if (manCapBtnConf.has("buttonColor")) {
+ //btnCapture.setBackgroundColor(Color.parseColor("#" + manCapBtnConf.getString("buttonColor")));
+ btnCapture.setColorFilter(Color.parseColor("#" + manCapBtnConf.getString("buttonColor")));
+
+ }
+
+ // init Manual Capture Button
+ btnCapture.setVisibility(View.VISIBLE);
+ btnCapture.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ btnCapture.setClickable(false);
+ documentScanView.stop();
+ ((DocumentScanViewPlugin) documentScanView.getScanViewPlugin()).triggerPictureCornerDetection();
+ }
+ });
+
+ } else {
+ btnCapture.setVisibility(View.GONE);
+ }
+
+ } catch (JSONException e) {
+ Log.e(TAG, e.getMessage());
+ }
+ }
// initialize Anyline with the license key and a Listener that is called if a result is found
documentScanView.getScanViewPlugin().addScanResultListener(new DocumentScanResultListener() {
@@ -119,6 +162,7 @@ public void onResult(ScanResult documentResult) {
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
+ btnCapture.setClickable(false);
AnylineImage transformedImage = (AnylineImage) documentResult.getResult();
AnylineImage fullFrame = documentResult.getFullImage();
@@ -158,7 +202,8 @@ public void onResult(ScanResult documentResult) {
File outDir = new File(getCacheDir(), "ok");
outDir.mkdir();
// change the file ending to png if you want a png
- JSONObject jsonResult = new JSONObject();
+ //JSONObject
+ jsonResult = new JSONObject();
try {
// convert the transformed image into a gray scaled image internally
// transformedImage.getGrayCvMat(false);
@@ -166,9 +211,10 @@ public void onResult(ScanResult documentResult) {
// Bitmap bmp = transformedImage.getBitmap();
// save the image with quality 100 (only used for jpeg, ignored for png)
File imageFile = TempFileUtil.createTempFileCheckCache(Document4Activity.this,
- UUID.randomUUID().toString(), ".jpg");
+ UUID.randomUUID().toString(), ".jpg");
transformedImage.save(imageFile, quality);
- showToast(getString(getResources().getIdentifier("document_image_saved_to", "string", getPackageName())) + " " + imageFile.getAbsolutePath());
+ showToast(getString(
+ getResources().getIdentifier("document_image_saved_to", "string", getPackageName())) + " " + imageFile.getAbsolutePath());
jsonResult.put("imagePath", imageFile.getAbsolutePath());
@@ -176,7 +222,7 @@ public void onResult(ScanResult documentResult) {
// Save the Full Frame Image
if (fullFrame != null) {
imageFile = TempFileUtil.createTempFileCheckCache(Document4Activity.this,
- UUID.randomUUID().toString(), ".jpg");
+ UUID.randomUUID().toString(), ".jpg");
fullFrame.save(imageFile, quality);
jsonResult.put("fullImagePath", imageFile.getAbsolutePath());
}
@@ -209,10 +255,9 @@ public void onResult(ScanResult documentResult) {
setResult(AnylineSDKPlugin.RESULT_OK);
finish();
} else {
+ btnCapture.setClickable(true);
ResultReporter.onResult(jsonResult, false);
}
-
-
}
@@ -241,7 +286,7 @@ public void onPictureProcessingFailure(DocumentScanViewPlugin.DocumentError docu
// if there is a problem, here is how images could be saved in the error case
// this will be a full, not cropped, not transformed image
- AnylineImage image = ((DocumentScanViewPlugin)documentScanView.getScanViewPlugin()).getCurrentFullImage();
+ AnylineImage image = ((DocumentScanViewPlugin) documentScanView.getScanViewPlugin()).getCurrentFullImage();
if (image != null) {
File outDir = new File(getCacheDir(), "error");
@@ -268,9 +313,11 @@ public boolean onDocumentOutlineDetected(List rect, boolean documentShapeAndBrig
@Override
public void onTakePictureSuccess() {
// this is called after the image has been captured from the camera and is about to be processed
- progressDialog = ProgressDialog.show(Document4Activity.this, getString(getResources().getIdentifier("document_processing_picture_header", "string", getPackageName())),
- getString(getResources().getIdentifier("document_processing_picture", "string", getPackageName())),
- true);
+ progressDialog = ProgressDialog.show(Document4Activity.this, getString(
+ getResources().getIdentifier("document_processing_picture_header", "string", getPackageName())),
+ getString(
+ getResources().getIdentifier("document_processing_picture", "string", getPackageName())),
+ true);
if (errorMessageAnimator != null && errorMessageAnimator.isRunning()) {
@@ -293,16 +340,76 @@ public void onTakePictureError(Throwable throwable) {
}
@Override
- public void onPictureCornersDetected(AnylineImage anylineImage, List rect) {
+ public void onPictureCornersDetected(AnylineImage anylineImage, List list) {
// this is called after manual corner detection was requested
- // Note: not implemented in this example
+
+ // save fullFrame
+ //JSONObject
+ jsonResult = new JSONObject();
+
+ try {
+ File imageFile = TempFileUtil.createTempFileCheckCache(Document4Activity.this, UUID.randomUUID().toString(), ".jpg");
+ anylineImage.save(imageFile, quality);
+ //manualResult.put("fullImagePath", imageFile.getAbsolutePath());
+ jsonResult.put("fullImagePath", imageFile.getAbsolutePath());
+ jsonResult.put("outline", jsonForOutline(list));
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ ((DocumentScanViewPlugin) documentScanView.getScanViewPlugin()).transformPicture(anylineImage, list);
+ anylineImage.release();
}
+
@Override
public void onPictureTransformed(AnylineImage anylineImage) {
// this is called after a full frame image and 4 corners were passed to the SDK for
// transformation (e.g. when a user manually selected the corners in an image)
- // Note: not implemented in this example
+
+ // handle the result document images here
+ if (progressDialog != null && progressDialog.isShowing()) {
+ progressDialog.dismiss();
+ }
+
+ // save fullFrame
+ try {
+ File imageFile = TempFileUtil.createTempFileCheckCache(Document4Activity.this, UUID.randomUUID().toString(), ".jpg");
+ anylineImage.save(imageFile, quality);
+ jsonResult.put("imagePath", imageFile.getAbsolutePath());
+
+ // if (showSuccessToast) {
+ // // Only show toast if user has specified it should be shown
+ // showToast(getString(getResources().getIdentifier("document_image_saved_to", "string", getPackageName())) + " " + imageFile.getAbsolutePath());
+ // }
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ anylineImage.release();
+
+ Boolean cancelOnResult = true;
+ JSONObject jsonObject;
+ try {
+ jsonObject = new JSONObject(configJson);
+ cancelOnResult = jsonObject.getBoolean("cancelOnResult");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ if (cancelOnResult) {
+ ResultReporter.onResult(jsonResult, true);
+ setResult(AnylineSDKPlugin.RESULT_OK);
+ finish();
+ } else {
+ btnCapture.setClickable(true);
+ ResultReporter.onResult(jsonResult, false);
+ }
}
@Override
@@ -313,7 +420,6 @@ public void onPictureTransformError(DocumentScanViewPlugin.DocumentError documen
});
-
// optionally stop the scan once a valid result was returned
// documentScanView.setCancelOnResult(cancelOnResult);
diff --git a/plugin/android/src/main/res/drawable/manual_picture.png b/plugin/android/src/main/res/drawable/manual_picture.png
new file mode 100644
index 00000000..e1627352
Binary files /dev/null and b/plugin/android/src/main/res/drawable/manual_picture.png differ
diff --git a/plugin/android/src/main/res/layout/activity_scan_document.xml b/plugin/android/src/main/res/layout/activity_scan_document.xml
index 58c55903..eb81a22d 100755
--- a/plugin/android/src/main/res/layout/activity_scan_document.xml
+++ b/plugin/android/src/main/res/layout/activity_scan_document.xml
@@ -1,62 +1,63 @@
-
+
-
+
+ android:id="@+id/image_result"
+ android:layout_width="100dp"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:layout_alignParentBottom="true"
+ android:adjustViewBounds="true" />
+ android:id="@+id/full_image"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentBottom="true"
+ android:adjustViewBounds="true" />
-
+
+ android:id="@+id/error_message_layout"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:visibility="gone"
+ tools:visibility="visible">
+ android:id="@+id/error_message"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:layout_margin="24dp"
+ android:background="@android:color/background_dark"
+ android:gravity="center"
+ android:padding="16dp"
+ android:textColor="@android:color/primary_text_dark"
+ tools:text="Error: image to dark! but I am very very very long and you can not read me" />
diff --git a/plugin/ios/AnylineReact.podspec b/plugin/ios/AnylineReact.podspec
index 9e7922fc..84a67e73 100644
--- a/plugin/ios/AnylineReact.podspec
+++ b/plugin/ios/AnylineReact.podspec
@@ -19,6 +19,6 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/Anyline/anyline-ocr-react-native-module.git", :tag => "#{s.version}" }
s.source_files = "*.{h,m}"
- s.dependency "Anyline", "~> 20"
+ s.dependency "Anyline", "~> 21.0"
s.dependency "React"
end
diff --git a/plugin/package.json b/plugin/package.json
index 5fdc6cb0..e0364364 100644
--- a/plugin/package.json
+++ b/plugin/package.json
@@ -1,6 +1,6 @@
{
- "_from": "anyline-ocr-react-native-module@^20.0.0",
- "_id": "anyline-ocr-react-native-module@20.0.0",
+ "_from": "anyline-ocr-react-native-module@^21.0.0",
+ "_id": "anyline-ocr-react-native-module@21.0.0",
"_inBundle": false,
"_integrity": "sha512-BGi9zNkSsoxXywDBIqzgBRvKUBniQOJHDKBrozZubKthZNRBAj8Ry5tW0Me0yLXt/fauME//hbC0wsenfPJZqw==",
"_location": "/anyline-ocr-react-native-module",
@@ -8,19 +8,19 @@
"_requested": {
"type": "range",
"registry": true,
- "raw": "anyline-ocr-react-native-module@^20.0.0",
+ "raw": "anyline-ocr-react-native-module@^21.0.0",
"name": "anyline-ocr-react-native-module",
"escapedName": "anyline-ocr-react-native-module",
- "rawSpec": "^20.0.0",
+ "rawSpec": "^21.0.0",
"saveSpec": null,
- "fetchSpec": "^20.0.0"
+ "fetchSpec": "^21.0.0"
},
"_requiredBy": [
"/"
],
- "_resolved": "https://registry.npmjs.org/anyline-ocr-react-native-module/-/anyline-ocr-react-native-module-20.0.0.tgz",
+ "_resolved": "https://registry.npmjs.org/anyline-ocr-react-native-module/-/anyline-ocr-react-native-module-21.0.0.tgz",
"_shasum": "62ab2a6c30e365851e5c6951546576a711d9183e",
- "_spec": "anyline-ocr-react-native-module@^20.0.0",
+ "_spec": "anyline-ocr-react-native-module@^21.0.0",
"_where": "/Users/amiransari/Projects/anyline-ocr-react-native-module1/example/RNExampleApp",
"bugs": {
"url": "https://github.com/Anyline/anyline-ocr-react-native-module/issues"
@@ -47,5 +47,5 @@
"type": "git",
"url": "git+https://github.com/Anyline/anyline-ocr-react-native-module.git"
},
- "version": "20.0.0"
+ "version": "21.0.0"
}