anyline-ocr-react-native-module 55.8.1 → 56.0.0

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.
@@ -0,0 +1,129 @@
1
+ import { NativeModules, NativeEventEmitter, EmitterSubscription } from 'react-native';
2
+ import { version as pluginVersion } from './package.json';
3
+ import {
4
+ WrapperSessionSdkInitializationRequest,
5
+ WrapperSessionSdkInitializationResponse,
6
+ WrapperSessionScanStartRequest,
7
+ WrapperSessionScanResponse,
8
+ WrapperSessionScanResultsResponse,
9
+ WrapperSessionScanStopRequest,
10
+ WrapperSessionUcrReportRequest,
11
+ WrapperSessionUcrReportResponse,
12
+ WrapperSessionExportCachedEventsResponse,
13
+ } from './types/wrapper_session_parameters';
14
+ import { UiFeedbackElementConfig } from './types/sdk_config';
15
+
16
+ export * from './types/wrapper_session_parameters';
17
+ export * from './types/sdk_config';
18
+
19
+ const MODULE_NAME = 'AnylineInfinityPlugin';
20
+ const EVENT_ON_SCAN_RESULTS = 'INFINITY_ON_SCAN_RESULTS';
21
+ const EVENT_ON_UI_ELEMENT_CLICKED = 'INFINITY_ON_UI_ELEMENT_CLICKED';
22
+
23
+ const nativeModule = NativeModules[MODULE_NAME];
24
+ const emitter = new NativeEventEmitter(nativeModule);
25
+
26
+ let _sessionReady = false;
27
+
28
+ function _setupWrapperSessionOnce(): void {
29
+ if (_sessionReady) return;
30
+ _sessionReady = true;
31
+ nativeModule.setupWrapperSession(pluginVersion);
32
+ }
33
+
34
+ /// Entrypoint for the Anyline Infinity scanning API.
35
+ ///
36
+ /// Exposes a typed, schema-driven interface that mirrors WrapperSessionProvider
37
+ /// directly. JSON serialization/deserialization is handled in this TypeScript
38
+ /// layer; the native bridge only passes raw JSON strings.
39
+ export class AnylineInfinityPlugin {
40
+ /// Returns the plugin version string.
41
+ getPluginVersion(): string {
42
+ _setupWrapperSessionOnce();
43
+ return pluginVersion;
44
+ }
45
+
46
+ /// Returns the native SDK version string.
47
+ getSDKVersion(): Promise<string> {
48
+ _setupWrapperSessionOnce();
49
+ return nativeModule.getSDKVersion();
50
+ }
51
+
52
+ /// Initializes the Anyline SDK with the supplied request parameters.
53
+ requestSdkInitialization(
54
+ request: WrapperSessionSdkInitializationRequest
55
+ ): Promise<WrapperSessionSdkInitializationResponse> {
56
+ _setupWrapperSessionOnce();
57
+ return nativeModule
58
+ .requestSdkInitialization(JSON.stringify(request))
59
+ .then((json: string) => JSON.parse(json) as WrapperSessionSdkInitializationResponse);
60
+ }
61
+
62
+ /// Starts a scanning session.
63
+ ///
64
+ /// Resolves with the lifecycle response when the session ends
65
+ /// (success / failure / abort). Intermediate scan results and UI element
66
+ /// click events arrive via onScanResults and onUIElementClicked.
67
+ requestScanStart(
68
+ request: WrapperSessionScanStartRequest
69
+ ): Promise<WrapperSessionScanResponse> {
70
+ return nativeModule
71
+ .requestScanStart(JSON.stringify(request))
72
+ .then((json: string) => JSON.parse(json) as WrapperSessionScanResponse);
73
+ }
74
+
75
+ /// Switches to a new scan mode using the provided scan-start request.
76
+ requestScanSwitchWithScanStartRequestParams(
77
+ request: WrapperSessionScanStartRequest
78
+ ): void {
79
+ nativeModule.requestScanSwitchWithScanStartRequestParams(JSON.stringify(request));
80
+ }
81
+
82
+ /// Switches to a new scan mode using a raw ScanViewConfig JSON string.
83
+ requestScanSwitchWithScanViewConfigContentString(
84
+ scanViewConfigContentString: string
85
+ ): void {
86
+ nativeModule.requestScanSwitchWithScanViewConfigContentString(
87
+ scanViewConfigContentString
88
+ );
89
+ }
90
+
91
+ /// Stops the active scanning session.
92
+ requestScanStop(request?: WrapperSessionScanStopRequest): void {
93
+ nativeModule.requestScanStop(request ? JSON.stringify(request) : null);
94
+ }
95
+
96
+ /// Submits a User Corrected Result (UCR) report.
97
+ requestUCRReport(
98
+ request: WrapperSessionUcrReportRequest
99
+ ): Promise<WrapperSessionUcrReportResponse> {
100
+ return nativeModule
101
+ .requestUCRReport(JSON.stringify(request))
102
+ .then((json: string) => JSON.parse(json) as WrapperSessionUcrReportResponse);
103
+ }
104
+
105
+ /// Exports all cached scan events as a ZIP archive.
106
+ requestExportCachedEvents(): Promise<WrapperSessionExportCachedEventsResponse> {
107
+ return nativeModule
108
+ .requestExportCachedEvents()
109
+ .then((json: string) => JSON.parse(json) as WrapperSessionExportCachedEventsResponse);
110
+ }
111
+
112
+ /// Subscribes to scan results emitted during the active scan session (0..N).
113
+ onScanResults(
114
+ callback: (scanResults: WrapperSessionScanResultsResponse) => void
115
+ ): EmitterSubscription {
116
+ return emitter.addListener(EVENT_ON_SCAN_RESULTS, (json: string) => {
117
+ callback(JSON.parse(json) as WrapperSessionScanResultsResponse);
118
+ });
119
+ }
120
+
121
+ /// Subscribes to UI element click events during the active scan session (0..N).
122
+ onUIElementClicked(
123
+ callback: (uiElementClicked: UiFeedbackElementConfig) => void
124
+ ): EmitterSubscription {
125
+ return emitter.addListener(EVENT_ON_UI_ELEMENT_CLICKED, (json: string) => {
126
+ callback(JSON.parse(json) as UiFeedbackElementConfig);
127
+ });
128
+ }
129
+ }
@@ -18,7 +18,7 @@ Pod::Spec.new do |s|
18
18
  s.source = { :git => "https://github.com/Anyline/anyline-ocr-react-native-module.git", :tag => "#{s.version}" }
