diff --git a/example/RNExampleApp/android/.project b/example/RNExampleApp/android/.project index 11d1f9d6..33b4feb8 100644 --- a/example/RNExampleApp/android/.project +++ b/example/RNExampleApp/android/.project @@ -16,12 +16,12 @@ - 1644311700747 + 1669021212230 30 org.eclipse.core.resources.regexFilterMatcher - node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ diff --git a/example/RNExampleApp/android/app/.project b/example/RNExampleApp/android/app/.project index fcbad646..7a185896 100644 --- a/example/RNExampleApp/android/app/.project +++ b/example/RNExampleApp/android/app/.project @@ -22,12 +22,12 @@ - 1644311700752 + 1669021212234 30 org.eclipse.core.resources.regexFilterMatcher - node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ diff --git a/example/RNExampleApp/android/app/build.gradle b/example/RNExampleApp/android/app/build.gradle index eb8fea7c..eb661ba0 100644 --- a/example/RNExampleApp/android/app/build.gradle +++ b/example/RNExampleApp/android/app/build.gradle @@ -160,8 +160,6 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } - - } @@ -177,13 +175,19 @@ dependencies { else { implementation jscFlavor } implementation project(':anyline-ocr-react-native-module') implementation fileTree(dir: "libs", include: ["*.jar"]) - implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" + implementation 'androidx.appcompat:appcompat:1.2.0' implementation "com.facebook.react:react-native:+" // From node_modules implementation 'androidx.multidex:multidex:2.0.1' } +configurations.all { + resolutionStrategy { + force 'androidx.core:core:1.5.0' + } +} + // Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) { diff --git a/example/RNExampleApp/android/build.gradle b/example/RNExampleApp/android/build.gradle index d14daf00..410d91a9 100644 --- a/example/RNExampleApp/android/build.gradle +++ b/example/RNExampleApp/android/build.gradle @@ -2,11 +2,10 @@ buildscript { ext { - buildToolsVersion = "29.0.3" + buildToolsVersion = "33.0.0" minSdkVersion = 21 - compileSdkVersion = 29 - targetSdkVersion = 29 - supportLibVersion = "28.0.0" + compileSdkVersion = 31 + targetSdkVersion = 31 ndkVersion = "20.1.5948944" } repositories { diff --git a/example/RNExampleApp/android/gradle/wrapper/gradle-wrapper.properties b/example/RNExampleApp/android/gradle/wrapper/gradle-wrapper.properties index 3c9d0852..cb24abda 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-6.7-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip diff --git a/example/RNExampleApp/package.json b/example/RNExampleApp/package.json index e42edc2f..42ad6a51 100644 --- a/example/RNExampleApp/package.json +++ b/example/RNExampleApp/package.json @@ -4,8 +4,8 @@ "private": true, "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", - "reinstall": "yarn remove anyline-ocr-react-native-module && yarn add ../../plugin && react-native link", - "reinstall-pods": "cd ios/ && rm -rf Pods Podfile.lock && pod update --verbose && cd .. && react-native link", + "reinstall": "yarn remove anyline-ocr-react-native-module && yarn add ../../plugin && yarn react-native link", + "reinstall-pods": "cd ios/ && rm -rf Pods Podfile.lock && pod update --verbose && cd .. && yarn react-native link", "test": "jest", "bundleAndroid": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/", "bundleiOS": "react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios" @@ -16,7 +16,7 @@ "hermes-engine": "^0.7.2", "jsc-android": "^241213.1.0", "react": "17.0.2", - "react-native": "0.67.2" + "react-native": "0.67.5" }, "devDependencies": { "@babel/core": "^7.12.9", diff --git a/example/RNExampleApp/src/Result.js b/example/RNExampleApp/src/Result.js index e1fedf8b..ece3c549 100755 --- a/example/RNExampleApp/src/Result.js +++ b/example/RNExampleApp/src/Result.js @@ -1,4 +1,7 @@ -import React from 'react'; +import React, { + Component, + useState +} from 'react'; import { Button, Image, @@ -7,9 +10,12 @@ import { Text, View, Dimensions, + Platform, TouchableWithoutFeedback, + TextInput, } from 'react-native'; import {flattenObject} from './utils/utils'; +import AnylineOCR from 'anyline-ocr-react-native-module'; const withoutImagePaths = value => value !== 'imagePath' && value !== 'fullImagePath'; @@ -23,6 +29,66 @@ export default function Result({ hasBackButton, title = false, }) { + + const [correctedResult, setCorrectedResult] = useState(''); + const [responseText, setResponseText] = useState(''); + + let onReportCorrectedResultResponseHandler = function(response) { + /* + The response is a string with the following style if it's an error: + { + "code": , + "message": { + "code": , + "timestamp": , + "path": , + "method": , + "message": + } + } + + If the response is successful it looks like this: + { + "code" : 201, + "message" : { + "message": "ok" + } + } + */ + var parsedResponse = JSON.parse(response); + if(parsedResponse["code"] === 201){ + setResponseText("Sending corrected result was successful."); + } else { + setResponseText("Error while sending corrected result: " + parsedResponse["message"]); + } + } + + let onReportCorrectedResultPressed = function() { + let blobKey = result["blobKey"]; + + if(typeof blobKey === 'undefined' || blobKey === '' || blobKey === null){ + setResponseText("Only licenses with 'debugReporting' set to 'on' allow user corrected results."); + } else if(correctedResult !== "") { + setResponseText("Waiting for response..."); + AnylineOCR.reportCorrectedResult(result["blobKey"], correctedResult, onReportCorrectedResultResponseHandler); + } + }; + + let reportCorrectedResultButton = ( + + setCorrectedResult(newCorrectedResult) } + /> +