@scrumble-nl/react-native-honeywell-scanner 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -0
- package/android/README.md +14 -0
- package/android/build.gradle +150 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/android/gradlew +172 -0
- package/android/gradlew.bat +84 -0
- package/android/libs/DataCollection.jar +0 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/reactlibrary/HoneywellScannerModule.java +126 -0
- package/android/src/main/java/com/reactlibrary/HoneywellScannerPackage.java +24 -0
- package/package.json +36 -0
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# react-native-honeywell-scanner-v2
|
|
2
|
+
|
|
3
|
+
This module is fork of react-native-honeywell-scanner.
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
`$ npm install react-native-honeywell-scanner-v2 --save`
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
```javascript
|
|
11
|
+
import HoneywellScanner from 'react-native-honeywell-scanner-v2';
|
|
12
|
+
|
|
13
|
+
...
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if( HoneywellScanner.isCompatible ) {
|
|
17
|
+
HoneywellScanner.startReader().then((claimed) => {
|
|
18
|
+
console.log(claimed ? 'Barcode reader is claimed' : 'Barcode reader is busy');
|
|
19
|
+
HoneywellScanner.onBarcodeReadSuccess(event => {
|
|
20
|
+
console.log('Received data', event.data);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
return(
|
|
27
|
+
() => {
|
|
28
|
+
HoneywellScanner.stopReader().then(() => {
|
|
29
|
+
console.log("Freedom!!");
|
|
30
|
+
HoneywellScanner.offBarcodeReadSuccess();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
}, []);
|
|
36
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
README
|
|
2
|
+
======
|
|
3
|
+
|
|
4
|
+
If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm:
|
|
5
|
+
|
|
6
|
+
1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed
|
|
7
|
+
2. Be sure to have a `local.properties` file in this folder that points to the Android SDK and NDK
|
|
8
|
+
```
|
|
9
|
+
ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle
|
|
10
|
+
sdk.dir=/Users/{username}/Library/Android/sdk
|
|
11
|
+
```
|
|
12
|
+
3. Delete the `maven` folder
|
|
13
|
+
4. Run `./gradlew installArchives`
|
|
14
|
+
5. Verify that latest set of generated files is in the maven folder with the correct version number
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// android/build.gradle
|
|
2
|
+
|
|
3
|
+
// based on:
|
|
4
|
+
//
|
|
5
|
+
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle
|
|
6
|
+
// original location:
|
|
7
|
+
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle
|
|
8
|
+
//
|
|
9
|
+
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle
|
|
10
|
+
// original location:
|
|
11
|
+
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
|
|
12
|
+
|
|
13
|
+
def DEFAULT_COMPILE_SDK_VERSION = 28
|
|
14
|
+
def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
|
|
15
|
+
def DEFAULT_MIN_SDK_VERSION = 16
|
|
16
|
+
def DEFAULT_TARGET_SDK_VERSION = 28
|
|
17
|
+
|
|
18
|
+
def safeExtGet(prop, fallback) {
|
|
19
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
apply plugin: 'com.android.library'
|
|
23
|
+
apply plugin: 'maven'
|
|
24
|
+
|
|
25
|
+
buildscript {
|
|
26
|
+
// The Android Gradle plugin is only required when opening the android folder stand-alone.
|
|
27
|
+
// This avoids unnecessary downloads and potential conflicts when the library is included as a
|
|
28
|
+
// module dependency in an application project.
|
|
29
|
+
// ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
|
|
30
|
+
if (project == rootProject) {
|
|
31
|
+
repositories {
|
|
32
|
+
google()
|
|
33
|
+
jcenter()
|
|
34
|
+
}
|
|
35
|
+
dependencies {
|
|
36
|
+
classpath 'com.android.tools.build:gradle:3.4.1'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
apply plugin: 'com.android.library'
|
|
42
|
+
apply plugin: 'maven'
|
|
43
|
+
|
|
44
|
+
android {
|
|
45
|
+
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
|
|
46
|
+
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
|
|
47
|
+
defaultConfig {
|
|
48
|
+
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
|
|
49
|
+
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
|
|
50
|
+
versionCode 1
|
|
51
|
+
versionName "1.0"
|
|
52
|
+
}
|
|
53
|
+
lintOptions {
|
|
54
|
+
abortOnError false
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
repositories {
|
|
59
|
+
// ref: https://www.baeldung.com/maven-local-repository
|
|
60
|
+
mavenLocal()
|
|
61
|
+
maven {
|
|
62
|
+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
|
63
|
+
url "$rootDir/../node_modules/react-native/android"
|
|
64
|
+
}
|
|
65
|
+
maven {
|
|
66
|
+
// Android JSC is installed from npm
|
|
67
|
+
url "$rootDir/../node_modules/jsc-android/dist"
|
|
68
|
+
}
|
|
69
|
+
google()
|
|
70
|
+
jcenter()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
dependencies {
|
|
74
|
+
compile fileTree(dir: "libs", include: ["*.jar"])
|
|
75
|
+
//noinspection GradleDynamicVersion
|
|
76
|
+
implementation 'com.facebook.react:react-native:+' // From node_modules
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
def configureReactNativePom(def pom) {
|
|
80
|
+
def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
|
|
81
|
+
|
|
82
|
+
pom.project {
|
|
83
|
+
name packageJson.title
|
|
84
|
+
artifactId packageJson.name
|
|
85
|
+
version = packageJson.version
|
|
86
|
+
group = "com.reactlibrary"
|
|
87
|
+
description packageJson.description
|
|
88
|
+
url packageJson.repository.baseUrl
|
|
89
|
+
|
|
90
|
+
licenses {
|
|
91
|
+
license {
|
|
92
|
+
name packageJson.license
|
|
93
|
+
url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
|
|
94
|
+
distribution 'repo'
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
developers {
|
|
99
|
+
developer {
|
|
100
|
+
id packageJson.author
|
|
101
|
+
name packageJson.author
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
afterEvaluate { project ->
|
|
108
|
+
// some Gradle build hooks ref:
|
|
109
|
+
// https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
|
|
110
|
+
task androidJavadoc(type: Javadoc) {
|
|
111
|
+
source = android.sourceSets.main.java.srcDirs
|
|
112
|
+
classpath += files(android.bootClasspath)
|
|
113
|
+
classpath += files(project.getConfigurations().getByName('compile').asList())
|
|
114
|
+
include '**/*.java'
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
|
|
118
|
+
classifier = 'javadoc'
|
|
119
|
+
from androidJavadoc.destinationDir
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
task androidSourcesJar(type: Jar) {
|
|
123
|
+
classifier = 'sources'
|
|
124
|
+
from android.sourceSets.main.java.srcDirs
|
|
125
|
+
include '**/*.java'
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
android.libraryVariants.all { variant ->
|
|
129
|
+
def name = variant.name.capitalize()
|
|
130
|
+
def javaCompileTask = variant.javaCompileProvider.get()
|
|
131
|
+
|
|
132
|
+
task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
|
|
133
|
+
from javaCompileTask.destinationDir
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
artifacts {
|
|
138
|
+
archives androidSourcesJar
|
|
139
|
+
archives androidJavadocJar
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
task installArchives(type: Upload) {
|
|
143
|
+
configuration = configurations.archives
|
|
144
|
+
repositories.mavenDeployer {
|
|
145
|
+
// Deploy to react-native-event-bridge/maven, ready to publish to npm
|
|
146
|
+
repository url: "file://${projectDir}/../android/maven"
|
|
147
|
+
configureReactNativePom pom
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
Binary file
|
package/android/gradlew
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
|
|
3
|
+
##############################################################################
|
|
4
|
+
##
|
|
5
|
+
## Gradle start up script for UN*X
|
|
6
|
+
##
|
|
7
|
+
##############################################################################
|
|
8
|
+
|
|
9
|
+
# Attempt to set APP_HOME
|
|
10
|
+
# Resolve links: $0 may be a link
|
|
11
|
+
PRG="$0"
|
|
12
|
+
# Need this for relative symlinks.
|
|
13
|
+
while [ -h "$PRG" ] ; do
|
|
14
|
+
ls=`ls -ld "$PRG"`
|
|
15
|
+
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
16
|
+
if expr "$link" : '/.*' > /dev/null; then
|
|
17
|
+
PRG="$link"
|
|
18
|
+
else
|
|
19
|
+
PRG=`dirname "$PRG"`"/$link"
|
|
20
|
+
fi
|
|
21
|
+
done
|
|
22
|
+
SAVED="`pwd`"
|
|
23
|
+
cd "`dirname \"$PRG\"`/" >/dev/null
|
|
24
|
+
APP_HOME="`pwd -P`"
|
|
25
|
+
cd "$SAVED" >/dev/null
|
|
26
|
+
|
|
27
|
+
APP_NAME="Gradle"
|
|
28
|
+
APP_BASE_NAME=`basename "$0"`
|
|
29
|
+
|
|
30
|
+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
31
|
+
DEFAULT_JVM_OPTS='"-Xmx64m"'
|
|
32
|
+
|
|
33
|
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
34
|
+
MAX_FD="maximum"
|
|
35
|
+
|
|
36
|
+
warn () {
|
|
37
|
+
echo "$*"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
die () {
|
|
41
|
+
echo
|
|
42
|
+
echo "$*"
|
|
43
|
+
echo
|
|
44
|
+
exit 1
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
# OS specific support (must be 'true' or 'false').
|
|
48
|
+
cygwin=false
|
|
49
|
+
msys=false
|
|
50
|
+
darwin=false
|
|
51
|
+
nonstop=false
|
|
52
|
+
case "`uname`" in
|
|
53
|
+
CYGWIN* )
|
|
54
|
+
cygwin=true
|
|
55
|
+
;;
|
|
56
|
+
Darwin* )
|
|
57
|
+
darwin=true
|
|
58
|
+
;;
|
|
59
|
+
MINGW* )
|
|
60
|
+
msys=true
|
|
61
|
+
;;
|
|
62
|
+
NONSTOP* )
|
|
63
|
+
nonstop=true
|
|
64
|
+
;;
|
|
65
|
+
esac
|
|
66
|
+
|
|
67
|
+
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|
68
|
+
|
|
69
|
+
# Determine the Java command to use to start the JVM.
|
|
70
|
+
if [ -n "$JAVA_HOME" ] ; then
|
|
71
|
+
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
|
72
|
+
# IBM's JDK on AIX uses strange locations for the executables
|
|
73
|
+
JAVACMD="$JAVA_HOME/jre/sh/java"
|
|
74
|
+
else
|
|
75
|
+
JAVACMD="$JAVA_HOME/bin/java"
|
|
76
|
+
fi
|
|
77
|
+
if [ ! -x "$JAVACMD" ] ; then
|
|
78
|
+
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
|
79
|
+
|
|
80
|
+
Please set the JAVA_HOME variable in your environment to match the
|
|
81
|
+
location of your Java installation."
|
|
82
|
+
fi
|
|
83
|
+
else
|
|
84
|
+
JAVACMD="java"
|
|
85
|
+
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
86
|
+
|
|
87
|
+
Please set the JAVA_HOME variable in your environment to match the
|
|
88
|
+
location of your Java installation."
|
|
89
|
+
fi
|
|
90
|
+
|
|
91
|
+
# Increase the maximum file descriptors if we can.
|
|
92
|
+
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
|
93
|
+
MAX_FD_LIMIT=`ulimit -H -n`
|
|
94
|
+
if [ $? -eq 0 ] ; then
|
|
95
|
+
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
|
96
|
+
MAX_FD="$MAX_FD_LIMIT"
|
|
97
|
+
fi
|
|
98
|
+
ulimit -n $MAX_FD
|
|
99
|
+
if [ $? -ne 0 ] ; then
|
|
100
|
+
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
|
101
|
+
fi
|
|
102
|
+
else
|
|
103
|
+
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
|
104
|
+
fi
|
|
105
|
+
fi
|
|
106
|
+
|
|
107
|
+
# For Darwin, add options to specify how the application appears in the dock
|
|
108
|
+
if $darwin; then
|
|
109
|
+
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
|
110
|
+
fi
|
|
111
|
+
|
|
112
|
+
# For Cygwin, switch paths to Windows format before running java
|
|
113
|
+
if $cygwin ; then
|
|
114
|
+
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
|
115
|
+
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
|
116
|
+
JAVACMD=`cygpath --unix "$JAVACMD"`
|
|
117
|
+
|
|
118
|
+
# We build the pattern for arguments to be converted via cygpath
|
|
119
|
+
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
120
|
+
SEP=""
|
|
121
|
+
for dir in $ROOTDIRSRAW ; do
|
|
122
|
+
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
123
|
+
SEP="|"
|
|
124
|
+
done
|
|
125
|
+
OURCYGPATTERN="(^($ROOTDIRS))"
|
|
126
|
+
# Add a user-defined pattern to the cygpath arguments
|
|
127
|
+
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
|
128
|
+
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
|
129
|
+
fi
|
|
130
|
+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
131
|
+
i=0
|
|
132
|
+
for arg in "$@" ; do
|
|
133
|
+
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
|
134
|
+
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
|
135
|
+
|
|
136
|
+
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
|
137
|
+
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
|
138
|
+
else
|
|
139
|
+
eval `echo args$i`="\"$arg\""
|
|
140
|
+
fi
|
|
141
|
+
i=$((i+1))
|
|
142
|
+
done
|
|
143
|
+
case $i in
|
|
144
|
+
(0) set -- ;;
|
|
145
|
+
(1) set -- "$args0" ;;
|
|
146
|
+
(2) set -- "$args0" "$args1" ;;
|
|
147
|
+
(3) set -- "$args0" "$args1" "$args2" ;;
|
|
148
|
+
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
|
149
|
+
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
|
150
|
+
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
|
151
|
+
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
|
152
|
+
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
|
153
|
+
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
|
154
|
+
esac
|
|
155
|
+
fi
|
|
156
|
+
|
|
157
|
+
# Escape application args
|
|
158
|
+
save () {
|
|
159
|
+
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
|
160
|
+
echo " "
|
|
161
|
+
}
|
|
162
|
+
APP_ARGS=$(save "$@")
|
|
163
|
+
|
|
164
|
+
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
|
165
|
+
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
|
166
|
+
|
|
167
|
+
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
|
168
|
+
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
|
169
|
+
cd "$(dirname "$0")"
|
|
170
|
+
fi
|
|
171
|
+
|
|
172
|
+
exec "$JAVACMD" "$@"
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
@if "%DEBUG%" == "" @echo off
|
|
2
|
+
@rem ##########################################################################
|
|
3
|
+
@rem
|
|
4
|
+
@rem Gradle startup script for Windows
|
|
5
|
+
@rem
|
|
6
|
+
@rem ##########################################################################
|
|
7
|
+
|
|
8
|
+
@rem Set local scope for the variables with windows NT shell
|
|
9
|
+
if "%OS%"=="Windows_NT" setlocal
|
|
10
|
+
|
|
11
|
+
set DIRNAME=%~dp0
|
|
12
|
+
if "%DIRNAME%" == "" set DIRNAME=.
|
|
13
|
+
set APP_BASE_NAME=%~n0
|
|
14
|
+
set APP_HOME=%DIRNAME%
|
|
15
|
+
|
|
16
|
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
17
|
+
set DEFAULT_JVM_OPTS="-Xmx64m"
|
|
18
|
+
|
|
19
|
+
@rem Find java.exe
|
|
20
|
+
if defined JAVA_HOME goto findJavaFromJavaHome
|
|
21
|
+
|
|
22
|
+
set JAVA_EXE=java.exe
|
|
23
|
+
%JAVA_EXE% -version >NUL 2>&1
|
|
24
|
+
if "%ERRORLEVEL%" == "0" goto init
|
|
25
|
+
|
|
26
|
+
echo.
|
|
27
|
+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
28
|
+
echo.
|
|
29
|
+
echo Please set the JAVA_HOME variable in your environment to match the
|
|
30
|
+
echo location of your Java installation.
|
|
31
|
+
|
|
32
|
+
goto fail
|
|
33
|
+
|
|
34
|
+
:findJavaFromJavaHome
|
|
35
|
+
set JAVA_HOME=%JAVA_HOME:"=%
|
|
36
|
+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
37
|
+
|
|
38
|
+
if exist "%JAVA_EXE%" goto init
|
|
39
|
+
|
|
40
|
+
echo.
|
|
41
|
+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
|
42
|
+
echo.
|
|
43
|
+
echo Please set the JAVA_HOME variable in your environment to match the
|
|
44
|
+
echo location of your Java installation.
|
|
45
|
+
|
|
46
|
+
goto fail
|
|
47
|
+
|
|
48
|
+
:init
|
|
49
|
+
@rem Get command-line arguments, handling Windows variants
|
|
50
|
+
|
|
51
|
+
if not "%OS%" == "Windows_NT" goto win9xME_args
|
|
52
|
+
|
|
53
|
+
:win9xME_args
|
|
54
|
+
@rem Slurp the command line arguments.
|
|
55
|
+
set CMD_LINE_ARGS=
|
|
56
|
+
set _SKIP=2
|
|
57
|
+
|
|
58
|
+
:win9xME_args_slurp
|
|
59
|
+
if "x%~1" == "x" goto execute
|
|
60
|
+
|
|
61
|
+
set CMD_LINE_ARGS=%*
|
|
62
|
+
|
|
63
|
+
:execute
|
|
64
|
+
@rem Setup the command line
|
|
65
|
+
|
|
66
|
+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
67
|
+
|
|
68
|
+
@rem Execute Gradle
|
|
69
|
+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
|
70
|
+
|
|
71
|
+
:end
|
|
72
|
+
@rem End local scope for the variables with windows NT shell
|
|
73
|
+
if "%ERRORLEVEL%"=="0" goto mainEnd
|
|
74
|
+
|
|
75
|
+
:fail
|
|
76
|
+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
77
|
+
rem the _cmd.exe /c_ return code!
|
|
78
|
+
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
|
79
|
+
exit /b 1
|
|
80
|
+
|
|
81
|
+
:mainEnd
|
|
82
|
+
if "%OS%"=="Windows_NT" endlocal
|
|
83
|
+
|
|
84
|
+
:omega
|
|
Binary file
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
package com.reactlibrary;
|
|
2
|
+
|
|
3
|
+
import android.os.Build;
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.bridge.*;
|
|
7
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
8
|
+
import com.honeywell.aidc.*;
|
|
9
|
+
import com.honeywell.aidc.AidcManager.CreatedCallback;
|
|
10
|
+
|
|
11
|
+
import javax.annotation.Nullable;
|
|
12
|
+
|
|
13
|
+
import java.util.HashMap;
|
|
14
|
+
import java.util.Map;
|
|
15
|
+
|
|
16
|
+
import static com.reactlibrary.HoneywellScannerPackage.HoneyWellTAG;
|
|
17
|
+
|
|
18
|
+
public class HoneywellScannerModule extends ReactContextBaseJavaModule implements BarcodeReader.BarcodeListener, BarcodeReader.TriggerListener {
|
|
19
|
+
|
|
20
|
+
// Debugging
|
|
21
|
+
private static final boolean D = true;
|
|
22
|
+
|
|
23
|
+
private final ReactApplicationContext reactContext;
|
|
24
|
+
private AidcManager manager;
|
|
25
|
+
private BarcodeReader reader;
|
|
26
|
+
|
|
27
|
+
private static final String BARCODE_READ_SUCCESS = "barcodeReadSuccess";
|
|
28
|
+
private static final String BARCODE_READ_FAIL = "barcodeReadFail";
|
|
29
|
+
|
|
30
|
+
public HoneywellScannerModule(ReactApplicationContext reactContext) {
|
|
31
|
+
super(reactContext);
|
|
32
|
+
this.reactContext = reactContext;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@Override
|
|
36
|
+
public String getName() {
|
|
37
|
+
return "HoneywellScanner";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Send event to javascript
|
|
42
|
+
*
|
|
43
|
+
* @param eventName Name of the event
|
|
44
|
+
* @param params Additional params
|
|
45
|
+
*/
|
|
46
|
+
private void sendEvent(String eventName, @Nullable WritableMap params) {
|
|
47
|
+
if (reactContext.hasActiveCatalystInstance()) {
|
|
48
|
+
if (D) Log.d(HoneyWellTAG, "Sending event: " + eventName);
|
|
49
|
+
reactContext
|
|
50
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
51
|
+
.emit(eventName, params);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@Override
|
|
56
|
+
public void onBarcodeEvent(BarcodeReadEvent barcodeReadEvent) {
|
|
57
|
+
if (D) Log.d(HoneyWellTAG, "HoneywellBarcodeReader - Barcode scan read");
|
|
58
|
+
WritableMap params = Arguments.createMap();
|
|
59
|
+
params.putString("data", barcodeReadEvent.getBarcodeData());
|
|
60
|
+
sendEvent(BARCODE_READ_SUCCESS, params);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@Override
|
|
64
|
+
public void onFailureEvent(BarcodeFailureEvent barcodeFailureEvent) {
|
|
65
|
+
if (D) Log.d(HoneyWellTAG, "HoneywellBarcodeReader - Barcode scan failed");
|
|
66
|
+
sendEvent(BARCODE_READ_FAIL, null);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/*******************************/
|
|
70
|
+
/** Methods Available from JS **/
|
|
71
|
+
/*******************************/
|
|
72
|
+
|
|
73
|
+
@ReactMethod
|
|
74
|
+
public void startReader(final Promise promise) {
|
|
75
|
+
AidcManager.create(reactContext, new CreatedCallback() {
|
|
76
|
+
@Override
|
|
77
|
+
public void onCreated(AidcManager aidcManager) {
|
|
78
|
+
Log.d("BarcodeDevices: ", manager.listConnectedBarcodeDevices());
|
|
79
|
+
manager = aidcManager;
|
|
80
|
+
reader = manager.createBarcodeReader();
|
|
81
|
+
if (reader != null) {
|
|
82
|
+
reader.addBarcodeListener(HoneywellScannerModule.this);
|
|
83
|
+
try {
|
|
84
|
+
reader.claim();
|
|
85
|
+
reader.setProperty(BarcodeReader.PROPERTY_EAN_8_ENABLED, true);
|
|
86
|
+
reader.setProperty(BarcodeReader.PROPERTY_EAN_8_CHECK_DIGIT_TRANSMIT_ENABLED, true);
|
|
87
|
+
reader.setProperty(BarcodeReader.PROPERTY_EAN_13_ENABLED, true);
|
|
88
|
+
reader.setProperty(BarcodeReader.PROPERTY_EAN_13_CHECK_DIGIT_TRANSMIT_ENABLED, true);
|
|
89
|
+
reader.setProperty(BarcodeReader.PROPERTY_EAN_13_TWO_CHAR_ADDENDA_ENABLED, true);
|
|
90
|
+
reader.setProperty(BarcodeReader.PROPERTY_EAN_13_FIVE_CHAR_ADDENDA_ENABLED, true);
|
|
91
|
+
promise.resolve(true);
|
|
92
|
+
} catch (ScannerUnavailableException | UnsupportedPropertyException e) {
|
|
93
|
+
promise.resolve(false);
|
|
94
|
+
e.printStackTrace();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@ReactMethod
|
|
102
|
+
public void stopReader(Promise promise) {
|
|
103
|
+
if (reader != null) {
|
|
104
|
+
reader.close();
|
|
105
|
+
}
|
|
106
|
+
if (manager != null) {
|
|
107
|
+
manager.close();
|
|
108
|
+
}
|
|
109
|
+
promise.resolve(null);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private boolean isCompatible() {
|
|
113
|
+
// This... is not optimal. Need to find a better way to performantly check whether device has a Honeywell scanner
|
|
114
|
+
return Build.BRAND.toLowerCase().contains("honeywell");
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@Override
|
|
118
|
+
public Map<String, Object> getConstants() {
|
|
119
|
+
final Map<String, Object> constants = new HashMap<>();
|
|
120
|
+
constants.put("BARCODE_READ_SUCCESS", BARCODE_READ_SUCCESS);
|
|
121
|
+
constants.put("BARCODE_READ_FAIL", BARCODE_READ_FAIL);
|
|
122
|
+
constants.put("isCompatible", isCompatible());
|
|
123
|
+
return constants;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package com.reactlibrary;
|
|
2
|
+
|
|
3
|
+
import java.util.Arrays;
|
|
4
|
+
import java.util.Collections;
|
|
5
|
+
import java.util.List;
|
|
6
|
+
|
|
7
|
+
import com.facebook.react.ReactPackage;
|
|
8
|
+
import com.facebook.react.bridge.NativeModule;
|
|
9
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
11
|
+
|
|
12
|
+
public class HoneywellScannerPackage implements ReactPackage {
|
|
13
|
+
static final String HoneyWellTAG = "HoneywellBarcodeReader";
|
|
14
|
+
|
|
15
|
+
@Override
|
|
16
|
+
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
17
|
+
return Arrays.<NativeModule>asList(new HoneywellScannerModule(reactContext));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@Override
|
|
21
|
+
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
22
|
+
return Collections.emptyList();
|
|
23
|
+
}
|
|
24
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@scrumble-nl/react-native-honeywell-scanner",
|
|
3
|
+
"title": "React Native Honeywell Scanner-v2",
|
|
4
|
+
"version": "1.0.3",
|
|
5
|
+
"description": "Bridge to use the Honeywell scanner",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
|
+
"build": "tsc"
|
|
11
|
+
},
|
|
12
|
+
"repository": "https://gitlab.com/Scrumble/lekkerland/react-native-honeywell-scanner",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"react-native",
|
|
15
|
+
"honeywell"
|
|
16
|
+
],
|
|
17
|
+
"author": "Scrumble <admin@scrumble.nl> (https://www.scrumble.nl)",
|
|
18
|
+
"contributors": [
|
|
19
|
+
"AMI3GO Ltd <enquiry@ami3go.com> (https://ami3go.com)"
|
|
20
|
+
],
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://gitlab.com/Scrumble/lekkerland/react-native-honeywell-scanner/issues"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://gitlab.com/Scrumble/lekkerland/react-native-honeywell-scanner#readme",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"licenseFilename": "LICENSE",
|
|
27
|
+
"readmeFilename": "README.md",
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"react": "16.*",
|
|
30
|
+
"react-native": "0.*"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"react": "16.*",
|
|
34
|
+
"react-native": "0.*"
|
|
35
|
+
}
|
|
36
|
+
}
|