react-native-scanbot-barcode-scanner-sdk 3.0.0-beta7 → 3.1.0-alpha3
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/RNScanbotBarcodeSDK.podspec +1 -1
- package/android/.gradle/6.1.1/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/6.1.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/6.1.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/6.1.1/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/6.1.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/6.1.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/caches/build_file_checksums.ser +0 -0
- package/android/.idea/compiler.xml +6 -0
- package/android/.idea/gradle.xml +22 -0
- package/android/.idea/jarRepositories.xml +50 -0
- package/android/.idea/libraries/Gradle__androidx_activity_activity_1_2_3_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_annotation_annotation_1_2_0.xml +11 -0
- package/android/.idea/libraries/Gradle__androidx_annotation_annotation_experimental_1_1_0_rc01_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_3_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_3_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_arch_core_core_common_2_1_0.xml +11 -0
- package/android/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_asynclayoutinflater_asynclayoutinflater_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_camera_camera_camera2_1_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_camera_camera_core_1_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_camera_camera_lifecycle_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_camera_camera_view_1_0_0_alpha24_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_cardview_cardview_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_collection_collection_1_1_0.xml +11 -0
- package/android/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_2_0_4_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_solver_2_0_4.xml +9 -0
- package/android/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_1_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_core_core_1_5_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_core_core_ktx_1_3_2_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_databinding_viewbinding_4_2_1_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_dynamicanimation_dynamicanimation_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_fragment_fragment_1_3_4_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_ui_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_v4_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_3_1.xml +11 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_3_1_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_3_1_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_ktx_2_3_1_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_3_1_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_savedstate_2_3_1_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_media_media_1_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_print_print_1_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_recyclerview_recyclerview_1_1_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_slidingpanelayout_slidingpanelayout_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_swiperefreshlayout_swiperefreshlayout_1_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_transition_transition_1_2_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_1_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_viewpager2_viewpager2_1_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_commonsware_cwac_camera_camera_0_6_41_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_drawee_2_0_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_fbcore_2_0_0_aar.xml +18 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_fresco_2_0_0_aar.xml +18 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_2_0_0_aar.xml +18 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_base_2_0_0_aar.xml +18 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_okhttp3_2_0_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_nativeimagefilters_2_0_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_nativeimagetranscoder_2_0_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_infer_annotation_infer_annotation_0_11_2.xml +13 -0
- package/android/.idea/libraries/Gradle__com_facebook_react_react_native_0_60_6_aar.xml +18 -0
- package/android/.idea/libraries/Gradle__com_facebook_soloader_soloader_0_6_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_google_android_material_material_1_3_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_2.xml +13 -0
- package/android/.idea/libraries/Gradle__com_google_code_gson_gson_2_8_6.xml +13 -0
- package/android/.idea/libraries/Gradle__com_google_dagger_dagger_2_35.xml +13 -0
- package/android/.idea/libraries/Gradle__com_google_guava_listenablefuture_1_0.xml +13 -0
- package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_3_12_1.xml +13 -0
- package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_urlconnection_3_12_1.xml +13 -0
- package/android/.idea/libraries/Gradle__com_squareup_okio_okio_1_15_0.xml +13 -0
- package/android/.idea/libraries/Gradle__commons_io_commons_io_2_4.xml +13 -0
- package/android/.idea/libraries/Gradle__io_reactivex_rxjava2_rxandroid_2_0_1_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__io_reactivex_rxjava2_rxjava_2_1_5.xml +13 -0
- package/android/.idea/libraries/Gradle__io_scanbot_scanbot_barcode_scanner_sdk_3_0_1_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__io_scanbot_scanbot_barcode_scanner_sdk_ui_3_0_1_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__io_scanbot_scanbot_sdk_barcode_3_0_1_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__io_scanbot_scanbot_sdk_base_3_0_1_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__io_scanbot_scanbot_sdk_ui_barcode_3_0_1_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__io_scanbot_scanbot_sdk_ui_base_3_0_1_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__io_scanbot_sdk_barcode_assets_3_0_1_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__io_scanbot_sdk_core_barcode_3_0_1_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__io_scanbot_sdk_core_barcode_native_3_0_1_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__io_scanbot_sdk_core_sap_3_0_1_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__javax_inject_javax_inject_1.xml +13 -0
- package/android/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml +13 -0
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_4_20.xml +13 -0
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_4_20.xml +13 -0
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_4_20.xml +13 -0
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_android_1_4_1.xml +13 -0
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_core_jvm_1_4_1.xml +13 -0
- package/android/.idea/libraries/Gradle__org_reactivestreams_reactive_streams_1_0_1.xml +13 -0
- package/android/.idea/misc.xml +9 -0
- package/android/.idea/modules/android.iml +133 -0
- package/android/.idea/modules.xml +8 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/.idea/workspace.xml +62 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/JSONUtils.java +74 -9
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkModule.java +2 -2
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkPackage.java +5 -1
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/EventEmitter.java +55 -0
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewConfiguration.java +113 -0
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewFragment.java +246 -0
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewManager.java +160 -0
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/common/ScanbotComponentFrameLayout.java +53 -0
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/common/ScanbotComponentRootView.java +159 -0
- package/android/src/main/res/layout/component_barcode_camera_view.xml +11 -0
- package/android/src/main/res/layout/fragment_barcode_scanner.xml +23 -0
- package/index.d.ts +4 -0
- package/index.js +3 -0
- package/ios/Components/BarcodeCameraView/RNScanbotBarcodeCameraView.h +54 -0
- package/ios/Components/BarcodeCameraView/RNScanbotBarcodeCameraView.m +235 -0
- package/ios/Components/BarcodeCameraView/RNScanbotBarcodeCameraViewManager.h +16 -0
- package/ios/Components/BarcodeCameraView/RNScanbotBarcodeCameraViewManager.m +30 -0
- package/ios/ScanbotBarcodeSdk.m +1 -1
- package/package.json +4 -1
- package/src/components/barcode-camera-view/scanbot-barcode-camera-view-types.tsx +115 -0
- package/src/components/barcode-camera-view/scanbot-barcode-camera-view.tsx +163 -0
- package/src/components/barcode-camera-view/scanbot-native-barcode-camera-view.tsx +6 -0
- package/src/configuration.ts +2 -2
- package/src/enum.ts +1 -1
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
package io.scanbot.barcodesdk.plugin.reactnative.components.barcodecameraview;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.view.LayoutInflater;
|
|
5
|
+
import android.view.View;
|
|
6
|
+
import android.widget.FrameLayout;
|
|
7
|
+
|
|
8
|
+
import androidx.annotation.NonNull;
|
|
9
|
+
import androidx.annotation.Nullable;
|
|
10
|
+
import androidx.appcompat.app.AppCompatActivity;
|
|
11
|
+
import androidx.fragment.app.FragmentManager;
|
|
12
|
+
|
|
13
|
+
import com.facebook.react.ReactRootView;
|
|
14
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
15
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
16
|
+
import com.facebook.react.bridge.WritableNativeMap;
|
|
17
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
18
|
+
import com.facebook.react.uimanager.ViewGroupManager;
|
|
19
|
+
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
20
|
+
|
|
21
|
+
import java.util.Map;
|
|
22
|
+
|
|
23
|
+
import io.scanbot.barcodesdk.plugin.reactnative.JSONUtils;
|
|
24
|
+
import io.scanbot.barcodesdk.plugin.reactnative.ObjectMapper;
|
|
25
|
+
import io.scanbot.barcodesdk.plugin.reactnative.R;
|
|
26
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.EventEmitter;
|
|
27
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.common.ScanbotComponentFrameLayout;
|
|
28
|
+
import io.scanbot.barcodesdk.plugin.reactnative.components.common.ScanbotComponentRootView;
|
|
29
|
+
|
|
30
|
+
public class ScanbotBarcodeCameraViewManager extends ViewGroupManager<ReactRootView> {
|
|
31
|
+
|
|
32
|
+
public static final String REACT_CLASS = "ScanbotBarcodeCameraView";
|
|
33
|
+
|
|
34
|
+
private final ReactApplicationContext mCallerContext;
|
|
35
|
+
private ScanbotComponentRootView viewGroup;
|
|
36
|
+
private ScanbotBarcodeCameraViewFragment cameraViewFragment;
|
|
37
|
+
private ScanbotBarcodeCameraViewConfiguration cameraViewConfiguration = new ScanbotBarcodeCameraViewConfiguration();
|
|
38
|
+
|
|
39
|
+
public ScanbotBarcodeCameraViewManager(ReactApplicationContext context) {
|
|
40
|
+
mCallerContext = context;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@NonNull
|
|
44
|
+
@Override
|
|
45
|
+
public String getName() {
|
|
46
|
+
return REACT_CLASS;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@ReactProp(name = "configuration")
|
|
50
|
+
public void setConfiguration(FrameLayout frameLayout, ReadableMap configuration) {
|
|
51
|
+
cameraViewConfiguration = new ScanbotBarcodeCameraViewConfiguration();
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
ObjectMapper.map(configuration, cameraViewConfiguration);
|
|
55
|
+
} catch (Exception e) {
|
|
56
|
+
e.printStackTrace();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (configuration.hasKey("barcodeFormats")) {
|
|
60
|
+
cameraViewConfiguration.barcodeFormats = JSONUtils.extractBarcodeFormats(configuration);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (configuration.hasKey("acceptedDocumentFormats")) {
|
|
64
|
+
cameraViewConfiguration.acceptedDocumentFormats = JSONUtils.extractBarcodeDocumentFormats(configuration);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (configuration.hasKey("cameraZoomFactor")) {
|
|
68
|
+
float value = (float) configuration.getDouble("cameraZoomFactor");
|
|
69
|
+
if (value != -1) {
|
|
70
|
+
cameraViewConfiguration.setCameraZoomFactor(value);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (configuration.hasKey("flashEnabled")) {
|
|
75
|
+
cameraViewConfiguration.setFlashEnabled(configuration.getBoolean("flashEnabled"));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
cameraViewConfiguration.additionalConfiguration = JSONUtils.extractBarcodeScannerAdditionalConfig(configuration);
|
|
79
|
+
cameraViewConfiguration.engineMode = JSONUtils.extractEngineMode(configuration);
|
|
80
|
+
|
|
81
|
+
if (cameraViewFragment != null) {
|
|
82
|
+
cameraViewFragment.updateWithConfiguration(cameraViewConfiguration);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@Nullable
|
|
87
|
+
@Override
|
|
88
|
+
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
|
89
|
+
return EventEmitter.getMapForNativeEvents(new EventEmitter.NativeEvent[] {
|
|
90
|
+
EventEmitter.NativeEvent.BARCODE_SCANNER_RESULT,
|
|
91
|
+
EventEmitter.NativeEvent.REQUEST_COMPONENT_RELOAD
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@NonNull
|
|
96
|
+
@Override
|
|
97
|
+
protected ReactRootView createViewInstance(@NonNull final ThemedReactContext reactContext) {
|
|
98
|
+
|
|
99
|
+
// Retrieve Current Activity
|
|
100
|
+
final Activity activity = reactContext.getCurrentActivity();
|
|
101
|
+
assert activity != null;
|
|
102
|
+
|
|
103
|
+
// Inflate Layout
|
|
104
|
+
viewGroup = (ScanbotComponentRootView) LayoutInflater
|
|
105
|
+
.from(activity)
|
|
106
|
+
.inflate(R.layout.component_barcode_camera_view, null, false);
|
|
107
|
+
|
|
108
|
+
// Add Camera View Fragment
|
|
109
|
+
cameraViewFragment = new ScanbotBarcodeCameraViewFragment();
|
|
110
|
+
cameraViewFragment.instantiate(reactContext, viewGroup);
|
|
111
|
+
final AppCompatActivity fragmentActivity = (AppCompatActivity) activity;
|
|
112
|
+
final FragmentManager fragmentManager = fragmentActivity.getSupportFragmentManager();
|
|
113
|
+
|
|
114
|
+
final ScanbotComponentFrameLayout fragmentLayout = viewGroup.findViewById(R.id.fragment_container_view);
|
|
115
|
+
fragmentLayout.setZ(-1.0f);
|
|
116
|
+
fragmentLayout.setLayoutParams(new FrameLayout.LayoutParams(
|
|
117
|
+
FrameLayout.LayoutParams.MATCH_PARENT,
|
|
118
|
+
FrameLayout.LayoutParams.MATCH_PARENT));
|
|
119
|
+
|
|
120
|
+
// Configure Camera View fragment with configuration parameters
|
|
121
|
+
cameraViewFragment.updateWithConfiguration(cameraViewConfiguration);
|
|
122
|
+
viewGroup.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
|
|
123
|
+
@Override
|
|
124
|
+
public void onViewAttachedToWindow(View v) {
|
|
125
|
+
if (cameraViewFragment.isAdded()) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
reactContext.runOnUiQueueThread(new Runnable() {
|
|
129
|
+
@Override
|
|
130
|
+
public void run() {
|
|
131
|
+
fragmentManager
|
|
132
|
+
.beginTransaction()
|
|
133
|
+
.add(R.id.fragment_container_view, cameraViewFragment)
|
|
134
|
+
.commit();
|
|
135
|
+
|
|
136
|
+
viewGroup.post(viewGroup.measureAndLayout);
|
|
137
|
+
|
|
138
|
+
viewGroup.addOneShotChildRemovedListener(new ScanbotComponentRootView.IOnChildRemovedListener() {
|
|
139
|
+
@Override
|
|
140
|
+
public void onChildRemoved(View child) {
|
|
141
|
+
new EventEmitter(mCallerContext, viewGroup)
|
|
142
|
+
.emitEvent(
|
|
143
|
+
EventEmitter.NativeEvent.REQUEST_COMPONENT_RELOAD,
|
|
144
|
+
new WritableNativeMap());
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@Override
|
|
152
|
+
public void onViewDetachedFromWindow(View v) {
|
|
153
|
+
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
return viewGroup;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
package io.scanbot.barcodesdk.plugin.reactnative.components.common;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.util.AttributeSet;
|
|
5
|
+
import android.widget.FrameLayout;
|
|
6
|
+
|
|
7
|
+
import java.util.ArrayList;
|
|
8
|
+
import java.util.List;
|
|
9
|
+
|
|
10
|
+
public class ScanbotComponentFrameLayout extends FrameLayout {
|
|
11
|
+
|
|
12
|
+
interface ILayoutChangeListener {
|
|
13
|
+
void onFrameLayoutChanged(int width, int height, int left, int top, int right, int bottom);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public ScanbotComponentFrameLayout(Context context, AttributeSet attrs) {
|
|
17
|
+
super(context, attrs);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public ScanbotComponentFrameLayout(Context context, AttributeSet attrs, int defStyle) {
|
|
21
|
+
super(context, attrs, defStyle);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public final Runnable measureAndLayout =
|
|
25
|
+
new Runnable() {
|
|
26
|
+
@Override
|
|
27
|
+
public void run() {
|
|
28
|
+
measure(
|
|
29
|
+
MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY),
|
|
30
|
+
MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.EXACTLY));
|
|
31
|
+
layout(getLeft(), getTop(), getRight(), getBottom());
|
|
32
|
+
notifyListeners(getWidth(), getHeight(), getLeft(), getTop(), getRight(), getBottom());
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
private final List<ILayoutChangeListener> layoutChangeListeners = new ArrayList<>();
|
|
37
|
+
|
|
38
|
+
@Override
|
|
39
|
+
public void requestLayout() {
|
|
40
|
+
super.requestLayout();
|
|
41
|
+
post(measureAndLayout);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public void addLayoutChangeListener(ILayoutChangeListener listener) {
|
|
45
|
+
layoutChangeListeners.add(listener);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private void notifyListeners(int width, int height, int left, int top, int right, int bottom) {
|
|
49
|
+
for(ILayoutChangeListener listener : layoutChangeListeners) {
|
|
50
|
+
listener.onFrameLayoutChanged(width, height, left, top, right, bottom);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
package io.scanbot.barcodesdk.plugin.reactnative.components.common;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.util.AttributeSet;
|
|
5
|
+
import android.view.Choreographer;
|
|
6
|
+
import android.view.MotionEvent;
|
|
7
|
+
import android.view.View;
|
|
8
|
+
import android.widget.FrameLayout;
|
|
9
|
+
|
|
10
|
+
import com.facebook.react.ReactRootView;
|
|
11
|
+
|
|
12
|
+
import java.lang.reflect.Type;
|
|
13
|
+
import java.util.ArrayList;
|
|
14
|
+
import java.util.List;
|
|
15
|
+
|
|
16
|
+
public class ScanbotComponentRootView extends ReactRootView {
|
|
17
|
+
|
|
18
|
+
public interface ILayoutChangeListener {
|
|
19
|
+
void onFrameLayoutChanged(int width, int height, int left, int top, int right, int bottom);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public interface IOnChildRemovedListener {
|
|
23
|
+
void onChildRemoved(final View child);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public final Runnable measureAndLayout =
|
|
27
|
+
new Runnable() {
|
|
28
|
+
@Override
|
|
29
|
+
public void run() {
|
|
30
|
+
measure(
|
|
31
|
+
MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY),
|
|
32
|
+
MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.EXACTLY));
|
|
33
|
+
layout(getLeft(), getTop(), getRight(), getBottom());
|
|
34
|
+
notifyLayoutChangeListeners(getWidth(), getHeight(), getLeft(), getTop(), getRight(), getBottom());
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
private final List<ILayoutChangeListener> layoutChangeListeners = new ArrayList<>();
|
|
39
|
+
private final List<IOnChildRemovedListener> childRemovedListeners = new ArrayList<>();
|
|
40
|
+
private final List<View> lastNotifiedChildViews = new ArrayList<>();
|
|
41
|
+
private final List<Type> reservedComponents = new ArrayList<>();
|
|
42
|
+
private boolean shouldNotifyWhenChildIsRemoved = false;
|
|
43
|
+
|
|
44
|
+
private void instantiate() {
|
|
45
|
+
reservedComponents.add(ScanbotComponentRootView.class);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public ScanbotComponentRootView(Context context) {
|
|
49
|
+
super(context);
|
|
50
|
+
instantiate();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public ScanbotComponentRootView(Context context, AttributeSet attrs) {
|
|
54
|
+
super(context, attrs);
|
|
55
|
+
instantiate();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public ScanbotComponentRootView(Context context, AttributeSet attrs, int defStyle) {
|
|
59
|
+
super(context, attrs, defStyle);
|
|
60
|
+
instantiate();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@Override
|
|
64
|
+
protected void onAttachedToWindow() {
|
|
65
|
+
super.onAttachedToWindow();
|
|
66
|
+
applyChildrenMeasureWorkaround();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private void applyChildrenMeasureWorkaround() {
|
|
70
|
+
Choreographer.getInstance().postFrameCallback(new Choreographer.FrameCallback() {
|
|
71
|
+
@Override
|
|
72
|
+
public void doFrame(long frameTimeNanos) {
|
|
73
|
+
for (int i = 0; i < getChildCount(); i++) {
|
|
74
|
+
View child = getChildAt(i);
|
|
75
|
+
if (child instanceof FrameLayout) {
|
|
76
|
+
child.measure(MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY),
|
|
77
|
+
MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY));
|
|
78
|
+
child.layout(0, 0, child.getMeasuredWidth(), child.getMeasuredHeight());
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
getViewTreeObserver().dispatchOnGlobalLayout();
|
|
82
|
+
shouldNotifyWhenChildIsRemoved = true;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@Override
|
|
88
|
+
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
|
89
|
+
return super.onInterceptTouchEvent(ev);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@Override
|
|
93
|
+
public void requestLayout() {
|
|
94
|
+
super.requestLayout();
|
|
95
|
+
post(measureAndLayout);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public void addLayoutChangeListener(ILayoutChangeListener listener) {
|
|
99
|
+
layoutChangeListeners.add(listener);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public void addOneShotChildRemovedListener(IOnChildRemovedListener listener) {
|
|
103
|
+
if (!childRemovedListeners.contains(listener)) {
|
|
104
|
+
childRemovedListeners.add(listener);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private void notifyLayoutChangeListeners(int width, int height, int left, int top, int right, int bottom) {
|
|
109
|
+
for(ILayoutChangeListener listener : layoutChangeListeners) {
|
|
110
|
+
listener.onFrameLayoutChanged(width, height, left, top, right, bottom);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private void notifyChildRemovedListeners(final View childView) {
|
|
115
|
+
for (IOnChildRemovedListener listener : childRemovedListeners) {
|
|
116
|
+
if (!lastNotifiedChildViews.contains(childView)) {
|
|
117
|
+
listener.onChildRemoved(childView);
|
|
118
|
+
lastNotifiedChildViews.add(childView);
|
|
119
|
+
} else {
|
|
120
|
+
lastNotifiedChildViews.clear();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
childRemovedListeners.clear();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@Override
|
|
128
|
+
public void onViewAdded(View child) {
|
|
129
|
+
super.onViewAdded(child);
|
|
130
|
+
child.bringToFront();
|
|
131
|
+
child.setZ(2.0f);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Called when a child view is removed from this ViewGroup. Overrides should always
|
|
136
|
+
* call super.onViewRemoved.
|
|
137
|
+
*
|
|
138
|
+
* @param child the removed child view
|
|
139
|
+
*/
|
|
140
|
+
@Override
|
|
141
|
+
public void onViewRemoved(View child) {
|
|
142
|
+
super.onViewRemoved(child);
|
|
143
|
+
if (shouldNotifyWhenChildIsRemoved) {
|
|
144
|
+
//notifyChildRemovedListeners(child);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@Override
|
|
149
|
+
public void onAttachedToReactInstance() {
|
|
150
|
+
super.onAttachedToReactInstance();
|
|
151
|
+
shouldNotifyWhenChildIsRemoved = false;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@Override
|
|
155
|
+
protected void onDetachedFromWindow() {
|
|
156
|
+
super.onDetachedFromWindow();
|
|
157
|
+
shouldNotifyWhenChildIsRemoved = false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<io.scanbot.barcodesdk.plugin.reactnative.components.common.ScanbotComponentRootView
|
|
3
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
|
+
android:descendantFocusability="afterDescendants"
|
|
5
|
+
android:layout_width="match_parent"
|
|
6
|
+
android:layout_height="match_parent">
|
|
7
|
+
<io.scanbot.barcodesdk.plugin.reactnative.components.common.ScanbotComponentFrameLayout
|
|
8
|
+
android:id="@+id/fragment_container_view"
|
|
9
|
+
android:layout_width="match_parent"
|
|
10
|
+
android:layout_height="match_parent" />
|
|
11
|
+
</io.scanbot.barcodesdk.plugin.reactnative.components.common.ScanbotComponentRootView>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<io.scanbot.barcodesdk.plugin.reactnative.components.common.ScanbotComponentFrameLayout
|
|
3
|
+
android:id="@+id/barcode_camera_layout"
|
|
4
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
5
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
6
|
+
android:layout_width="match_parent"
|
|
7
|
+
android:layout_height="match_parent">
|
|
8
|
+
|
|
9
|
+
<io.scanbot.sdk.camera.ScanbotCameraView
|
|
10
|
+
android:id="@+id/barcode_camera"
|
|
11
|
+
android:orientation="vertical"
|
|
12
|
+
android:layout_width="match_parent"
|
|
13
|
+
android:layout_height="match_parent"
|
|
14
|
+
android:background="@android:color/black"
|
|
15
|
+
app:finder_view_id="@id/barcode_finder_overlay"/>
|
|
16
|
+
|
|
17
|
+
<io.scanbot.sdk.ui.camera.FinderOverlayView
|
|
18
|
+
android:id="@+id/barcode_finder_overlay"
|
|
19
|
+
app:min_padding="64dp"
|
|
20
|
+
android:layout_width="match_parent"
|
|
21
|
+
android:layout_height="match_parent" />
|
|
22
|
+
|
|
23
|
+
</io.scanbot.barcodesdk.plugin.reactnative.components.common.ScanbotComponentFrameLayout>
|
package/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { BarcodeScannerConfiguration, BatchBarcodeScannerConfiguration } from ".
|
|
|
2
2
|
import { BarcodeDocumentFormat, BarcodeFormat, EngineMode } from "./src/enum";
|
|
3
3
|
import { BarcodeResult, BarcodeScannerResult, BatchBarcodeScannerResult } from "./src/result";
|
|
4
4
|
|
|
5
|
+
|
|
5
6
|
export {
|
|
6
7
|
BarcodeScannerConfiguration,
|
|
7
8
|
BatchBarcodeScannerConfiguration,
|
|
@@ -39,3 +40,6 @@ export interface ScanbotBarcodeSdk {
|
|
|
39
40
|
declare var ScanbotBarcodeSDK: ScanbotBarcodeSdk;
|
|
40
41
|
|
|
41
42
|
export default ScanbotBarcodeSDK;
|
|
43
|
+
|
|
44
|
+
export * from './src/components/barcode-camera-view/scanbot-barcode-camera-view';
|
|
45
|
+
export * from './src/components/barcode-camera-view/scanbot-barcode-camera-view-types';
|
package/index.js
CHANGED
|
@@ -8,3 +8,6 @@ import { NativeModules } from 'react-native';
|
|
|
8
8
|
const { ScanbotBarcodeSdk } = NativeModules;
|
|
9
9
|
|
|
10
10
|
export default ScanbotBarcodeSdk;
|
|
11
|
+
|
|
12
|
+
export * from './src/components/barcode-camera-view/scanbot-barcode-camera-view';
|
|
13
|
+
export * from './src/components/barcode-camera-view/scanbot-barcode-camera-view-types';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNScanbotCameraView.h
|
|
3
|
+
// RNScanbotSDK
|
|
4
|
+
//
|
|
5
|
+
// Created by Marco Saia on 18.05.21.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#ifndef RNScanbotCameraView_h
|
|
9
|
+
#define RNScanbotCameraView_h
|
|
10
|
+
|
|
11
|
+
#import <React/RCTComponent.h>
|
|
12
|
+
@import ScanbotBarcodeScannerSDK;
|
|
13
|
+
|
|
14
|
+
@interface RNScanbotBarcodeCameraView: UIView<SBSDKBarcodeScannerViewControllerDelegate>
|
|
15
|
+
|
|
16
|
+
@property UIViewController* _Nullable cameraViewController;
|
|
17
|
+
@property NSMutableArray* _Nonnull barcodes;
|
|
18
|
+
@property (nonatomic, copy) RCTBubblingEventBlock _Nullable onBarcodeScannerResult;
|
|
19
|
+
@property (nonatomic, copy) RCTBubblingEventBlock _Nullable requestComponentReload;
|
|
20
|
+
@property (nonatomic) BOOL shouldUseFinderView;
|
|
21
|
+
@property (nonatomic, copy) NSDictionary* _Nullable configuration;
|
|
22
|
+
|
|
23
|
+
- (void) createCameraViewController;
|
|
24
|
+
- (UIViewController* _Nullable) getParentViewController;
|
|
25
|
+
|
|
26
|
+
@end
|
|
27
|
+
|
|
28
|
+
@interface RNScanbotCameraViewConfiguration: NSObject
|
|
29
|
+
|
|
30
|
+
// Non-Nullable Properties
|
|
31
|
+
@property (nonatomic) CGFloat finderLineWidth;
|
|
32
|
+
@property (nonatomic) UIColor* _Nonnull finderLineColor;
|
|
33
|
+
@property (nonatomic) UIColor* _Nonnull finderBackgroundColor;
|
|
34
|
+
@property (nonatomic) CGFloat finderBackgroundOpacity;
|
|
35
|
+
@property (nonatomic) SBSDKAspectRatio* _Nonnull finderAspectRatio;
|
|
36
|
+
@property (nonatomic) CGFloat finderMinimumPadding;
|
|
37
|
+
@property (nonatomic) CGFloat finderVerticalOffset;
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
// Nullable Properties (-1 for enums)
|
|
41
|
+
@property (nonatomic, copy) NSNumber* _Nullable shouldUseFinderView;
|
|
42
|
+
@property (nonatomic, copy) NSNumber* _Nullable flashEnabled;
|
|
43
|
+
@property (nonatomic, copy) NSNumber* _Nullable cameraZoomFactor;
|
|
44
|
+
@property (nonatomic, copy) NSNumber* _Nullable gs1DecodingEnabled;
|
|
45
|
+
@property (nonatomic, copy) NSNumber* _Nullable minimumTextLength;
|
|
46
|
+
@property (nonatomic, copy) NSNumber* _Nullable maximumTextLength;
|
|
47
|
+
@property (nonatomic, copy) NSArray<SBSDKBarcodeType *>* _Nullable barcodeFormats;
|
|
48
|
+
@property (nonatomic, copy) NSArray<SBSDKBarcodeDocumentType *>* _Nullable acceptedDocumentFormats;
|
|
49
|
+
@property (nonatomic) SBSDKBarcodeMSIPlesseyChecksumAlgorithm msiPlesseyChecksumAlgorithm;
|
|
50
|
+
@property (nonatomic) SBSDKBarcodeEngineMode engineMode;
|
|
51
|
+
|
|
52
|
+
@end
|
|
53
|
+
|
|
54
|
+
#endif /* RNScanbotCameraView_h */
|