react-native-scanbot-barcode-scanner-sdk 3.3.1-beta1 → 3.3.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.
Files changed (27) hide show
  1. package/LICENSE +1 -1
  2. package/Libraries.txt +2 -2
  3. package/android/.gradle/6.2/executionHistory/executionHistory.lock +0 -0
  4. package/android/build.gradle +1 -1
  5. package/android/src/main/java/com/reactlibrary/ScanbotBarcodeSdkModule.java +0 -6
  6. package/android/src/main/java/com/reactlibrary/ScanbotBarcodeSdkPackage.java +7 -10
  7. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkPackage.java +6 -10
  8. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraView.java +380 -0
  9. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/{RNScanbotBarcodeCameraConfiguration.java → ScanbotBarcodeCameraViewConfiguration.java} +18 -21
  10. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/ScanbotBarcodeCameraViewManager.java +114 -0
  11. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/base/communication/{RNScanbotEventEmitter.java → ScanbotEventEmitter.java} +7 -7
  12. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/base/communication/{RNScanbotEventReceiver.java → ScanbotEventReceiver.java} +7 -7
  13. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/base/models/ScanbotFinderInset.java +8 -0
  14. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/base/ui/ScanbotViewWrapper.java +26 -0
  15. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/utils/ScanbotViewUtils.java +52 -0
  16. package/ios/Components/BarcodeCameraView/RNScanbotBarcodeCameraView.m +1 -1
  17. package/package.json +1 -1
  18. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/RNScanbotBarcodeCameraComponent.java +0 -283
  19. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcodecameraview/RNScanbotBarcodeCameraUi.java +0 -81
  20. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/base/RNScanbotNativeComponent.java +0 -90
  21. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/base/RNScanbotNativeComponentManager.java +0 -133
  22. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/base/RNScanbotNativeComponentManagerFactory.java +0 -40
  23. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/base/RNScanbotNativeComponentUi.java +0 -131
  24. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/base/views/RNScanbotNativeComponentFrameLayout.java +0 -53
  25. package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/base/views/RNScanbotNativeComponentRootView.java +0 -154
  26. package/android/src/main/res/layout/component_barcode_camera_view.xml +0 -28
  27. package/android/src/main/res/layout/fragment_barcode_scanner.xml +0 -23
