@regulaforensics/document-reader 8.2.186-beta → 8.2.204-beta

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.
Files changed (53) hide show
  1. package/RNDocumentReader.podspec +2 -2
  2. package/android/build.gradle +2 -2
  3. package/android/cordova.gradle +2 -2
  4. package/android/src/main/java/com/regula/plugin/documentreader/Config.kt +2 -0
  5. package/android/src/main/java/com/regula/plugin/documentreader/Main.kt +6 -0
  6. package/examples/capacitor/package.json +1 -1
  7. package/examples/capacitor/src/extra/bt_device.tsx +2 -2
  8. package/examples/capacitor/src/extra/custom_rfid.tsx +29 -42
  9. package/examples/capacitor/src/main.tsx +85 -53
  10. package/examples/cordova/config.xml +3 -2
  11. package/examples/cordova/package.json +1 -1
  12. package/examples/cordova/www/images/portrait.png +0 -0
  13. package/examples/cordova/www/index.html +2 -17
  14. package/examples/cordova/www/index.js +40 -0
  15. package/examples/cordova/www/src/extra/bt_device.js +31 -0
  16. package/examples/cordova/www/src/extra/custom_rfid.js +60 -0
  17. package/examples/cordova/www/src/main.css +7 -6
  18. package/examples/cordova/www/src/main.html +10 -32
  19. package/examples/cordova/www/src/main.js +174 -22
  20. package/examples/ionic/config.xml +9 -4
  21. package/examples/ionic/index.ts +1 -2
  22. package/examples/ionic/package-lock.json +1862 -1638
  23. package/examples/ionic/package.json +1 -4
  24. package/examples/ionic/src/extra/bt_device.ts +32 -0
  25. package/examples/ionic/src/extra/custom_rfid.ts +61 -0
  26. package/examples/ionic/src/images/portrait.png +0 -0
  27. package/examples/ionic/src/main.css +7 -6
  28. package/examples/ionic/src/main.html +39 -61
  29. package/examples/ionic/src/main.ts +183 -36
  30. package/examples/react_native/app.config.ts +3 -1
  31. package/examples/react_native/images/portrait.png +0 -0
  32. package/examples/react_native/index.tsx +8 -2
  33. package/examples/react_native/package.json +1 -1
  34. package/examples/react_native/src/extra/bt_device.tsx +33 -0
  35. package/examples/react_native/src/extra/custom_rfid.tsx +62 -0
  36. package/examples/react_native/src/main.css +7 -6
  37. package/examples/react_native/src/main.html +10 -32
  38. package/examples/react_native/src/main.tsx +167 -21
  39. package/ios/RGLWConfig.m +2 -0
  40. package/ios/RGLWMain.m +10 -0
  41. package/package.json +1 -1
  42. package/plugin.xml +2 -2
  43. package/www/capacitor/index.js +16 -0
  44. package/www/capacitor/params/customization/Customization.js +7 -0
  45. package/www/capacitor/results/visual_results/FieldType.js +3 -1
  46. package/www/cordova.js +26 -1
  47. package/www/react-native/index.js +16 -0
  48. package/www/react-native/internal/bridge.js +1 -1
  49. package/www/react-native/params/customization/Customization.js +7 -0
  50. package/www/react-native/results/visual_results/FieldType.js +3 -1
  51. package/www/types/index.d.ts +6 -0
  52. package/www/types/params/customization/Customization.d.ts +5 -0
  53. package/www/types/results/visual_results/FieldType.d.ts +5 -1
@@ -5,7 +5,7 @@ source = File.join(__dir__, 'ios')
5
5
 
6
6
  Pod::Spec.new do |s|
7
7
  s.name = 'RNDocumentReader'
8
- s.version = '8.2.186-beta'
8
+ s.version = '8.2.204-beta'
9
9
  s.summary = package['description']
10
10
  s.license = package['license']
11
11
 
@@ -16,6 +16,6 @@ Pod::Spec.new do |s|
16
16
  s.ios.deployment_target = '13.0'
17
17
  s.source_files = 'ios/**/*.{h,m}'
18
18
  s.exclude_files = [ 'ios/CVDDocumentReader.h', 'ios/CVDDocumentReader.m' ]
