@regulaforensics/cordova-plugin-document-reader-api 6.9.0 → 7.1.0

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.
@@ -0,0 +1,690 @@
1
+ //
2
+ // Config.java
3
+ // DocumentReader
4
+ //
5
+ // Created by Pavel Masiuk on 21.09.2023.
6
+ // Copyright © 2023 Regula. All rights reserved.
7
+ //
8
+
9
+ package cordova.plugin.documentreader
10
+
11
+ import android.content.Context
12
+ import android.graphics.Paint
13
+ import android.graphics.Typeface
14
+ import android.graphics.drawable.Drawable
15
+ import android.text.SpannableString
16
+ import android.widget.ImageView
17
+ import androidx.core.content.ContextCompat
18
+ import com.regula.documentreader.api.enums.CustomizationColor
19
+ import com.regula.documentreader.api.enums.CustomizationFont
20
+ import com.regula.documentreader.api.enums.CustomizationImage
21
+ import com.regula.documentreader.api.params.AuthenticityParams
22
+ import com.regula.documentreader.api.params.Functionality
23
+ import com.regula.documentreader.api.params.ImageQA
24
+ import com.regula.documentreader.api.params.LivenessParams
25
+ import com.regula.documentreader.api.params.ParamsCustomization
26
+ import com.regula.documentreader.api.params.ProcessParam
27
+ import com.regula.documentreader.api.params.RfidScenario
28
+ import com.regula.documentreader.api.params.rfid.dg.DataGroups
29
+ import com.regula.documentreader.api.params.rfid.dg.EIDDataGroups
30
+ import com.regula.documentreader.api.params.rfid.dg.EPassportDataGroups
31
+ import cordova.plugin.documentreader.Convert.toDrawable
32
+ import cordova.plugin.documentreader.Convert.toString
33
+ import org.json.JSONArray
34
+ import org.json.JSONObject
35
+
36
+ fun setFunctionality(functionality: Functionality, opts: JSONObject) = opts.forEach { k, v ->
37
+ val editor = functionality.edit()
38
+ when (k) {
39
+ "pictureOnBoundsReady" -> editor.setPictureOnBoundsReady(v as Boolean)
40
+ "showTorchButton" -> editor.setShowTorchButton(v as Boolean)
41
+ "showCloseButton" -> editor.setShowCloseButton(v as Boolean)
42
+ "videoCaptureMotionControl" -> editor.setVideoCaptureMotionControl(v as Boolean)
43
+ "showCaptureButton" -> editor.setShowCaptureButton(v as Boolean)
44
+ "showChangeFrameButton" -> editor.setShowChangeFrameButton(v as Boolean)
45
+ "showSkipNextPageButton" -> editor.setShowSkipNextPageButton(v as Boolean)
46
+ "useAuthenticator" -> editor.setUseAuthenticator(v as Boolean)
47
+ "skipFocusingFrames" -> editor.setSkipFocusingFrames(v as Boolean)
48
+ "showCameraSwitchButton" -> editor.setShowCameraSwitchButton(v as Boolean)
49
+ "displayMetadata" -> editor.setDisplayMetadata(v as Boolean)
50
+ "isZoomEnabled" -> editor.setZoomEnabled(v as Boolean)
51
+ "isCameraTorchCheckDisabled" -> editor.setIsCameraTorchCheckDisabled(v as Boolean)
52
+ "recordScanningProcess" -> editor.setDoRecordProcessingVideo(v as Boolean)
53
+ "manualMultipageMode" -> editor.setManualMultipageMode(v as Boolean)
54
+ "showCaptureButtonDelayFromDetect" -> editor.setShowCaptureButtonDelayFromDetect(v.toLong())
55
+ "showCaptureButtonDelayFromStart" -> editor.setShowCaptureButtonDelayFromStart(v.toLong())
56
+ "orientation" -> editor.setOrientation(v.toInt())
57
+ "captureMode" -> editor.setCaptureMode(v.toInt())
58
+ "cameraPosition" -> editor.setCameraMode(v.toInt())
59
+ "rfidTimeout" -> editor.setRfidTimeout(v.toInt())
60
+ "forcePagesCount" -> editor.setForcePagesCount(v.toInt())
61
+ "cameraFrame" -> editor.setCameraFrame(v as String)
62
+ "btDeviceName" -> editor.setBtDeviceName(v as String)
63
+ "zoomFactor" -> editor.setZoomFactor(v.toFloat())
64
+ "exposure" -> editor.setExposure(v.toFloat())
65
+ "excludedCamera2Models" -> editor.setExcludedCamera2Models(stringListFromJson(v as JSONArray))
66
+ "cameraSize" -> editor.setCameraSize(cameraSizeFromJSON(v as JSONObject).first, cameraSizeFromJSON(v).second)
67
+ }
68
+ editor.apply()
69
+ }
70
+
71
+ fun getFunctionality(functionality: Functionality) = mapOf(
72
+ "pictureOnBoundsReady" to functionality.isPictureOnBoundsReady,
73
+ "showTorchButton" to functionality.isShowTorchButton,
74
+ "showCloseButton" to functionality.isShowCloseButton,
75
+ "videoCaptureMotionControl" to functionality.isVideoCaptureMotionControl,
76
+ "showCaptureButton" to functionality.isShowCaptureButton,
77
+ "showChangeFrameButton" to functionality.isShowChangeFrameButton,
78
+ "showSkipNextPageButton" to functionality.isShowSkipNextPageButton,
79
+ "useAuthenticator" to functionality.isUseAuthenticator,
80
+ "skipFocusingFrames" to functionality.isSkipFocusingFrames,
81
+ "showCameraSwitchButton" to functionality.isShowCameraSwitchButton,
82
+ "displayMetadata" to functionality.isDisplayMetaData,
83
+ "isZoomEnabled" to functionality.isZoomEnabled,
84
+ "isCameraTorchCheckDisabled" to functionality.isCameraTorchCheckDisabled,
85
+ "recordScanningProcess" to functionality.doRecordProcessingVideo(),
86
+ "manualMultipageMode" to functionality.isManualMultipageMode,
87
+ "showCaptureButtonDelayFromDetect" to functionality.showCaptureButtonDelayFromDetect,
88
+ "showCaptureButtonDelayFromStart" to functionality.showCaptureButtonDelayFromStart,
89
+ "orientation" to functionality.orientation,
90
+ "captureMode" to functionality.captureMode,
91
+ "cameraPosition" to functionality.cameraMode,
92
+ "rfidTimeout" to functionality.rfidTimeout,
93
+ "forcePagesCount" to functionality.forcePagesCount,
94
+ "cameraFrame" to functionality.cameraFrame,
95
+ "btDeviceName" to functionality.btDeviceName,
96
+ "zoomFactor" to functionality.zoomFactor,
97
+ "exposure" to functionality.exposure,
98
+ "excludedCamera2Models" to generateList(functionality.excludedCamera2Models),
99
+ "cameraSize" to generateCameraSize(functionality.cameraWidth, functionality.cameraHeight)
100
+ ).toJsonObject()
101
+
102
+ @Suppress("DEPRECATION")
103
+ fun setProcessParams(processParams: ProcessParam, opts: JSONObject) = opts.forEach { k, v ->
104
+ when (k) {
105
+ "multipageProcessing" -> processParams.multipageProcessing = v as Boolean
106
+ "logs" -> processParams.setLogs(v as Boolean)
107
+ "debugSaveImages" -> processParams.debugSaveImages = v as Boolean
108
+ "debugSaveLogs" -> processParams.debugSaveLogs = v as Boolean
109
+ "returnUncroppedImage" -> processParams.returnUncroppedImage = v as Boolean
110
+ "uvTorchEnabled" -> processParams.uvTorchEnabled = v as Boolean
111
+ "debugSaveCroppedImages" -> processParams.debugSaveCroppedImages = v as Boolean
112
+ "disableFocusingCheck" -> processParams.disableFocusingCheck = v as Boolean
113
+ "debugSaveRFIDSession" -> processParams.debugSaveRFIDSession = v as Boolean
114
+ "doublePageSpread" -> processParams.doublePageSpread = v as Boolean
115
+ "manualCrop" -> processParams.manualCrop = v as Boolean
116
+ "integralImage" -> processParams.integralImage = v as Boolean
117
+ "returnCroppedBarcode" -> processParams.returnCroppedBarcode = v as Boolean
118
+ "checkRequiredTextFields" -> processParams.checkRequiredTextFields = v as Boolean
119
+ "depersonalizeLog" -> processParams.depersonalizeLog = v as Boolean
120
+ "generateDoublePageSpreadImage" -> processParams.generateDoublePageSpreadImage = v as Boolean
121
+ "alreadyCropped" -> processParams.alreadyCropped = v as Boolean
122
+ "matchTextFieldMask" -> processParams.matchTextFieldMask = v as Boolean
123
+ "updateOCRValidityByGlare" -> processParams.updateOCRValidityByGlare = v as Boolean
124
+ "noGraphics" -> processParams.noGraphics = v as Boolean
125
+ "multiDocOnImage" -> processParams.multiDocOnImage = v as Boolean
126
+ "forceReadMrzBeforeLocate" -> processParams.forceReadMrzBeforeLocate = v as Boolean
127
+ "parseBarcodes" -> processParams.parseBarcodes = v as Boolean
128
+ "shouldReturnPackageForReprocess" -> processParams.shouldReturnPackageForReprocess = v as Boolean
129
+ "disablePerforationOCR" -> processParams.disablePerforationOCR = v as Boolean
130
+ "respectImageQuality" -> processParams.respectImageQuality = v as Boolean
131
+ "splitNames" -> processParams.splitNames = v as Boolean
132
+ "doDetectCan" -> processParams.doDetectCan = v as Boolean
133
+ "useFaceApi" -> processParams.useFaceApi = v as Boolean
134
+ "useAuthenticityCheck" -> processParams.useAuthenticityCheck = v as Boolean
135
+ "checkHologram" -> processParams.checkHologram = v as Boolean
136
+ "measureSystem" -> processParams.measureSystem = v.toInt()
137
+ "barcodeParserType" -> processParams.barcodeParserType = v.toInt()
138
+ "perspectiveAngle" -> processParams.perspectiveAngle = v.toInt()
139
+ "minDPI" -> processParams.minDPI = v.toInt()
140
+ "imageDpiOutMax" -> processParams.imageDpiOutMax = v.toInt()
141
+ "forceDocID" -> processParams.forceDocID = v.toInt()
142
+ "forceDocFormat" -> processParams.forceDocFormat = v.toInt()
143
+ "shiftExpiryDate" -> processParams.shiftExpiryDate = v.toInt()
144
+ "minimalHolderAge" -> processParams.minimalHolderAge = v.toInt()
145
+ "imageOutputMaxHeight" -> processParams.imageOutputMaxHeight = v.toInt()
146
+ "imageOutputMaxWidth" -> processParams.imageOutputMaxWidth = v.toInt()
147
+ "processAuth" -> processParams.processAuth = v.toInt()
148
+ "convertCase" -> processParams.convertCase = v.toInt()
149
+ "dateFormat" -> processParams.dateFormat = v as String
150
+ "scenario" -> processParams.scenario = v as String
151
+ "captureButtonScenario" -> processParams.captureButtonScenario = v as String
152
+ "sessionLogFolder" -> processParams.sessionLogFolder = v as String
153
+ "timeout" -> processParams.timeout = v as Double
154
+ "timeoutFromFirstDetect" -> processParams.timeoutFromFirstDetect = v as Double
155
+ "timeoutFromFirstDocType" -> processParams.timeoutFromFirstDocType = v as Double
156
+ "documentAreaMin" -> processParams.documentAreaMin = v as Double
157
+ "documentIDList" -> processParams.documentIDList = v.toIntArray()
158
+ "fieldTypesFilter" -> processParams.fieldTypesFilter = v.toIntArray()
159
+ "resultTypeOutput" -> processParams.resultTypeOutput = v.toIntArray()
160
+ "documentGroupFilter" -> processParams.documentGroupFilter = v.toIntArray()
161
+ "lcidIgnoreFilter" -> processParams.lcidIgnoreFilter = v.toIntArray()
162
+ "lcidFilter" -> processParams.lcidFilter = v.toIntArray()
163
+ "barcodeTypes" -> processParams.doBarcodes = barcodeTypeArrayFromJson(v as JSONArray)
164
+ "mrzFormatsFilter" -> processParams.mrzFormatsFilter = stringArrayFromJson(v as JSONArray)
165
+ "customParams" -> processParams.customParams = v as JSONObject
166
+ "imageQA" -> setImageQA(processParams.imageQA, v as JSONObject)
167
+ "rfidParams" -> processParams.rfidParams = rfidParamsFromJSON(v as JSONObject)
168
+ "faceApiParams" -> processParams.faceApiParams = faceApiParamsFromJSON(v as JSONObject)
169
+ "backendProcessingConfig" -> processParams.backendProcessingConfig = backendProcessingConfigFromJSON(v as JSONObject)
170
+ "authenticityParams" -> {
171
+ if (processParams.authenticityParams == null) processParams.authenticityParams = AuthenticityParams.defaultParams()
172
+ setAuthenticityParams(processParams.authenticityParams!!, v as JSONObject)
173
+ }
174
+ }
175
+ }
176
+
177
+ @Suppress("DEPRECATION")
178
+ fun getProcessParams(processParams: ProcessParam) = mapOf(
179
+ "multipageProcessing" to processParams.multipageProcessing,
180
+ "logs" to processParams.isLogEnable,
181
+ "debugSaveImages" to processParams.debugSaveImages,
182
+ "debugSaveLogs" to processParams.debugSaveLogs,
183
+ "returnUncroppedImage" to processParams.returnUncroppedImage,
184
+ "uvTorchEnabled" to processParams.uvTorchEnabled,
185
+ "debugSaveCroppedImages" to processParams.debugSaveCroppedImages,
186
+ "disableFocusingCheck" to processParams.disableFocusingCheck,
187
+ "debugSaveRFIDSession" to processParams.debugSaveRFIDSession,
188
+ "doublePageSpread" to processParams.doublePageSpread,
189
+ "manualCrop" to processParams.manualCrop,
190
+ "integralImage" to processParams.integralImage,
191
+ "returnCroppedBarcode" to processParams.returnCroppedBarcode,
192
+ "checkRequiredTextFields" to processParams.checkRequiredTextFields,
193
+ "depersonalizeLog" to processParams.depersonalizeLog,
194
+ "generateDoublePageSpreadImage" to processParams.generateDoublePageSpreadImage,
195
+ "alreadyCropped" to processParams.alreadyCropped,
196
+ "matchTextFieldMask" to processParams.matchTextFieldMask,
197
+ "updateOCRValidityByGlare" to processParams.updateOCRValidityByGlare,
198
+ "noGraphics" to processParams.noGraphics,
199
+ "multiDocOnImage" to processParams.multiDocOnImage,
200
+ "forceReadMrzBeforeLocate" to processParams.forceReadMrzBeforeLocate,
201
+ "parseBarcodes" to processParams.parseBarcodes,
202
+ "shouldReturnPackageForReprocess" to processParams.shouldReturnPackageForReprocess,
203
+ "disablePerforationOCR" to processParams.disablePerforationOCR,
204
+ "respectImageQuality" to processParams.respectImageQuality,
205
+ "splitNames" to processParams.splitNames,
206
+ "doDetectCan" to processParams.doDetectCan,
207
+ "useFaceApi" to processParams.useFaceApi,
208
+ "useAuthenticityCheck" to processParams.useAuthenticityCheck,
209
+ "checkHologram" to processParams.checkHologram,
210
+ "measureSystem" to processParams.measureSystem,
211
+ "barcodeParserType" to processParams.barcodeParserType,
212
+ "perspectiveAngle" to processParams.perspectiveAngle,
213
+ "minDPI" to processParams.minDPI,
214
+ "imageDpiOutMax" to processParams.imageDpiOutMax,
215
+ "forceDocID" to processParams.forceDocID,
216
+ "forceDocFormat" to processParams.forceDocFormat,
217
+ "shiftExpiryDate" to processParams.shiftExpiryDate,
218
+ "minimalHolderAge" to processParams.minimalHolderAge,
219
+ "imageOutputMaxHeight" to processParams.imageOutputMaxHeight,
220
+ "imageOutputMaxWidth" to processParams.imageOutputMaxWidth,
221
+ "processAuth" to processParams.processAuth,
222
+ "convertCase" to processParams.convertCase,
223
+ "dateFormat" to processParams.dateFormat,
224
+ "scenario" to processParams.scenario,
225
+ "captureButtonScenario" to processParams.captureButtonScenario,
226
+ "sessionLogFolder" to processParams.sessionLogFolder,
227
+ "timeout" to processParams.timeout,
228
+ "timeoutFromFirstDetect" to processParams.timeoutFromFirstDetect,
229
+ "timeoutFromFirstDocType" to processParams.timeoutFromFirstDocType,
230
+ "documentAreaMin" to processParams.documentAreaMin,
231
+ "documentIDList" to processParams.documentIDList.generate(),
232
+ "fieldTypesFilter" to processParams.fieldTypesFilter.generate(),
233
+ "documentGroupFilter" to processParams.documentGroupFilter.generate(),
234
+ "lcidIgnoreFilter" to processParams.lcidIgnoreFilter.generate(),
235
+ "lcidFilter" to processParams.lcidFilter.generate(),
236
+ "resultTypeOutput" to processParams.resultTypeOutput.generate(),
237
+ "mrzFormatsFilter" to generateArray(processParams.mrzFormatsFilter),
238
+ "barcodeTypes" to generateBarcodeTypeArray(processParams.doBarcodes),
239
+ "imageQA" to getImageQA(processParams.imageQA),
240
+ "rfidParams" to generateRFIDParams(processParams.rfidParams),
241
+ "faceApiParams" to generateFaceApiParams(processParams.faceApiParams),
242
+ "backendProcessingConfig" to generateBackendProcessingConfig(processParams.backendProcessingConfig),
243
+ "authenticityParams" to getAuthenticityParams(processParams.authenticityParams),
244
+ "customParams" to processParams.customParams,
245
+ ).toJsonObject()
246
+
247
+ fun setCustomization(customization: ParamsCustomization, opts: JSONObject, context: Context) = opts.forEach { k, v ->
248
+ val editor = customization.edit()
249
+ when (k) {
250
+ "showStatusMessages" -> editor.setShowStatusMessages(v as Boolean)
251
+ "showResultStatusMessages" -> editor.setShowResultStatusMessages(v as Boolean)
252
+ "showHelpAnimation" -> editor.setShowHelpAnimation(v as Boolean)
253
+ "showNextPageAnimation" -> editor.setShowNextPageAnimation(v as Boolean)
254
+ "showBackgroundMask" -> editor.setShowBackgroundMask(v as Boolean)
255
+ "cameraFrameBorderWidth" -> editor.setCameraFrameBorderWidth(v.toInt())
256
+ "cameraFrameLineLength" -> editor.setCameraFrameLineLength(v.toInt())
257
+ "cameraFrameShapeType" -> editor.setCameraFrameShapeType(v.toInt())
258
+ "cameraFrameOffsetWidth" -> editor.setCameraFrameOffsetWidth(v.toInt())
259
+ "activityIndicatorSize" -> editor.setActivityIndicatorSize(v.toInt())
260
+ "status" -> editor.setStatus(v as String)
261
+ "resultStatus" -> editor.setResultStatus(v as String)
262
+ "cameraFrameDefaultColor" -> editor.setCameraFrameDefaultColor(v.toColor())
263
+ "cameraFrameActiveColor" -> editor.setCameraFrameActiveColor(v.toColor())
264
+ "statusTextColor" -> editor.setStatusTextColor(v.toColor())
265
+ "resultStatusTextColor" -> editor.setResultStatusTextColor(v.toColor())
266
+ "resultStatusBackgroundColor" -> editor.setResultStatusBackgroundColor(v.toColor())
267
+ "multipageButtonBackgroundColor" -> editor.setMultipageButtonBackgroundColor(v.toColor())
268
+ "tintColor" -> editor.setTintColor(v.toColor())
269
+ "activityIndicatorColor" -> editor.setActivityIndicatorColor(v.toColor())
270
+ "statusBackgroundColor" -> editor.setStatusBackgroundColor(v.toColor())
271
+ "cameraPreviewBackgroundColor" -> editor.setCameraPreviewBackgroundColor(v.toColor())
272
+ "statusPositionMultiplier" -> editor.setStatusPositionMultiplier(v.toFloat())
273
+ "resultStatusPositionMultiplier" -> editor.setResultStatusPositionMultiplier(v.toFloat())
274
+ "toolbarSize" -> editor.setToolbarSize(v.toFloat())
275
+ "backgroundMaskAlpha" -> editor.setBackgroundMaskAlpha(v.toFloat())
276
+ "customStatusPositionMultiplier" -> editor.setCustomStatusPositionMultiplier(v.toFloat())
277
+ "cameraFrameVerticalPositionMultiplier" -> editor.setCameraFrameVerticalPositionMultiplier(v.toFloat())
278
+ "cameraFrameLandscapeAspectRatio" -> editor.setCameraFrameLandscapeAspectRatio(v.toFloat())
279
+ "cameraFramePortraitAspectRatio" -> editor.setCameraFramePortraitAspectRatio(v.toFloat())
280
+ "cameraFrameCornerRadius" -> editor.setCameraFrameCornerRadius(v.toFloat())
281
+ "livenessAnimationPositionMultiplier" -> editor.setLivenessAnimationPositionMultiplier(v.toFloat())
282
+ "multipageAnimationFrontImage" -> editor.setMultipageAnimationFrontImage(v.toDrawable(context))
283
+ "multipageAnimationBackImage" -> editor.setMultipageAnimationBackImage(v.toDrawable(context))
284
+ "borderBackgroundImage" -> editor.setBorderBackgroundImage(v.toDrawable(context))
285
+ "helpAnimationImage" -> editor.setHelpAnimationImage(v.toDrawable(context))
286
+ "closeButtonImage" -> editor.setCloseButtonImage(v.toDrawable(context))
287
+ "captureButtonImage" -> editor.setCaptureButtonImage(v.toDrawable(context))
288
+ "changeFrameButtonCollapseImage" -> editor.setChangeFrameCollapseButtonImage(v.toDrawable(context))
289
+ "changeFrameButtonExpandImage" -> editor.setChangeFrameExpandButtonImage(v.toDrawable(context))
290
+ "cameraSwitchButtonImage" -> editor.setCameraSwitchButtonImage(v.toDrawable(context))
291
+ "torchButtonOnImage" -> editor.setTorchImageOn(v.toDrawable(context))
292
+ "torchButtonOffImage" -> editor.setTorchImageOff(v.toDrawable(context))
293
+ "livenessAnimationImage" -> editor.setLivenessAnimationImage(v.toDrawable(context))
294
+ "helpAnimationImageMatrix" -> editor.setHelpAnimationImageMatrix(v.toMatrix()).setHelpAnimationImageScaleType(ImageView.ScaleType.MATRIX)
295
+ "multipageAnimationFrontImageMatrix" -> editor.setMultipageAnimationFrontImageMatrix(v.toMatrix()).setMultipageAnimationFrontImageScaleType(ImageView.ScaleType.MATRIX)
296
+ "multipageAnimationBackImageMatrix" -> editor.setMultipageAnimationBackImageMatrix(v.toMatrix()).setMultipageAnimationBackImageScaleType(ImageView.ScaleType.MATRIX)
297
+ "livenessAnimationImageMatrix" -> editor.setLivenessAnimationImageMatrix(v.toMatrix()).setLivenessAnimationImageScaleType(ImageView.ScaleType.MATRIX)
298
+ "borderBackgroundImageMatrix" -> editor.setBorderBackgroundImageMatrix(v.toMatrix()).setBorderBackgroundImageScaleType(ImageView.ScaleType.MATRIX)
299
+ "customLabelStatus" -> editor.setCustomLabelStatus(SpannableString(v as String))
300
+ "cameraFrameLineCap" -> editor.setCameraFrameLineCap(Paint.Cap.values()[v.toInt()])
301
+ "uiCustomizationLayer" -> editor.setUiCustomizationLayer(v as JSONObject)
302
+ "colors" -> setColors(editor, v as JSONObject)
303
+ "fonts" -> setFonts(editor, v as JSONObject)
304
+ "images" -> setImages(editor, v as JSONObject, context)
305
+ "statusTextFont" -> {
306
+ val font = typefaceFromJSON(v as JSONObject)
307
+ editor.setStatusTextFont(font.first)
308
+ font.second?.let { editor.setStatusTextSize(it) }
309
+ }
310
+
311
+ "resultStatusTextFont" -> {
312
+ val font = typefaceFromJSON(v as JSONObject)
313
+ editor.setResultStatusTextFont(font.first)
314
+ font.second?.let { editor.setResultStatusTextSize(it) }
315
+ }
316
+ }
317
+ editor.applyImmediately(context)
318
+ }
319
+
320
+ fun getCustomization(customization: ParamsCustomization) = mapOf(
321
+ "showStatusMessages" to customization.isShowStatusMessages,
322
+ "showResultStatusMessages" to customization.isShowResultStatusMessages,
323
+ "showHelpAnimation" to customization.isShowHelpAnimation,
324
+ "showNextPageAnimation" to customization.isShowNextPageAnimation,
325
+ "showBackgroundMask" to customization.isShowBackgroundMask,
326
+ "cameraFrameBorderWidth" to customization.cameraFrameBorderWidth,
327
+ "cameraFrameLineLength" to customization.cameraFrameLineLength,
328
+ "cameraFrameShapeType" to customization.cameraFrameShapeType,
329
+ "cameraFrameOffsetWidth" to customization.cameraFrameOffsetWidth,
330
+ "activityIndicatorSize" to customization.activityIndicatorSize,
331
+ "status" to customization.status,
332
+ "resultStatus" to customization.resultStatus,
333
+ "cameraFrameDefaultColor" to customization.cameraFrameDefaultColor.toLong(),
334
+ "cameraFrameActiveColor" to customization.cameraFrameActiveColor.toLong(),
335
+ "statusTextColor" to customization.statusTextColor.toLong(),
336
+ "resultStatusTextColor" to customization.resultStatusTextColor.toLong(),
337
+ "resultStatusBackgroundColor" to customization.resultStatusBackgroundColor.toLong(),
338
+ "multipageButtonBackgroundColor" to customization.multipageButtonBackgroundColor.toLong(),
339
+ "tintColor" to customization.tintColor.toLong(),
340
+ "activityIndicatorColor" to customization.activityIndicatorColor.toLong(),
341
+ "statusBackgroundColor" to customization.statusBackgroundColor.toLong(),
342
+ "cameraPreviewBackgroundColor" to customization.cameraPreviewBackgroundColor.toLong(),
343
+ "statusPositionMultiplier" to customization.statusPositionMultiplier,
344
+ "resultStatusPositionMultiplier" to customization.resultStatusPositionMultiplier,
345
+ "backgroundMaskAlpha" to customization.backgroundMaskAlpha,
346
+ "toolbarSize" to customization.toolbarSize,
347
+ "customStatusPositionMultiplier" to customization.customStatusPositionMultiplier,
348
+ "cameraFrameVerticalPositionMultiplier" to customization.cameraFrameVerticalPositionMultiplier,
349
+ "cameraFrameLandscapeAspectRatio" to customization.cameraFrameLandscapeAspectRatio,
350
+ "cameraFramePortraitAspectRatio" to customization.cameraFramePortraitAspectRatio,
351
+ "cameraFrameCornerRadius" to customization.cameraFrameCornerRadius,
352
+ "livenessAnimationPositionMultiplier" to customization.livenessAnimationPositionMultiplier,
353
+ "multipageAnimationFrontImage" to customization.multipageAnimationFrontImage.toString(),
354
+ "multipageAnimationBackImage" to customization.multipageAnimationBackImage.toString(),
355
+ "borderBackgroundImage" to customization.borderBackgroundImage.toString(),
356
+ "helpAnimationImage" to customization.helpAnimationImageDrawable.toString(),
357
+ "closeButtonImage" to customization.closeButtonDrawable.toString(),
358
+ "captureButtonImage" to customization.captureButtonDrawable.toString(),
359
+ "changeFrameButtonCollapseImage" to customization.changeFrameCollapseButtonDrawable.toString(),
360
+ "changeFrameButtonExpandImage" to customization.changeFrameExpandButtonDrawable.toString(),
361
+ "cameraSwitchButtonImage" to customization.cameraSwitchButtonDrawable.toString(),
362
+ "torchButtonOnImage" to customization.torchImageOnDrawable.toString(),
363
+ "torchButtonOffImage" to customization.torchImageOffDrawable.toString(),
364
+ "livenessAnimationImage" to customization.livenessAnimationImage.toString(),
365
+ "helpAnimationImageMatrix" to customization.helpAnimationImageMatrix.generate(),
366
+ "multipageAnimationFrontImageMatrix" to customization.multipageAnimationFrontImageMatrix.generate(),
367
+ "multipageAnimationBackImageMatrix" to customization.multipageAnimationBackImageMatrix.generate(),
368
+ "livenessAnimationImageMatrix" to customization.livenessAnimationImageMatrix.generate(),
369
+ "borderBackgroundImageMatrix" to customization.borderBackgroundImageMatrix.generate(),
370
+ "statusTextFont" to generateTypeface(customization.statusTextFont, customization.statusTextSize),
371
+ "resultStatusTextFont" to generateTypeface(customization.resultStatusTextFont, customization.resultStatusTextSize),
372
+ "customLabelStatus" to customization.customLabelStatus?.toString(),
373
+ "cameraFrameLineCap" to paintCapToInt(customization.cameraFrameLineCap),
374
+ "uiCustomizationLayer" to customization.uiCustomizationLayer,
375
+ "colors" to getColors(customization.colors),
376
+ "fonts" to getFonts(customization.typeFaces, customization.fontSizes),
377
+ "images" to getImages(customization.images)
378
+ ).toJsonObject()
379
+
380
+ fun setRfidScenario(rfidScenario: RfidScenario, opts: JSONObject) = opts.forEach { k, v ->
381
+ when (k) {
382
+ "paceStaticBinding" -> rfidScenario.isPaceStaticBinding = v as Boolean
383
+ "onlineTA" -> rfidScenario.isOnlineTA = v as Boolean
384
+ "writeEid" -> rfidScenario.isWriteEid = v as Boolean
385
+ "universalAccessRights" -> rfidScenario.isUniversalAccessRights = v as Boolean
386
+ "authorizedRestrictedIdentification" -> rfidScenario.isAuthorizedRestrictedIdentification = v as Boolean
387
+ "auxVerificationCommunityID" -> rfidScenario.isAuxVerificationCommunityID = v as Boolean
388
+ "auxVerificationDateOfBirth" -> rfidScenario.isAuxVerificationDateOfBirth = v as Boolean
389
+ "skipAA" -> rfidScenario.isSkipAA = v as Boolean
390
+ "strictProcessing" -> rfidScenario.isStrictProcessing = v as Boolean
391
+ "pkdDSCertPriority" -> rfidScenario.isPkdDSCertPriority = v as Boolean
392
+ "pkdUseExternalCSCA" -> rfidScenario.isPkdUseExternalCSCA = v as Boolean
393
+ "trustedPKD" -> rfidScenario.isTrustedPKD = v as Boolean
394
+ "passiveAuth" -> rfidScenario.isPassiveAuth = v as Boolean
395
+ "useSFI" -> rfidScenario.isUseSFI = v as Boolean
396
+ "readEPassport" -> rfidScenario.isReadEPassport = v as Boolean
397
+ "readEID" -> rfidScenario.isReadEID = v as Boolean
398
+ "readEDL" -> rfidScenario.isReadEDL = v as Boolean
399
+ "authorizedSTSignature" -> rfidScenario.isAuthorizedSTSignature = v as Boolean
400
+ "authorizedSTQSignature" -> rfidScenario.isAuthorizedSTQSignature = v as Boolean
401
+ "authorizedWriteDG17" -> rfidScenario.isAuthorizedWriteDG17 = v as Boolean
402
+ "authorizedWriteDG18" -> rfidScenario.isAuthorizedWriteDG18 = v as Boolean
403
+ "authorizedWriteDG19" -> rfidScenario.isAuthorizedWriteDG19 = v as Boolean
404
+ "authorizedWriteDG20" -> rfidScenario.isAuthorizedWriteDG20 = v as Boolean
405
+ "authorizedWriteDG21" -> rfidScenario.isAuthorizedWriteDG21 = v as Boolean
406
+ "authorizedVerifyAge" -> rfidScenario.isAuthorizedVerifyAge = v as Boolean
407
+ "authorizedVerifyCommunityID" -> rfidScenario.isAuthorizedVerifyCommunityID = v as Boolean
408
+ "authorizedPrivilegedTerminal" -> rfidScenario.isAuthorizedPrivilegedTerminal = v as Boolean
409
+ "authorizedCANAllowed" -> rfidScenario.isAuthorizedCANAllowed = v as Boolean
410
+ "authorizedPINManagement" -> rfidScenario.isAuthorizedPINManagment = v as Boolean
411
+ "authorizedInstallCert" -> rfidScenario.isAuthorizedInstallCert = v as Boolean
412
+ "authorizedInstallQCert" -> rfidScenario.isAuthorizedInstallQCert = v as Boolean
413
+ "applyAmendments" -> rfidScenario.isApplyAmendments = v as Boolean
414
+ "autoSettings" -> rfidScenario.isAutoSettings = v as Boolean
415
+ "signManagementAction" -> rfidScenario.signManagementAction = v.toInt()
416
+ "readingBuffer" -> rfidScenario.readingBuffer = v.toInt()
417
+ "onlineTAToSignDataType" -> rfidScenario.onlineTAToSignDataType = v.toInt()
418
+ "profilerType" -> rfidScenario.profilerType = v.toInt()
419
+ "authProcType" -> rfidScenario.authProcType = v.toInt()
420
+ "baseSMProcedure" -> rfidScenario.baseSMProcedure = v.toInt()
421
+ "pacePasswordType" -> rfidScenario.pacePasswordType = v.toInt()
422
+ "terminalType" -> rfidScenario.terminalType = v.toInt()
423
+ "defaultReadingBufferSize" -> rfidScenario.defaultReadingBufferSize = v.toInt()
424
+ "password" -> rfidScenario.password = v as String
425
+ "pkdPA" -> rfidScenario.pkdPA = v as String
426
+ "pkdEAC" -> rfidScenario.pkdEAC = v as String
427
+ "mrz" -> rfidScenario.mrz = v as String
428
+ "eSignPINDefault" -> rfidScenario.seteSignPINDefault(v as String)
429
+ "eSignPINNewValue" -> rfidScenario.seteSignPINNewValue(v as String)
430
+ "ePassportDataGroups" -> setDataGroups(rfidScenario.ePassportDataGroups(), v as JSONObject)
431
+ "eIDDataGroups" -> setDataGroups(rfidScenario.eIDDataGroups(), v as JSONObject)
432
+ "eDLDataGroups" -> setDataGroups(rfidScenario.eDLDataGroups(), v as JSONObject)
433
+ }
434
+ }
435
+
436
+ fun getRfidScenario(rfidScenario: RfidScenario) = mapOf(
437
+ "paceStaticBinding" to rfidScenario.isPaceStaticBinding,
438
+ "onlineTA" to rfidScenario.isOnlineTA,
439
+ "writeEid" to rfidScenario.isWriteEid,
440
+ "universalAccessRights" to rfidScenario.isUniversalAccessRights,
441
+ "authorizedRestrictedIdentification" to rfidScenario.isAuthorizedRestrictedIdentification,
442
+ "auxVerificationCommunityID" to rfidScenario.isAuxVerificationCommunityID,
443
+ "auxVerificationDateOfBirth" to rfidScenario.isAuxVerificationDateOfBirth,
444
+ "skipAA" to rfidScenario.isSkipAA,
445
+ "strictProcessing" to rfidScenario.isStrictProcessing,
446
+ "pkdDSCertPriority" to rfidScenario.isPkdDSCertPriority,
447
+ "pkdUseExternalCSCA" to rfidScenario.isPkdUseExternalCSCA,
448
+ "trustedPKD" to rfidScenario.isTrustedPKD,
449
+ "passiveAuth" to rfidScenario.isPassiveAuth,
450
+ "useSFI" to rfidScenario.isUseSFI,
451
+ "readEPassport" to rfidScenario.isReadEPassport,
452
+ "readEID" to rfidScenario.isReadEID,
453
+ "readEDL" to rfidScenario.isReadEDL,
454
+ "authorizedSTSignature" to rfidScenario.isAuthorizedSTSignature,
455
+ "authorizedSTQSignature" to rfidScenario.isAuthorizedSTQSignature,
456
+ "authorizedWriteDG17" to rfidScenario.isAuthorizedWriteDG17,
457
+ "authorizedWriteDG18" to rfidScenario.isAuthorizedWriteDG18,
458
+ "authorizedWriteDG19" to rfidScenario.isAuthorizedWriteDG19,
459
+ "authorizedWriteDG20" to rfidScenario.isAuthorizedWriteDG20,
460
+ "authorizedWriteDG21" to rfidScenario.isAuthorizedWriteDG21,
461
+ "authorizedVerifyAge" to rfidScenario.isAuthorizedVerifyAge,
462
+ "authorizedVerifyCommunityID" to rfidScenario.isAuthorizedVerifyCommunityID,
463
+ "authorizedPrivilegedTerminal" to rfidScenario.isAuthorizedPrivilegedTerminal,
464
+ "authorizedCANAllowed" to rfidScenario.isAuthorizedCANAllowed,
465
+ "authorizedPINManagement" to rfidScenario.isAuthorizedPINManagment,
466
+ "authorizedInstallCert" to rfidScenario.isAuthorizedInstallCert,
467
+ "authorizedInstallQCert" to rfidScenario.isAuthorizedInstallQCert,
468
+ "applyAmendments" to rfidScenario.isApplyAmendments,
469
+ "autoSettings" to rfidScenario.isAutoSettings,
470
+ "signManagementAction" to rfidScenario.signManagementAction,
471
+ "readingBuffer" to rfidScenario.readingBuffer,
472
+ "onlineTAToSignDataType" to rfidScenario.onlineTAToSignDataType,
473
+ "profilerType" to rfidScenario.profilerType,
474
+ "authProcType" to rfidScenario.authProcType,
475
+ "baseSMProcedure" to rfidScenario.baseSMProcedure,
476
+ "pacePasswordType" to rfidScenario.pacePasswordType,
477
+ "terminalType" to rfidScenario.terminalType,
478
+ "defaultReadingBufferSize" to rfidScenario.defaultReadingBufferSize,
479
+ "password" to rfidScenario.password,
480
+ "pkdPA" to rfidScenario.pkdPA,
481
+ "pkdEAC" to rfidScenario.pkdEAC,
482
+ "mrz" to rfidScenario.mrz,
483
+ "eSignPINDefault" to rfidScenario.geteSignPINDefault(),
484
+ "eSignPINNewValue" to rfidScenario.geteSignPINNewValue(),
485
+ "ePassportDataGroups" to getDataGroups(rfidScenario.ePassportDataGroups()),
486
+ "eIDDataGroups" to getDataGroups(rfidScenario.eIDDataGroups()),
487
+ "eDLDataGroups" to getDataGroups(rfidScenario.eDLDataGroups())
488
+ ).toJsonObject()
489
+
490
+ fun setDataGroups(dataGroup: DataGroups, opts: JSONObject) = opts.forEach { k, v ->
491
+ val value = v as Boolean
492
+ when (k) {
493
+ "DG1" -> dataGroup.isDG1 = value
494
+ "DG2" -> dataGroup.isDG2 = value
495
+ "DG3" -> dataGroup.isDG3 = value
496
+ "DG4" -> dataGroup.isDG4 = value
497
+ "DG5" -> dataGroup.isDG5 = value
498
+ "DG6" -> dataGroup.isDG6 = value
499
+ "DG7" -> dataGroup.isDG7 = value
500
+ "DG8" -> dataGroup.isDG8 = value
501
+ "DG9" -> dataGroup.isDG9 = value
502
+ "DG10" -> dataGroup.isDG10 = value
503
+ "DG11" -> dataGroup.isDG11 = value
504
+ "DG12" -> dataGroup.isDG12 = value
505
+ "DG13" -> dataGroup.isDG13 = value
506
+ "DG14" -> dataGroup.isDG14 = value
507
+ }
508
+ if (dataGroup is EPassportDataGroups) when (k) {
509
+ "DG15" -> dataGroup.isDG15 = value
510
+ "DG16" -> dataGroup.isDG16 = value
511
+ }
512
+ if (dataGroup is EIDDataGroups) when (k) {
513
+ "DG15" -> dataGroup.isDG15 = value
514
+ "DG16" -> dataGroup.isDG16 = value
515
+ "DG17" -> dataGroup.isDG17 = value
516
+ "DG18" -> dataGroup.isDG18 = value
517
+ "DG19" -> dataGroup.isDG19 = value
518
+ "DG20" -> dataGroup.isDG20 = value
519
+ "DG21" -> dataGroup.isDG21 = value
520
+ }
521
+ }
522
+
523
+ fun getDataGroups(dataGroup: DataGroups): JSONObject {
524
+ val result = mutableMapOf(
525
+ "DG1" to dataGroup.isDG1,
526
+ "DG2" to dataGroup.isDG2,
527
+ "DG3" to dataGroup.isDG3,
528
+ "DG4" to dataGroup.isDG4,
529
+ "DG5" to dataGroup.isDG5,
530
+ "DG6" to dataGroup.isDG6,
531
+ "DG7" to dataGroup.isDG7,
532
+ "DG8" to dataGroup.isDG8,
533
+ "DG9" to dataGroup.isDG9,
534
+ "DG10" to dataGroup.isDG10,
535
+ "DG11" to dataGroup.isDG11,
536
+ "DG12" to dataGroup.isDG12,
537
+ "DG13" to dataGroup.isDG13,
538
+ "DG14" to dataGroup.isDG14
539
+ )
540
+ if (dataGroup is EPassportDataGroups) {
541
+ result["DG15"] = dataGroup.isDG15
542
+ result["DG16"] = dataGroup.isDG16
543
+ }
544
+ if (dataGroup is EIDDataGroups) {
545
+ result["DG15"] = dataGroup.isDG15
546
+ result["DG16"] = dataGroup.isDG16
547
+ result["DG17"] = dataGroup.isDG17
548
+ result["DG18"] = dataGroup.isDG18
549
+ result["DG19"] = dataGroup.isDG19
550
+ result["DG20"] = dataGroup.isDG20
551
+ result["DG21"] = dataGroup.isDG21
552
+ }
553
+ return result.toJsonObject()
554
+ }
555
+
556
+ fun setImageQA(input: ImageQA, opts: JSONObject) = opts.forEach { k, v ->
557
+ when (k) {
558
+ "focusCheck" -> input.focusCheck = v as Boolean
559
+ "glaresCheck" -> input.glaresCheck = v as Boolean
560
+ "colornessCheck" -> input.colornessCheck = v as Boolean
561
+ "screenCapture" -> input.screenCapture = v as Boolean
562
+ "dpiThreshold" -> input.dpiThreshold = v.toInt()
563
+ "angleThreshold" -> input.angleThreshold = v.toInt()
564
+ "documentPositionIndent" -> input.documentPositionIndent = v.toInt()
565
+ "brightnessThreshold" -> input.brightnessThreshold = v as Double
566
+ "expectedPass" -> input.expectedPass = v.toIntArray()
567
+ "glaresCheckParams" -> input.glaresCheckParams = glaresCheckParamsFromJSON(v as JSONObject)
568
+ }
569
+ }
570
+
571
+ fun getImageQA(input: ImageQA) = mapOf(
572
+ "focusCheck" to input.focusCheck,
573
+ "glaresCheck" to input.glaresCheck,
574
+ "colornessCheck" to input.colornessCheck,
575
+ "screenCapture" to input.screenCapture,
576
+ "dpiThreshold" to input.dpiThreshold,
577
+ "angleThreshold" to input.angleThreshold,
578
+ "documentPositionIndent" to input.documentPositionIndent,
579
+ "brightnessThreshold" to input.brightnessThreshold,
580
+ "expectedPass" to input.expectedPass.generate(),
581
+ "glaresCheckParams" to generateGlaresCheckParams(input.glaresCheckParams),
582
+ ).toJsonObject()
583
+
584
+ fun setAuthenticityParams(input: AuthenticityParams, opts: JSONObject) = opts.forEach { k, v ->
585
+ when (k) {
586
+ "useLivenessCheck" -> input.useLivenessCheck = v as Boolean
587
+ "checkUVLuminiscence" -> input.checkUVLuminiscence = v as Boolean
588
+ "checkIRB900" -> input.checkIRB900 = v as Boolean
589
+ "checkImagePatterns" -> input.checkImagePatterns = v as Boolean
590
+ "checkFibers" -> input.checkFibers = v as Boolean
591
+ "checkExtMRZ" -> input.checkExtMRZ = v as Boolean
592
+ "checkExtOCR" -> input.checkExtOCR = v as Boolean
593
+ "checkAxial" -> input.checkAxial = v as Boolean
594
+ "checkBarcodeFormat" -> input.checkBarcodeFormat = v as Boolean
595
+ "checkIRVisibility" -> input.checkIRVisibility = v as Boolean
596
+ "checkIPI" -> input.checkIPI = v as Boolean
597
+ "checkPhotoEmbedding" -> input.checkPhotoEmbedding = v as Boolean
598
+ "checkPhotoComparison" -> input.checkPhotoComparison = v as Boolean
599
+ "checkLetterScreen" -> input.checkLetterScreen = v as Boolean
600
+ "livenessParams" -> {
601
+ if (input.livenessParams == null) input.livenessParams = LivenessParams.defaultParams()
602
+ setLivenessParams(input.livenessParams!!, v as JSONObject)
603
+ }
604
+ }
605
+ }
606
+
607
+ fun getAuthenticityParams(input: AuthenticityParams?) = input?.let {
608
+ mapOf(
609
+ "useLivenessCheck" to it.useLivenessCheck,
610
+ "checkUVLuminiscence" to it.checkUVLuminiscence,
611
+ "checkIRB900" to input.checkIRB900,
612
+ "checkImagePatterns" to it.checkImagePatterns,
613
+ "checkFibers" to it.checkFibers,
614
+ "checkExtMRZ" to it.checkExtMRZ,
615
+ "checkExtOCR" to it.checkExtOCR,
616
+ "checkAxial" to it.checkAxial,
617
+ "checkBarcodeFormat" to it.checkBarcodeFormat,
618
+ "checkIRVisibility" to it.checkIRVisibility,
619
+ "checkIPI" to it.checkIPI,
620
+ "checkPhotoEmbedding" to it.checkPhotoEmbedding,
621
+ "checkPhotoComparison" to it.checkPhotoComparison,
622
+ "checkLetterScreen" to it.checkLetterScreen,
623
+ "livenessParams" to getLivenessParams(it.livenessParams)
624
+ ).toJsonObject()
625
+ }
626
+
627
+ fun setLivenessParams(input: LivenessParams, opts: JSONObject) = opts.forEach { k, v ->
628
+ when (k) {
629
+ "checkOVI" -> input.checkOVI = v as Boolean
630
+ "checkMLI" -> input.checkMLI = v as Boolean
631
+ "checkHolo" -> input.checkHolo = v as Boolean
632
+ "checkED" -> input.checkED = v as Boolean
633
+ }
634
+ }
635
+
636
+ fun getLivenessParams(input: LivenessParams?) = input?.let {
637
+ mapOf(
638
+ "checkOVI" to input.checkOVI,
639
+ "checkMLI" to input.checkMLI,
640
+ "checkHolo" to input.checkHolo,
641
+ "checkED" to input.checkED
642
+ ).toJsonObject()
643
+ }
644
+
645
+ fun setColors(input: ParamsCustomization.CustomizationEditor, opts: JSONObject) = opts.forEach { key, v ->
646
+ val value = v.toLong()
647
+ when (key) {
648
+ "rfidProcessingScreenBackground" -> input.setColor(CustomizationColor.RFID_PROCESSING_SCREEN_BACKGROUND, value)
649
+ "rfidProcessingScreenHintLabelText" -> input.setColor(CustomizationColor.RFID_PROCESSING_SCREEN_HINT_LABEL_TEXT, value)
650
+ "rfidProcessingScreenHintLabelBackground" -> input.setColor(CustomizationColor.RFID_PROCESSING_SCREEN_HINT_LABEL_BACKGROUND, value)
651
+ "rfidProcessingScreenProgressLabelText" -> input.setColor(CustomizationColor.RFID_PROCESSING_SCREEN_PROGRESS_LABEL_TEXT, value)
652
+ "rfidProcessingScreenProgressBar" -> input.setColor(CustomizationColor.RFID_PROCESSING_SCREEN_PROGRESS_BAR, value)
653
+ "rfidProcessingScreenProgressBarBackground" -> input.setColor(CustomizationColor.RFID_PROCESSING_SCREEN_PROGRESS_BAR_BACKGROUND, value)
654
+ "rfidProcessingScreenResultLabelText" -> input.setColor(CustomizationColor.RFID_PROCESSING_SCREEN_RESULT_LABEL_TEXT, value)
655
+ }
656
+ }
657
+
658
+ fun getColors(input: Map<CustomizationColor, Long>) = mapOf(
659
+ "rfidProcessingScreenBackground" to input[CustomizationColor.RFID_PROCESSING_SCREEN_BACKGROUND],
660
+ "rfidProcessingScreenHintLabelText" to input[CustomizationColor.RFID_PROCESSING_SCREEN_HINT_LABEL_TEXT],
661
+ "rfidProcessingScreenHintLabelBackground" to input[CustomizationColor.RFID_PROCESSING_SCREEN_HINT_LABEL_BACKGROUND],
662
+ "rfidProcessingScreenProgressLabelText" to input[CustomizationColor.RFID_PROCESSING_SCREEN_PROGRESS_LABEL_TEXT],
663
+ "rfidProcessingScreenProgressBar" to input[CustomizationColor.RFID_PROCESSING_SCREEN_PROGRESS_BAR],
664
+ "rfidProcessingScreenProgressBarBackground" to input[CustomizationColor.RFID_PROCESSING_SCREEN_PROGRESS_BAR_BACKGROUND],
665
+ "rfidProcessingScreenResultLabelText" to input[CustomizationColor.RFID_PROCESSING_SCREEN_RESULT_LABEL_TEXT],
666
+ ).toJsonObject()
667
+
668
+ fun setFonts(input: ParamsCustomization.CustomizationEditor, opts: JSONObject) = opts.forEach { key, value ->
669
+ when (key) {
670
+ "rfidProcessingScreenHintLabel" -> CustomizationFont.RFID_PROCESSING_SCREEN_HINT_LABEL.setFont(input, value)
671
+ "rfidProcessingScreenProgressLabel" -> CustomizationFont.RFID_PROCESSING_SCREEN_PROGRESS_LABEL.setFont(input, value)
672
+ "rfidProcessingScreenResultLabel" -> CustomizationFont.RFID_PROCESSING_SCREEN_RESULT_LABEL.setFont(input, value)
673
+ }
674
+ }
675
+
676
+ fun getFonts(fonts: Map<CustomizationFont, Typeface>, sizes: Map<CustomizationFont, Int>) = mapOf(
677
+ "rfidProcessingScreenHintLabel" to CustomizationFont.RFID_PROCESSING_SCREEN_HINT_LABEL.generate(fonts, sizes),
678
+ "rfidProcessingScreenProgressLabel" to CustomizationFont.RFID_PROCESSING_SCREEN_PROGRESS_LABEL.generate(fonts, sizes),
679
+ "rfidProcessingScreenResultLabel" to CustomizationFont.RFID_PROCESSING_SCREEN_RESULT_LABEL.generate(fonts, sizes),
680
+ ).toJsonObject()
681
+
682
+ fun setImages(input: ParamsCustomization.CustomizationEditor, opts: JSONObject, context: Context) = opts.forEach { key, v ->
683
+ when (key) {
684
+ "rfidProcessingScreenFailureImage" -> input.setImage(CustomizationImage.RFID_PROCESSING_SCREEN_FAILURE_IMAGE, v.toDrawable(context))
685
+ }
686
+ }
687
+
688
+ fun getImages(input: Map<CustomizationImage, Drawable>) = mapOf(
689
+ "rfidProcessingScreenFailureImage" to (input[CustomizationImage.RFID_PROCESSING_SCREEN_FAILURE_IMAGE] ?: ContextCompat.getDrawable(context, com.regula.documentreader.api.R.drawable.reg_ic_error)).toString(),
690
+ ).toJsonObject()