react-native-okaycam 1.1.22 → 1.1.27

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
@@ -95,12 +95,17 @@ const license = Platform.select({
95
95
  |-|captureBtnColor|color of the capture button|#ffffff|
96
96
  |-|firstPhotoConfig|config for the first capture|delay:0s,onFlash:false,outputPath: null|
97
97
  |-|secondPhotoConfig|config for the second capture|null|
98
- |preview <sup>**New**</sup>|title|title on preview screen|""(empty string)|
99
- |preview <sup>**New**</sup>|refImg|ref image on preview screen|null|
100
- |preview <sup>**New**</sup>|instruction1|instruction on preview screen|""(empty string)|
101
- |preview <sup>**New**</sup>|instruction2|instruction on preview screen|""(empty string)|
102
- |preview <sup>**New**</sup>|instruction3|instruction on preview screen|""(empty string)|
103
- |preview <sup>**New**</sup>|backgroundColor|background color of preview screen|null|
98
+ |preview |title|title on preview screen|""(empty string)|
99
+ |preview |refImg|ref image on preview screen|null|
100
+ |preview |instruction1|instruction on preview screen|""(empty string)|
101
+ |preview|instruction2|instruction on preview screen|""(empty string)|
102
+ |preview |instruction3|instruction on preview screen|""(empty string)|
103
+ |preview |backgroundColor|background color of preview screen|null|
104
+ |instruction <sup>**New**</sup> |title|Instruction's title on camera caputre screen|""(empty string)|
105
+ |instruction <sup>**New**</sup> |refImage1|Instruction's reference image 1|null|
106
+ |instruction <sup>**New**</sup> |refImage2|Instruction's reference image 2|null|
107
+
108
+
104
109
 
105
110
  ## Usage
106
111
  ```
@@ -162,7 +167,18 @@ captureDocument(
162
167
  instruction2: {text: 'instr2', color: '#000000', size: 14},
163
168
  instruction3: {text: 'instr3', color: '#000000', size: 14},
164
169
  backgroundColor: '#374fff',
165
- }
170
+ },
171
+ instruction: {
172
+ title: {text: 'instr1', color: '#ffffff', size: 14},
173
+ refImage1: {
174
+ title: {text: 'ref1', color: '#ffffff', size: 14},
175
+ img: require('./images/ref.png'),
176
+ },
177
+ refImage2: {
178
+ title: {text: 'ref2', color: '#ffffff', size: 14},
179
+ img: require('./images/ref.png'),
180
+ },
181
+ },
166
182
  }
167
183
  )
168
184
  .then(result => {
@@ -36,5 +36,10 @@
36
36
  <option name="name" value="maven" />
37
37
  <option name="url" value="https://s01.oss.sonatype.org/content/repositories/cominnov8tif-1063" />
38
38
  </remote-repository>
39
+ <remote-repository>
40
+ <option name="id" value="maven" />
41
+ <option name="name" value="maven" />
42
+ <option name="url" value="https://s01.oss.sonatype.org/content/repositories/cominnov8tif-1064" />
43
+ </remote-repository>
39
44
  </component>
40
45
  </project>
@@ -0,0 +1,15 @@
1
+ <component name="libraryTable">
2
+ <library name="Gradle: com.innov8tif.okaycam:OkayCam:1.1.10@aar">
3
+ <CLASSES>
4
+ <root url="jar://$USER_HOME$/.gradle/caches/transforms-3/d475d7eab3beed356dcb43e92fe8afa3/transformed/jetified-OkayCam-1.1.10/jars/classes.jar!/" />
5
+ <root url="file://$USER_HOME$/.gradle/caches/transforms-3/d475d7eab3beed356dcb43e92fe8afa3/transformed/jetified-OkayCam-1.1.10/res" />
6
+ <root url="file://$USER_HOME$/.gradle/caches/transforms-3/d475d7eab3beed356dcb43e92fe8afa3/transformed/jetified-OkayCam-1.1.10/AndroidManifest.xml" />
7
+ </CLASSES>
8
+ <JAVADOC>
9
+ <root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.innov8tif.okaycam/OkayCam/1.1.10/d87bd11330b88497cefe8e10482aefbe6e25e795/OkayCam-1.1.10-javadoc.jar!/" />
10
+ </JAVADOC>
11
+ <SOURCES>
12
+ <root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.innov8tif.okaycam/OkayCam/1.1.10/d869c29d69b3fa6aaed3ea3025849f5a099de27f/OkayCam-1.1.10-sources.jar!/" />
13
+ </SOURCES>
14
+ </library>
15
+ </component>
@@ -99,7 +99,7 @@
99
99
  <orderEntry type="library" name="Gradle: androidx.localbroadcastmanager:localbroadcastmanager:1.0.0@aar" level="project" />
100
100
  <orderEntry type="library" name="Gradle: androidx.print:print:1.0.0@aar" level="project" />
101
101
  <orderEntry type="library" name="Gradle: org.webkit:android-jsc:r174650@aar" level="project" />
102
- <orderEntry type="library" name="Gradle: com.innov8tif.okaycam:OkayCam:1.1.9@aar" level="project" />
102
+ <orderEntry type="library" name="Gradle: com.innov8tif.okaycam:OkayCam:1.1.10@aar" level="project" />
103
103
  <orderEntry type="library" name="Gradle: com.caverock:androidsvg-aar:1.4@aar" level="project" />
104
104
  </component>
105
105
  </module>
@@ -33,7 +33,7 @@ android {
33
33
 
34
34
  repositories {
35
35
  // jcenter({ url "https://dl.bintray.com/innov8tifekyc/OkayCam/" })
36
- // maven { url "https://s01.oss.sonatype.org/content/repositories/cominnov8tif-1063" }
36
+ // maven { url "https://s01.oss.sonatype.org/content/repositories/cominnov8tif-1064" }
37
37
 
38
38
  }
39
39
 
@@ -46,7 +46,7 @@ repositories {
46
46
 
47
47
  dependencies {
48
48
  implementation 'com.facebook.react:react-native:+'
49
- implementation('com.innov8tif.okaycam:OkayCam:1.1.9@aar') {
49
+ implementation('com.innov8tif.okaycam:OkayCam:1.1.11@aar') {
50
50
  transitive = true
51
51
  }
52
52
  implementation 'com.googlecode.json-simple:json-simple:1.1.1'
@@ -26,6 +26,8 @@ import com.innov8tif.okaycam.config.OkayCamBtnConfig;
26
26
  import com.innov8tif.okaycam.config.OkayCamCaptureConfig;
27
27
  import com.innov8tif.okaycam.config.OkayCamConfig;
28
28
  import com.innov8tif.okaycam.config.OkayCamFrameConfig;
29
+ import com.innov8tif.okaycam.config.OkayCamInstruction;
30
+ import com.innov8tif.okaycam.config.OkayCamInstructionRefImg;
29
31
  import com.innov8tif.okaycam.config.OkayCamLabelConfig;
30
32
  import com.innov8tif.okaycam.config.OkayCamPreviewConfig;
31
33
  import com.innov8tif.okaycam.config.OkayCamTimerConfig;
@@ -76,6 +78,7 @@ public class RNOkayCamModule extends ReactContextBaseJavaModule {
76
78
  ReadableMap firstPhoto = captureConfigPair.getMap("firstPhoto");
77
79
  ReadableMap secondPhoto = captureConfigPair.getMap("secondPhoto");
78
80
  ReadableMap preview = userConfig.getMap("preview");
81
+ ReadableMap instruction = userConfig.getMap("instruction");
79
82
 
80
83
 
81
84
  OkayCamConfig okayCamConfig = OkayCamConfig.init(this.getCurrentActivity());
@@ -136,6 +139,7 @@ public class RNOkayCamModule extends ReactContextBaseJavaModule {
136
139
 
137
140
 
138
141
  okayCamConfig.setPreview(getPreviewConfig(preview, frameConfig));
142
+ okayCamConfig.setInstruction(getInstructionConfig(instruction, frameConfig));
139
143
 
140
144
  OkayCamDoc.start(this.getCurrentActivity(), LICENSE_KEY, okayCamConfig, (success, images, exception) -> {
141
145
 
@@ -170,6 +174,102 @@ public class RNOkayCamModule extends ReactContextBaseJavaModule {
170
174
  });
171
175
  }
172
176
 
177
+ private OkayCamInstruction getInstructionConfig(ReadableMap instruction, OkayCamFrameConfig frameConfig) {
178
+ if (instruction == null) return null;
179
+ OkayCamLabelConfig title = mapToLabelConfig(instruction.getMap("title"));
180
+
181
+ ReadableMap refMap1 = instruction.getMap("refImage1");
182
+ OkayCamInstructionRefImg ref1 = mapToRef(refMap1, frameConfig, "instr1");
183
+
184
+ ReadableMap refMap2 = instruction.getMap("refImage2");
185
+ OkayCamInstructionRefImg ref2 = mapToRef(refMap2, frameConfig, "instr2");
186
+
187
+
188
+ return new OkayCamInstruction(
189
+ title,
190
+ ref1,
191
+ ref2
192
+ );
193
+ }
194
+
195
+ private OkayCamInstructionRefImg mapToRef(ReadableMap refMap, OkayCamFrameConfig frameConfig, String fileName) {
196
+ if (refMap == null) return null;
197
+ OkayCamLabelConfig title = mapToLabelConfig(refMap.getMap("title"));
198
+ String img1 = getImageFromJs(refMap.getString("img"), frameConfig, fileName);
199
+
200
+ return new OkayCamInstructionRefImg(title, img1);
201
+ }
202
+
203
+ private String getImageFromJs(String refImage, OkayCamFrameConfig frameConfig, String fileName) {
204
+
205
+
206
+ Size size = frameConfig.getSize();
207
+ int frameWidth = size.getWidth();
208
+ int frameHeight = size.getHeight();
209
+
210
+ Bitmap contentBmp = null;
211
+ try {
212
+ if (refImage != null) {
213
+
214
+ // In debug, the image is returned as URL
215
+ if (BuildConfig.DEBUG) {
216
+ InputStream inputStream = new URL(refImage).openStream();
217
+
218
+ if (refImage.contains("svg")) {
219
+
220
+ SVG svg = SVG.getFromInputStream(inputStream);
221
+
222
+ svg.setDocumentWidth(frameWidth);
223
+ svg.setDocumentHeight(frameHeight);
224
+
225
+ if (svg.getDocumentWidth() != -1) {
226
+ contentBmp = Bitmap.createBitmap((int) Math.ceil(svg.getDocumentWidth()),
227
+ (int) Math.ceil(svg.getDocumentHeight()),
228
+ Bitmap.Config.ARGB_8888);
229
+
230
+ Canvas bmcanvas = new Canvas(contentBmp);
231
+
232
+ // Render our document onto our canvas
233
+ svg.renderToCanvas(bmcanvas, new RenderOptions().preserveAspectRatio(PreserveAspectRatio.FULLSCREEN));
234
+ }
235
+ } else {
236
+ contentBmp = BitmapFactory.decodeStream(inputStream);
237
+ }
238
+ } else {
239
+ // In release, the image is returned as raw (svg) or drawable (png, jpeg and etc)
240
+ int resourceId = this.getCurrentActivity().getResources().getIdentifier(refImage, "raw", this.getCurrentActivity().getPackageName());
241
+
242
+ if (resourceId != 0) {
243
+ SVG svg = SVG.getFromResource(getReactApplicationContext(), resourceId);
244
+
245
+ svg.setDocumentWidth(frameWidth);
246
+ svg.setDocumentHeight(frameHeight);
247
+
248
+ if (svg.getDocumentWidth() != -1) {
249
+ contentBmp = Bitmap.createBitmap((int) Math.ceil(svg.getDocumentWidth()),
250
+ (int) Math.ceil(svg.getDocumentHeight()),
251
+ Bitmap.Config.ARGB_8888);
252
+
253
+ Canvas bmcanvas = new Canvas(contentBmp);
254
+
255
+ // Render our document onto our canvas
256
+ svg.renderToCanvas(bmcanvas, new RenderOptions().preserveAspectRatio(PreserveAspectRatio.FULLSCREEN));
257
+ }
258
+ } else {
259
+ resourceId = this.getCurrentActivity().getResources().getIdentifier(refImage, "drawable", this.getCurrentActivity().getPackageName());
260
+ contentBmp = BitmapFactory.decodeResource(getReactApplicationContext().getResources(), resourceId);
261
+ }
262
+ }
263
+ }
264
+ } catch (SVGParseException | MalformedURLException e) {
265
+ e.printStackTrace();
266
+ } catch (IOException e) {
267
+ e.printStackTrace();
268
+ }
269
+
270
+ return generateFile(contentBmp, fileName);
271
+ }
272
+
173
273
  private OkayCamPreviewConfig getPreviewConfig(ReadableMap preview, OkayCamFrameConfig frameConfig) {
174
274
  if (preview == null) return null;
175
275
  OkayCamLabelConfig title = mapToLabelConfig(preview.getMap("title"));
package/index.ts CHANGED
@@ -26,6 +26,16 @@ interface OkayCamPreviewConfig {
26
26
  backgroundColor: string;
27
27
  }
28
28
 
29
+ interface OkaycamInstructionRefImg {
30
+ title: LabelConfig;
31
+ img: ImageResolvedAssetSource;
32
+ }
33
+ interface OkayCamInstruction {
34
+ title: LabelConfig;
35
+ refImage1: OkaycamInstructionRefImg;
36
+ refImage2?: OkaycamInstructionRefImg;
37
+ }
38
+
29
39
  interface FrameSize {
30
40
  width: number;
31
41
  height: number;
@@ -100,8 +110,41 @@ const captureConfigFirst: CaptureConfig = {
100
110
 
101
111
  const defaultPreview: OkayCamPreviewConfig = null;
102
112
 
113
+ const defaultInstruction: OkayCamInstruction = null;
114
+
103
115
  const captureConfigSecond: CaptureConfig = null;
104
116
 
117
+ const formatImage = (img: ImageResolvedAssetSource) => {
118
+ return Image.resolveAssetSource(img).uri;
119
+ // return img;
120
+ };
121
+
122
+ const formatInstruction = (
123
+ instruction: OkayCamInstruction
124
+ ): OkayCamInstruction => {
125
+ if (instruction == null) return null;
126
+
127
+ const ref1: OkaycamInstructionRefImg = {
128
+ ...instruction.refImage1,
129
+ img: formatImage(instruction.refImage1.img),
130
+ };
131
+
132
+ let ref2: OkaycamInstructionRefImg = null;
133
+ if (instruction.refImage2 != null) {
134
+ ref2 = {
135
+ ...instruction.refImage2,
136
+ img: formatImage(instruction.refImage2.img),
137
+ };
138
+ }
139
+
140
+ const formattedInstruction: OkayCamInstruction = {
141
+ title: instruction.title,
142
+ refImage1: ref1,
143
+ refImage2: ref2,
144
+ };
145
+ return formattedInstruction;
146
+ };
147
+
105
148
  // cal native capture document
106
149
  export const captureDocument = (
107
150
  license: string,
@@ -122,6 +165,7 @@ export const captureDocument = (
122
165
  width = imageResizedWidth,
123
166
  imageQuality = 1.0,
124
167
  preview = defaultPreview,
168
+ instruction = defaultInstruction,
125
169
  }
126
170
  ) => {
127
171
  if (frame.size == undefined) {
@@ -174,6 +218,7 @@ export const captureDocument = (
174
218
  width: width,
175
219
  imageQuality: imageQuality,
176
220
  preview: resultedPreview,
221
+ instruction: formatInstruction(instruction),
177
222
  },
178
223
  })
179
224
  .then((result) => {
@@ -80,7 +80,7 @@ class RNOkayCam: NSObject {
80
80
  okayCamConfig.showOverlay = showOverlay
81
81
 
82
82
  // timer
83
- okayCamConfig.timer.backgroundColor = self.hexStringToUIColor(hex: timer.object(forKey: "backgroundColor") as! String)
83
+ okayCamConfig.timer.backgroundColor = self.hexStringToUIColor(hex: timer.object(forKey: "backgroundColor") as! String,alpha:0.5)
84
84
  okayCamConfig.timer.textColor = self.hexStringToUIColor(hex: timer.object(forKey: "textColor") as! String)
85
85
 
86
86
  // capture button color
@@ -127,6 +127,10 @@ class RNOkayCam: NSObject {
127
127
  let previewConfig = rnOkayCamConfig.object(forKey: "preview") as? NSDictionary
128
128
 
129
129
  okayCamConfig.preview = self.getOkaycamPreview(previewConfig: previewConfig)
130
+
131
+ // instruction config
132
+ let instructionConfig = rnOkayCamConfig.object(forKey: "instruction") as? NSDictionary
133
+ okayCamConfig.instruction = self.getOkayCamInstruction(instructionConfig: instructionConfig)
130
134
 
131
135
  // start the SDK
132
136
  OkayCamDoc.start(
@@ -199,6 +203,36 @@ class RNOkayCam: NSObject {
199
203
 
200
204
  return OkayCamPreviewConfig(title: title, refImage: refUrl!, instruction1: instr1, instruction2: instr2, instruction3: instr3, backgroundColor: bgColor)
201
205
  }
206
+
207
+ func getOkayCamInstruction(instructionConfig: NSDictionary?) -> OkayCamInstruction?{
208
+ if instructionConfig == nil {return nil}
209
+
210
+ let title = configToOkayCamLabel(config: instructionConfig?.object(forKey: "title") as! NSDictionary)
211
+
212
+ let ref1 = getInstructionRefImage(refImage: instructionConfig?.object(forKey: "refImage1") as! NSDictionary)
213
+
214
+ let ref2 = getInstructionRefImage(refImage: instructionConfig?.object(forKey: "refImage2") as? NSDictionary)
215
+
216
+ return OkayCamInstruction(title:title,refImage1:ref1!,refImage2:ref2)
217
+ }
218
+
219
+ func getInstructionRefImage(refImage:NSDictionary?) -> OkaycamInstructionRefImg?{
220
+ if refImage == nil {return nil}
221
+
222
+ let title = configToOkayCamLabel(config: refImage?.object(forKey: "title") as! NSDictionary)
223
+
224
+ // frame contet
225
+ let ref = refImage?.object(forKey: "img") as? String
226
+ var refUrl:URL? = nil
227
+ if (ref != nil) {
228
+ #if DEBUG
229
+ refUrl = URL(string: ref!)!
230
+ #else
231
+ refUrl = URL(fileURLWithPath: ref!.replacingOccurrences(of: "file:///", with: ""))
232
+ #endif
233
+ }
234
+ return OkaycamInstructionRefImg(title:title,img:refUrl!)
235
+ }
202
236
 
203
237
  func configToOkayCamLabel(config:NSDictionary) -> OkayCamLabelConfig{
204
238
  let text = config.object(forKey: "text") as! String
@@ -314,7 +348,7 @@ class RNOkayCam: NSObject {
314
348
  return result
315
349
  }
316
350
 
317
- func hexStringToUIColor (hex:String) -> UIColor {
351
+ func hexStringToUIColor (hex:String,alpha : Float = 1.0) -> UIColor {
318
352
  var cString:String = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased()
319
353
 
320
354
  if (cString.hasPrefix("#")) {
@@ -332,7 +366,7 @@ class RNOkayCam: NSObject {
332
366
  red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
333
367
  green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
334
368
  blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
335
- alpha: CGFloat(1.0)
369
+ alpha: CGFloat(alpha)
336
370
  )
337
371
  }
338
372
 
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.1.22",
4
+ "version": "1.1.27",
5
5
  "description": "React-Native version of OkayCam",
6
6
  "main": "index.ts",
7
7
  "files": [
@@ -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.8"
25
+ s.dependency "OkayCam", "1.1.10"
26
26
  end
27
27
 
28
28
 
@@ -1,15 +0,0 @@
1
- <component name="libraryTable">
2
- <library name="Gradle: com.innov8tif.okaycam:OkayCam:1.1.9@aar">
3
- <CLASSES>
4
- <root url="jar://$USER_HOME$/.gradle/caches/transforms-3/b12bf69e41ba9a9e3fd3f5f7d0798395/transformed/jetified-OkayCam-1.1.9/jars/classes.jar!/" />
5
- <root url="file://$USER_HOME$/.gradle/caches/transforms-3/b12bf69e41ba9a9e3fd3f5f7d0798395/transformed/jetified-OkayCam-1.1.9/res" />
6
- <root url="file://$USER_HOME$/.gradle/caches/transforms-3/b12bf69e41ba9a9e3fd3f5f7d0798395/transformed/jetified-OkayCam-1.1.9/AndroidManifest.xml" />
7
- </CLASSES>
8
- <JAVADOC>
9
- <root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.innov8tif.okaycam/OkayCam/1.1.9/36c120ad1e000095296163b137076379bf7e52c/OkayCam-1.1.9-javadoc.jar!/" />
10
- </JAVADOC>
11
- <SOURCES>
12
- <root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.innov8tif.okaycam/OkayCam/1.1.9/be529d2fe231cd2bd0e084261ac2b686bd62f1f/OkayCam-1.1.9-sources.jar!/" />
13
- </SOURCES>
14
- </library>
15
- </component>