19
19
 
20
20
  s.source_files = 'ios/**/*.{h,m,swift}'
21
- s.dependency "Anyline", "55.8.1"
21
+ s.dependency "Anyline", "56.0.0"
22
22
  s.dependency "React"
23
23
 
24
24
  end
package/LICENSE.md ADDED
@@ -0,0 +1,11 @@
1
+ # Copyright © 2026 Anyline GmbH. All rights reserved.
2
+
3
+ ## License
4
+
5
+ The contents of this repository are the intellectual property of Anyline GmbH.
6
+
7
+ The use of the SDK and this app is subject to the most recent Master Subscription Terms of Anyline GmbH (or one of its subsidiaries), Terms of Use for the Anyline App and Anyline's Privacy Policies, available under Imprint & Legal of Anyline GmbH & Anyline Inc. | Anyline (or to a "Master Partner Agreement" if you are a partner of Anyline), and is only allowed if you have received a "Trial Access" (as defined in the Master Subscription Terms) or a license according to the Master Subscription Terms (or Master Partner Agreement).
8
+
9
+ ## Contact
10
+
11
+ For more information about the software development kit and licensing options, please contact Anyline GmbH at [anyline.com](https://anyline.com).
@@ -61,6 +61,6 @@ repositories {
61
61
 
62
62
  dependencies {
63
63
  implementation fileTree(dir: "libs", include: ["*.jar"])
64
- implementation 'io.anyline:anylinesdk:55.8.1'
64
+ implementation 'io.anyline:anylinesdk:56.0.0'
65
65
  implementation "com.facebook.react:react-native:+"
66
66
  }
@@ -0,0 +1,195 @@
1
+ package com.anyline.reactnative;
2
+
3
+ import android.content.Context;
4
+ import android.view.ViewGroup;
5
+
6
+ import androidx.annotation.NonNull;
7
+ import androidx.annotation.Nullable;
8
+
9
+ import com.anyline.reactnative.nativeview.NativeViewRegistry;
10
+
11
+ import com.facebook.react.bridge.Promise;
12
+ import com.facebook.react.bridge.ReactApplicationContext;
13
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
14
+ import com.facebook.react.bridge.ReactMethod;
15
+ import com.facebook.react.bridge.UiThreadUtil;
16
+ import com.facebook.react.modules.core.DeviceEventManagerModule;
17
+
18
+ import org.jetbrains.annotations.NotNull;
19
+
20
+ import io.anyline.plugin.config.UIFeedbackElementConfig;
21
+ import io.anyline.wrapper.config.WrapperSessionExportCachedEventsResponse;
22
+ import io.anyline.wrapper.config.WrapperSessionScanResponse;
23
+ import io.anyline.wrapper.config.WrapperSessionScanResultConfig;
24
+ import io.anyline.wrapper.config.WrapperSessionScanResultsResponse;
25
+ import io.anyline.wrapper.config.WrapperSessionSdkInitializationResponse;
26
+ import io.anyline.wrapper.config.WrapperSessionUCRReportResponse;
27
+ import io.anyline2.WrapperInfo;
28
+ import io.anyline2.sdk.extension.UIFeedbackElementConfigExtensionKt;
29
+ import io.anyline2.wrapper.WrapperSessionClientInterface;
30
+ import io.anyline2.wrapper.WrapperSessionProvider;
31
+ import io.anyline2.wrapper.extensions.WrapperSessionExportCachedEventsResponseExtensionKt;
32
+ import io.anyline2.wrapper.extensions.WrapperSessionScanResponseExtensionKt;
33
+ import io.anyline2.wrapper.extensions.WrapperSessionScanResultsResponseExtensionKt;
34
+ import io.anyline2.wrapper.extensions.WrapperSessionSdkInitializationResponseExtensionKt;
35
+ import io.anyline2.wrapper.extensions.WrapperSessionUCRReportResponseExtensionKt;
36
+
37
+ class AnylineInfinityPlugin extends ReactContextBaseJavaModule
38
+ implements WrapperSessionClientInterface {
39
+
40
+ // Retain the WrapperSessionProvider instance to prevent GC-related crashes.
41
+ protected static final WrapperSessionProvider wrapperSessionProvider = WrapperSessionProvider.INSTANCE;
42
+
43
+ static final String REACT_CLASS = "AnylineInfinityPlugin";
44
+ private static final String EVENT_ON_SCAN_RESULTS = "INFINITY_ON_SCAN_RESULTS";
45
+ private static final String EVENT_ON_UI_ELEMENT_CLICKED = "INFINITY_ON_UI_ELEMENT_CLICKED";
46
+
47
+ private final ReactApplicationContext reactContext;
48
+
49
+ private Promise sdkInitializationPromise = null;
50
+ private Promise scanResponsePromise = null;
51
+ private Promise ucrReportPromise = null;
52
+ private Promise exportCachedEventsPromise = null;
53
+
54
+ AnylineInfinityPlugin(ReactApplicationContext context) {
55
+ super(context);
56
+ this.reactContext = context;
57
+ }
58
+
59
+ @Override
60
+ public String getName() {
61
+ return REACT_CLASS;
62
+ }
63
+
64
+ @ReactMethod
65
+ public void getSDKVersion(final Promise promise) {
66
+ promise.resolve(at.nineyards.anyline.BuildConfig.VERSION_NAME);
67
+ }
68
+
69
+ @ReactMethod
70
+ protected void setupWrapperSession(final String pluginVersion) {
71
+ WrapperInfo wrapperInfo = new WrapperInfo(
72
+ WrapperInfo.WrapperType.ReactNative,
73
+ pluginVersion,
74
+ WrapperInfo.WrapperCodename.Infinity);
75
+ WrapperSessionProvider.setupWrapperSession(wrapperInfo, this);
76
+ }
77
+
78
+ @ReactMethod
79
+ public void requestSdkInitialization(String request, Promise promise) {
80
+ sdkInitializationPromise = promise;
81
+ WrapperSessionProvider.requestSdkInitialization(request);
82
+ }
83
+
84
+ @ReactMethod
85
+ public void requestScanStart(String request, Promise promise) {
86
+ scanResponsePromise = promise;
87
+ UiThreadUtil.runOnUiThread(() -> {
88
+ try {
89
+ WrapperSessionProvider.requestScanStart(request);
90
+ } catch (Exception e) {
91
+ promise.reject(e);
92
+ }
93
+ });
94
+ }
95
+
96
+ @ReactMethod
97
+ public void requestScanSwitchWithScanStartRequestParams(String request) {
98
+ WrapperSessionProvider.requestScanSwitchWithScanStartRequestParams(request);
99
+ }
100
+
101
+ @ReactMethod
102
+ public void requestScanSwitchWithScanViewConfigContentString(String request) {
103
+ WrapperSessionProvider.requestScanSwitchWithScanViewConfigContentString(request);
104
+ }
105
+
106
+ @ReactMethod
107
+ public void requestScanStop(@Nullable String request) {
108
+ WrapperSessionProvider.requestScanStop(request);
109
+ }
110
+
111
+ @ReactMethod
112
+ public void requestUCRReport(String request, Promise promise) {
113
+ ucrReportPromise = promise;
114
+ WrapperSessionProvider.requestUCRReport(request);
115
+ }
116
+
117
+ @ReactMethod
118
+ public void requestExportCachedEvents(Promise promise) {
119
+ exportCachedEventsPromise = promise;
120
+ WrapperSessionProvider.requestExportCachedEvents();
121
+ }
122
+
123
+ private void sendEvent(String eventName, String params) {
124
+ reactContext
125
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
126
+ .emit(eventName, params);
127
+ }
128
+
129
+ @Override
130
+ public @NotNull Context getContext() {
131
+ return reactContext;
132
+ }
133
+
134
+ @Override
135
+ public @Nullable ViewGroup getContainerView() {
136
+ return (ViewGroup) NativeViewRegistry.getLastOrNull();
137
+ }
138
+
139
+ @Override
140
+ public void onSdkInitializationResponse(
141
+ @NotNull WrapperSessionSdkInitializationResponse initializationResponse) {
142
+ if (sdkInitializationPromise != null) {
143
+ sdkInitializationPromise.resolve(
144
+ WrapperSessionSdkInitializationResponseExtensionKt
145
+ .toJsonObject(initializationResponse).toString());
146
+ sdkInitializationPromise = null;
147
+ }
148
+ }
149
+
150
+ @Override
151
+ public void onScanResults(@NotNull WrapperSessionScanResultsResponse scanResultsResponse) {
152
+ sendEvent(EVENT_ON_SCAN_RESULTS,
153
+ WrapperSessionScanResultsResponseExtensionKt
154
+ .toJsonObject(scanResultsResponse).toString());
155
+ }
156
+
157
+ @Override
158
+ public void onScanResponse(@NotNull WrapperSessionScanResponse scanResponse) {
159
+ if (scanResponsePromise != null) {
160
+ scanResponsePromise.resolve(
161
+ WrapperSessionScanResponseExtensionKt
162
+ .toJsonObject(scanResponse).toString());
163
+ scanResponsePromise = null;
164
+ }
165
+ }
166
+
167
+ @Override
168
+ public void onUIElementClicked(
169
+ @NonNull WrapperSessionScanResultConfig scanResultConfig,
170
+ @NonNull UIFeedbackElementConfig uiFeedbackElementConfig) {
171
+ sendEvent(EVENT_ON_UI_ELEMENT_CLICKED,
172
+ UIFeedbackElementConfigExtensionKt.toJsonObject(uiFeedbackElementConfig).toString());
173
+ }
174
+
175
+ @Override
176
+ public void onUCRReportResponse(@NotNull WrapperSessionUCRReportResponse ucrReportResponse) {
177
+ if (ucrReportPromise != null) {
178
+ ucrReportPromise.resolve(
179
+ WrapperSessionUCRReportResponseExtensionKt
180
+ .toJsonObject(ucrReportResponse).toString());
181
+ ucrReportPromise = null;
182
+ }
183
+ }
184
+
185
+ @Override
186
+ public void onExportCachedEventsResponse(
187
+ @NotNull WrapperSessionExportCachedEventsResponse exportCachedEventsResponse) {
188
+ if (exportCachedEventsPromise != null) {
189
+ exportCachedEventsPromise.resolve(
190
+ WrapperSessionExportCachedEventsResponseExtensionKt
191
+ .toJsonObject(exportCachedEventsResponse).toString());
192
+ exportCachedEventsPromise = null;
193
+ }
194
+ }
195
+ }
@@ -1,5 +1,8 @@
1
1
  package com.anyline.reactnative;
2
2
 
3
+ import androidx.annotation.NonNull;
4
+
5
+ import com.anyline.reactnative.nativeview.AnylineNativeViewManager;
3
6
  import com.facebook.react.ReactPackage;
4
7
  import com.facebook.react.bridge.JavaScriptModule;
5
8
  import com.facebook.react.bridge.NativeModule;
@@ -12,19 +15,27 @@ import java.util.List;
12
15
 
13
16
  public class AnylinePackage implements ReactPackage {
14
17
 
18
+ private AnylineNativeViewManager viewManager = null;
19
+
15
20
  public List<Class<? extends JavaScriptModule>> createJSModules() {
16
21
  return Collections.emptyList();
17
22
  }
18
23
 
24
+ @NonNull
19
25
  @Override
20
- public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
21
- return Collections.emptyList();
26
+ public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
27
+ if (viewManager == null) {
28
+ viewManager = new AnylineNativeViewManager();
29
+ }
30
+ return List.of(viewManager);
22
31
  }
23
32
 
33
+ @NonNull
24
34
  @Override
25
- public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
35
+ public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
26
36
  List<NativeModule> modules = new ArrayList<>();
27
37
  modules.add(new AnylineSDKPlugin(reactContext));
38
+ modules.add(new AnylineInfinityPlugin(reactContext));
28
39
  return modules;
29
40
  }
30
41
  }