19
- s.dependency 'DocumentReader', '8.1.4772'
19
+ s.dependency 'DocumentReaderStage', '8.2.4879'
20
20
  s.dependency 'React'
21
21
  end
@@ -20,7 +20,7 @@ android {
20
20
  rootProject.allprojects {
21
21
  repositories {
22
22
  maven {
23
- url "https://maven.regulaforensics.com/RegulaDocumentReader"
23
+ url "https://maven.regulaforensics.com/RegulaDocumentReader/Stage"
24
24
  }
25
25
  }
26
26
  }
@@ -29,7 +29,7 @@ dependencies {
29
29
  //noinspection GradleDynamicVersion
30
30
  implementation 'com.facebook.react:react-native:+'
31
31
  //noinspection GradleDependency
32
- implementation('com.regula.documentreader:api:8.1.11551'){
32
+ implementation('com.regula.documentreader:api:8.2.11640'){
33
33
  transitive = true
34
34
  }
35
35
  }
@@ -1,12 +1,12 @@
1
1
  repositories {
2
2
  maven {
3
- url "https://maven.regulaforensics.com/RegulaDocumentReader"
3
+ url "https://maven.regulaforensics.com/RegulaDocumentReader/Stage"
4
4
  }
5
5
  }
6
6
 
7
7
  dependencies {
8
8
  //noinspection GradleDependency
9
- implementation('com.regula.documentreader:api:8.1.11551'){
9
+ implementation('com.regula.documentreader:api:8.2.11640'){
10
10
  transitive = true
11
11
  }
12
12
  }
@@ -316,6 +316,7 @@ fun setCustomization(customization: ParamsCustomization, opts: JSONObject) = opt
316
316
  "torchButtonOnImage" -> editor.setTorchImageOn(v.toDrawable())
317
317
  "torchButtonOffImage" -> editor.setTorchImageOff(v.toDrawable())
318
318
  "livenessAnimationImage" -> editor.setLivenessAnimationImage(v.toDrawable())
319
+ "multipageButtonImage" -> editor.setMultipageButtonDrawable(v.toDrawable())
319
320
  "helpAnimationImageMatrix" -> editor.setHelpAnimationImageMatrix(matrixFromJSON(v as JSONArray?)).setHelpAnimationImageScaleType(ImageView.ScaleType.MATRIX)
320
321
  "multipageAnimationFrontImageMatrix" -> editor.setMultipageAnimationFrontImageMatrix(matrixFromJSON(v as JSONArray?)).setMultipageAnimationFrontImageScaleType(ImageView.ScaleType.MATRIX)
321
322
  "multipageAnimationBackImageMatrix" -> editor.setMultipageAnimationBackImageMatrix(matrixFromJSON(v as JSONArray?)).setMultipageAnimationBackImageScaleType(ImageView.ScaleType.MATRIX)
@@ -401,6 +402,7 @@ fun getCustomization(customization: ParamsCustomization) = mapOf(
401
402
  "torchButtonOnImage" to customization.torchImageOnDrawable.toBase64(),
402
403
  "torchButtonOffImage" to customization.torchImageOffDrawable.toBase64(),
403
404
  "livenessAnimationImage" to customization.livenessAnimationImage.toBase64(),
405
+ "multipageButtonImage" to customization.multipageButtonDrawable.toBase64(),
404
406
  "helpAnimationImageMatrix" to generateMatrix(customization.helpAnimationImageMatrix),
405
407
  "multipageAnimationFrontImageMatrix" to generateMatrix(customization.multipageAnimationFrontImageMatrix),
406
408
  "multipageAnimationBackImageMatrix" to generateMatrix(customization.multipageAnimationBackImageMatrix),
@@ -55,6 +55,8 @@ fun methodCall(method: String, callback: (Any?) -> Unit): Any = when (method) {
55
55
  "setTenant" -> setTenant(argsNullable(0))
56
56
  "getEnv" -> getEnv(callback)
57
57
  "setEnv" -> setEnv(argsNullable(0))
58
+ "getLocale" -> getLocale(callback)
59
+ "setLocale" -> setLocale(argsNullable(0))
58
60
  "getFunctionality" -> getFunctionality(callback)
59
61
  "setFunctionality" -> setFunctionality(args(0))
60
62
  "getProcessParams" -> getProcessParams(callback)
@@ -160,6 +162,10 @@ fun getEnv(callback: Callback) = callback(Instance().env)
160
162
 
161
163
  fun setEnv(tag: String?) = tag.let { Instance().env = it }
162
164
 
165
+ fun getLocale(callback: Callback) = callback(Instance().locale)
166
+
167
+ fun setLocale(locale: String?) = locale.let { Instance().locale = it }
168
+
163
169
  fun getFunctionality(callback: Callback) = callback(getFunctionality(Instance().functionality()))
164
170
 
165
171
  fun setFunctionality(functionality: JSONObject) = setFunctionality(Instance().functionality(), functionality)
@@ -6,7 +6,7 @@
6
6
  "android": "scripts/android.sh"
7
7
  },
8
8
  "dependencies": {
9
- "@regulaforensics/document-reader": "8.2.186-beta",
9
+ "@regulaforensics/document-reader": "8.2.204-beta",
10
10
  "@regulaforensics/document-reader-core-fullauthrfid": "8.2.8-beta",
11
11
  "@regulaforensics/document-reader-btdevice": "8.2.8-beta",
12
12
  "@awesome-cordova-plugins/file": "6.6.0",
@@ -13,14 +13,14 @@ export function setupBTDevice() {
13
13
  async function connect() {
14
14
  setStatus("Searching for devices...")
15
15
  if (await DocumentReader.instance.connectBluetoothDevice(btDeviceName)) {
16
- await initializeBTDevice()
16
+ await initialize()
17
17
  DocumentReader.instance.functionality.useAuthenticator = true
18
18
  document.getElementById("bt-device").style.display = "none"
19
19
  } else
20
20
  setStatus("Failed to connect")
21
21
  }
22
22
 
23
- async function initializeBTDevice() {
23
+ async function initialize() {
24
24
  setStatus("Initializing...")
25
25
 
26
26
  var initConfig = InitConfig.withBleDevice()
@@ -1,31 +1,13 @@
1
- import { DocReaderAction, DocumentReader, Results, RFIDConfig, RFIDDataFileType, RFIDErrorCodes, RFIDNotificationCodes } from "@regulaforensics/document-reader"
2
- import { displayResults, handleCompletion, setStatus } from "../main"
1
+ import { DocReaderAction, DocumentReader, RFIDConfig, RFIDDataFileType, RFIDNotificationCodes } from "@regulaforensics/document-reader"
2
+ import { displayResults, setStatus } from "../main"
3
3
 
4
- export enum RfidOption {
5
- Basic,
6
- Advanced,
7
- SelfHostedUI
8
- }
9
-
10
- export const rfidOption: RfidOption = RfidOption.Basic
11
-
12
- export function advancedRfid() {
13
- var config = new RFIDConfig(handleCompletion)
14
-
15
- config.onChipDetected = () => console.log("Chip detected, reading rfid.")
16
- config.onRetryReadChip = async (error) => console.log(await RFIDErrorCodes.getTranslation(error.code) + ". Retrying...")
17
-
18
- DocumentReader.instance.rfid(config)
19
- }
4
+ export const useRfidSelfHostedUI = false
20
5
 
21
- export function selfHostedUIRfid() {
22
- var config = RFIDConfig.withoutUI((action, results, error) => {
23
- if (DocReaderAction.stopped(action)) finish(results)
24
- if (error != null) {
25
- setStatus("Try again")
26
- setDescription("Error" + error.message)
27
- console.log(error.code + ": " + error.message)
28
- }
6
+ export function rfidSelfHostedUI() {
7
+ var config = RFIDConfig.withoutUI((action, results, _) => {
8
+ if (DocReaderAction.stopped(action)) stop()
9
+ if (DocReaderAction.finished(action)) displayResults(results)
10
+ if (DocReaderAction.interrupted(action)) setStatus("Error reading RFID")
29
11
  })
30
12
 
31
13
  config.onProgress = async (notification) => {
@@ -40,35 +22,40 @@ export function selfHostedUIRfid() {
40
22
  DocumentReader.instance.rfid(config)
41
23
  }
42
24
 
43
- function finish(results: Results) {
44
- DocumentReader.instance.stopRFIDReader()
45
- setShowing(false)
46
- displayResults(results)
47
- }
48
-
49
25
  function setup() {
50
- document.getElementById("cancel-rfid").onclick = () => finish(null)
51
-
52
26
  setStatus("Reading RFID")
53
27
  setDescription("Place your phone on top of the NFC tag")
54
- setProgress(0)
28
+ setProgress(-1)
29
+ currentProgress = -1
55
30
  setShowing(true)
31
+ document.getElementById("cancel-rfid").onclick = () => stop()
56
32
  }
57
33
 
58
- var setDescription = (data: string) => document.getElementById("rfid-description").innerHTML = data
59
- var setProgress = (next: number) => {
34
+ function stop() {
35
+ DocumentReader.instance.stopRFIDReader()
36
+ displayResults(null)
37
+ setShowing(false)
38
+ }
39
+
40
+ function setDescription(data) {
41
+ document.getElementById("rfid-description").innerHTML = data
42
+ }
43
+
44
+ var currentProgress = -1
45
+ function setProgress(next) {
60
46
  var progress = document.getElementById("progress")
61
- var previous = parseInt(progress.style.width.substring(0, progress.style.width.length - 1))
62
47
  // make progress bar look better
63
- if (next <= 0) return // ignore idle 0s, leave progress at 100 while its not moving
64
- if (next < previous) next = 0 // move to 0 if progress finaly started moving
48
+ if (next == 0) return // ignore idle 0s, leave progress at 100 while its not moving
49
+ if (next < currentProgress) next = 0 // move to 0 if progress finaly started moving
65
50
  if (next >= 95) next = 100 // rfid never returns 100 and it looks ugly, fix it
66
- if (next < previous) progress.style.transition = 'none' // instantly reset progress
51
+ if (next < currentProgress) progress.style.transition = 'none' // instantly reset progress
67
52
  else progress.style.transition = 'width 0.5s' // smoothly increase progress
68
53
 
69
54
  progress.style.width = next + "%"
55
+ currentProgress = next
70
56
  }
71
- var setShowing = (data: boolean) => {
57
+
58
+ function setShowing(data) {
72
59
  document.getElementById("main").style.display = data ? "none" : "flex"
73
60
  document.getElementById("custom-rfid").style.display = data ? "flex" : "none"
74
61
  }
@@ -1,20 +1,21 @@
1
- import { setupIonicReact } from '@ionic/react'
2
1
  import '@ionic/react/css/core.css'
3
2
  import './main.css'
4
- import { File } from '@awesome-cordova-plugins/file'
5
- import { DocumentReader, DocReaderException, InitConfig, DocReaderAction, Results, FieldType, GraphicFieldType, ResultType, RFIDConfig, ScannerConfig, Scenario, DocReaderScenario, RecognizeConfig } from '@regulaforensics/document-reader'
3
+ import { setupIonicReact } from '@ionic/react'
6
4
  import { StatusBar, Style } from '@capacitor/status-bar'
7
- import { setupBTDevice, useBtDevice } from './extra/bt_device'
8
- import { advancedRfid, rfidOption, RfidOption, selfHostedUIRfid } from './extra/custom_rfid'
5
+ import { File } from '@awesome-cordova-plugins/file'
9
6
  import { Camera, DestinationType, MediaType, PictureSourceType } from '@awesome-cordova-plugins/camera'
10
7
 
11
- const documentReader = DocumentReader.instance
12
- var selectedScenario = Scenario.MRZ
8
+ import { DocumentReader, DocReaderAction, FieldType, GraphicFieldType, InitConfig, RecognizeConfig, ResultType, RFIDConfig, ScannerConfig, Scenario } from '@regulaforensics/document-reader'
9
+ import { setupBTDevice, useBtDevice } from './extra/bt_device'
10
+ import { useRfidSelfHostedUI, rfidSelfHostedUI } from './extra/custom_rfid'
11
+
12
+ var documentReader = DocumentReader.instance
13
+ var selectedScenario
13
14
  var doRfid = false
14
15
  var isReadingRfid = false
15
16
 
16
17
  async function init() {
17
- if (!await initializeReader()) return
18
+ if (!await initialize()) return
18
19
  setScenarios(documentReader.availableScenarios)
19
20
  setCanRfid(await documentReader.isRFIDAvailableForUse())
20
21
  setStatus("Ready")
@@ -31,11 +32,9 @@ async function scan() {
31
32
 
32
33
  async function recognize() {
33
34
  if (!await documentReader.isReady()) return
34
- var image = await Camera.getPicture({
35
- destinationType: DestinationType.DATA_URL,
36
- mediaType: MediaType.PICTURE,
37
- sourceType: PictureSourceType.PHOTOLIBRARY
38
- })
35
+ var image = await pickImage()
36
+ if (image == null) return
37
+
39
38
  clearResults()
40
39
  documentReader.recognize(
41
40
  RecognizeConfig.withScenario(selectedScenario, { image: image }),
@@ -43,7 +42,7 @@ async function recognize() {
43
42
  )
44
43
  }
45
44
 
46
- export function handleCompletion(action: DocReaderAction, results?: Results, error?: DocReaderException) {
45
+ export function handleCompletion(action, results, error) {
47
46
  handleException(error)
48
47
  if (DocReaderAction.stopped(action) && !shouldRfid(results)) {
49
48
  displayResults(results)
@@ -53,7 +52,7 @@ export function handleCompletion(action: DocReaderAction, results?: Results, err
53
52
  }
54
53
  }
55
54
 
56
- export async function displayResults(results?: Results) {
55
+ export async function displayResults(results) {
57
56
  isReadingRfid = false
58
57
  clearResults()
59
58
  if (results == null) return
@@ -68,11 +67,17 @@ export async function displayResults(results?: Results) {
68
67
  setDocImage(docImage)
69
68
  }
70
69
 
71
- var readRfid = () => documentReader.rfid(new RFIDConfig(handleCompletion))
70
+ var readRfid = () => {
71
+ documentReader.rfid(new RFIDConfig(handleCompletion))
72
+ }
72
73
 
73
- var shouldRfid = (results?: Results) => doRfid && !isReadingRfid && results != null && results.chipPage != 0
74
+ function shouldRfid(results) {
75
+ return doRfid &&
76
+ !isReadingRfid &&
77
+ results != null && results.chipPage != 0
78
+ }
74
79
 
75
- async function initializeReader() {
80
+ async function initialize() {
76
81
  setStatus("Initializing...")
77
82
 
78
83
  var license = await loadAsset("regula.license")
@@ -83,14 +88,51 @@ async function initializeReader() {
83
88
  return success
84
89
  }
85
90
 
86
- export function handleException(error: DocReaderException) {
91
+ export function handleException(error) {
87
92
  if (error != null) {
88
93
  setStatus(error.message)
89
94
  console.log(error.code + ": " + error.message)
90
95
  }
91
96
  }
92
97
 
93
- // --------------------------------------------------------------------------------------------------------------------
98
+ // ui --------------------------------------------------------------------------------------------------------------------
99
+
100
+ export function setStatus(data) {
101
+ if (data != null)
102
+ document.getElementById("status").innerHTML = data
103
+ }
104
+
105
+ function setPortrait(data) {
106
+ if (data != null)
107
+ portraitUIImage.src = "data:image/png;base64," + data
108
+ }
109
+
110
+ function setDocImage(data) {
111
+ if (data != null)
112
+ documentUIImage.src = "data:image/png;base64," + data
113
+ }
114
+
115
+ function clearResults() {
116
+ setStatus("Ready")
117
+ portraitUIImage.src = "images/portrait.png"
118
+ documentUIImage.src = "images/document.png"
119
+ }
120
+
121
+ function setCanRfid(data) {
122
+ var checkbox // implicitly any, since cordova sample is pure js
123
+ checkbox = document.getElementById('rfid-checkbox')
124
+ var checkboxDescription = document.getElementById("rfid-checkbox-description")
125
+ if (data) {
126
+ checkbox.disabled = false
127
+ checkboxDescription.innerHTML = "Process rfid reading"
128
+ checkboxDescription.onclick = () => {
129
+ doRfid = !doRfid
130
+ checkbox.checked = doRfid
131
+ }
132
+ }
133
+ }
134
+
135
+ // not equal --------------------------------------------------------------------------------------------------------------------
94
136
 
95
137
  async function loadAsset(path: string): Promise<string> {
96
138
  var dir = await File.resolveDirectoryUrl(File.applicationDirectory + "public/assets")
@@ -105,36 +147,39 @@ async function loadAsset(path: string): Promise<string> {
105
147
  return result
106
148
  }
107
149
 
108
- var documentUIImage: HTMLImageElement
109
- var portraitUIImage: HTMLImageElement
150
+ async function pickImage(): Promise<string | null> {
151
+ return await Camera.getPicture({
152
+ destinationType: DestinationType.DATA_URL,
153
+ mediaType: MediaType.PICTURE,
154
+ sourceType: PictureSourceType.PHOTOLIBRARY
155
+ })
156
+ }
157
+
158
+ var documentUIImage
159
+ var portraitUIImage
110
160
  document.addEventListener('deviceready', () => {
111
- documentUIImage = document.getElementById("document-image") as HTMLImageElement
112
- portraitUIImage = document.getElementById("portrait-image") as HTMLImageElement
161
+ documentUIImage = document.getElementById("document-image")
162
+ portraitUIImage = document.getElementById("portrait-image")
113
163
  document.getElementById("scan").onclick = () => scan()
114
164
  document.getElementById("recognize").onclick = () => recognize()
115
165
 
116
- // btDevice
166
+ // custom rfid
167
+ if (useRfidSelfHostedUI) readRfid = () => rfidSelfHostedUI()
168
+
169
+ // bt device
117
170
  if (!useBtDevice) init()
118
171
  else setupBTDevice()
119
-
120
- // rfid
121
- if (rfidOption == RfidOption.Advanced) readRfid = () => advancedRfid()
122
- if (rfidOption == RfidOption.SelfHostedUI) readRfid = () => selfHostedUIRfid()
123
172
  })
124
173
 
125
- export var setStatus = (data: string) => { if (data != null) document.getElementById("status").innerHTML = data }
126
- var setPortrait = (data: string) => { if (data != null) portraitUIImage.src = "data:image/png;base64," + data }
127
- var setDocImage = (data: string) => { if (data != null) documentUIImage.src = "data:image/png;base64," + data }
128
- var clearResults = () => {
129
- setStatus("Ready")
130
- portraitUIImage.src = "images/portrait.png"
131
- documentUIImage.src = "images/document.png"
132
- }
133
- var setScenarios = (data: DocReaderScenario[]) => {
174
+ // not resolved --------------------------------------------------------------------------------------------------------------------
175
+
176
+ function setScenarios(data) {
177
+ selectedScenario = Scenario.MRZ
134
178
  const scenariosContainer = document.getElementById("scenarios")
135
179
  data.forEach(scenario => scenariosContainer.appendChild(createScenarioElement(scenario)))
136
180
  }
137
- var createScenarioElement = (scenario: DocReaderScenario) => {
181
+
182
+ function createScenarioElement(scenario) {
138
183
  const div = document.createElement('div')
139
184
  div.className = 'row radio'
140
185
 
@@ -149,7 +194,7 @@ var createScenarioElement = (scenario: DocReaderScenario) => {
149
194
  span.style.paddingLeft = '5px'
150
195
  span.textContent = scenario.caption
151
196
 
152
- input.onclick = () => selectedScenario = scenario.name as Scenario
197
+ input.onclick = () => selectedScenario = scenario.name
153
198
  span.onclick = () => input.click()
154
199
 
155
200
  div.appendChild(input)
@@ -157,19 +202,6 @@ var createScenarioElement = (scenario: DocReaderScenario) => {
157
202
 
158
203
  return div
159
204
  }
160
- var setCanRfid = (data: boolean) => {
161
- var checkbox = document.getElementById('rfid-checkbox') as HTMLInputElement
162
- var checkboxDescription = document.getElementById("rfid-checkbox-description")
163
- if (data) {
164
- checkbox.disabled = false
165
- checkbox.onclick = () => {
166
- doRfid = !doRfid
167
- checkbox.checked = doRfid
168
- }
169
- checkboxDescription.innerHTML = "Process rfid reading"
170
- checkboxDescription.onclick = () => checkbox.click()
171
- }
172
- }
173
205
 
174
206
  setupIonicReact()
175
207
  StatusBar.setStyle({ style: Style.Light })
@@ -3,11 +3,12 @@
3
3
  <name>DocumentReader</name>
4
4
  <platform name="android">
5
5
  <preference name="orientation" value="portrait" />
6
- <preference name="GradlePluginKotlinEnabled" value="true" />
7
6
  <preference name="android-minSdkVersion" value="24" />
8
7
  <preference name="android-targetSdkVersion" value="35" />
8
+ <preference name="GradlePluginKotlinEnabled" value="true" />
9
9
  <config-file parent="/*" target="AndroidManifest.xml">
10
- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
10
+ <uses-permission android:name="android.permission.NFC" />
11
+ <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
11
12
  </config-file>
12
13
  <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
13
14
  <application android:usesCleartextTraffic="true" />
@@ -6,7 +6,7 @@
6
6
  "android": "scripts/android.sh"
7
7
  },
8
8
  "dependencies": {
9
- "@regulaforensics/document-reader": "8.2.186-beta",
9
+ "@regulaforensics/document-reader": "8.2.204-beta",
10
10
  "@regulaforensics/document-reader-core-fullauthrfid": "8.2.8-beta",
11
11
  "@regulaforensics/document-reader-btdevice": "8.2.8-beta",
12
12
  "cordova-ios": "7.1.1",
@@ -1,21 +1,6 @@
1
1
  <meta name="viewport" content="initial-scale=1, user-scalable=no, viewport-fit=cover">
2
2
  <link rel="stylesheet" href="src/main.css">
3
- <script src="cordova.js"></script>
4
- <script src="src/main.js"></script>
5
-
6
3
  <div id="content" style="height: 100%"></div>
7
4
 
8
- <script>
9
- document.addEventListener('deviceready', () => {
10
- window.resolveLocalFileSystemURL(cordova.file.applicationDirectory + 'www/src/main.html', (fileEntry) => {
11
- fileEntry.file((file) => {
12
- const reader = new FileReader()
13
- reader.onloadend = function () {
14
- document.getElementById('content').innerHTML = this.result
15
- document.dispatchEvent(new CustomEvent("ready"))
16
- }
17
- reader.readAsText(file)
18
- })
19
- })
20
- })
21
- </script>
5
+ <script src="cordova.js"></script>
6
+ <script src="index.js"></script>
@@ -0,0 +1,40 @@
1
+ document.addEventListener('deviceready', () => {
2
+ // imports
3
+ window.DocumentReader = DocumentReaderPlugin.DocumentReader
4
+ DocReaderAction = DocumentReaderPlugin.DocReaderAction
5
+ FieldType = DocumentReaderPlugin.FieldType
6
+ GraphicFieldType = DocumentReaderPlugin.GraphicFieldType
7
+ InitConfig = DocumentReaderPlugin.InitConfig
8
+ RecognizeConfig = DocumentReaderPlugin.RecognizeConfig
9
+ ResultType = DocumentReaderPlugin.ResultType
10
+ RFIDConfig = DocumentReaderPlugin.RFIDConfig
11
+ ScannerConfig = DocumentReaderPlugin.ScannerConfig
12
+ Scenario = DocumentReaderPlugin.Scenario
13
+ RFIDDataFileType = DocumentReaderPlugin.RFIDDataFileType
14
+ RFIDNotificationCodes = DocumentReaderPlugin.RFIDNotificationCodes
15
+
16
+ window.resolveLocalFileSystemURL(cordova.file.applicationDirectory + 'www/src/main.html', (fileEntry) => {
17
+ fileEntry.file((file) => {
18
+ const reader = new FileReader()
19
+ reader.onloadend = async function () {
20
+ await loadModule('src/main.js')
21
+ await loadModule('src/extra/bt_device.js')
22
+ await loadModule('src/extra/custom_rfid.js')
23
+
24
+ document.getElementById('content').innerHTML = this.result
25
+ document.dispatchEvent(new CustomEvent("ready"))
26
+ }
27
+ reader.readAsText(file)
28
+ })
29
+ })
30
+ })
31
+
32
+ function loadModule(src) {
33
+ return new Promise((resolve) => {
34
+ const script = document.createElement('script');
35
+ script.type = 'module';
36
+ script.src = src;
37
+ script.onload = resolve;
38
+ document.body.appendChild(script);
39
+ });
40
+ }
@@ -0,0 +1,31 @@
1
+ import { handleException, setStatus } from "../main.js"
2
+
3
+ export const useBtDevice = false
4
+ const btDeviceName = "Regula 0000"
5
+
6
+ export function setupBTDevice() {
7
+ document.getElementById("bt-device").style.display = "flex"
8
+ document.getElementById("connect").onclick = () => connect()
9
+ setStatus("Connect to a bluetooth device")
10
+ }
11
+
12
+ async function connect() {
13
+ setStatus("Searching for devices...")
14
+ if (await DocumentReader.instance.connectBluetoothDevice(btDeviceName)) {
15
+ await initialize()
16
+ DocumentReader.instance.functionality.useAuthenticator = true
17
+ document.getElementById("bt-device").style.display = "none"
18
+ } else
19
+ setStatus("Failed to connect")
20
+ }
21
+
22
+ async function initialize() {
23
+ setStatus("Initializing...")
24
+
25
+ var initConfig = InitConfig.withBleDevice()
26
+ initConfig.delayedNNLoad = true
27
+ var [success, error] = await DocumentReader.instance.initialize(initConfig)
28
+
29
+ handleException(error)
30
+ return success
31
+ }
@@ -0,0 +1,60 @@
1
+ import { displayResults, setStatus } from "../main.js"
2
+
3
+ export const useRfidSelfHostedUI = false
4
+
5
+ export function rfidSelfHostedUI() {
6
+ var config = RFIDConfig.withoutUI((action, results, _) => {
7
+ if (DocReaderAction.stopped(action)) stop()
8
+ if (DocReaderAction.finished(action)) displayResults(results)
9
+ if (DocReaderAction.interrupted(action)) setStatus("Error reading RFID")
10
+ })
11
+
12
+ config.onProgress = async (notification) => {
13
+ if (notification.progress == 1) return
14
+ if (notification.notificationCode == RFIDNotificationCodes.PCSC_READING_DATAGROUP)
15
+ setDescription(await RFIDDataFileType.getTranslation(notification.dataFileType))
16
+ setStatus("Reading RFID")
17
+ setProgress(notification.progress)
18
+ }
19
+
20
+ setup()
21
+ DocumentReader.instance.rfid(config)
22
+ }
23
+
24
+ function setup() {
25
+ setStatus("Reading RFID")
26
+ setDescription("Place your phone on top of the NFC tag")
27
+ setProgress(-1)
28
+ currentProgress = -1
29
+ setShowing(true)
30
+ document.getElementById("cancel-rfid").onclick = () => stop()
31
+ }
32
+
33
+ function stop() {
34
+ DocumentReader.instance.stopRFIDReader()
35
+ displayResults(null)
36
+ setShowing(false)
37
+ }
38
+
39
+ function setDescription(data) {
40
+ document.getElementById("rfid-description").innerHTML = data
41
+ }
42
+
43
+ var currentProgress = -1
44
+ function setProgress(next) {
45
+ var progress = document.getElementById("progress")
46
+ // make progress bar look better
47
+ if (next == 0) return // ignore idle 0s, leave progress at 100 while its not moving
48
+ if (next < currentProgress) next = 0 // move to 0 if progress finaly started moving
49
+ if (next >= 95) next = 100 // rfid never returns 100 and it looks ugly, fix it
50
+ if (next < currentProgress) progress.style.transition = 'none' // instantly reset progress
51
+ else progress.style.transition = 'width 0.5s' // smoothly increase progress
52
+
53
+ progress.style.width = next + "%"
54
+ currentProgress = next
55
+ }
56
+
57
+ function setShowing(data) {
58
+ document.getElementById("main").style.display = data ? "none" : "flex"
59
+ document.getElementById("custom-rfid").style.display = data ? "flex" : "none"
60
+ }
@@ -88,10 +88,12 @@ body {
88
88
  top: 1px;
89
89
  }
90
90
 
91
+ .radio {
92
+ align-items: baseline;
93
+ padding: 15px;
94
+ }
95
+
91
96
  input[type="checkbox"] {
92
- appearance: none;
93
- -webkit-appearance: none;
94
- -moz-appearance: none;
95
97
  width: 20px;
96
98
  height: 20px;
97
99
  border: 2px solid black;
@@ -121,10 +123,9 @@ input[type="text"] {
121
123
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
122
124
  }
123
125
 
124
- .progress {
126
+ #progress {
125
127
  width: 0%;
126
128
  height: 20px;
127
129
  background-color: #4285F4;
128
130
  border-radius: 5px;
129
- transition: width 0.5s ease-in-out;
130
- }
131
+ }