react-native-okaycam 3.0.5 → 3.0.6
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/android/build.gradle
CHANGED
|
@@ -44,7 +44,7 @@ repositories {
|
|
|
44
44
|
|
|
45
45
|
dependencies {
|
|
46
46
|
compileOnly "com.facebook.react:react-android"
|
|
47
|
-
implementation('com.innov8tif.okaycam:OkayCam:3.
|
|
47
|
+
implementation('com.innov8tif.okaycam:OkayCam:3.1.3@aar') {
|
|
48
48
|
transitive = true
|
|
49
49
|
exclude group: "junit", module: "junit"
|
|
50
50
|
exclude group: "org.hamcrest", module: "hamcrest-core"
|
|
@@ -20,6 +20,7 @@ import com.facebook.react.bridge.ReactMethod;
|
|
|
20
20
|
import com.facebook.react.bridge.ReadableMap;
|
|
21
21
|
|
|
22
22
|
import com.innov8tif.okaycam.cam.OkayCamAutoDoc;
|
|
23
|
+
import com.innov8tif.okaycam.cam.OkayCamAutoSelfie;
|
|
23
24
|
import com.innov8tif.okaycam.config.CameraFacing;
|
|
24
25
|
import com.innov8tif.okaycam.config.OkayCamBtnConfig;
|
|
25
26
|
import com.innov8tif.okaycam.config.OkayCamCaptureConfig;
|
|
@@ -27,9 +28,9 @@ import com.innov8tif.okaycam.config.OkayCamAutoCaptureConfig;
|
|
|
27
28
|
import com.innov8tif.okaycam.config.OkaySelfieConfig;
|
|
28
29
|
import com.innov8tif.okaycam.config.OkaySelfieLabelConfig;
|
|
29
30
|
import com.innov8tif.okaycam.config.OkaySelfieSwichBtnConfig;
|
|
30
|
-
import com.innov8tif.okaycam.selfie.OkayCamSelfie;
|
|
31
|
-
import com.innov8tif.okaycam.utils.BitmapUtils;
|
|
32
31
|
import com.innov8tif.okaycam.config.OkayCamAutoCaptureMode;
|
|
32
|
+
import com.innov8tif.okaycam.config.OkayCamAutoSelfieConfig;
|
|
33
|
+
import com.innov8tif.okaycam.utils.BitmapUtils;
|
|
33
34
|
|
|
34
35
|
import org.json.JSONException;
|
|
35
36
|
import org.json.JSONObject;
|
|
@@ -43,11 +44,8 @@ import java.net.URL;
|
|
|
43
44
|
|
|
44
45
|
public class RNOkayCamModule extends ReactContextBaseJavaModule {
|
|
45
46
|
|
|
46
|
-
private final ReactApplicationContext reactContext;
|
|
47
|
-
|
|
48
47
|
public RNOkayCamModule(ReactApplicationContext reactContext) {
|
|
49
48
|
super(reactContext);
|
|
50
|
-
this.reactContext = reactContext;
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
@Override
|
|
@@ -89,18 +87,18 @@ public class RNOkayCamModule extends ReactContextBaseJavaModule {
|
|
|
89
87
|
if (success) {
|
|
90
88
|
JSONObject results = new JSONObject();
|
|
91
89
|
try {
|
|
92
|
-
results.put("fullDocumentImage", convertImgToBase64(base64, images.get(0)));
|
|
90
|
+
results.put("fullDocumentImage", base64 ? convertImgToBase64(base64, images.get(0)) : images.get(0));
|
|
93
91
|
|
|
94
92
|
if (images.size() > 1) {
|
|
95
|
-
results.put("fullDocumentImage2", convertImgToBase64(base64, images.get(1)));
|
|
93
|
+
results.put("fullDocumentImage2", base64 ? convertImgToBase64(base64, images.get(1)) : images.get(1));
|
|
96
94
|
}
|
|
97
95
|
|
|
98
96
|
if (images.size() > 2) {
|
|
99
|
-
results.put("fullDocumentImage3", convertImgToBase64(base64, images.get(2)));
|
|
97
|
+
results.put("fullDocumentImage3", base64 ? convertImgToBase64(base64, images.get(2)) : images.get(2));
|
|
100
98
|
}
|
|
101
99
|
|
|
102
100
|
if (images.size() > 3) {
|
|
103
|
-
results.put("fullDocumentImage4", convertImgToBase64(base64, images.get(3)));
|
|
101
|
+
results.put("fullDocumentImage4", base64 ? convertImgToBase64(base64, images.get(3)) : images.get(3));
|
|
104
102
|
}
|
|
105
103
|
|
|
106
104
|
promise.resolve(results.toString());
|
|
@@ -121,55 +119,13 @@ public class RNOkayCamModule extends ReactContextBaseJavaModule {
|
|
|
121
119
|
|
|
122
120
|
Boolean base64 = configs.getBoolean("base64");
|
|
123
121
|
|
|
124
|
-
|
|
125
|
-
ReadableMap topLabel = userConfig.getMap("topLabel");
|
|
126
|
-
ReadableMap switchBtnConfig = userConfig.getMap("switchBtnConfig");
|
|
127
|
-
ReadableMap confirmBtnConfig = userConfig.getMap("confirmBtnConfig");
|
|
128
|
-
ReadableMap retakeBtnConfig = userConfig.getMap("retakeBtnConfig");
|
|
129
|
-
|
|
130
|
-
OkaySelfieConfig okaySelfieConfig = OkaySelfieConfig.init(this.getCurrentActivity());
|
|
131
|
-
|
|
132
|
-
okaySelfieConfig.setTopLabel(new OkaySelfieLabelConfig(
|
|
133
|
-
topLabel.getString("text"),
|
|
134
|
-
Color.parseColor(topLabel.getString("color")),
|
|
135
|
-
topLabel.getInt("size")
|
|
136
|
-
));
|
|
137
|
-
okaySelfieConfig.setBottomFrameColor(Color.parseColor(userConfig.getString("bottomFrameColor")));
|
|
138
|
-
|
|
139
|
-
okaySelfieConfig.setCaptureBtnColor(Color.parseColor(userConfig.getString("captureBtnColor")));
|
|
140
|
-
|
|
141
|
-
okaySelfieConfig.setSwitchBtnConfig(new OkaySelfieSwichBtnConfig(
|
|
142
|
-
Color.parseColor(switchBtnConfig.getString("color")),
|
|
143
|
-
switchBtnConfig.getBoolean("show")
|
|
144
|
-
));
|
|
145
|
-
|
|
146
|
-
okaySelfieConfig.setConfirmBtnConfig(new OkayCamBtnConfig(
|
|
147
|
-
Color.parseColor(confirmBtnConfig.getString("backgroundColor")),
|
|
148
|
-
Color.parseColor(confirmBtnConfig.getString("contentColor"))
|
|
149
|
-
));
|
|
150
|
-
|
|
151
|
-
okaySelfieConfig.setRetakeBtnConfig(new OkayCamBtnConfig(
|
|
152
|
-
Color.parseColor(retakeBtnConfig.getString("backgroundColor")),
|
|
153
|
-
Color.parseColor(retakeBtnConfig.getString("contentColor"))
|
|
154
|
-
));
|
|
155
|
-
|
|
156
|
-
if (userConfig.getString("defaultCameraFacing").equals("front")) {
|
|
157
|
-
okaySelfieConfig.setDefaultCameraFacing(CameraFacing.FRONT);
|
|
158
|
-
} else if (userConfig.getString("defaultCameraFacing").equals("back")) {
|
|
159
|
-
okaySelfieConfig.setDefaultCameraFacing(CameraFacing.BACK);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (userConfig.getInt("width") != -1) {
|
|
163
|
-
okaySelfieConfig.setWidth(userConfig.getInt("width"));
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
okaySelfieConfig.setImageQuality((float) userConfig.getDouble("imageQuality"));
|
|
122
|
+
OkayCamAutoSelfieConfig okaySelfieConfig = OkayCamAutoSelfieConfig.init();
|
|
167
123
|
|
|
168
|
-
|
|
124
|
+
OkayCamAutoSelfie.start(this.getCurrentActivity(), LICENSE_KEY, okaySelfieConfig, (success, image, exception) -> {
|
|
169
125
|
if (success) {
|
|
170
126
|
JSONObject results = new JSONObject();
|
|
171
127
|
try {
|
|
172
|
-
results.put("selfieImage", convertImgToBase64(base64, image));
|
|
128
|
+
results.put("selfieImage", base64 ? convertImgToBase64(base64, image) : image);
|
|
173
129
|
promise.resolve(results.toString());
|
|
174
130
|
} catch (JSONException e) {
|
|
175
131
|
e.printStackTrace();
|
package/index.ts
CHANGED
|
@@ -9,39 +9,7 @@ export enum DocumentCaptureMode {
|
|
|
9
9
|
FRONT_WITH_FLASH = "FRONT_WITH_FLASH",
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
text: string;
|
|
14
|
-
color: string;
|
|
15
|
-
size: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface OkayCamBtnConfig {
|
|
19
|
-
backgroundColor: string;
|
|
20
|
-
contentColor: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
interface SwitchBtnConfig {
|
|
24
|
-
color: string;
|
|
25
|
-
show: boolean;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
type cameraFacingType = "front" | "back";
|
|
29
|
-
|
|
30
|
-
// Set default values
|
|
31
|
-
const defaultColor = "#ffffff";
|
|
32
|
-
const defaultColor2 = "#ffa500";
|
|
33
|
-
const imageResizedWidth = -1;
|
|
34
|
-
|
|
35
|
-
const labelConfig: LabelConfig = {
|
|
36
|
-
text: "",
|
|
37
|
-
color: defaultColor,
|
|
38
|
-
size: 20,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const okayCamBtnConfig: OkayCamBtnConfig = {
|
|
42
|
-
backgroundColor: defaultColor2,
|
|
43
|
-
contentColor: defaultColor,
|
|
44
|
-
};
|
|
12
|
+
const imageResizedWidth = 1080;
|
|
45
13
|
|
|
46
14
|
// cal native capture document
|
|
47
15
|
export const captureDocument = (
|
|
@@ -82,43 +50,23 @@ export const captureDocument = (
|
|
|
82
50
|
});
|
|
83
51
|
};
|
|
84
52
|
|
|
85
|
-
const defaultSwitchBtnConfig: SwitchBtnConfig = {
|
|
86
|
-
show: true,
|
|
87
|
-
color: defaultColor,
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const cameraFacing: cameraFacingType = "front";
|
|
91
|
-
|
|
92
53
|
// call native capture selfie
|
|
93
54
|
export const captureSelfie = (
|
|
94
55
|
license: string,
|
|
95
56
|
base64: boolean,
|
|
96
|
-
{
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
switchBtnConfig = defaultSwitchBtnConfig,
|
|
101
|
-
confirmBtnConfig = okayCamBtnConfig,
|
|
102
|
-
retakeBtnConfig = okayCamBtnConfig,
|
|
103
|
-
defaultCameraFacing = cameraFacing,
|
|
104
|
-
width = imageResizedWidth,
|
|
105
|
-
imageQuality = 1.0,
|
|
106
|
-
},
|
|
57
|
+
config: {
|
|
58
|
+
width?: number;
|
|
59
|
+
height?: number;
|
|
60
|
+
} = {},
|
|
107
61
|
) => {
|
|
62
|
+
const { width = imageResizedWidth, height = 1920 } = config;
|
|
108
63
|
return new Promise(function (resolve, reject) {
|
|
109
64
|
RNOkayCam.captureSelfie({
|
|
110
65
|
license: license,
|
|
111
66
|
base64: base64,
|
|
112
67
|
config: {
|
|
113
|
-
topLabel: topLabel,
|
|
114
|
-
bottomFrameColor: bottomFrameColor,
|
|
115
|
-
captureBtnColor: captureBtnColor,
|
|
116
|
-
switchBtnConfig: switchBtnConfig,
|
|
117
|
-
confirmBtnConfig: confirmBtnConfig,
|
|
118
|
-
retakeBtnConfig: retakeBtnConfig,
|
|
119
|
-
defaultCameraFacing: defaultCameraFacing,
|
|
120
68
|
width: width,
|
|
121
|
-
|
|
69
|
+
height: height,
|
|
122
70
|
},
|
|
123
71
|
})
|
|
124
72
|
.then((result: string) => {
|
package/ios/RNOkayCam.swift
CHANGED
|
@@ -59,7 +59,7 @@ class RNOkayCam: NSObject {
|
|
|
59
59
|
|
|
60
60
|
config.mode = self.parseMode(mode)
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
OkayCamAutoDoc.start(
|
|
63
63
|
okayCamConfig: config,
|
|
64
64
|
license: license
|
|
65
65
|
) { filePaths, error in
|
|
@@ -105,16 +105,6 @@ class RNOkayCam: NSObject {
|
|
|
105
105
|
|
|
106
106
|
let license = configs.object(forKey: "license")! as! String
|
|
107
107
|
let base64 = configs.object(forKey: "base64") as! Bool
|
|
108
|
-
let rnOkayCamConfig = configs.object(forKey: "config") as! NSDictionary
|
|
109
|
-
let topLabel = rnOkayCamConfig.object(forKey: "topLabel") as! NSDictionary
|
|
110
|
-
let bottomFrameColor = rnOkayCamConfig.object(forKey: "bottomFrameColor") as! String
|
|
111
|
-
let captureBtnColor = rnOkayCamConfig.object(forKey: "captureBtnColor") as! String
|
|
112
|
-
let switchBtnConfig = rnOkayCamConfig.object(forKey: "switchBtnConfig") as! NSDictionary
|
|
113
|
-
let confirmBtnConfig = rnOkayCamConfig.object(forKey: "confirmBtnConfig") as! NSDictionary
|
|
114
|
-
let retakeBtnConfig = rnOkayCamConfig.object(forKey: "retakeBtnConfig") as! NSDictionary
|
|
115
|
-
let defaultCameraFacing = rnOkayCamConfig.object(forKey: "defaultCameraFacing") as! String
|
|
116
|
-
let width = rnOkayCamConfig.object(forKey: "width") as! Int
|
|
117
|
-
let imageQuality = rnOkayCamConfig.object(forKey: "imageQuality") as! CGFloat
|
|
118
108
|
|
|
119
109
|
DispatchQueue.main.async {
|
|
120
110
|
guard let rootViewController = UIApplication.shared.windows.first?.rootViewController else {
|
|
@@ -122,51 +112,10 @@ class RNOkayCam: NSObject {
|
|
|
122
112
|
return
|
|
123
113
|
}
|
|
124
114
|
|
|
125
|
-
let okaySelfieConfig =
|
|
126
|
-
|
|
127
|
-
// top label
|
|
128
|
-
okaySelfieConfig.topLabel.text = topLabel.object(forKey: "text") as! String
|
|
129
|
-
okaySelfieConfig.topLabel.color = self.hexStringToUIColor(hex: topLabel.object(forKey: "color") as! String)
|
|
130
|
-
okaySelfieConfig.topLabel.size = CGFloat(topLabel.object(forKey: "size") as! Int)
|
|
131
|
-
|
|
132
|
-
// bottom frame color
|
|
133
|
-
okaySelfieConfig.bottomFrameColor = self.hexStringToUIColor(hex: bottomFrameColor)
|
|
134
|
-
|
|
135
|
-
// capture button color
|
|
136
|
-
okaySelfieConfig.captureBtnColor = self.hexStringToUIColor(hex: captureBtnColor)
|
|
137
|
-
|
|
138
|
-
// capture configurations
|
|
139
|
-
okaySelfieConfig.captureBtnColor = self.hexStringToUIColor(hex: captureBtnColor)
|
|
140
|
-
|
|
141
|
-
// confirm button config
|
|
142
|
-
okaySelfieConfig.confirmBtnConfig.backgroundColor = self.hexStringToUIColor(hex: confirmBtnConfig.object(forKey: "backgroundColor") as! String)
|
|
143
|
-
okaySelfieConfig.confirmBtnConfig.contentColor = self.hexStringToUIColor(hex: confirmBtnConfig.object(forKey: "contentColor") as! String)
|
|
144
|
-
|
|
145
|
-
// retake button config
|
|
146
|
-
okaySelfieConfig.retakeBtnConfig.backgroundColor = self.hexStringToUIColor(hex: retakeBtnConfig.object(forKey: "backgroundColor") as! String)
|
|
147
|
-
okaySelfieConfig.retakeBtnConfig.contentColor = self.hexStringToUIColor(hex: retakeBtnConfig.object(forKey: "contentColor") as! String)
|
|
148
|
-
|
|
149
|
-
// switch button config
|
|
150
|
-
okaySelfieConfig.switchBtnConfig.color = self.hexStringToUIColor(hex: switchBtnConfig.object(forKey: "color") as! String)
|
|
151
|
-
// okaySelfieConfig.switchBtnConfig.show = switchBtnConfig.object(forKey: "show") as! Bool
|
|
152
|
-
okaySelfieConfig.switchBtnConfig.show = true
|
|
153
|
-
// camera facing
|
|
154
|
-
if (defaultCameraFacing == "front") {
|
|
155
|
-
okaySelfieConfig.defaultCameraFacing = OkayCam.CameraDevice.front
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
okaySelfieConfig.defaultCameraFacing = OkayCam.CameraDevice.back
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// resize
|
|
162
|
-
if (width != -1) {
|
|
163
|
-
okaySelfieConfig.width = width
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
okaySelfieConfig.imageQuality = imageQuality
|
|
115
|
+
let okaySelfieConfig = OkayCamAutoSelfieConfig(viewController: rootViewController)
|
|
167
116
|
|
|
168
117
|
// start the SDK
|
|
169
|
-
|
|
118
|
+
OkayCamAutoSelfie.start(
|
|
170
119
|
okaySelfieConfig: okaySelfieConfig,
|
|
171
120
|
license: license,
|
|
172
121
|
{ filePath, error in
|
package/package.json
CHANGED