react-native-okaycam 1.2.0 → 2.0.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.
package/README.md CHANGED
@@ -39,9 +39,16 @@ end
39
39
 
40
40
  #### Android Issue
41
41
 
42
- Duplicate class org.hamcrest.xxx
42
+ **Add following rules for proguard in the `android/app/proguard-rules.pro`**
43
43
 
44
- If you encouter the errors above, you may exclude junit module.
44
+ ```
45
+ -keep class org.pytorch.** { *; }
46
+ -keep class com.facebook.jni.** { *; }
47
+ ```
48
+
49
+ **Duplicate class org.hamcrest.xxx**
50
+
51
+ If you encouter the errors above, you may exclude junit module in the `android/app/build.gradle`
45
52
 
46
53
  ```
47
54
  configurations { compile.exclude group: "junit", module: "junit" }
@@ -92,9 +99,13 @@ const license = Platform.select({
92
99
  |confirmBtnConfig|contentColor|content color of the confirm button|#ffffff|
93
100
  |retakeBtnConfig|backgroundColor|background color of the retake button|#ffa500|
94
101
  |retakeBtnConfig|contentColor|content color of the retake button|#ffffff|
102
+ |captureConfig|first|config for the first capture|delay:0s,onFlash:false,outputPath: null|
103
+ |captureConfig|second|config for the second capture|delay:5s,onFlash:true,outputPath: null|
104
+ |<sup>**New**</sup>captureConfig|first|config for the first capture|delay:0s,onFlash:false,outputPath:null,onImageQuality:false|
105
+ |<sup>**New**</sup>captureConfig|second|config for the second capture|delay:5s,onFlash:true,outputPath:null,onImageQuality:false|
95
106
  |-|captureBtnColor|color of the capture button|#ffffff|
96
107
  |-|firstPhotoConfig|config for the first capture|delay:0s,onFlash:false,outputPath: null|
97
- |-|secondPhotoConfig|config for the second capture|null|
108
+ |-|secondPhotoConfig|config for the second capture|delay:5s,onFlash:false,outputPath: null|
98
109
  |preview |title|title on preview screen|""(empty string)|
99
110
  |preview |refImg|ref image on preview screen|null|
100
111
  |preview |instruction1|instruction on preview screen|""(empty string)|
@@ -189,11 +200,17 @@ captureDocument(
189
200
  })
190
201
  ```
191
202
 
203
+ > **_NOTE:_** <br/>
204
+ Supported image format : JPG | PNG | SVG <br/>
205
+ Preffered size : less than 500KB
206
+
192
207
  ### Result
193
208
  | Result | Description |
194
209
  |--|--|
195
210
  |fullDocumentImage|Result of firstPhotoConfig|
196
- |fullDocumentImage2|Result of secondPhotoConfig. Will only return if secondPhotoConfig is configured|
211
+ |fullDocumentImage2|Result of secondPhotoConfig. Will only return if secondPhotoConfig is configured. if secondPhotoConfig is not configured, it will be original image of fullDocumentImage|
212
+ |fullDocumentImage3|Original Image if it exist|
213
+ |fullDocumentImage4|Original Image if it exist|
197
214
 
198
215
  ## OkayCam Selfie
199
216
  ### Configuration
