Skip to content

Commit

Permalink
Merge pull request #156 from Anyline/release/42.2.0
Browse files Browse the repository at this point in the history
Release/42.2.0
  • Loading branch information
patrickAnyline authored Nov 25, 2022
2 parents 579f6cd + 71b5f96 commit db57175
Show file tree
Hide file tree
Showing 13 changed files with 218 additions and 138 deletions.
4 changes: 2 additions & 2 deletions example/RNExampleApp/android/.project
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
</natures>
<filteredResources>
<filter>
<id>1644311700747</id>
<id>1669021212230</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
Expand Down
4 changes: 2 additions & 2 deletions example/RNExampleApp/android/app/.project
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
</natures>
<filteredResources>
<filter>
<id>1644311700752</id>
<id>1669021212234</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
Expand Down
14 changes: 9 additions & 5 deletions example/RNExampleApp/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ android {
applicationId "com.anyline.example.reactnative"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 4
versionName "42.0.0"
versionCode 5
versionName "42.2.0"
multiDexEnabled true

}
Expand Down Expand Up @@ -160,8 +160,6 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}


}


Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
7 changes: 3 additions & 4 deletions example/RNExampleApp/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions example/RNExampleApp/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "RNExampleApp",
"version": "42.0.0",
"version": "42.2.0",
"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"
Expand All @@ -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",
Expand Down
77 changes: 76 additions & 1 deletion example/RNExampleApp/src/Result.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import React from 'react';
import React, {
Component,
useState
} from 'react';
import {
Button,
Image,
Expand All @@ -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';
Expand All @@ -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": <Error code>,
"message": {
"code": <Error code>,
"timestamp": <Timestamp>,
"path": <Endpoint URL of our Api>,
"method": <POST, GET etc.>,
"message": <Error 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 = (
<View
style={styles.reportCorrectedResultButtonStyle}
>
<TextInput
placeholder='Enter corrected result'
backgroundColor='white'
marginBottom={16}
onChangeText={ newCorrectedResult => setCorrectedResult(newCorrectedResult) }
/>
<Button title={'Report corrected result'} onPress={onReportCorrectedResultPressed} />
<Text style={styles.text}>{responseText}</Text>
</View>
);

let fullImage = <View />;
let fullImageText = <View />;
if (fullImagePath && fullImagePath !== '') {
Expand Down Expand Up @@ -90,6 +156,7 @@ export default function Result({
</View>
);
})}
{ Platform.OS === 'android' && reportCorrectedResultButton }
{BackButton}
</ScrollView>
</View>
Expand Down Expand Up @@ -163,6 +230,14 @@ const styles = StyleSheet.create({
alignSelf: 'center',
},

reportCorrectedResultButtonStyle: {
marginTop: 25,
width: Dimensions.get('window').width,
alignSelf: 'center',
paddingLeft: 24,
paddingRight: 24
},

titleText: {
color: '#0099FF',
fontSize: 20
Expand Down
8 changes: 4 additions & 4 deletions plugin/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ allprojects {


android {
compileSdkVersion 28
compileSdkVersion rootProject.ext.compileSdkVersion

defaultConfig {
minSdkVersion 21
targetSdkVersion 28
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
ndk {
Expand Down Expand Up @@ -65,7 +65,7 @@ repositories {

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'io.anyline:anylinesdk:42.0.0'
implementation 'io.anyline:anylinesdk:42.2.0'
implementation "com.facebook.react:react-native:+" // from node_modules
implementation("com.google.android.material:material:1.4.0-rc01")
implementation 'androidx.multidex:multidex:2.0.1'
Expand Down
Loading

0 comments on commit db57175

Please sign in to comment.