@@ -5,8 +5,12 @@ package com.anyline.reactnative;
5
5
  */
6
6
 
7
7
  import android.content.Context;
8
+ import android.view.ViewGroup;
8
9
 
9
10
  import androidx.annotation.NonNull;
11
+ import androidx.annotation.Nullable;
12
+
13
+ import com.anyline.reactnative.nativeview.NativeViewRegistry;
10
14
 
11
15
  import com.facebook.react.bridge.Callback;
12
16
  import com.facebook.react.bridge.Promise;
@@ -14,6 +18,7 @@ import com.facebook.react.bridge.ReactApplicationContext;
14
18
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
15
19
  import com.facebook.react.bridge.ReactMethod;
16
20
  import com.facebook.react.bridge.Arguments;
21
+ import com.facebook.react.bridge.UiThreadUtil;
17
22
  import com.facebook.react.modules.core.DeviceEventManagerModule;
18
23
 
19
24
  import org.jetbrains.annotations.NotNull;
@@ -45,6 +50,10 @@ import io.anyline2.wrapper.extensions.WrapperSessionSdkInitializationResponseExt
45
50
  import io.anyline2.wrapper.extensions.WrapperSessionUCRReportRequestExtensionKt;
46
51
  import io.anyline2.wrapper.legacy.LegacyPluginHelper;
