react-native-ux-cam 5.4.16 → 6.0.1
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/CHANGELOG.md +2 -0
- package/RNUxcam.podspec +22 -3
- package/android/build.gradle +39 -5
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradlew +240 -0
- package/android/gradlew.bat +91 -0
- package/android/src/main/java/com/uxcam/RNUxViewFinder.java +7 -0
- package/android/src/main/java/com/uxcam/RNUxcamModuleImpl.java +446 -0
- package/android/src/main/java/com/uxcam/RNUxcamPackage.java +33 -18
- package/android/src/newarch/java/com/uxcam/RNUxcamModule.java +208 -0
- package/android/src/oldarch/java/com/uxcam/RNUxcamModule.java +205 -0
- package/ios/RNUxcam/RNUxcam.h +16 -0
- package/ios/RNUxcam/RNUxcam.mm +526 -0
- package/package.json +36 -32
- package/src/NativeRNUxcam.ts +60 -0
- package/src/UXCam.js +343 -0
- package/src/UXCamOcclusion.tsx +29 -0
- package/{index.d.ts → src/index.d.ts} +9 -130
- package/src/index.js +3 -0
- package/src/types.ts +19 -0
- package/UXCam.js +0 -570
- package/UXCamOcclusion.tsx +0 -36
- package/android/.classpath +0 -6
- package/android/src/main/java/com/uxcam/RNUxcamModule.java +0 -559
- package/index.js +0 -3
- package/ios/RNUxcam.h +0 -19
- package/ios/RNUxcam.m +0 -670
- package/ios/RNUxcam.xcodeproj/project.pbxproj +0 -266
- package/ios/RNUxcam.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/RNUxcam.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- /package/{jest.config.js → src/jest.config.js} +0 -0
- /package/{tsconfig.json → src/tsconfig.json} +0 -0
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
package com.uxcam;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
import android.view.View;
|
|
6
|
+
|
|
7
|
+
import com.facebook.react.bridge.NoSuchKeyException;
|
|
8
|
+
import com.facebook.react.bridge.Promise;
|
|
9
|
+
|
|
10
|
+
import java.util.ArrayList;
|
|
11
|
+
import java.util.List;
|
|
12
|
+
import java.util.Map;
|
|
13
|
+
import java.util.HashMap;
|
|
14
|
+
import com.facebook.react.bridge.Arguments;
|
|
15
|
+
|
|
16
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
17
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
18
|
+
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
19
|
+
import com.facebook.react.bridge.ReadableType;
|
|
20
|
+
import com.facebook.react.bridge.UIManager;
|
|
21
|
+
import com.facebook.react.bridge.UiThreadUtil;
|
|
22
|
+
import com.facebook.react.bridge.UnexpectedNativeTypeException;
|
|
23
|
+
import com.facebook.react.bridge.WritableMap;
|
|
24
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
25
|
+
import com.facebook.react.uimanager.NativeViewHierarchyManager;
|
|
26
|
+
import com.facebook.react.uimanager.UIBlock;
|
|
27
|
+
import com.facebook.react.uimanager.UIManagerHelper;
|
|
28
|
+
import com.facebook.react.uimanager.UIManagerModule;
|
|
29
|
+
import com.facebook.react.uimanager.common.UIManagerType;
|
|
30
|
+
import com.uxcam.screenshot.model.UXCamBlur;
|
|
31
|
+
import com.uxcam.screenshot.model.UXCamOverlay;
|
|
32
|
+
import com.uxcam.screenshot.model.UXCamOcclusion;
|
|
33
|
+
import com.uxcam.screenshot.model.UXCamOccludeAllTextFields;
|
|
34
|
+
import com.uxcam.datamodel.UXConfig;
|
|
35
|
+
|
|
36
|
+
public class RNUxcamModuleImpl {
|
|
37
|
+
|
|
38
|
+
public static final String MODULE_NAME = "RNUxcam";
|
|
39
|
+
|
|
40
|
+
private static final String UXCAM_VERIFICATION_EVENT_KEY = "UXCam_Verification_Event";
|
|
41
|
+
private static final String PARAM_SUCCESS_KEY = "success";
|
|
42
|
+
private static final String PARAM_ERROR_MESSAGE_KEY = "error";
|
|
43
|
+
|
|
44
|
+
public static final String USER_APP_KEY = "userAppKey";
|
|
45
|
+
public static final String ENABLE_MUTLI_SESSION_RECORD = "enableMultiSessionRecord";
|
|
46
|
+
public static final String ENABLE_CRASH_HANDLING = "enableCrashHandling";
|
|
47
|
+
public static final String ENABLE_AUTOMATIC_SCREEN_NAME_TAGGING = "enableAutomaticScreenNameTagging";
|
|
48
|
+
public static final String ENABLE_IMPROVED_SCREEN_CAPTURE = "enableImprovedScreenCapture";
|
|
49
|
+
public static final String OCCLUSION = "occlusions";
|
|
50
|
+
public static final String SCREENS = "screens";
|
|
51
|
+
public static final String NAME = "name";
|
|
52
|
+
public static final String TYPE = "type";
|
|
53
|
+
public static final String EXCLUDE_MENTIONED_SCREENS = "excludeMentionedScreens";
|
|
54
|
+
public static final String CONFIG = "config";
|
|
55
|
+
public static final String BLUR_RADIUS = "blurRadius";
|
|
56
|
+
public static final String HIDE_GESTURES = "hideGestures";
|
|
57
|
+
|
|
58
|
+
private static final String UXCAM_PLUGIN_TYPE = "react-native";
|
|
59
|
+
private static final String UXCAM_REACT_PLUGIN_VERSION = "6.0.1";
|
|
60
|
+
|
|
61
|
+
private final ReactApplicationContext reactContext;
|
|
62
|
+
|
|
63
|
+
public RNUxcamModuleImpl(ReactApplicationContext reactApplicationContext) {
|
|
64
|
+
this.reactContext = reactApplicationContext;
|
|
65
|
+
UXCam.addVerificationListener(new OnVerificationListener() {
|
|
66
|
+
@Override
|
|
67
|
+
public void onVerificationSuccess() {
|
|
68
|
+
WritableMap params = Arguments.createMap();
|
|
69
|
+
params.putBoolean(PARAM_SUCCESS_KEY, true);
|
|
70
|
+
sendEvent(getReactApplicationContext(), params);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@Override
|
|
74
|
+
public void onVerificationFailed(String errorMessage) {
|
|
75
|
+
WritableMap params = Arguments.createMap();
|
|
76
|
+
params.putBoolean(PARAM_SUCCESS_KEY, false);
|
|
77
|
+
params.putString(PARAM_ERROR_MESSAGE_KEY, errorMessage);
|
|
78
|
+
sendEvent(getReactApplicationContext(), params);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private ReactApplicationContext getReactApplicationContext() {
|
|
84
|
+
return this.reactContext;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private Activity getCurrentActivity() {
|
|
88
|
+
return this.reactContext.getCurrentActivity();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public void startWithConfiguration(ReadableMap configuration) {
|
|
92
|
+
try {
|
|
93
|
+
UXConfig config = getConfiguration(configuration);
|
|
94
|
+
if (config != null) {
|
|
95
|
+
|
|
96
|
+
UXCam.pluginType(UXCAM_PLUGIN_TYPE, UXCAM_REACT_PLUGIN_VERSION);
|
|
97
|
+
UXCam.startWithConfigurationCrossPlatform(getCurrentActivity(), config);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
} catch (Exception e) {
|
|
101
|
+
Log.d("config", "Error starting with configuration");
|
|
102
|
+
e.printStackTrace();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public UXConfig getConfiguration(ReadableMap configuration) {
|
|
107
|
+
HashMap<String, Object> configMap = configuration.toHashMap();
|
|
108
|
+
String appKey = (String) configMap.get(USER_APP_KEY);
|
|
109
|
+
if (appKey == null) {
|
|
110
|
+
Log.d("config", "Empty app key value for starting UXCam");
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
Boolean enableMultiSessionRecord = (Boolean) configMap.get(ENABLE_MUTLI_SESSION_RECORD);
|
|
115
|
+
Boolean enableCrashHandling = (Boolean) configMap.get(ENABLE_CRASH_HANDLING);
|
|
116
|
+
Boolean enableAutomaticScreenNameTagging = (Boolean) configMap.get(ENABLE_AUTOMATIC_SCREEN_NAME_TAGGING);
|
|
117
|
+
Boolean enableImprovedScreenCapture = (Boolean) configMap.get(ENABLE_IMPROVED_SCREEN_CAPTURE);
|
|
118
|
+
// // occlusion
|
|
119
|
+
List<UXCamOcclusion> occlusionList = null;
|
|
120
|
+
if (configMap.get(OCCLUSION) != null) {
|
|
121
|
+
List<Map<String, Object>> occlusionObjects = (List<Map<String, Object>>) configMap.get(OCCLUSION);
|
|
122
|
+
occlusionList = convertToOcclusionList(occlusionObjects);
|
|
123
|
+
}
|
|
124
|
+
UXConfig.Builder uxConfigBuilder = new UXConfig.Builder(appKey);
|
|
125
|
+
if (enableMultiSessionRecord != null)
|
|
126
|
+
uxConfigBuilder.enableMultiSessionRecord(enableMultiSessionRecord);
|
|
127
|
+
if (enableCrashHandling != null)
|
|
128
|
+
uxConfigBuilder.enableCrashHandling(enableCrashHandling);
|
|
129
|
+
if (enableAutomaticScreenNameTagging != null)
|
|
130
|
+
uxConfigBuilder.enableAutomaticScreenNameTagging(enableAutomaticScreenNameTagging);
|
|
131
|
+
if (enableImprovedScreenCapture != null) {
|
|
132
|
+
Log.d("config", "improved screen capture enabled " + enableImprovedScreenCapture);
|
|
133
|
+
uxConfigBuilder.enableImprovedScreenCapture(enableImprovedScreenCapture);
|
|
134
|
+
}
|
|
135
|
+
if (occlusionList != null)
|
|
136
|
+
uxConfigBuilder.occlusions(occlusionList);
|
|
137
|
+
UXConfig config = uxConfigBuilder.build();
|
|
138
|
+
return config;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
private List<UXCamOcclusion> convertToOcclusionList(List<Map<String, Object>> occlusionObjects) {
|
|
142
|
+
List<UXCamOcclusion> occlusionList = new ArrayList<UXCamOcclusion>();
|
|
143
|
+
for (Map<String, Object> occlusionMap :
|
|
144
|
+
occlusionObjects) {
|
|
145
|
+
UXCamOcclusion occlusion = getOcclusion(occlusionMap);
|
|
146
|
+
if (occlusion != null)
|
|
147
|
+
occlusionList.add(getOcclusion(occlusionMap));
|
|
148
|
+
}
|
|
149
|
+
return occlusionList;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
private UXCamOcclusion getOcclusion(Map<String, Object> occlusionMap) {
|
|
153
|
+
double typeIndex = (double) occlusionMap.get(TYPE);
|
|
154
|
+
switch ((int)typeIndex) {
|
|
155
|
+
case 1:
|
|
156
|
+
return (UXCamOcclusion) getOccludeAllTextFields();
|
|
157
|
+
case 2:
|
|
158
|
+
return (UXCamOcclusion) getOverlay(occlusionMap);
|
|
159
|
+
case 3:
|
|
160
|
+
return (UXCamOcclusion) getBlur(occlusionMap);
|
|
161
|
+
default:
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private UXCamOccludeAllTextFields getOccludeAllTextFields() {
|
|
167
|
+
return new UXCamOccludeAllTextFields.Builder().build();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
private UXCamOverlay getOverlay(Map<String, Object> overlayMap) {
|
|
171
|
+
// get data
|
|
172
|
+
List<String> screens = (List<String>) overlayMap.get(SCREENS);
|
|
173
|
+
Boolean excludeMentionedScreens = (Boolean) overlayMap.get(EXCLUDE_MENTIONED_SCREENS);
|
|
174
|
+
Boolean hideGestures = (Boolean) overlayMap.get(HIDE_GESTURES);
|
|
175
|
+
|
|
176
|
+
// set data
|
|
177
|
+
UXCamOverlay.Builder overlayBuilder = new UXCamOverlay.Builder();
|
|
178
|
+
if (screens != null && !screens.isEmpty())
|
|
179
|
+
overlayBuilder.screens(screens);
|
|
180
|
+
if (excludeMentionedScreens != null)
|
|
181
|
+
overlayBuilder.excludeMentionedScreens(excludeMentionedScreens);
|
|
182
|
+
if (hideGestures != null)
|
|
183
|
+
overlayBuilder.withoutGesture(hideGestures);
|
|
184
|
+
return overlayBuilder.build();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
private UXCamBlur getBlur(Map<String, Object> blurMap) {
|
|
188
|
+
// get data
|
|
189
|
+
List<String> screens = (List<String>) blurMap.get(SCREENS);
|
|
190
|
+
Boolean excludeMentionedScreens = (Boolean) blurMap.get(EXCLUDE_MENTIONED_SCREENS);
|
|
191
|
+
Double blurRadius = (Double) blurMap.get(BLUR_RADIUS);
|
|
192
|
+
Boolean hideGestures = (Boolean) blurMap.get(HIDE_GESTURES);
|
|
193
|
+
|
|
194
|
+
// set data
|
|
195
|
+
UXCamBlur.Builder blurBuilder = new UXCamBlur.Builder();
|
|
196
|
+
if (screens != null && !screens.isEmpty())
|
|
197
|
+
blurBuilder.screens(screens);
|
|
198
|
+
if (excludeMentionedScreens != null)
|
|
199
|
+
blurBuilder.excludeMentionedScreens(excludeMentionedScreens);
|
|
200
|
+
if (blurRadius != null)
|
|
201
|
+
blurBuilder.blurRadius(blurRadius.intValue());
|
|
202
|
+
if (hideGestures != null)
|
|
203
|
+
blurBuilder.withoutGesture(hideGestures);
|
|
204
|
+
return blurBuilder.build();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
private void sendEvent(ReactApplicationContext reactContext,
|
|
208
|
+
WritableMap params) {
|
|
209
|
+
reactContext
|
|
210
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
211
|
+
.emit(RNUxcamModuleImpl.UXCAM_VERIFICATION_EVENT_KEY, params);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
public void addListener(String eventName) {
|
|
215
|
+
// Handled through initializer, only for interface confirmation
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
public void removeListeners(double count) {
|
|
219
|
+
// Not needed on android, only for interface confirmation
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
public void applyOcclusion(ReadableMap occlusionMap) {
|
|
223
|
+
UXCamOcclusion occlusion = getOcclusion(occlusionMap.toHashMap());
|
|
224
|
+
UXCam.applyOcclusion(occlusion);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
public void removeOcclusion(ReadableMap occlusionMap) {
|
|
228
|
+
UXCamOcclusion occlusion = getOcclusion(occlusionMap.toHashMap());
|
|
229
|
+
UXCam.removeOcclusion(occlusion);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
public void startNewSession() {
|
|
233
|
+
UXCam.startNewSession();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
public void stopSessionAndUploadData() {
|
|
237
|
+
UXCam.stopSessionAndUploadData();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
public void cancelCurrentSession() {
|
|
241
|
+
UXCam.cancelCurrentSession();
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
public void occludeAllTextFields(boolean occludeAll) {
|
|
245
|
+
UXCam.occludeAllTextFields(occludeAll);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
public void occludeSensitiveScreen(boolean occlude, boolean hideGestures) {
|
|
249
|
+
UXCam.occludeSensitiveScreen(occlude, hideGestures);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
public void occludeSensitiveView(final double tag, boolean hideGestures) {
|
|
253
|
+
if (hideGestures) {
|
|
254
|
+
occludeSensitiveViewWithoutGesture((int)tag);
|
|
255
|
+
} else {
|
|
256
|
+
occludeSensitiveViewWithGesture((int)tag);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
public void occludeSensitiveViewWithGesture(final int id) {
|
|
261
|
+
findView(id, (new RNUxViewFinder() {
|
|
262
|
+
@Override
|
|
263
|
+
public void obtainView(View view) {
|
|
264
|
+
UXCam.occludeSensitiveView(view);
|
|
265
|
+
}
|
|
266
|
+
}));
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
public void occludeSensitiveViewWithoutGesture(final int id) {
|
|
270
|
+
findView(id, (new RNUxViewFinder() {
|
|
271
|
+
@Override
|
|
272
|
+
public void obtainView(View view) {
|
|
273
|
+
UXCam.occludeSensitiveViewWithoutGesture(view);
|
|
274
|
+
}
|
|
275
|
+
}));
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
public void unOccludeSensitiveView(final double id) {
|
|
279
|
+
findView((int) id, (new RNUxViewFinder() {
|
|
280
|
+
@Override
|
|
281
|
+
public void obtainView(View view) {
|
|
282
|
+
UXCam.unOccludeSensitiveView(view);
|
|
283
|
+
}
|
|
284
|
+
}));
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
private void findView(final int tag, RNUxViewFinder viewFinder) {
|
|
288
|
+
int type = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED ? UIManagerType.FABRIC : UIManagerType.DEFAULT;
|
|
289
|
+
UIManager uiManager = UIManagerHelper.getUIManager(getReactApplicationContext(), type);
|
|
290
|
+
assert uiManager != null;
|
|
291
|
+
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
|
|
292
|
+
// Temporary fix for nullable view on new architecture due to lazy loading
|
|
293
|
+
UiThreadUtil.runOnUiThread(new Runnable() {
|
|
294
|
+
@Override
|
|
295
|
+
public void run() {
|
|
296
|
+
View view = uiManager.resolveView(tag);
|
|
297
|
+
if (view != null) {
|
|
298
|
+
viewFinder.obtainView(view);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}, 100);
|
|
302
|
+
} else {
|
|
303
|
+
((UIManagerModule)uiManager).addUIBlock(new UIBlock() {
|
|
304
|
+
@Override
|
|
305
|
+
public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
|
|
306
|
+
View view = nativeViewHierarchyManager.resolveView(tag);
|
|
307
|
+
if (view != null) {
|
|
308
|
+
viewFinder.obtainView(view);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
public void optInOverall() {
|
|
317
|
+
UXCam.optIn();
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
public void optOutOverall() {
|
|
321
|
+
UXCam.optOut();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
public boolean optInOverallStatus() {
|
|
325
|
+
return UXCam.optStatus();
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
public void optIntoVideoRecording() {
|
|
329
|
+
UXCam.optIntoVideoRecording();
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
public void optOutOfVideoRecording() {
|
|
333
|
+
UXCam.optOutOfVideoRecording();
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
public boolean optInVideoRecordingStatus() {
|
|
337
|
+
return UXCam.optInVideoRecordingStatus();
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
public void optIntoSchematicRecordings() {
|
|
341
|
+
UXCam.optIntoVideoRecording();
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
public void optOutOfSchematicRecordings() {
|
|
345
|
+
UXCam.optOutOfVideoRecording();
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
public boolean optInSchematicRecordingStatus() {
|
|
349
|
+
return UXCam.optInVideoRecordingStatus();
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
public void urlForCurrentSession(Promise promise) {
|
|
353
|
+
promise.resolve(UXCam.urlForCurrentSession());
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
public void urlForCurrentUser(Promise promise) {
|
|
357
|
+
promise.resolve(UXCam.urlForCurrentUser());
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
public void uploadPendingSession() {
|
|
361
|
+
// Method not available in android
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
public void deletePendingUploads() {
|
|
365
|
+
UXCam.deletePendingUploads();
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
public double pendingSessionCount() {
|
|
369
|
+
return UXCam.pendingSessionCount();
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
public void allowShortBreakForAnotherAppInMillis(double millis) {
|
|
373
|
+
UXCam.allowShortBreakForAnotherApp((int)millis);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
public void allowShortBreakForAnotherApp(boolean continueSession) {
|
|
377
|
+
UXCam.allowShortBreakForAnotherApp(continueSession);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
public boolean isRecording() {
|
|
381
|
+
return UXCam.isRecording();
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
public void pauseScreenRecording() {
|
|
385
|
+
UXCam.pauseScreenRecording();
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
public void resumeScreenRecording() {
|
|
389
|
+
UXCam.resumeScreenRecording();
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
public void tagScreenName(String screenName) {
|
|
393
|
+
UXCam.tagScreenName(screenName);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
public void logEvent(String event, ReadableMap properties) {
|
|
397
|
+
HashMap<String, Object> convertedProperties = new HashMap<>();
|
|
398
|
+
|
|
399
|
+
if (properties != null) {
|
|
400
|
+
ReadableMapKeySetIterator iterator = properties.keySetIterator();
|
|
401
|
+
|
|
402
|
+
while (iterator.hasNextKey()) {
|
|
403
|
+
String key = iterator.nextKey();
|
|
404
|
+
ReadableType type = properties.getType(key);
|
|
405
|
+
try {
|
|
406
|
+
switch (type) {
|
|
407
|
+
case Null:
|
|
408
|
+
convertedProperties.put(key, "");
|
|
409
|
+
case Boolean:
|
|
410
|
+
convertedProperties.put(key, properties.getBoolean(key));
|
|
411
|
+
break;
|
|
412
|
+
case Number:
|
|
413
|
+
convertedProperties.put(key, properties.getDouble(key));
|
|
414
|
+
break;
|
|
415
|
+
case String:
|
|
416
|
+
convertedProperties.put(key, properties.getString(key));
|
|
417
|
+
break;
|
|
418
|
+
case Map:
|
|
419
|
+
convertedProperties.put(key, properties.getMap(key).toString());
|
|
420
|
+
break;
|
|
421
|
+
case Array:
|
|
422
|
+
convertedProperties.put(key, properties.getArray(key).toString());
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
} catch (NullPointerException | NoSuchKeyException | UnexpectedNativeTypeException e) {
|
|
426
|
+
convertedProperties.put(key, "");
|
|
427
|
+
e.printStackTrace();
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
UXCam.logEvent(event, convertedProperties);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
public void setUserIdentity(String id) {
|
|
436
|
+
UXCam.setUserIdentity(id);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
public void setUserProperty(String key, String value) {
|
|
440
|
+
UXCam.setUserProperty(key, value);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
public void setSessionProperty(String key, String value) {
|
|
444
|
+
UXCam.setSessionProperty(key, value);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
@@ -1,28 +1,43 @@
|
|
|
1
|
-
|
|
2
1
|
package com.uxcam;
|
|
3
2
|
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import java.util.List;
|
|
7
|
-
|
|
8
|
-
import com.facebook.react.ReactPackage;
|
|
3
|
+
import androidx.annotation.Nullable;
|
|
4
|
+
import com.facebook.react.TurboReactPackage;
|
|
9
5
|
import com.facebook.react.bridge.NativeModule;
|
|
10
6
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
11
|
-
import com.facebook.react.
|
|
12
|
-
import com.facebook.react.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return Arrays.<NativeModule>asList(new RNUxcamModule(reactContext));
|
|
17
|
-
}
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfo;
|
|
8
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
|
9
|
+
|
|
10
|
+
import java.util.HashMap;
|
|
11
|
+
import java.util.Map;
|
|
18
12
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
public class RNUxcamPackage extends TurboReactPackage {
|
|
14
|
+
@Nullable
|
|
15
|
+
@Override
|
|
16
|
+
public NativeModule getModule(String name, ReactApplicationContext reactContext) {
|
|
17
|
+
if (name.equals(RNUxcamModuleImpl.MODULE_NAME)) {
|
|
18
|
+
return new RNUxcamModule(reactContext);
|
|
19
|
+
} else {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
@Override
|
|
25
|
-
public
|
|
26
|
-
|
|
25
|
+
public ReactModuleInfoProvider getReactModuleInfoProvider() {
|
|
26
|
+
return () -> {
|
|
27
|
+
final Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
|
|
28
|
+
boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
|
|
29
|
+
moduleInfos.put(
|
|
30
|
+
RNUxcamModuleImpl.MODULE_NAME,
|
|
31
|
+
new ReactModuleInfo(
|
|
32
|
+
RNUxcamModuleImpl.MODULE_NAME,
|
|
33
|
+
RNUxcamModuleImpl.MODULE_NAME,
|
|
34
|
+
false, // canOverrideExistingModule
|
|
35
|
+
false, // needsEagerInit
|
|
36
|
+
true, // hasConstants
|
|
37
|
+
false, // isCxxModule
|
|
38
|
+
isTurboModule
|
|
39
|
+
));
|
|
40
|
+
return moduleInfos;
|
|
41
|
+
};
|
|
27
42
|
}
|
|
28
43
|
}
|