@@ -1,9 +1,9 @@
1
1
  buildscript {
2
2
  ext.kotlin_version = '1.4.21'
3
3
  repositories {
4
+ google()
4
5
  jcenter()
5
6
  mavenCentral()
6
- google()
7
7
  }
8
8
 
9
9
  dependencies {
@@ -14,12 +14,11 @@ buildscript {
14
14
  apply plugin: 'com.android.library'
15
15
 
16
16
  android {
17
- compileSdkVersion 23
18
- buildToolsVersion "23.0.3"
17
+ compileSdkVersion 33
19
18
 
20
19
  defaultConfig {
21
20
  minSdkVersion 21
22
- targetSdkVersion 22
21
+ targetSdkVersion 33
23
22
  versionCode 1
24
23
  versionName "1.0"
25
24
  }
@@ -30,28 +29,22 @@ android {
30
29
  sourceCompatibility JavaVersion.VERSION_1_8
31
30
  targetCompatibility JavaVersion.VERSION_1_8
32
31
  }
33
-
34
- repositories {
35
- // jcenter({ url "https://dl.bintray.com/innov8tifekyc/OkayCam/" })
36
- // maven { url "https://s01.oss.sonatype.org/content/repositories/cominnov8tif-1064" }
37
-
38
- }
39
-
40
32
  }
41
33
 
42
34
  repositories {
43
- mavenCentral()
44
35
  google()
36
+ mavenCentral()
45
37
  }
46
38
 
47
39
  dependencies {
48
- implementation 'com.facebook.react:react-native:+'
49
- implementation('com.innov8tif.okaycam:OkayCam:1.2.2@aar') {
40
+ implementation('com.facebook.react:react-native:+'){
41
+ exclude module: 'fbjni-java-only'
42
+ }
43
+ implementation('com.innov8tif.okaycam:OkayCam:1.1.18@aar') {
50
44
  transitive = true
51
45
  }
52
46
  implementation 'com.googlecode.json-simple:json-simple:1.1.1'
53
47
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
54
-
55
48
  implementation 'com.caverock:androidsvg-aar:1.4'
56
49
  }
57
50
 
@@ -1,6 +1,6 @@
1
1
  distributionBase=GRADLE_USER_HOME
2
2
  distributionPath=wrapper/dists
3
- distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
4
4
  zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
6
6
 
@@ -128,12 +128,14 @@ public class RNOkayCamModule extends ReactContextBaseJavaModule {
128
128
  firstPhoto != null ? new OkayCamCaptureConfig(
129
129
  firstPhoto.getInt("delay"),
130
130
  firstPhoto.getBoolean("onFlash"),
131
- firstPhoto.getString("outputPath")
131
+ firstPhoto.getString("outputPath"),
132
+ firstPhoto.getBoolean("onImageQuality")
132
133
  ) : null,
133
134
  secondPhoto != null ? new OkayCamCaptureConfig(
134
135
  secondPhoto.getInt("delay"),
135
136
  secondPhoto.getBoolean("onFlash"),
136
- secondPhoto.getString("outputPath")
137
+ secondPhoto.getString("outputPath"),
138
+ secondPhoto.getBoolean("onImageQuality")
137
139
  ) : null
138
140
  ));
139
141
 
package/index.ts CHANGED
@@ -61,6 +61,7 @@ interface CaptureConfig {
61
61
  delay: number;
62
62
  onFlash: Boolean;
63
63
  outputPath?: string;
64
+ onImageQuality: Boolean;
64
65
  }
65
66
 
66
67
  interface SwitchBtnConfig {
@@ -75,6 +76,13 @@ const defaultColor = "#ffffff";
75
76
  const defaultColor2 = "#ffa500";
76
77
  const imageResizedWidth = -1;
77
78
 
79
+ const imageResolvedAssetSource: ImageResolvedAssetSource = {
80
+ height: 0,
81
+ width: 0,
82
+ scale: 0,
83
+ uri: "",
84
+ };
85
+
78
86
  const labelConfig: LabelConfig = {
79
87
  text: "",
80
88
  color: defaultColor,
@@ -87,7 +95,7 @@ const defaultFrame: Frame = {
87
95
  height: (screenWidth * 54) / 85,
88
96
  },
89
97
  color: defaultColor,
90
- content: null,
98
+ content: imageResolvedAssetSource,
91
99
  };
92
100
 
93
101
  const timerConfig: TimerConfig = {
@@ -105,31 +113,37 @@ const defaultCaptureBtnColor: string = defaultColor;
105
113
  const captureConfigFirst: CaptureConfig = {
106
114
  delay: 0,
107
115
  onFlash: false,
108
- outputPath: null,
116
+ outputPath: "",
117
+ onImageQuality: false,
109
118
  };
110
119
 
111
- const defaultPreview: OkayCamPreviewConfig = null;
120
+ const defaultPreview: OkayCamPreviewConfig = null!;
112
121
 
113
- const defaultInstruction: OkayCamInstruction = null;
122
+ const defaultInstruction: OkayCamInstruction = null!;
114
123
 
115
- const captureConfigSecond: CaptureConfig = null;
124
+ const captureConfigSecond: CaptureConfig = {
125
+ delay: 5,
126
+ onFlash: false,
127
+ outputPath: "",
128
+ onImageQuality: false,
129
+ };
116
130
 
117
131
  const formatImage = (img: ImageResolvedAssetSource) => {
118
- return Image.resolveAssetSource(img).uri;
119
- // return img;
132
+ // return Image.resolveAssetSource(img).uri;
133
+ return img;
120
134
  };
121
135
 
122
136
  const formatInstruction = (
123
137
  instruction: OkayCamInstruction
124
138
  ): OkayCamInstruction => {
125
- if (instruction == null) return null;
139
+ if (instruction == null) return null!;
126
140
 
127
141
  const ref1: OkaycamInstructionRefImg = {
128
142
  ...instruction.refImage1,
129
143
  img: formatImage(instruction.refImage1.img),
130
144
  };
131
145
 
132
- let ref2: OkaycamInstructionRefImg = null;
146
+ let ref2: OkaycamInstructionRefImg = null!;
133
147
  if (instruction.refImage2 != null) {
134
148
  ref2 = {
135
149
  ...instruction.refImage2,
@@ -168,10 +182,98 @@ export const captureDocument = (
168
182
  instruction = defaultInstruction,
169
183
  }
170
184
  ) => {
185
+ if (topLabel.text == undefined) {
186
+ topLabel.text = labelConfig.text;
187
+ }
188
+
189
+ if (topLabel.color == undefined) {
190
+ topLabel.color = labelConfig.color;
191
+ }
192
+
193
+ if (topLabel.size == undefined) {
194
+ topLabel.size = labelConfig.size;
195
+ }
196
+
197
+ if (bottomLabel.text == undefined) {
198
+ bottomLabel.text = labelConfig.text;
199
+ }
200
+
201
+ if (bottomLabel.color == undefined) {
202
+ bottomLabel.color = labelConfig.color;
203
+ }
204
+
205
+ if (bottomLabel.size == undefined) {
206
+ bottomLabel.size = labelConfig.size;
207
+ }
208
+
171
209
  if (frame.size == undefined) {
172
210
  frame.size = defaultFrame.size;
173
211
  }
174
212
 
213
+ if (timer.backgroundColor == undefined || timer.textColor == undefined) {
214
+ timer.backgroundColor = timerConfig.backgroundColor;
215
+ }
216
+
217
+ if (timer.textColor == undefined) {
218
+ timer.textColor = timerConfig.textColor;
219
+ }
220
+
221
+ if (confirmBtnConfig.backgroundColor == undefined) {
222
+ confirmBtnConfig.backgroundColor = okayCamBtnConfig.backgroundColor;
223
+ }
224
+
225
+ if (confirmBtnConfig.contentColor == undefined) {
226
+ confirmBtnConfig.contentColor = okayCamBtnConfig.contentColor;
227
+ }
228
+
229
+ if (retakeBtnConfig.backgroundColor == undefined) {
230
+ retakeBtnConfig.backgroundColor = okayCamBtnConfig.backgroundColor;
231
+ }
232
+
233
+ if (retakeBtnConfig.contentColor == undefined) {
234
+ retakeBtnConfig.contentColor = okayCamBtnConfig.contentColor;
235
+ }
236
+
237
+ if (captureBtnColor == undefined) {
238
+ captureBtnColor = defaultCaptureBtnColor;
239
+ }
240
+
241
+ if (firstPhotoConfig.delay == undefined) {
242
+ firstPhotoConfig.delay = captureConfigFirst.delay;
243
+ }
244
+
245
+ if (firstPhotoConfig.onFlash == undefined) {
246
+ firstPhotoConfig.onFlash = captureConfigFirst.onFlash;
247
+ }
248
+
249
+ if (firstPhotoConfig.onImageQuality == undefined) {
250
+ firstPhotoConfig.onImageQuality = captureConfigFirst.onImageQuality;
251
+ }
252
+
253
+ if (firstPhotoConfig.outputPath == undefined) {
254
+ firstPhotoConfig.outputPath = captureConfigFirst.outputPath;
255
+ }
256
+
257
+ if (secondPhotoConfig.delay == undefined) {
258
+ secondPhotoConfig.delay = captureConfigSecond.delay;
259
+ }
260
+
261
+ if (secondPhotoConfig.onFlash == undefined) {
262
+ secondPhotoConfig.onFlash = captureConfigSecond.onFlash;
263
+ }
264
+
265
+ if (secondPhotoConfig.onImageQuality == undefined) {
266
+ secondPhotoConfig.onImageQuality = captureConfigSecond.onImageQuality;
267
+ }
268
+
269
+ if (secondPhotoConfig.outputPath == undefined) {
270
+ secondPhotoConfig.outputPath = captureConfigSecond.outputPath;
271
+ }
272
+
273
+ if (width == undefined) {
274
+ width = imageResizedWidth;
275
+ }
276
+
175
277
  const resultedPreview =
176
278
  preview == null
177
279
  ? null
@@ -253,6 +355,54 @@ export const captureSelfie = (
253
355
  imageQuality = 1.0,
254
356
  }
255
357
  ) => {
358
+ if (topLabel.text == undefined) {
359
+ topLabel.text = labelConfig.text;
360
+ }
361
+
362
+ if (topLabel.color == undefined) {
363
+ topLabel.color = labelConfig.color;
364
+ }
365
+
366
+ if (topLabel.size == undefined) {
367
+ topLabel.size = labelConfig.size;
368
+ }
369
+
370
+ if (switchBtnConfig.color == undefined) {
371
+ switchBtnConfig.color = defaultSwitchBtnConfig.color;
372
+ }
373
+
374
+ if (switchBtnConfig.show == undefined) {
375
+ switchBtnConfig.show = defaultSwitchBtnConfig.show;
376
+ }
377
+
378
+ if (confirmBtnConfig.backgroundColor == undefined) {
379
+ confirmBtnConfig.backgroundColor = okayCamBtnConfig.backgroundColor;
380
+ }
381
+
382
+ if (confirmBtnConfig.contentColor == undefined) {
383
+ confirmBtnConfig.contentColor = okayCamBtnConfig.contentColor;
384
+ }
385
+
386
+ if (retakeBtnConfig.backgroundColor == undefined) {
387
+ retakeBtnConfig.backgroundColor = okayCamBtnConfig.backgroundColor;
388
+ }
389
+
390
+ if (retakeBtnConfig.contentColor == undefined) {
391
+ retakeBtnConfig.contentColor = okayCamBtnConfig.contentColor;
392
+ }
393
+
394
+ if (defaultCameraFacing == undefined) {
395
+ defaultCameraFacing = cameraFacing;
396
+ }
397
+
398
+ if (captureBtnColor == undefined) {
399
+ captureBtnColor = defaultCaptureBtnColor;
400
+ }
401
+
402
+ if (width == undefined) {
403
+ width = imageResizedWidth;
404
+ }
405
+
256
406
  return new Promise(function (resolve, reject) {
257
407
  RNOkayCam.captureSelfie({
258
408
  license: license,
@@ -106,12 +106,12 @@ class RNOkayCam: NSObject {
106
106
  okayCamConfig.captureConfigPair = CaptureConfigPair(
107
107
  firstPhoto: OkayCamCaptureConfig(
108
108
  timeOut: firstPhoto.object(forKey: "delay") as! Int,
109
- onFlash: firstPhoto.object(forKey: "onFlash") as! Bool,
109
+ onFlash: firstPhoto.object(forKey: "onFlash") as! Bool, onImageQuality: firstPhoto.object(forKey: "onImageQuality") as! Bool,
110
110
  outputPath: (firstPhotoPath != nil) ? URL(string: (firstPhoto.object(forKey: "outputPath") as? String)!) : nil
111
111
  ),
112
112
  secondPhoto: (secondPhoto != nil) ? OkayCamCaptureConfig(
113
113
  timeOut: secondPhoto?.object(forKey: "delay") as? Int ?? 0,
114
- onFlash: secondPhoto?.object(forKey: "onFlash") as? Bool ?? false,
114
+ onFlash: secondPhoto?.object(forKey: "onFlash") as? Bool ?? false, onImageQuality: secondPhoto?.object(forKey: "onImageQuality") as! Bool,
115
115
  outputPath: (secondPhotoPath != nil) ? URL(string: (secondPhoto?.object(forKey: "outputPath") as! String?)!) : nil
116
116
  ) : nil
117
117
  )
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-okaycam",
3
3
  "title": "React Native OkayCam",
4
- "version": "1.2.0",
4
+ "version": "2.0.0",
5
5
  "description": "React-Native version of OkayCam",
6
6
  "main": "index.ts",
7
7
  "files": [
@@ -35,6 +35,10 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "react": "^16.9.0",
38
- "react-native": "^0.61.5"
38
+ "react-native": "^0.65.1"
39
+ },
40
+ "dependencies": {
41
+ "@types/react-native": "^0.71.3",
42
+ "react-native-codegen": "^0.0.7"
39
43
  }
40
44
  }
@@ -22,7 +22,7 @@ Pod::Spec.new do |s|
22
22
  s.requires_arc = true
23
23
  s.static_framework = true
24
24
  s.dependency "React"
25
- s.dependency "OkayCam", "1.1.10"
25
+ s.dependency "OkayCam", "1.1.14"
26
26
  end
27
27
 
28
28