47
52
 
53
+ /**
54
+ * @deprecated Use {@link AnylineInfinityPlugin} instead.
55
+ */
56
+ @Deprecated
48
57
  class AnylineSDKPlugin extends ReactContextBaseJavaModule
49
58
  implements WrapperSessionClientInterface, ResultReporter.OnResultListener {
50
59
 
@@ -97,7 +106,7 @@ class AnylineSDKPlugin extends ReactContextBaseJavaModule
97
106
 
98
107
  @ReactMethod
99
108
  protected void setupWrapperSession(final String pluginVersion) {
100
- WrapperInfo wrapperInfo = new WrapperInfo(WrapperInfo.WrapperType.ReactNative, pluginVersion);
109
+ WrapperInfo wrapperInfo = new WrapperInfo(WrapperInfo.WrapperType.ReactNative, pluginVersion, WrapperInfo.WrapperCodename.Legacy);
101
110
  WrapperSessionProvider.setupWrapperSession(wrapperInfo,this);
102
111
  }
103
112
 
@@ -168,6 +177,16 @@ class AnylineSDKPlugin extends ReactContextBaseJavaModule
168
177
  wrapperSessionSdkInitializationRequestJson.toString());
169
178
  }
170
179
 
180
+ @ReactMethod
181
+ public void setDefaultScanStartPlatformOptions(String scanStartPlatformOptionsString, final Promise promise) {
182
+ try {
183
+ WrapperSessionProvider.setDefaultScanStartPlatformOptions(scanStartPlatformOptionsString);
184
+ promise.resolve("");
185
+ } catch (Exception e) {
186
+ promise.reject(E_ERROR, e.getMessage());
187
+ }
188
+ }
189
+
171
190
  @ReactMethod