@@ -1,90 +0,0 @@
1
- package io.scanbot.barcodesdk.plugin.reactnative.components.base;
2
-
3
- import androidx.annotation.NonNull;
4
- import androidx.annotation.Nullable;
5
-
6
- import com.facebook.react.bridge.ReactContext;
7
- import com.facebook.react.bridge.ReadableArray;
8
- import com.facebook.react.bridge.ReadableMap;
9
-
10
- import io.scanbot.barcodesdk.plugin.reactnative.components.base.communication.RNScanbotEventEmitter;
11
- import io.scanbot.barcodesdk.plugin.reactnative.components.base.communication.RNScanbotEventReceiver;
12
- import io.scanbot.barcodesdk.plugin.reactnative.components.base.views.RNScanbotNativeComponentRootView;
13
- import kotlin.NotImplementedError;
14
-
15
- public abstract class RNScanbotNativeComponent {
16
- // The UI layer of the native component
17
- private RNScanbotNativeComponentUi nativeComponentUi;
18
- // Internally set to true when the UI root view is recreated
19
- private boolean isDirty;
20
-
21
- public RNScanbotNativeComponent(@NonNull final ReactContext reactContext) {
22
- this.nativeComponentUi = createNativeComponentUi(reactContext);
23
- }
24
- /*
25
- * Every native component must have a UI component of type RNScanbotNativeComponentUi.
26
- * You must override this method to provide your own custom implementation for it.
27
- */
28
- public RNScanbotNativeComponentUi createNativeComponentUi(@NonNull final ReactContext reactContext) {
29
- throw new NotImplementedError("You must override createNativeComponentUi() in your Native Component implementation");
30
- }
31
- /*
32
- * Initialize the component
33
- */
34
- public abstract void initializeComponent();
35
- /*
36
- * You must override this method to write your implementation mapping the JSON configuration
37
- * that is passed to the component from the React Native JavaScript layer
38
- */
39
- public abstract void applyConfiguration(@NonNull final ReadableMap configuration);
40
- /*
41
- * This is called when a new view instance is requested to the ViewManager.
42
- * It mostly disposes listeners and callbacks, and the .dispose() function of
43
- * the UI Component can be overridden to add custom disposal methods.
44
- */
45
- public void recreateWithContext(final ReactContext reactContext) {
46
- this.nativeComponentUi.dispose();
47
- this.nativeComponentUi = createNativeComponentUi(reactContext);
48
- this.nativeComponentUi._setOnViewRecreatedListener(() -> this.isDirty = true);
49
- }
50
-
51
- /*
52
- * Called on componentDidMount
53
- */
54
- public void onComponentDidMount() {
55
- this.initializeComponent();
56
- }
57
- /*
58
- * Called on componentWillUnmount
59
- */
60
- public void onComponentWillUnmount() {}
61
- /*
62
- * Called on componentDidUpdate
63
- */
64
- public void onComponentDidUpdate() {
65
- if (this.isDirty) {
66
- initializeComponent();
67
- this.isDirty = false;
68
- }
69
- }
70
- /*
71
- * Called on orientationChanged
72
- */
73
- public void onOrientationChanged() {}
74
- /*
75
- * Creates the root view for the component
76
- */
77
- public RNScanbotNativeComponentRootView getRootView() { return this.nativeComponentUi.getRootView(); }
78
- /*
79
- * Returns the list of Native events (from Native to JavaScript); default: empty
80
- */
81
- public RNScanbotEventEmitter.NativeEvent[] getNativeEvents() { return new RNScanbotEventEmitter.NativeEvent[] {}; }
82
- /*
83
- * Returns the list of JavaScript events (from JavaScript to Native); default: empty
84
- */
85
- public RNScanbotEventReceiver.JavaScriptEvent[] getJavascriptEvents() { return new RNScanbotEventReceiver.JavaScriptEvent[] {}; }
86
- /*
87
- * Override this to handle events defined in the getJavascriptEvents method; default: empty
88
- */
89
- public void handleJavascriptEvent(RNScanbotEventReceiver.JavaScriptEvent event, @Nullable ReadableArray args) {}
90
- }
@@ -1,133 +0,0 @@
1
- package io.scanbot.barcodesdk.plugin.reactnative.components.base;
2
-
3
- import android.widget.FrameLayout;
4
-
5
- import androidx.annotation.NonNull;
6
- import androidx.annotation.Nullable;
7
-
8
- import com.facebook.react.ReactRootView;
9
- import com.facebook.react.bridge.ReactContext;
10
- import com.facebook.react.bridge.ReadableArray;
11
- import com.facebook.react.bridge.ReadableMap;
12
- import com.facebook.react.uimanager.ThemedReactContext;
13
- import com.facebook.react.uimanager.ViewGroupManager;
14
- import com.facebook.react.uimanager.annotations.ReactProp;
15
-
16
- import java.util.ArrayList;
17
- import java.util.List;
18
- import java.util.Map;
19
-
20
- import io.scanbot.barcodesdk.plugin.reactnative.components.base.communication.RNScanbotEventEmitter;
21
- import io.scanbot.barcodesdk.plugin.reactnative.components.base.communication.RNScanbotEventReceiver;
22
-
23
- /**
24
- * This class takes care of setting up a ViewManager that:
25
- * - Returns the correct name for registering the view in React Native
26
- * - Accepts a JSON configuration under the prop name 'configuration' and passes it to the native component
27
- * - Sets up events (both JS -> Java and Java -> JS) and it handles common core events
28
- * automatically (like componentDidMount, orientationChanged etc.)
29
- * - Takes care of creating (and recreating) the root view and passing it to the React Native View Manager
30
- * @param <T> Your custom type that extends RNScanbotNativeComponent
31
- */
32
- public abstract class RNScanbotNativeComponentManager<T extends RNScanbotNativeComponent> extends ViewGroupManager<ReactRootView> implements RNScanbotEventReceiver.IEventHandler {
33
- protected final ReactContext reactContext;
34
- protected final T nativeComponent;
35
- protected RNScanbotEventReceiver eventReceiver;
36
- private boolean isInitialized = false;
37
-
38
- public RNScanbotNativeComponentManager(
39
- @NonNull final ReactContext reactContext,
40
- @NonNull final T nativeComponent
41
- ) {
42
- super();
43
- this.reactContext = reactContext;
44
- this.nativeComponent = nativeComponent;
45
- this.eventReceiver = new RNScanbotEventReceiver(this, nativeComponent.getJavascriptEvents());
46
- }
47
-
48
- @ReactProp(name = "configuration")
49
- public void setConfiguration(FrameLayout frameLayout, ReadableMap configuration) {
50
- final RNScanbotNativeComponent component = nativeComponent;
51
- if (component == null) {
52
- return;
53
- }
54
- component.applyConfiguration(configuration);
55
- }
56
-
57
- protected void componentDidMount() { this.nativeComponent.onComponentDidMount(); }
58
- protected void componentWillUnmount() { this.nativeComponent.onComponentWillUnmount(); }
59
- protected void componentDidUpdate() { this.nativeComponent.onComponentDidUpdate(); }
60
- protected void orientationChanged() { this.nativeComponent.onOrientationChanged(); }
61
-
62
- /* --------------------------------------------------*/
63
- /* Internal stuff you probably shouldn't worry about */
64
- /* --------------------------------------------------*/
65
-
66
- // Maps native events (from Native to JS)
67
- @Nullable
68
- @Override
69
- public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
70
- final RNScanbotEventEmitter.NativeEvent[] commonEvents = RNScanbotEventEmitter.CommonEvents.values();
71
- final RNScanbotEventEmitter.NativeEvent[] customEvents = nativeComponent.getNativeEvents();
72
- final RNScanbotEventEmitter.NativeEvent[] allEvents = RNScanbotEventEmitter.concatEvents(commonEvents, customEvents);
73
- return RNScanbotEventEmitter.getMapForNativeEvents(allEvents);
74
- }
75
-
76
- // Creates the view instance when requested from the RN layer
77
- @NonNull
78
- @Override
79
- protected ReactRootView createViewInstance(@NonNull final ThemedReactContext reactContext) {
80
- if (isInitialized) {
81
- this.nativeComponent.recreateWithContext(reactContext);
82
- }
83
- isInitialized = true;
84
- return this.nativeComponent.getRootView();
85
- }
86
-
87
- // Parses notifications from the EventReceiver:
88
- // - It handles common events and stops them from getting to the inheriting class
89
- // - It sends non-common events to the handleJavascriptEvent delegate method in the inheriting class
90
- @Override
91
- public void eventHandler_eventReceived(RNScanbotEventReceiver.JavaScriptEvent event, @Nullable ReadableArray args) {
92
- List<RNScanbotEventReceiver.JavaScriptEvent> handledEvents = new ArrayList<>();
93
- RNScanbotEventReceiver.CommonEvents commonEvent = eventReceiver.getCommonEventFromName(event.getName());
94
- if (commonEvent == null) {
95
- this.nativeComponent.handleJavascriptEvent(event, args);
96
- return;
97
- }
98
-
99
- this.handleCommonEvent(commonEvent, args);
100
- }
101
-
102
- // Calls the common events handlers
103
- private void handleCommonEvent(RNScanbotEventReceiver.CommonEvents commonEvent, @Nullable ReadableArray args) {
104
- switch (commonEvent) {
105
- case COMPONENT_DID_UPDATE:
106
- componentDidUpdate();
107
- break;
108
- case COMPONENT_DID_MOUNT:
109
- componentDidMount();
110
- break;
111
- case COMPONENT_WILL_UNMOUNT:
112
- componentWillUnmount();
113
- break;
114
- case ORIENTATION_CHANGED:
115
- orientationChanged();
116
- break;
117
- }
118
- }
119
-
120
- // Maps JavaScript events (from JavaScript to Native)
121
- @Nullable
122
- @Override
123
- public Map<String, Integer> getCommandsMap() {
124
- return eventReceiver.getCommandsMap();
125
- }
126
-
127
- // Hands over JavaScript events to our beatufiul event receiver
128
- @Override
129
- public void receiveCommand(@NonNull ReactRootView root, String commandId, @Nullable ReadableArray args) {
130
- super.receiveCommand(root, commandId, args);
131
- eventReceiver.receiveCommand(commandId, args);
132
- }
133
- }
@@ -1,40 +0,0 @@
1
- package io.scanbot.barcodesdk.plugin.reactnative.components.base;
2
-
3
- import androidx.annotation.NonNull;
4
-
5
- import com.facebook.react.bridge.ReactContext;
6
-
7
- /**
8
- * This class is used to create ViewManagers for native components
9
- */
10
- public class RNScanbotNativeComponentManagerFactory {
11
-
12
- private final ReactContext reactContext;
13
-
14
- public RNScanbotNativeComponentManagerFactory(@NonNull final ReactContext reactContext) {
15
- this.reactContext = reactContext;
16
- }
17
-
18
- private static class RNScanbotNativeComponentManagerCreator<T extends RNScanbotNativeComponent> {
19
- public RNScanbotNativeComponentManager<T> create(
20
- @NonNull final ReactContext reactContext,
21
- @NonNull final T nativeComponent,
22
- @NonNull final String name
23
- ) {
24
- return new RNScanbotNativeComponentManager<T>(reactContext, nativeComponent) {
25
- @NonNull @Override public String getName() {
26
- return name;
27
- }
28
- };
29
- }
30
- }
31
-
32
- @SuppressWarnings({"unchecked", "rawtypes"})
33
- public RNScanbotNativeComponentManager createManager(
34
- @NonNull final RNScanbotNativeComponent nativeComponent,
35
- @NonNull final String name
36
- ) {
37
- return new RNScanbotNativeComponentManagerCreator().create(reactContext, nativeComponent, name);
38
- }
39
- }
40
-
@@ -1,131 +0,0 @@
1
- package io.scanbot.barcodesdk.plugin.reactnative.components.base;
2
-
3
- import android.view.View;
4
-
5
- import androidx.annotation.NonNull;
6
-
7
- import com.facebook.react.bridge.ReactContext;
8
- import com.facebook.react.bridge.WritableNativeMap;
9
-
10
- import io.scanbot.barcodesdk.plugin.reactnative.components.base.communication.RNScanbotEventEmitter;
11
- import io.scanbot.barcodesdk.plugin.reactnative.components.base.views.RNScanbotNativeComponentRootView;
12
-
13
- /**
14
- * This is the UI component of your custom React Native components.
15
- * It expects you to return a ScanbotComponentRootView in createRootView.
16
- * It takes care of attaching listeners and handling layout changes re-measurements.
17
- */
18
- public abstract class RNScanbotNativeComponentUi {
19
- // The rootView created through createRootView()
20
- protected RNScanbotNativeComponentRootView rootView;
21
-
22
- // The React Context
23
- protected ReactContext reactContext;
24
-
25
- // Listener to handle the re-layout when children change... they grow up so fast
26
- private RNScanbotNativeComponentRootView.IOnChildRemovedListener childRemovedListener;
27
- private View.OnAttachStateChangeListener onAttachStateChangeListener;
28
- private Runnable onViewRecreated;
29
-
30
- public RNScanbotNativeComponentUi(@NonNull final ReactContext reactContext) { this.reactContext = reactContext; }
31
-
32
- /*
33
- * Disposes the component
34
- */
35
- public void dispose() {
36
- if (childRemovedListener != null) {
37
- rootView.removeOneShotChildRemovedListener(childRemovedListener);
38
- }
39
- if (onAttachStateChangeListener != null) {
40
- rootView.removeOnAttachStateChangeListener(onAttachStateChangeListener);
41
- }
42
-
43
- childRemovedListener = null;
44
- onAttachStateChangeListener = null;
45
-
46
- this.rootView = null;
47
- this.reactContext = null;
48
- }
49
-
50
- /*
51
- * Returns the rootView created by createRootView, after performing some UI post operations
52
- */
53
- public RNScanbotNativeComponentRootView getRootView() {
54
- if (this.rootView == null) {
55
- this.rootView = createAndSetupRootView();
56
- this.notifyViewRecreated();
57
- }
58
- return this.rootView;
59
- }
60
-
61
- public void _setOnViewRecreatedListener(final Runnable runnable) {
62
- this.onViewRecreated = runnable;
63
- }
64
-
65
- public void removeOnViewRecreatedListener() {
66
- this.onViewRecreated = null;
67
- }
68
-
69
- private void notifyViewRecreated() {
70
- if (this.onViewRecreated == null) {
71
- return;
72
- }
73
- this.onViewRecreated.run();
74
- }
75
-
76
- /*
77
- * You must construct your view inside this method, and then return it.
78
- */
79
- protected abstract RNScanbotNativeComponentRootView createRootView(@NonNull final ReactContext reactContext);
80
-
81
- /*
82
- * Calls the inheriting class's Root View custom creator, and performs some additional setup to
83
- * it, before returning it.
84
- */
85
- private RNScanbotNativeComponentRootView createAndSetupRootView() {
86
- final RNScanbotNativeComponentRootView rootView = createRootView(this.reactContext);
87
- onAttachStateChangeListener = new View.OnAttachStateChangeListener() {
88
- @Override
89
- public void onViewAttachedToWindow(View v) {
90
- remeasureViews(rootView, reactContext);
91
- }
92
-
93
- @Override
94
- public void onViewDetachedFromWindow(View v) {}
95
- };
96
- rootView.addOnAttachStateChangeListener(onAttachStateChangeListener);
97
- return rootView;
98
- }
99
-
100
- /*
101
- * UI Thread: Remeasures and layouts the views
102
- */
103
- public void remeasureViews(
104
- @NonNull final RNScanbotNativeComponentRootView rootView,
105
- @NonNull final ReactContext reactContext
106
- ) {
107
- reactContext.runOnUiQueueThread(() -> {
108
- // The view is remeasured as soon as it is attached to the window
109
- rootView.post(rootView.measureAndLayout);
110
-
111
- // Runs custom logic that has to be performed after the remeasuring of the views
112
- rootView.post(this::onViewsRemeasured);
113
-
114
- // Take care of your children
115
- if (childRemovedListener != null) {
116
- rootView.removeOneShotChildRemovedListener(childRemovedListener);
117
- }
118
- childRemovedListener = child -> new RNScanbotEventEmitter(reactContext, rootView)
119
- .emitEvent(
120
- RNScanbotEventEmitter.CommonEvents.REQUEST_COMPONENT_RELOAD,
121
- new WritableNativeMap());
122
- rootView.addOneShotChildRemovedListener(childRemovedListener);
123
- });
124
- }
125
-
126
- /**
127
- * Called after the remeasuring of the views has been completed. Override this if you want
128
- * to apply some custom UI logic in that point of the lifecycle.
129
- */
130
- protected void onViewsRemeasured() {}
131
- }
@@ -1,53 +0,0 @@
1
- package io.scanbot.barcodesdk.plugin.reactnative.components.base.views;
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 RNScanbotNativeComponentFrameLayout 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 RNScanbotNativeComponentFrameLayout(Context context, AttributeSet attrs) {
17
- super(context, attrs);
18
- }
19
-
20
- public RNScanbotNativeComponentFrameLayout(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
- }
@@ -1,154 +0,0 @@
1
- package io.scanbot.barcodesdk.plugin.reactnative.components.base.views;
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 RNScanbotNativeComponentRootView 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
- measure(
28
- MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY),
29
- MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.EXACTLY));
30
- layout(getLeft(), getTop(), getRight(), getBottom());
31
- notifyLayoutChangeListeners(getWidth(), getHeight(), getLeft(), getTop(), getRight(), getBottom());
32
- };
33
-
34
- private final List<ILayoutChangeListener> layoutChangeListeners = new ArrayList<>();
35
- private final List<IOnChildRemovedListener> childRemovedListeners = new ArrayList<>();
36
- private boolean shouldNotifyWhenChildIsRemoved = false;
37
-
38
- public RNScanbotNativeComponentRootView(Context context) {
39
- super(context);
40
- instantiate();
41
- }
42
-
43
- public RNScanbotNativeComponentRootView(Context context, AttributeSet attrs) {
44
- super(context, attrs);
45
- instantiate();
46
- }
47
-
48
- public RNScanbotNativeComponentRootView(Context context, AttributeSet attrs, int defStyle) {
49
- super(context, attrs, defStyle);
50
- instantiate();
51
- }
52
-
53
- private void instantiate() {}
54
-
55
- @Override
56
- protected void onAttachedToWindow() {
57
- super.onAttachedToWindow();
58
- applyChildrenMeasureWorkaround();
59
- }
60
-
61
- public void applyChildrenMeasureWorkaround() {
62
- Choreographer.getInstance().postFrameCallback(frameTimeNanos -> {
63
- for (int i = 0; i < getChildCount(); i++) {
64
- View child = getChildAt(i);
65
- if (child instanceof FrameLayout) {
66
- child.measure(MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY),
67
- MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY));
68
- child.layout(0, 0, child.getMeasuredWidth(), child.getMeasuredHeight());
69
- }
70
- }
71
- getViewTreeObserver().dispatchOnGlobalLayout();
72
- shouldNotifyWhenChildIsRemoved = true;
73
- });
74
- }
75
-
76
- @Override
77
- public boolean onInterceptTouchEvent(MotionEvent ev) {
78
- return super.onInterceptTouchEvent(ev);
79
- }
80
-
81
- @Override
82
- public void requestLayout() {
83
- super.requestLayout();
84
- post(measureAndLayout);
85
- }
86
-
87
- public void addLayoutChangeListener(ILayoutChangeListener listener) {
88
- layoutChangeListeners.add(listener);
89
- }
90
-
91
- public void addOneShotChildRemovedListener(IOnChildRemovedListener listener) {
92
- if (!childRemovedListeners.contains(listener)) {
93
- childRemovedListeners.add(listener);
94
- }
95
- }
96
-
97
- public void removeOneShotChildRemovedListener(IOnChildRemovedListener listener) {
98
- childRemovedListeners.remove(listener);
99
- }
100
-
101
- private void notifyLayoutChangeListeners(int width, int height, int left, int top, int right, int bottom) {
102
- for(ILayoutChangeListener listener : layoutChangeListeners) {
103
- listener.onFrameLayoutChanged(width, height, left, top, right, bottom);
104
- }
105
- }
106
-
107
- private void notifyChildRemovedListeners(final View childView) {
108
- // if (!shouldNotifyWhenChildIsRemoved) {
109
- // return;
110
- // }
111
- // -> Might be useful one day
112
- // for (IOnChildRemovedListener listener : childRemovedListeners) {
113
- // if (!lastNotifiedChildViews.contains(childView)) {
114
- // listener.onChildRemoved(childView);
115
- // lastNotifiedChildViews.add(childView);
116
- // } else {
117
- // lastNotifiedChildViews.clear();
118
- // }
119
- // }
120
- //
121
- // childRemovedListeners.clear();
122
- }
123
-
124
- @Override
125
- public void onViewAdded(View child) {
126
- super.onViewAdded(child);
127
- child.bringToFront();
128
- child.setZ(2.0f);
129
- }
130
-
131
- /**
132
- * Called when a child view is removed from this ViewGroup. Overrides should always
133
- * call super.onViewRemoved.
134
- *
135
- * @param child the removed child view
136
- */
137
- @Override
138
- public void onViewRemoved(View child) {
139
- super.onViewRemoved(child);
140
- notifyChildRemovedListeners(child);
141
- }
142
-
143
- @Override
144
- public void onAttachedToReactInstance() {
145
- super.onAttachedToReactInstance();
146
- shouldNotifyWhenChildIsRemoved = false;
147
- }
148
-
149
- @Override
150
- protected void onDetachedFromWindow() {
151
- super.onDetachedFromWindow();
152
- shouldNotifyWhenChildIsRemoved = false;
153
- }
154
- }
@@ -1,28 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <io.scanbot.barcodesdk.plugin.reactnative.components.base.views.RNScanbotNativeComponentRootView
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.base.views.RNScanbotNativeComponentFrameLayout
8
- android:id="@+id/barcode_camera_layout"
9
- xmlns:app="http://schemas.android.com/apk/res-auto"
10
- android:layout_width="match_parent"
11
- android:layout_height="match_parent">
12
-
13
- <io.scanbot.sdk.ui.camera.ScanbotCameraXView
14
- android:id="@+id/barcode_camera"
15
- android:orientation="vertical"
16
- android:layout_width="match_parent"
17
- android:layout_height="match_parent"
18
- android:background="@android:color/black"
19
- app:finder_view_id="@id/barcode_finder_overlay"/>
20
-
21
- <io.scanbot.sdk.ui.camera.FinderOverlayView
22
- android:id="@+id/barcode_finder_overlay"
23
- app:min_padding="64dp"
24
- android:layout_width="match_parent"
25
- android:layout_height="match_parent" />
26
-
27
- </io.scanbot.barcodesdk.plugin.reactnative.components.base.views.RNScanbotNativeComponentFrameLayout>
28
- </io.scanbot.barcodesdk.plugin.reactnative.components.base.views.RNScanbotNativeComponentRootView>
@@ -1,23 +0,0 @@
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>