172
191
  public void setup(String config, String scanMode, Callback onResultReact, Callback onErrorReact) {
173
192
  setupWithInitializationParameters(null, config, scanMode, onResultReact, onErrorReact);
@@ -224,7 +243,13 @@ class AnylineSDKPlugin extends ReactContextBaseJavaModule
224
243
  JSONObject wrapperSessionScanStartRequestJson
225
244
  = WrapperSessionScanStartRequestExtensionKt.toJsonObject(wrapperSessionScanRequest);
226
245
 
227
- WrapperSessionProvider.requestScanStart(wrapperSessionScanStartRequestJson.toString());
246
+ UiThreadUtil.runOnUiThread(() -> {
247
+ try {
248
+ WrapperSessionProvider.requestScanStart(wrapperSessionScanStartRequestJson.toString());
249
+ } catch (Exception e) {
250
+ returnError("Unable to request ScanStart: " + e.getMessage());
251
+ }
252
+ });
228
253
 
229
254
  ResultReporter.setListener(this);
230
255
  }
@@ -248,6 +273,11 @@ class AnylineSDKPlugin extends ReactContextBaseJavaModule
248
273
  WrapperSessionProvider.requestExportCachedEvents();
249
274
  }
250
275
 
276
+ @ReactMethod
277
+ public void trySwitchScan(String scanViewConfigContent) {
278
+ WrapperSessionProvider.requestScanSwitchWithScanViewConfigContentString(scanViewConfigContent);
279
+ }
280
+
251
281
  @ReactMethod
252
282
  public void tryStopScan(String scanStopRequestParams) {
253
283
  WrapperSessionProvider.requestScanStop(scanStopRequestParams);
@@ -315,6 +345,11 @@ class AnylineSDKPlugin extends ReactContextBaseJavaModule
315
345
  return this.reactContext;
316
346
  }
317
347
 
348
+ @Override
349
+ public @Nullable ViewGroup getContainerView() {
350
+ return (ViewGroup) NativeViewRegistry.getLastOrNull();
351
+ }
352
+
318
353
  @Override
319
354
  public void onSdkInitializationResponse(@NotNull WrapperSessionSdkInitializationResponse initializationResponse) {
320
355
  JSONObject json =
@@ -4,6 +4,7 @@ package com.anyline.reactnative;
4
4
  * Created by jonesBoi on 02.12.16.
5
5
  */
6
6
 
7
+ @Deprecated
7
8
  public class ResultReporter {
8
9
 
9
10
  private static OnResultListener listener;
@@ -0,0 +1,26 @@
1
+ package com.anyline.reactnative.nativeview;
2
+
3
+ import android.widget.FrameLayout;
4
+ import com.facebook.react.uimanager.SimpleViewManager;
5
+ import com.facebook.react.uimanager.ThemedReactContext;
6
+
7
+ public class AnylineNativeViewManager extends SimpleViewManager<FrameLayout> {
8
+ public static final String REACT_CLASS = "AnylineNativeView";
9
+
10
+ @Override
11
+ public String getName() {
12
+ return REACT_CLASS;
13
+ }
14
+
15
+ @Override
16
+ protected FrameLayout createViewInstance(ThemedReactContext reactContext) {
17
+ return new NativeFragmentContainerView(reactContext);
18
+ }
19
+
20
+ @Override
21
+ public void onDropViewInstance(FrameLayout view) {
22
+ // Remove view from registry
23
+ NativeViewRegistry.remove(view);
24
+ super.onDropViewInstance(view);
25
+ }
26
+ }
@@ -0,0 +1,44 @@
1
+
2
+ package com.anyline.reactnative.nativeview;
3
+
4
+ import android.content.Context;
5
+ import android.graphics.PixelFormat;
6
+ import android.view.View;
7
+ import android.view.ViewGroup;
8
+ import android.view.WindowManager;
9
+ import android.widget.FrameLayout;
10
+
11
+ public class NativeFragmentContainerView extends FrameLayout {
12
+ NativeFragmentContainerView(Context context) {
13
+ super(context);
14
+ setLayoutParams(
15
+ new WindowManager.LayoutParams(
16
+ ViewGroup.LayoutParams.MATCH_PARENT,
17
+ ViewGroup.LayoutParams.MATCH_PARENT,
18
+ WindowManager.LayoutParams.TYPE_APPLICATION,
19
+ WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
20
+ PixelFormat.TRANSLUCENT
21
+ ));
22
+
23
+ isHardwareAccelerated();
24
+
25
+ // Generate a unique ID for the container
26
+ int containerId = View.generateViewId();
27
+
28
+ setId(containerId);
29
+
30
+ NativeViewRegistry.register(String.valueOf(containerId), this);
31
+ }
32
+
33
+ @Override
34
+ public void requestLayout() {
35
+ super.requestLayout();
36
+ post(measureAndLayoutRunnable);
37
+ }
38
+
39
+ private final Runnable measureAndLayoutRunnable = () -> {
40
+ measure(MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY),
41
+ MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.EXACTLY));
42
+ layout(getLeft(), getTop(), getRight(), getBottom());
43
+ };
44
+ }
@@ -0,0 +1,38 @@
1
+ package com.anyline.reactnative.nativeview;
2
+
3
+ import android.view.View;
4
+
5
+ import java.util.HashMap;
6
+ import java.util.Map;
7
+
8
+ public class NativeViewRegistry {
9
+ private static final Map<String, View> registry = new HashMap<>();
10
+
11
+ private NativeViewRegistry() {
12
+
13
+ }
14
+
15
+ public static void register(String id, View view) {
16
+ registry.put(id, view);
17
+ }
18
+
19
+ public static View get(String id) {
20
+ return registry.get(id);
21
+ }
22
+
23
+ public static View getLastOrNull() {
24
+ if (registry.isEmpty()) {
25
+ return null;
26
+ } else {
27
+ return (View) registry.values().toArray()[registry.size() - 1];
28
+ }
29
+ }
30
+
31
+ public static void remove(String id) {
32
+ registry.remove(id);
33
+ }
34
+
35
+ public static void remove(View view) {
36
+ registry.values().removeIf(value -> (value == view));
37
+ }
38
+ }
package/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import {NativeModules} from 'react-native';
2
2
  import {version as pluginVersion} from './package.json';
3
3
 
4
+ /**
5
+ * @deprecated Use AnylineInfinityPlugin instead.
6
+ */
4
7
  const AnylineOCR = NativeModules.AnylineSDKPlugin;
5
8
 
6
9
  export default AnylineOCR;
@@ -0,0 +1,9 @@
1
+
2
+ #import <Foundation/Foundation.h>
3
+ #import <Anyline/Anyline.h>
4
+ #import <React/RCTEventEmitter.h>
5
+ #import <React/RCTBridgeModule.h>
6
+
7
+ @interface AnylineInfinityPlugin : RCTEventEmitter <RCTBridgeModule, ALWrapperSessionClientDelegate>
8
+
9
+ @end